/* =========================================================
   프롬프트 공방 — 스타일
   레이아웃: 왼쪽 작성 폼 + 오른쪽 고정 '프롬프트 용지'(결과 시트).
   컨셉: 종이 위의 잉크(블루), 형광펜(옐로)으로 모호한 표현 표시.
   ========================================================= */

:root {
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #EAEDF4;
  --line: #D7DCE7;
  --line-strong: #B9C1D3;
  --fg: #151A2D;
  --fg-2: #4B5469;
  --fg-3: #7C8498;
  --accent: #2447D6;
  --accent-hover: #1B38B3;
  --accent-fg: #FFFFFF;
  --accent-soft: #E4E9FB;
  --mark: #FFE66D;
  --mark-fg: #3A3000;
  --ok: #1D8F5A;
  --ok-soft: #DDF3E7;
  --warn: #B9700E;
  --warn-soft: #FBEBD2;
  --bad: #C73C3C;
  --bad-soft: #FADADA;
  --sheet: #FFFFFF;
  --shadow: 0 1px 2px rgba(21, 26, 45, .06), 0 10px 28px -14px rgba(21, 26, 45, .22);
  --radius: 10px;
  --radius-sm: 6px;
  --font-body: "Pretendard Variable", Pretendard, "IBM Plex Sans KR", -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: "Nanum Gothic Coding", "IBM Plex Mono", "D2Coding", Consolas, Menlo, monospace;
  --topbar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1219;
    --surface: #161A24;
    --surface-2: #1F2432;
    --line: #2A3042;
    --line-strong: #3A4258;
    --fg: #E7EAF2;
    --fg-2: #AAB1C3;
    --fg-3: #7B8397;
    --accent: #7F99FF;
    --accent-hover: #9DB1FF;
    --accent-fg: #0B1020;
    --accent-soft: #1D2543;
    --mark: #6A5A00;
    --mark-fg: #FFF2A8;
    --ok: #3FC48A;
    --ok-soft: #153426;
    --warn: #E7AB45;
    --warn-soft: #3A2B10;
    --bad: #EF7272;
    --bad-soft: #3D1A1A;
    --sheet: #121620;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0F1219;
  --surface: #161A24;
  --surface-2: #1F2432;
  --line: #2A3042;
  --line-strong: #3A4258;
  --fg: #E7EAF2;
  --fg-2: #AAB1C3;
  --fg-3: #7B8397;
  --accent: #7F99FF;
  --accent-hover: #9DB1FF;
  --accent-fg: #0B1020;
  --accent-soft: #1D2543;
  --mark: #6A5A00;
  --mark-fg: #FFF2A8;
  --ok: #3FC48A;
  --ok-soft: #153426;
  --warn: #E7AB45;
  --warn-soft: #3A2B10;
  --bad: #EF7272;
  --bad-soft: #3D1A1A;
  --sheet: #121620;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img, svg { max-width: 100%; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
code, pre, kbd { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: 16px; }

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; }
.brand-mark .ic { width: 16px; height: 16px; }
.brand-name { font-size: 16px; }
.nav { display: flex; align-items: stretch; gap: 2px; height: 100%; margin-left: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; color: var(--fg-2); text-decoration: none; font-weight: 500; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav-item:hover { color: var(--fg); }
.nav-item.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-item .count { font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ai-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-2); background: var(--surface-2); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.ai-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; color: var(--fg-2); flex: none;
}
.icon-btn:hover { color: var(--fg); border-color: var(--line-strong); }

/* ---------- 공용 컴포넌트 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font-weight: 600; font-size: 14px; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ai { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-ai:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 30%); color: var(--accent-fg); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--fg-2);
  border-radius: 999px; padding: 4px 11px; font-size: 13px; line-height: 1.4;
}
.chip:hover { border-color: var(--line-strong); color: var(--fg); }
.chip-more { border-style: dashed; color: var(--fg-3); }
.chip-more:hover { color: var(--accent); border-color: var(--accent); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tag { display: inline-block; font-size: 12px; color: var(--fg-3); background: var(--surface-2); border-radius: 4px; padding: 1px 7px; }
.kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--fg-2); background: var(--surface); }

input[type="text"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 9px 11px; font-size: 14.5px; line-height: 1.55; color: var(--fg);
}
textarea { resize: vertical; min-height: 72px; }
input::placeholder, textarea::placeholder { color: var(--fg-3); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%), linear-gradient(135deg, var(--fg-3) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
label { font-weight: 600; font-size: 14px; }

/* ---------- 뷰 ---------- */
.view { display: none; padding-block: 28px 64px; }
.view.is-active { display: block; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.view-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.lead { color: var(--fg-2); max-width: 64ch; margin-top: 6px; }

/* ---------- 작성 뷰 ---------- */
.quickstart { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 13px; color: var(--fg-2); }
.quickstart .label { font-weight: 600; color: var(--fg-3); margin-right: 2px; }
.quickstart .spacer { flex: 1; }
.sample-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  background: var(--accent-soft); color: var(--fg); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 18px; font-size: 14px;
}
.sample-banner .ic { color: var(--accent); }
.sample-banner button { margin-left: auto; }
.seg { display: none; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); gap: 28px; align-items: start; }

