:root {
  color-scheme: light dark;
  --bg: #ffffff; --surface: #f4f6f6; --fg: #17181c; --muted: #565b63; --line: #dfe3e3;
  --accent: #0f6b5c; --accent-fg: #ffffff; --danger: #c0262d;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem; --text-lg: 1.125rem;
  --text-xl: 1.25rem; --text-2xl: 1.5rem; --text-3xl: 2rem;
  --leading: 1.6; --leading-tight: 1.25;
  --radius: 8px; --radius-full: 999px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 6%);
  --measure: 65ch; --tap: 44px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111314; --surface: #1b1e1f; --fg: #ededf0; --muted: #a3a9ad; --line: #2c3133;
    --accent: #5fd3b8; --accent-fg: #04201a; --danger: #ff7b72;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px rgb(0 0 0 / 40%); }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: var(--leading);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-size: var(--text-md);
  overflow-wrap: anywhere; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: var(--leading-tight); margin: 0; }
h1 { font-size: var(--text-2xl); } h2 { font-size: var(--text-xl); } h3 { font-size: var(--text-md); }
p { margin: 0; }
.muted { color: var(--muted); font-size: var(--text-sm); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: var(--tap); padding: 0 var(--space-4); border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; transition: opacity .15s, transform .15s; }
button:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.ghost { border-color: transparent; color: var(--muted); }
button.danger { color: var(--danger); }
label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-1); }
input, select, textarea { width: 100%; min-height: var(--tap); padding: var(--space-2) var(--space-3); border: 1px solid var(--muted);
  border-radius: var(--radius); background: var(--bg); font-size: var(--text-md); }
textarea { min-height: 96px; }
.field { margin-bottom: var(--space-3); }
.err { color: var(--danger); font-size: var(--text-sm); margin-top: var(--space-1); min-height: 1em; }

.gate { max-width: 420px; margin: 0 auto; padding: var(--space-7) var(--space-4); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; margin-bottom: var(--space-5); }
.brand img { width: 32px; height: 32px; }
.gate h1 { margin-bottom: var(--space-2); }
.gate .box { margin-top: var(--space-5); padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 140px; }
.notice { padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); background: var(--surface); font-size: var(--text-sm); margin-bottom: var(--space-4); }

.app { max-width: 1120px; margin: 0 auto; padding: 0 var(--space-4) calc(var(--tap) + var(--space-7) + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: center; padding: var(--space-3) 0; gap: var(--space-2); }
.top .brand { margin: 0; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom)); z-index: 5; }
nav.tabs button { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--muted); font-size: var(--text-xs);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: var(--space-1); }
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button[aria-selected=true] { color: var(--accent); font-weight: 700; background: var(--surface); }
main h2 { margin: var(--space-4) 0 var(--space-3); }
.cards { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); background: var(--surface); }
.card .num { font-size: var(--text-3xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.bar { height: 8px; border-radius: var(--radius-full); background: var(--line); overflow: hidden; margin-top: var(--space-2); }
.bar > i { display: block; height: 100%; background: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); display: grid; gap: var(--space-2); background: var(--bg); }
.item.sample { border-style: dashed; }
.item .head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: flex-start; }
.item .name { font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px var(--space-2); border-radius: var(--radius-full); border: 1px solid var(--muted); font-size: var(--text-xs); color: var(--fg); white-space: nowrap; }
.tag.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.item select { min-height: var(--tap); width: auto; }
.board { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
.col { background: var(--surface); border-radius: var(--radius); padding: var(--space-3); border: 1px solid var(--line); }
.col h3 { display: flex; justify-content: space-between; margin-bottom: var(--space-2); }
.col .list { min-height: 8px; }
.steps { list-style: none; margin: 0; padding: 0; position: relative; }
.step { display: grid; grid-template-columns: 40px 1fr; gap: var(--space-3); padding-bottom: var(--space-4); position: relative; }
.step::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.dot { width: 40px; height: 40px; border-radius: var(--radius-full); border: 2px solid var(--muted); display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--bg); }
.step.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.step.doing .dot { border-color: var(--accent); color: var(--accent); }
.empty { text-align: center; padding: var(--space-5) var(--space-4); border: 1px dashed var(--muted); border-radius: var(--radius); margin-bottom: var(--space-3); }
.empty p { margin-bottom: var(--space-3); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tap) + var(--space-6) + env(safe-area-inset-bottom));
  background: var(--fg); color: var(--bg); padding: var(--space-2) var(--space-4); border-radius: var(--radius); z-index: 9; font-size: var(--text-sm); max-width: 90vw; }
