:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e8e5df;
  --text: #22211f;
  --text-2: #64605a;
  --muted: #9a958d;
  --primary: #4a7be0;
  --primary-hover: #3a68c8;
  --primary-soft: #eaf0fd;
  --warn: #c77700;
  --warn-soft: #fff4e0;
  --danger: #d0362c;
  --danger-soft: #fdecea;
  --ok: #3f8a4f;
  --photo-bg: #f2f6ff;
  --photo-border: #cfdcfb;
  --photo-text: #2b4a9a;
  --shadow: 0 1px 2px rgba(40, 35, 25, .04), 0 6px 20px rgba(40, 35, 25, .04);
  --radius: 14px;
  /* 생성 카드 (어두운 카드) */
  --card-dark: #2b2a27;
  --card-dark-2: #3a3935;
  --card-dark-text: #f3f1ec;
  --card-dark-muted: #aaa59b;
  /* 분석 막대 색 */
  --track: #eeece7;
  --lv-good: #4e7d4a;
  --lv-mid: #5b7fd6;
  --lv-low: #d9a23a;
  --lv-zero: #d0503f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413;
    --surface: #1d1c1a;
    --surface-2: #24231f;
    --border: #34322d;
    --text: #ece9e3;
    --text-2: #b0aaa0;
    --muted: #807a70;
    --primary: #7aa0f0;
    --primary-hover: #94b3f5;
    --primary-soft: #1f2a42;
    --warn: #f0a640;
    --warn-soft: #3a2c14;
    --danger: #f06a60;
    --danger-soft: #3a1e1c;
    --ok: #7fbf8a;
    --photo-bg: #1b2333;
    --photo-border: #2f3d5c;
    --photo-text: #a8c0f5;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3);
    --card-dark: #2a2926;
    --card-dark-2: #36342f;
    --card-dark-text: #f3f1ec;
    --card-dark-muted: #a29d93;
    --track: #2e2c28;
    --lv-good: #7fb878;
    --lv-mid: #86a3ec;
    --lv-low: #e8b75a;
    --lv-zero: #f07a6a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.muted { color: var(--muted); }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1600px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand-wrap { display: flex; align-items: center; gap: 10px; }
.brand { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: var(--primary); color: #fff; font-size: 15px;
}
.brand-sub {
  font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 99px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }
.dot.on { background: var(--ok); }

/* ===== Layout: 메모 | 결과 | 설정 ===== */
.layout {
  max-width: 1600px; margin: 0 auto; padding: 18px 20px 48px;
  display: grid; gap: 18px; align-items: start;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr) minmax(0, 300px);
  grid-template-areas: "memo out side";
}
.memo-panel { grid-area: memo; }
.output-panel { grid-area: out; }
.side { grid-area: side; display: grid; gap: 14px; }

/* 넓은 화면: 양옆 패널 고정 + 내부 스크롤 */
@media (min-width: 1201px) {
  .memo-panel, .side {
    position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto;
    scrollbar-width: thin;
  }
}
/* 중간 화면: 설정+메모 | 결과 */
@media (max-width: 1200px) {
  .layout {
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    grid-template-areas: "side out" "memo out";
  }
}
/* 좁은 화면: 한 줄 */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "memo" "out"; padding: 14px 16px 40px; }
}

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.panel-title { font-size: 15px; margin: 0; }
.hint { margin: 0 0 12px; font-size: 12px; color: var(--muted); }

/* ===== 메모 패널 ===== */
.memo-hint { margin: 0 0 4px; font-size: 13px; color: var(--text-2); }
.memo-fields { display: grid; gap: 4px; }
.memo-field { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.memo-field:last-child { border-bottom: 0; }
.memo-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); flex-wrap: wrap; }
.memo-icon { font-size: 15px; }
.req-badge {
  font-size: 11px; font-weight: 700; color: var(--primary); background: var(--primary-soft);
  padding: 1px 8px; border-radius: 6px;
}
.opt { font-size: 12px; font-weight: 400; color: var(--muted); }
.memo-field textarea, .memo-field input, .memo-field select {
  border-color: transparent; background: var(--surface-2); font-size: 14px;
}
.memo-field textarea { resize: none; overflow: hidden; min-height: 40px; line-height: 1.6; }
.memo-field textarea:hover, .memo-field input:hover, .memo-field select:hover { border-color: var(--border); }
.memo-extra { margin-top: 6px; }
.memo-extra textarea { min-height: 96px; resize: vertical; overflow: auto; }

/* ===== Fields (공통) ===== */
.fields { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.req { color: var(--danger); font-style: normal; }
.field-help { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--surface); }
textarea { resize: vertical; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--danger); background: var(--danger-soft); }