.form { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.group { display: flex; flex-direction: column; gap: 18px; }
.group-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.group-head h2 { font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.group-head p { font-size: 13px; color: var(--fg-3); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.field-head label { color: var(--fg); }
.hint { font-size: 12.5px; color: var(--fg-3); }
.req { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 6px; margin-left: 4px; vertical-align: middle; }
.field.is-core textarea { min-height: 112px; font-size: 15px; border-left: 3px solid var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vague-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 10px; }
.vague-note .ic { width: 16px; height: 16px; margin-top: 2px; }
.vague-note mark { background: var(--mark); color: var(--mark-fg); border-radius: 3px; padding: 0 3px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; font-weight: 500; color: var(--fg); cursor: pointer; }
.check input { margin: 4px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.check small { display: block; font-weight: 400; color: var(--fg-3); font-size: 12.5px; }

/* 결과 패널 */
.sheet-panel {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 16px);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  max-height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top, 0px) - 32px);
}
.score { display: flex; align-items: center; gap: 14px; }
.score-ring { position: relative; width: 56px; height: 56px; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .4s ease, stroke .3s; }
.score-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.score-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.score-text strong { font-size: 15px; }
.score-text span { font-size: 12.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.score[data-band="great"] .ring-fg { stroke: var(--ok); }
.score[data-band="good"] .ring-fg { stroke: var(--accent); }
.score[data-band="fair"] .ring-fg { stroke: var(--warn); }
.score[data-band="draft"] .ring-fg { stroke: var(--bad); }
.tips { display: flex; flex-direction: column; gap: 6px; }
.tip { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--fg-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 10px; }
.tip .ic { width: 15px; height: 15px; color: var(--warn); margin-top: 2px; }
.tip button { margin-left: auto; flex: none; background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 13px; padding: 0; }
.tip.is-ok { color: var(--ok); background: var(--ok-soft); }
.tip.is-ok .ic { color: var(--ok); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); }
.select-inline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--fg-3); }
.select-inline select { width: auto; padding: 4px 28px 4px 8px; font-size: 12.5px; }
.vars { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.vars-title { font-size: 12.5px; font-weight: 600; color: var(--fg-2); }
.var-row { display: grid; grid-template-columns: minmax(80px, 36%) 1fr; align-items: center; gap: 8px; }
.var-row label { font-size: 13px; font-family: var(--font-mono); font-weight: 400; color: var(--mark-fg); background: var(--mark); border-radius: 3px; padding: 1px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-row input { padding: 6px 9px; font-size: 13.5px; }
.sheet {
  margin: 0; min-height: 200px; flex: 1 1 auto; overflow: auto;
  background: var(--sheet); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word; color: var(--fg);
}
.sheet .sh { color: var(--accent); font-weight: 700; }
.sheet .m-var { background: var(--mark); color: var(--mark-fg); border-radius: 3px; padding: 0 3px; }
.sheet .m-vague { background: transparent; color: var(--warn); text-decoration: underline wavy var(--warn); text-underline-offset: 3px; }
.sheet .empty { color: var(--fg-3); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px;
}
.menu-list button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 10px; border-radius: 6px; font-size: 14px; text-align: left; color: var(--fg); }
.menu-list button:hover { background: var(--surface-2); }
.checklist { border-top: 1px solid var(--line); padding-top: 8px; }
.checklist summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--fg-2); display: flex; align-items: center; gap: 8px; list-style: none; }
.checklist summary::-webkit-details-marker { display: none; }
.checklist summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--fg-3); border-bottom: 2px solid var(--fg-3); transform: rotate(45deg); margin-left: auto; transition: transform .2s; }
.checklist[open] summary::after { transform: rotate(-135deg); }
.checklist ul { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.checklist li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--fg-2); }
.checklist li .ic { width: 15px; height: 15px; margin-top: 3px; }
.checklist li[data-status="ok"] .ic { color: var(--ok); }
.checklist li[data-status="warn"] .ic { color: var(--warn); }
.checklist li[data-status="miss"] .ic { color: var(--fg-3); }
.checklist li .w { margin-left: auto; color: var(--fg-3); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.stats-line { font-size: 12px; color: var(--fg-3); }

/* ---------- 템플릿 뷰 ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--fg-3); width: 16px; height: 16px; }
.search input { padding-left: 34px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tpl-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.tpl-card:hover { border-color: var(--line-strong); }
.tpl-cat { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tpl-card h3 { font-size: 16px; font-weight: 700; }
.tpl-card p { font-size: 13.5px; color: var(--fg-2); flex: 1; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-foot { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.tpl-foot .btn-link { background: none; border: 0; color: var(--fg-2); font-size: 13px; padding: 0; font-weight: 500; }
.tpl-foot .btn-link:hover { color: var(--accent); }
.tpl-preview { font-size: 12.5px; max-height: 240px; overflow: auto; }
.empty { color: var(--fg-3); padding: 24px 0; }

/* ---------- 보관함 ---------- */
.lib-list { display: flex; flex-direction: column; gap: 10px; }
.lib-item {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.lib-item .score-ring { width: 48px; height: 48px; }
.lib-item .score-num { font-size: 14px; }
.lib-item h3 { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item p { font-size: 13px; color: var(--fg-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lib-item .meta { font-size: 12px; color: var(--fg-3); margin-top: 4px; font-variant-numeric: tabular-nums; }
.lib-actions { display: flex; gap: 6px; }
.empty-state { text-align: center; padding: 48px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--fg-2); }
.empty-state .ic { width: 32px; height: 32px; color: var(--fg-3); margin-bottom: 10px; }
.empty-state h2 { font-size: 17px; margin-bottom: 6px; }

/* ---------- 가이드 ---------- */
.guide { max-width: 780px; display: flex; flex-direction: column; gap: 40px; }
.guide section { display: flex; flex-direction: column; gap: 14px; }
.guide h2 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.guide h3 { font-size: 16px; font-weight: 700; margin-top: 6px; }
.guide p, .guide li { color: var(--fg-2); font-size: 15px; }
.guide ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.guide ol { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.guide strong { color: var(--fg); }
.principle { display: flex; flex-direction: column; gap: 10px; padding: 18px 0; border-top: 1px solid var(--line); }
.principle:last-child { border-bottom: 1px solid var(--line); }
.principle h3 { margin: 0; }
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ba > div { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; background: var(--surface-2); border-left: 3px solid var(--bad); min-width: 0; }
.ba > div + div { border-left-color: var(--ok); }
.ba .lbl { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 4px; }
.ba p { color: var(--fg); font-size: 13.5px; white-space: pre-wrap; }
.skeleton { background: var(--sheet); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 14px 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; white-space: pre-wrap; margin: 0; overflow-x: auto; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--fg-3); font-weight: 600; }
td:last-child { font-variant-numeric: tabular-nums; }

/* ---------- 푸터 ---------- */
.footer { border-top: 1px solid var(--line); padding-block: 20px; color: var(--fg-3); font-size: 12.5px; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* ---------- 모달 / 토스트 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 20, .45); }
.modal-card {
  position: relative; width: min(680px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 4px 18px 14px; overflow: auto; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: var(--fg-2); }
.modal-body label { display: block; margin-bottom: 6px; color: var(--fg); }
.modal-body .field-note { font-size: 12.5px; color: var(--fg-3); }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 10px 18px 16px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }
.ai-notes { list-style: disc; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; color: var(--fg); }
.ai-field { display: flex; flex-direction: column; gap: 4px; }
.ai-field .k { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3); }
.ai-field pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--fg); }
.ai-status { display: flex; align-items: center; gap: 10px; color: var(--fg-2); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px);
  background: var(--fg); color: var(--bg); border-radius: 10px; padding: 10px 16px; font-size: 14px; box-shadow: var(--shadow);
}
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }

