:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #e7eefc;
  --ok: #0f9f6e;
  --warn: #d97706;
  --bad: #dc2626;
  --violet: #7c3aed;
  --radius: 16px;
  --tab-h: 64px;
  --font: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #111827; --surface-2: #1b2537; --text: #e5e7eb;
    --muted: #94a3b8; --line: #24314a; --brand: #60a5fa; --brand-strong: #93c5fd;
    --brand-soft: #172554; --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  font-size: var(--font); line-height: 1.45;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.28; }
h1 { font-size: 1.32em; }
h2 { font-size: 1.06em; }
h3 { font-size: .96em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.tiny { font-size: .76em; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app { max-width: 720px; margin: 0 auto; padding: 0 16px; overflow-x: hidden; }
.row > input, .row > select { min-width: 0; }
.app.wide { max-width: 1080px; }
.boot { min-height: 80vh; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; }
.logo { font-size: 2rem; font-weight: 850; letter-spacing: -.03em; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 0 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 1.12em; }
.topbar .sub { display: block; font-size: .72em; font-weight: 500; color: var(--muted); }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 1.05em; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 12px 0;
}
.card.tight { padding: 10px 12px; }
.card h2 { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.card.hero { background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, var(--surface)), var(--surface)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.start { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid { display: grid; gap: 10px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 430px) { .grid3 { grid-template-columns: 1fr 1fr; } }

.btn {
  white-space: nowrap;
  flex: none;
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 650; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: .85em; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: .85em; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); font-weight: 750; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .76em; font-weight: 750; white-space: nowrap; }
.badge.ok, .badge.met { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); }
.badge.warn, .badge.partial { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: #b45309; }
.badge.bad, .badge.missing { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); }

.stat { display: flex; gap: 10px; }
.stat > div { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 1.2em; }
.stat .lbl { font-size: .74em; color: var(--muted); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .92em; }
.kv:last-child { border-bottom: 0; }
.kv span:last-child { font-weight: 650; text-align: right; }
.kv.bad span:last-child { color: var(--bad); }
.kv.ok span:last-child { color: var(--ok); }
.kv.warn span:last-child { color: var(--warn); }
.kv.req { flex-direction: column; align-items: flex-start; gap: 2px; }
.kv.req span:last-child { text-align: left; font-weight: 600; }
.j1grid { grid-template-columns: 1fr; }
@media (min-width: 760px) { .j1grid { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: .8em; font-weight: 750; color: var(--muted); }
.field input, .field select, .field textarea {
  min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); width: 100%;
}
.field textarea { min-height: 110px; resize: vertical; }
.field .hint { font-size: .76em; color: var(--muted); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.tabs[hidden] { display: none; }
.tabs a { flex: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: .66em; color: var(--muted); font-weight: 650; }
.tabs a .ico { font-size: 1.2em; }
.tabs a[aria-current="page"] { color: var(--brand-strong); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: .85em; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 60; max-width: 90vw;
}
.toast.show { opacity: .96; transform: translateX(-50%) translateY(0); }

.notice { border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); padding: 10px 12px; border-radius: 8px; font-size: .86em; margin: 8px 0; }
.notice.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.notice.good { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.notice.brand { border-color: var(--brand); background: var(--brand-soft); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list li:last-child { border-bottom: 0; }
.linkrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.linkrow:last-child { border-bottom: 0; }

.timeline .ev { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: none; }
.timeline .ev .body { flex: 1; min-width: 0; }
.timeline .ev .meta { color: var(--muted); font-size: .78em; display: flex; gap: 8px; flex-wrap: wrap; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.board .col { background: var(--surface-2); border-radius: 14px; padding: 8px; min-height: 120px; }
.board .col h3 { font-size: .82em; color: var(--muted); padding: 2px 4px 8px; }
.board .bcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.board .bcard .co { font-weight: 750; }

.step { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.step:last-child { border-bottom: 0; }
.step .num { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: .8em; flex: none; }
.step.done .num { background: var(--ok); color: #fff; }
.step.current .num { background: var(--brand); color: #fff; }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); }
.check.done label { text-decoration: line-through; color: var(--muted); }

.ring {
  --p: 0; width: 132px; height: 132px; border-radius: 50%; margin: 8px auto;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center; position: relative;
}
.ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring .inner { position: relative; z-index: 1; text-align: center; font-weight: 800; font-size: 1.35em; }
.ring .inner small { display: block; font-size: .5em; color: var(--muted); font-weight: 600; }
.ring.over { background: conic-gradient(var(--bad) 100%, var(--surface-2) 0); }

.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-body { width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border: 1px solid var(--line); }
.sheet-handle { width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 14px; }

.login { padding: 40px 0; }
.login .card { padding: 24px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.pinpad button { min-height: 54px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 1.2em; font-weight: 750; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 16px 0; }
.pin-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.pin-dots i.on { background: var(--brand); }

.player { display: flex; flex-direction: column; gap: 10px; }
.player .bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.player .bar > i { display: block; height: 100%; background: var(--brand); width: 0; }
.player .controls { display: flex; justify-content: center; gap: 10px; }
.player .big { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 1.3em; }
.player .seg-text { font-size: .9em; min-height: 3.6em; }

.viewer { position: fixed; inset: 0; z-index: 40; background: var(--surface); display: flex; flex-direction: column; }
.viewer .vbar { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; border-bottom: 1px solid var(--line); }
.viewer iframe { flex: 1; width: 100%; border: 0; }

.qa { border-bottom: 1px dashed var(--line); padding: 10px 0; }
.qa:last-child { border-bottom: 0; }
.qa .q { font-weight: 650; }
.qa .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.answerbox { white-space: pre-wrap; font-size: .92em; background: var(--surface-2); padding: 12px; border-radius: 12px; }

.heat { display: flex; gap: 4px; flex-wrap: wrap; }
.heat i { width: 16px; height: 16px; border-radius: 4px; background: var(--surface-2); }
.heat i.on { background: var(--ok); }

@media (min-width: 760px) {
  .app { padding: 0 24px; }
  .grid2.wide { grid-template-columns: 1.15fr .85fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