form.add { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-3); display: grid; gap: var(--space-2); background: var(--surface); }
form.add .two { display: grid; gap: var(--space-2); grid-template-columns: 1fr 1fr; }
.note p { white-space: pre-wrap; }
.site { max-width: 1120px; margin: 0 auto; padding: var(--space-3) var(--space-4) 0; }
.site .brand { margin-bottom: var(--space-3); }
.mainnav { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.mainnav button { flex: 1 1 auto; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: var(--text-sm); white-space: nowrap; padding: 0 var(--space-3); }
.mainnav button[aria-current=page] { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.pub { max-width: 1120px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); }
.pub:focus { outline: none; }
.sec { margin-top: var(--space-6); }
.sec h2 { margin: 0 0 var(--space-3); }
.para { max-width: var(--measure); margin-bottom: var(--space-2); }
.bullets { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); max-width: var(--measure); }
.check-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); background: var(--surface); }
.check input { width: 24px; min-height: 24px; height: 24px; flex: none; margin: 2px 0 0; accent-color: var(--accent); }
.check label { margin: 0; font-weight: 400; display: grid; gap: var(--space-1); min-height: var(--tap); cursor: pointer; }
.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-3) 0; }
.filters button[aria-pressed=true] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.parts { grid-template-columns: 1fr; }
.part .head h3 { font-size: var(--text-md); }
.part code { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 var(--space-2); color: var(--fg); }
.part .meta { align-items: center; }
.warn { font-size: var(--text-sm); color: var(--muted); }
.callout { margin-top: var(--space-6); border: 2px solid var(--accent); border-radius: var(--radius); padding: var(--space-4); background: var(--surface); }
.callout h2 { margin-bottom: var(--space-2); }
nav.tabs button { font-size: 0.6875rem; }
.memo { font-size: var(--text-sm); color: var(--muted); white-space: pre-wrap; }
.tag.stage { justify-self: start; border-color: var(--accent); color: var(--accent); }
.sums { margin-bottom: var(--space-3); }
.sums .num { font-size: var(--text-xl); }
.filters button { padding: 0 var(--space-3); }
@media (min-width: 720px) {
  nav.tabs button { font-size: var(--text-sm); }
  .parts { grid-template-columns: repeat(2, 1fr); }
  .mainnav button { flex: 0 0 auto; padding: 0 var(--space-5); }
  .board { grid-template-columns: repeat(3, 1fr); align-items: start; }
  nav.tabs { position: static; border: 0; border-bottom: 1px solid var(--line); padding: 0; }
  nav.tabs button { flex-direction: row; flex: 0 0 auto; font-size: var(--text-sm); padding: 0 var(--space-4); }
  .app { padding-bottom: var(--space-7); }
  .toast { bottom: var(--space-5); }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } button:active { transform: none; } }

/* 채팅 */
nav.tabs button { position: relative; }
nav.tabs .badge { position: absolute; top: 2px; right: 50%; margin-right: -22px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full);
  background: var(--danger); color: #fff; font-size: var(--text-xs); line-height: 18px; text-align: center; font-weight: 700; }
ul.chat { list-style: none; margin: var(--space-3) 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); max-height: 55vh; overflow-y: auto; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msgmeta { font-size: var(--text-xs); }
.bubble { border-radius: var(--radius); padding: var(--space-2) var(--space-3); background: var(--surface); border: 1px solid var(--line); }
.msg.mine .bubble { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.msg.mine .bubble a { color: var(--accent-fg); }
.msgtext { white-space: pre-wrap; }
.tagline { font-size: var(--text-xs); font-weight: 700; opacity: .85; }
.msgacts { gap: 0; }
.msgacts button { font-size: var(--text-sm); padding: 0 var(--space-2); }