/* ---------- 반응형 ---------- */
@media (max-width: 1023px) {
  .builder { grid-template-columns: 1fr; gap: 20px; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--surface-2); border-radius: 8px; padding: 3px; margin-bottom: 16px; }
  .seg button { border: 0; background: none; border-radius: 6px; padding: 8px; font-weight: 600; color: var(--fg-2); display: flex; justify-content: center; gap: 6px; }
  .seg button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
  .seg .badge { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 7px; font-variant-numeric: tabular-nums; }
  .builder[data-pane="form"] .sheet-panel { display: none; }
  .builder[data-pane="sheet"] .form { display: none; }
  .sheet-panel { position: static; max-height: none; }
  .sheet { max-height: 60vh; }
}
@media (max-width: 720px) {
  .topbar-in { gap: 8px; }
  .brand-name { display: none; }
  .nav { margin-left: 0; gap: 0; }
  .nav-item { padding: 0 9px; font-size: 13px; }
  .nav-item .ic { display: none; }
  .ai-pill { display: none; }
  .view { padding-block: 20px 48px; }
  .view-head h1 { font-size: 22px; }
  .field-row { grid-template-columns: 1fr; }
  .checks { grid-template-columns: 1fr; }
  .ba { grid-template-columns: 1fr; }
  .lib-item { grid-template-columns: 48px minmax(0, 1fr); }
  .lib-item .lib-actions { grid-column: 1 / -1; }
  .sheet-panel { padding: 12px; }
  .actions .btn { flex: 1 1 auto; }
  .quickstart { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .quickstart::-webkit-scrollbar { display: none; }
  .quickstart .chips { flex-wrap: nowrap; }
  .quickstart .label { white-space: nowrap; }
  .sample-banner button { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
