:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #1d2130; --muted: #636b80; --line: #e3e6ef;
  --accent: #4f46e5; --accent-weak: #eef0ff; --accent-text: #ffffff;
  --dev: #0f766e; --dev-weak: #e6f5f3; --player: #b45309; --player-weak: #fdf3e5;
  --high: #c62828; --mid: #a16207; --low: #4b5563;
  --mark: #fff1a8; --ok: #15803d; --del: #b42318; --del-bg: #fde8e7; --ins: #116b37; --ins-bg: #ddf5e5; --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b; --card: #1b1e28; --text: #e8eaf2; --muted: #9aa1b5; --line: #2c3040;
    --accent: #8b85ff; --accent-weak: #262746; --accent-text: #12141b;
    --dev: #5eead4; --dev-weak: #16302d; --player: #fbbf24; --player-weak: #33281a;
    --high: #f87171; --mid: #facc15; --low: #9ca3af; --mark: #5b4b12; --ok: #4ade80; --del: #fca5a5; --del-bg: #4a1f1f; --ins: #86efac; --ins-bg: #183d27;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--text); }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 15px; }
.who { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand span:last-child, .who .btn { white-space: nowrap; }
@media (max-width: 480px) { .who span { display: none; } }

.view { max-width: 760px; margin: 0 auto; padding: 20px 16px 120px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
h1 { font-size: 24px; line-height: 1.35; margin: 0 0 8px; }
h2 { font-size: 20px; line-height: 1.4; margin: 6px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 12px; }

.field { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.field:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea.field { min-height: 140px; resize: vertical; line-height: 1.6; }
label.lbl { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; text-decoration: none; color: var(--text); }
.list .meta { color: var(--muted); font-size: 14px; white-space: nowrap; }

.progress { margin: 0 0 14px; }
.progress .label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--muted); }
.progress .count { font-size: 15px; color: var(--text); font-weight: 700; }
.progress .count b { color: var(--accent); font-size: 20px; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.doc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--accent-weak); color: var(--accent); }
.chip.dev { background: var(--dev-weak); color: var(--dev); }
.chip.player { background: var(--player-weak); color: var(--player); }
.chip.sev-높음 { color: var(--high); background: transparent; border: 1px solid currentColor; }
.chip.sev-중간 { color: var(--mid); background: transparent; border: 1px solid currentColor; }
.chip.sev-낮음 { color: var(--low); background: transparent; border: 1px solid currentColor; }

.question { font-size: 17px; }
.excerpt { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--line); font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.excerpt .where { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
details.why { margin-top: 12px; font-size: 15px; }
details.why summary { cursor: pointer; color: var(--muted); font-weight: 600; min-height: 32px; }
details.why ul { margin: 6px 0 0; padding-left: 20px; }

.options { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 720px) { .options { grid-template-columns: 1fr 1fr; } }
.opt { text-align: left; padding: 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.opt:hover, .opt:focus-visible { border-color: var(--accent); outline: none; }
.opt.selected { border-color: var(--accent); background: var(--accent-weak); }
.opt .persp { font-weight: 700; color: var(--accent); font-size: 15px; }
.opt .sum { font-size: 14px; color: var(--muted); }
.diff { display: grid; gap: 6px; font-size: 14px; line-height: 1.6; margin-top: 6px; }
.dline { display: grid; grid-template-columns: 26px 1fr; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--bg); white-space: pre-wrap; word-break: break-word; }
.dline b { font-size: 12px; color: var(--muted); padding-top: 2px; }
.dline.before span { color: var(--muted); }
del { background: var(--del-bg); color: var(--del); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
ins { background: var(--ins-bg); color: var(--ins); text-decoration: none; border-radius: 3px; padding: 0 2px; font-weight: 600; }
ins.newp { display: block; margin-top: 6px; padding: 4px 6px; }
.custom-diff { margin-top: 8px; }
.custom { margin-top: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-top: 16px; }
.answered-note { margin-top: 10px; font-size: 14px; color: var(--ok); font-weight: 600; }

.log { list-style: none; margin: 12px 0 0; padding: 0; font-size: 14px; max-height: 320px; overflow: auto; }
.log li { display: flex; gap: 10px; padding: 4px 0; color: var(--muted); }
.log li:last-child { color: var(--text); font-weight: 600; }
.log time { min-width: 44px; font-variant-numeric: tabular-nums; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.done-hero { text-align: center; padding: 28px 20px; }
.done-hero .big { font-size: 44px; line-height: 1; }
.done-hero h1 { margin-top: 12px; font-size: 26px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 13px; color: var(--muted); }
.changes { list-style: none; padding: 0; margin: 0; }
.changes li { padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.changes li:first-child { border-top: 0; }
.changes .ctitle { font-weight: 600; }
.changes .cnew { font-size: 14px; color: var(--muted); white-space: pre-wrap; margin-top: 4px; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); margin-right: 6px; }
.tag.on { background: var(--accent-weak); color: var(--accent); }
.err { color: var(--high); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .view { padding: 14px 12px 120px; }
  .card { padding: 16px; }
  h2 { font-size: 18px; }
  .actions .btn { flex: 1; }
}
