* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
  --bg:#0f1117; --panel:#181b24; --panel2:#20242f; --line:#2b3040;
  --text:#e7e9ef; --muted:#9aa2b4; --accent:#6c8cff; --accent2:#3a52c9;
  --green:#3fb27f; --red:#e5484d; --chip:#262b38; --chipOn:#2f4fd6;
}
body{ background:var(--bg); color:var(--text); font-family:"Segoe UI","Malgun Gothic",sans-serif; font-size:14px; }

.topbar{ display:flex; justify-content:space-between; align-items:center;
  padding:12px 18px; background:var(--panel); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20; }
.brand{ font-size:18px; font-weight:700; }
.brand .sub{ font-size:12px; color:var(--muted); font-weight:400; margin-left:6px; }
.top-actions{ display:flex; gap:8px; }

.btn{ background:var(--panel2); color:var(--text); border:1px solid var(--line);
  padding:8px 14px; border-radius:8px; cursor:pointer; font-size:13px; transition:.15s; }
.btn:hover{ border-color:var(--accent); }
.btn.primary{ background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
.btn.primary:hover{ background:var(--accent2); }
.btn.ghost{ background:transparent; }
.btn.small{ padding:5px 10px; font-size:12px; }
.btn.big{ padding:11px 26px; font-size:15px; }
.btn.refresh{ font-weight:600; }
.btn.refresh.update{ background:var(--red); border-color:var(--red); color:#fff; animation:pulse 1.2s infinite; }
@keyframes pulse{ 0%,100%{opacity:1} 50%{opacity:.65} }

/* 상단 API 바 */
.apibar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:10px 18px; background:var(--panel2); border-bottom:1px solid var(--line); }
.apibar-label{ font-size:13px; font-weight:600; white-space:nowrap; }
.apibar input#apiKeyTop{ flex:1; min-width:200px; width:auto; }
.apibar select#modelTop{ width:auto; min-width:150px; }
.api-status{ font-size:12px; white-space:nowrap; }
.api-status.set{ color:var(--green); }
.api-status.none{ color:var(--muted); }
.api-link{ font-size:12px; color:var(--accent); text-decoration:none; white-space:nowrap; }
.api-link:hover{ text-decoration:underline; }

.cats{ display:flex; gap:4px; padding:10px 18px 0; background:var(--panel); }
.cat{ background:transparent; border:none; color:var(--muted); padding:9px 18px; cursor:pointer;
  font-size:15px; border-bottom:3px solid transparent; }
.cat.active{ color:var(--text); border-bottom-color:var(--accent); font-weight:600; }

.platforms{ display:flex; flex-wrap:wrap; gap:6px; padding:12px 18px; background:var(--panel);
  border-bottom:1px solid var(--line); position:sticky; top:57px; z-index:19; }
.ptab{ background:var(--chip); border:1px solid var(--line); color:var(--muted);
  padding:6px 13px; border-radius:20px; cursor:pointer; font-size:13px; }
.ptab.active{ background:var(--chipOn); border-color:var(--accent); color:#fff; }

.wrap{ display:grid; grid-template-columns:1fr 1fr; gap:14px; padding:16px 18px; }
.card{ background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:14px; margin-bottom:14px; }
.left, .right{ min-width:0; }
.lbl{ display:block; font-weight:600; margin-bottom:7px; font-size:13px; }
.hint{ color:var(--muted); font-weight:400; font-size:11px; }
textarea, input[type=text], input[type=password], select{
  width:100%; background:var(--panel2); border:1px solid var(--line); color:var(--text);
  border-radius:8px; padding:9px 11px; font-size:13px; font-family:inherit; resize:vertical; }
textarea:focus, input:focus, select:focus{ outline:none; border-color:var(--accent); }
.saved-msg{ color:var(--green); font-size:12px; margin-left:8px; }

.dropzone{ border:2px dashed var(--line); text-align:center; transition:.15s; }
.dropzone.drag{ border-color:var(--accent); background:var(--panel2); }
.dz-inner{ padding:14px 6px; color:var(--muted); }
.dz-icon{ font-size:26px; display:block; margin-bottom:6px; }
.dz-inner b{ color:var(--accent); }
.dz-inner button{ margin-top:10px; }
.ref-box{ margin-top:12px; text-align:left; }

.options-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.opt-group{ margin-bottom:14px; }
.opt-group .gname{ font-size:12px; color:var(--muted); margin-bottom:6px; }
.chips{ display:flex; flex-wrap:wrap; gap:5px; }
.chip{ background:var(--chip); border:1px solid var(--line); color:var(--text);
  padding:5px 11px; border-radius:16px; cursor:pointer; font-size:12px; transition:.12s; }
.chip:hover{ border-color:var(--accent); }
.chip.on{ background:var(--chipOn); border-color:var(--accent); color:#fff; }
/* 프리셋으로 고정된 칩 (빨강 잠금, 수정 불가) */
.chip.locked{ background:rgba(229,72,77,.16); border-color:var(--red); color:#ff9b9e;
  cursor:not-allowed; font-weight:600; }
.chip.locked::before{ content:"🔒 "; font-size:10px; }

/* 그림체 프리셋 */
.preset-card{ border-color:#3a3450; }
.preset-chips .chip{ font-size:12px; }
.preset-chips .chip.on{ background:#7a3ff0; border-color:#a97bff; }
.preset-detail{ margin-top:12px; border-top:1px solid var(--line); padding-top:12px; }
.preset-desc{ font-size:13px; line-height:1.6; color:var(--text); background:var(--panel2);
  border-radius:8px; padding:10px 12px; margin-bottom:10px; }
.locked-title{ font-size:12px; color:var(--red); font-weight:600; margin-bottom:6px; }
.locked-chips .lchip{ background:rgba(229,72,77,.14); border:1px solid var(--red); color:#ff8b8f;
  padding:5px 11px; border-radius:16px; font-size:12px; cursor:not-allowed; user-select:none; }

.genbar{ display:flex; align-items:center; justify-content:center; gap:18px; padding:6px 18px 14px; }
.ai-toggle{ font-size:13px; color:var(--muted); cursor:pointer; user-select:none; }
.ai-toggle input{ width:auto; vertical-align:middle; margin-right:5px; }

.outputs{ display:grid; grid-template-columns:1fr 1fr; gap:14px; padding:0 18px; }
.output{ margin:0 0 6px; }
.out-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.out-head > div{ display:flex; gap:6px; align-items:center; }
.output textarea{ font-size:14px; line-height:1.5; }
.out-footer{ display:flex; align-items:center; gap:12px; padding:8px 18px 26px; }
.engine-tag{ font-size:11px; color:var(--muted); }
.out-note{ color:var(--muted); font-size:12px; min-height:16px; flex:1; }

/* 언어 토글 (우측 상단) */
.lang-toggle{ display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.lang-btn{ background:var(--panel2); color:var(--muted); border:none; padding:7px 12px;
  cursor:pointer; font-size:13px; font-weight:600; }
.lang-btn.active{ background:var(--accent); color:#fff; }
.top-actions{ align-items:center; }

@media (max-width:900px){ .outputs{ grid-template-columns:1fr; } }

.modal{ position:fixed; inset:0; background:rgba(0,0,0,.6); display:flex;
  align-items:center; justify-content:center; z-index:50; }
.modal-box{ background:var(--panel); border:1px solid var(--line); border-radius:14px;
  padding:22px; width:440px; max-width:92vw; }
.modal-box h3{ margin-bottom:14px; }
.modal-box .lbl{ margin-top:12px; }
.modal-actions{ display:flex; gap:8px; margin-top:18px; }

.toast{ position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:var(--panel2); border:1px solid var(--accent); color:var(--text);
  padding:10px 20px; border-radius:10px; opacity:0; transition:.25s; pointer-events:none; z-index:60; }
.toast.show{ opacity:1; }

@media (max-width:900px){ .wrap{ grid-template-columns:1fr; } }