/* ===== 설정 패널 ===== */
.side-title { margin: 0 0 14px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.settings-panel .fields { gap: 12px; }
.settings-panel { padding: 16px; }
.select-strong { font-weight: 600; }
.tone-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tone-opt {
  text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
  padding: 8px 10px; cursor: pointer; font-size: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.4;
  transition: border-color .15s, background .15s;
}
.tone-opt:hover { border-color: var(--primary); }
.tone-opt[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.tone-opt small { font-weight: 400; color: var(--muted); font-size: 11px; }
.style-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.style-status { margin: 0; font-size: 12px; color: var(--muted); flex: 1; min-width: 140px; }
.style-status.on { color: var(--ok); font-weight: 600; }

/* ===== AI 글 작성 카드 (어두운 카드) ===== */
.gen-card {
  background: var(--card-dark); color: var(--card-dark-text); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 10px; align-content: start; box-shadow: 0 8px 24px rgba(30, 25, 15, .18);
}
.gen-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gen-title { font-size: 14px; font-weight: 700; }
.conn-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px;
  background: var(--card-dark-2); color: var(--card-dark-muted); border: 0; cursor: pointer;
}
.conn-badge.on { color: #9fd8a8; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--card-dark-2); color: var(--card-dark-text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip.chip-empty { color: var(--card-dark-muted); }
.gen-sub { margin: 0; font-size: 12px; color: var(--card-dark-muted); }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.req-list li { display: flex; align-items: center; gap: 8px; color: var(--card-dark-muted); }
.req-list li::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 4px; border: 1.5px solid var(--card-dark-muted);
}
.req-list li.done { color: var(--card-dark-text); }
.req-list li.done::before { content: "✓"; display: grid; place-items: center; font-size: 10px; font-weight: 800; background: #9fd8a8; border-color: #9fd8a8; color: var(--card-dark); }
.btn-gen {
  width: 100%; padding: 14px; font-size: 15px; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, #5b8cf0, #3f6fd8); box-shadow: 0 6px 18px rgba(63, 111, 216, .35);
}
.btn-gen:not(:disabled):hover { filter: brightness(1.06); }
.gen-card .form-error { color: #ffb4a8; margin: 0; min-height: 0; }
.gen-card .form-error:empty { display: none; }
.usage { display: flex; align-items: baseline; justify-content: center; gap: 6px; font-size: 12px; color: var(--card-dark-muted); font-variant-numeric: tabular-nums; }
.usage strong { color: var(--card-dark-text); font-size: 13px; }
.usage.near strong { color: #f0c060; }
.usage.full strong { color: #ff9a8a; }

/* ===== Buttons ===== */
.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; cursor: pointer;
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  transition: background .15s, border-color .15s, opacity .15s, filter .15s; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:not(:disabled):hover { border-color: var(--primary); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:not(:disabled):hover { filter: brightness(.97); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; font-weight: 600; padding: 2px 4px; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 1em; }

/* ===== 결과 패널 ===== */
.output-panel { min-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.output-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.output-actions { display: flex; gap: 8px; }

.stats {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px;
  position: sticky; top: 56px; z-index: 5; background: var(--surface); padding: 4px 0 12px;
}
@media (max-width: 640px) { .stats { grid-template-columns: minmax(0, 1fr); position: static; } }
.stat { border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; background: var(--surface-2); }
.stat-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.stat-label small { font-weight: 400; }
.stat-value { font-variant-numeric: tabular-nums; }
.stat-value strong { font-size: 20px; }
.stat-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-2); margin-top: 6px; flex-wrap: wrap; }
.meter { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 8px; }
.meter-fill { height: 100%; width: 0; background: var(--lv-low); border-radius: 99px; transition: width .25s, background .25s; }
.meter-fill.ok { background: var(--primary); }
.meter-fill.over { background: var(--lv-good); }
.toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 12px; color: var(--text-2); }

.kw-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.kw-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kw-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kw-meta { font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; margin-left: 6px; }
.badge.low { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: #e7f3ea; color: var(--ok); }
.badge.high { background: var(--danger-soft); color: var(--danger); }

/* 빈 화면: 3단계 안내 */
.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 48px 16px; color: var(--text-2);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 8px; font-size: 20px; color: var(--text); }
.empty > p { margin: 0; line-height: 1.7; }
.steps { list-style: none; margin: 28px 0 16px; padding: 0; display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; justify-content: center; }
.step {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2);
  font-size: 12px; line-height: 1.5; min-width: 170px;
}
.step b { color: var(--primary); }
.step-num {
  width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 12px;
}
.step-arrow { align-self: center; color: var(--muted); }
@media (max-width: 760px) { .step-arrow { display: none; } .step { min-width: 0; width: 100%; } }
.steps-hint { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 6px 14px; margin: 0; }

.loading { padding: 8px 0 16px; color: var(--text-2); }
.loading-head { display: flex; align-items: center; gap: 12px; }
.loading-head p { margin: 0; flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.loading .meter { margin: 10px 0 12px; }
.preview {
  margin: 0; max-height: 60vh; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 14px; line-height: 1.75; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.short-note {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px;
  margin-bottom: 14px; font-size: 13px; font-weight: 600;
}
.spinner {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.article { display: grid; gap: 14px; }
.block { border: 1px solid var(--border); border-radius: 11px; padding: 14px; background: var(--surface); }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.block-tag { font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 6px; }
.block-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.title-input { font-size: 18px; font-weight: 700; }
.heading-input { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.body-input { min-height: 120px; line-height: 1.75; resize: none; overflow: hidden; }
.tags-input { font-size: 13px; }

.photo {
  margin-top: 10px; border: 1px dashed var(--photo-border); background: var(--photo-bg);
  border-radius: 8px; padding: 10px 12px; color: var(--photo-text); font-size: 13px;
}
.photo-title { font-weight: 700; margin-bottom: 4px; }
.photo ol { margin: 0; padding-left: 20px; }
.photo li + li { margin-top: 3px; }
.copy-opt { font-size: 13px; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }

/* ===== 미리보기 (블로그 발행 모습) ===== */
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.post {
  max-height: calc(100vh - 160px); overflow-y: auto; border: 1px solid var(--border); border-radius: 12px;
  padding: 28px 24px; background: var(--surface); line-height: 1.9; font-size: 15px;
}
.post-cat { font-size: 12px; color: var(--primary); font-weight: 700; margin: 0 0 6px; }
.post-title { font-size: 24px; line-height: 1.4; margin: 0 0 18px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.post h3 { font-size: 18px; margin: 28px 0 10px; }
.post p { margin: 0 0 14px; white-space: pre-wrap; }
.post-photo {
  margin: 14px 0; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border);
  min-height: 110px; display: grid; place-content: center; text-align: center;
  color: var(--muted); font-size: 13px; padding: 16px 20px;
}
.post-photo span { display: block; font-size: 26px; margin-bottom: 4px; }
.post-tags { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--primary); font-size: 14px; word-break: keep-all; }

/* Analysis */
.analysis {
  border: 1px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 14px;
  background: var(--surface); scroll-margin-top: 200px;
}
.analysis-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
@media (max-width: 760px) { .analysis-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; } }

/* 막대 공통 */
.bar { height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; position: relative; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; transition: width .35s ease, background .25s; background: var(--lv-mid); }
.bar-fill.lv-good { background: var(--lv-good); }
.bar-fill.lv-mid { background: var(--lv-mid); }
.bar-fill.lv-low { background: var(--lv-low); }
.bar-fill.lv-zero { background: var(--lv-zero); }
/* 키워드 비율 막대: 0~4% 중 2~3% 구간을 배경에 표시 */
.bar-zone::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 25%;
  background: var(--lv-good); opacity: .18;
}

/* 왼쪽 */
.a-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.a-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-2); }
.metric { margin-bottom: 18px; }
.metric-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.metric-top span { font-size: 15px; font-weight: 600; }
.metric-top strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.metric-note { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 8px; text-align: center;
  display: grid; gap: 4px; background: var(--surface-2);
}
.tile strong { font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; color: var(--text-2); }

/* 오른쪽 */
.total-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.total-box { display: grid; gap: 2px; }
.total-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.total-num { display: flex; align-items: baseline; gap: 4px; }
.total-num strong { font-size: 56px; line-height: 1; font-weight: 800; color: var(--lv-mid); font-variant-numeric: tabular-nums; }
.total-num span { font-size: 18px; color: var(--muted); }
.total-sub { font-size: 12px; color: var(--muted); }
.grade {
  width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; font-weight: 800; border: 3px solid currentColor;
}
.grade-a { color: var(--lv-good); }
.grade-b { color: var(--lv-mid); }
.grade-c { color: var(--lv-low); }
.grade-d { color: var(--lv-zero); }

.score-rows { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.score-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 52px; align-items: center; gap: 12px; }
.score-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-pts { font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.score-row.lv-good .score-pts { color: var(--lv-good); }
.score-row.lv-mid .score-pts { color: var(--lv-mid); }
.score-row.lv-low .score-pts { color: var(--lv-low); }
.score-row.lv-zero .score-pts { color: var(--lv-zero); }

.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tip {
  border-left: 3px solid var(--lv-low); border-radius: 4px 8px 8px 4px; background: var(--surface-2);
  padding: 9px 12px; font-size: 13px; line-height: 1.5;
}
.tip strong { font-weight: 700; }
.tip-mark { color: var(--lv-low); margin-right: 6px; font-size: 11px; }
.tip-ok { border-left-color: var(--lv-good); }
.analysis-foot { margin: 16px 0 0; font-size: 12px; color: var(--muted); }

/* Dialog */
.dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(10, 15, 12, .5); }
.dialog form, .dialog-body { padding: 22px; display: grid; gap: 14px; }
.dialog-wide { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog-desc { margin: 0; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.key-row { display: flex; gap: 6px; }
.key-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.dialog-foot { margin: 0; font-size: 12px; color: var(--muted); }
.test-result { margin: 0; font-size: 13px; min-height: 1em; white-space: pre-line; font-variant-numeric: tabular-nums; }
.test-result.ok { color: var(--primary); }
.test-result.err { color: var(--danger); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
