/* 색/폰트는 여기 변수만 바꾸면 전체가 바뀜 */
:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #26231e;
  --muted: #8a8276;
  --line: #e6dfd2;
  --accent: #d9603b;
  --accent-ink: #ffffff;
  --soft: #f0e6d6;
  --ok: #4f8a5b;
  --warn: #c2412d;
  --radius: 16px;
  --font: -apple-system, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  --tabbar-h: 64px;
  --quick-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a17; --surface: #25231f; --ink: #ece6da; --muted: #9a9284;
    --line: #36332d; --accent: #ef7a52; --soft: #2f2b25; --ok: #79b486; --warn: #f07b66;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a17; --surface: #25231f; --ink: #ece6da; --muted: #9a9284;
  --line: #36332d; --accent: #ef7a52; --soft: #2f2b25; --ok: #79b486; --warn: #f07b66;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); }
body { min-height: 100dvh; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

.tab { padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar-h) + var(--quick-h) + env(safe-area-inset-bottom) + 24px); max-width: 640px; margin: 0 auto; }
.top { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 16px; }
.top h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }
.top .ghost:not(#reader-back), .top #reader-archive { margin-left: auto; }
.hint, .muted { color: var(--muted); font-size: 14px; }
h2.sub { font-size: 14px; color: var(--muted); font-weight: 600; margin: 28px 4px 10px; }

.primary { background: var(--accent); color: var(--accent-ink); padding: 10px 18px; border-radius: 999px; font-weight: 600; }
.primary:disabled { opacity: .35; }
.primary.wide { width: 100%; padding: 14px; margin-top: 16px; }
.ghost { color: var(--muted); padding: 6px 10px; border-radius: 10px; font-size: 18px; }
.small { background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }

/* composer */
.composer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.composer textarea { width: 100%; min-height: 34dvh; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); font: 17px/1.6 var(--font); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.card .label { white-space: pre-wrap; overflow-wrap: anywhere; }
.card .result { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 15px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.pill.running, .pill.queued { color: var(--accent); }
.pill.running::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: middle; animation: pulse 1s infinite; }
.pill.done { color: var(--ok); }
.pill.error { color: var(--warn); }
@keyframes pulse { 50% { opacity: .2; } }

.topic { display: block; color: var(--ink); }
.topic .t { font-weight: 650; font-size: 17px; }
.topic .s { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* todo */
.todo-group h3 { font-size: 14px; color: var(--muted); margin: 18px 4px 8px; }
.todo { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.todo input { width: 22px; height: 22px; accent-color: var(--accent); margin: 1px 0 0; flex: none; }
.todo.done .txt { color: var(--muted); text-decoration: line-through; }
.todo .due { font-size: 13px; color: var(--muted); }
.todo .due.over { color: var(--warn); font-weight: 600; }

/* markdown */
.md { overflow-wrap: anywhere; }
.md h1 { font-size: 24px; letter-spacing: -0.02em; margin: 4px 0 12px; }
.md h2 { font-size: 18px; margin: 26px 0 8px; }
.md h3 { font-size: 16px; margin: 18px 0 6px; }
.md blockquote { margin: 10px 0; padding: 10px 14px; background: var(--soft); border-radius: 12px; border: 0; }
.md blockquote p { margin: 0; }
.md ul { padding-left: 20px; }
.md li { margin: 3px 0; }
.md code { background: var(--soft); padding: 1px 5px; border-radius: 6px; font-size: .9em; }
.md hr { border: 0; border-top: 1px solid var(--line); }

.random-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-height: 30dvh; }
.random-card .src { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.random-card .snip { overflow-wrap: anywhere; font-size: 16px; margin-top: 14px; }
.random-card .snip > :first-child { margin-top: 0; }
.random-card .card-actions { margin-top: 0; padding: 0 0 12px; border-top: 0; border-bottom: 1px dashed var(--line); }

.notice { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }

/* tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; color: var(--muted); }
.tabbar a span { font-size: 22px; filter: grayscale(1); opacity: .6; }
.tabbar a.on { color: var(--ink); font-weight: 600; }
.tabbar a.on span { filter: none; opacity: 1; }

/* login */
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(340px, 100%); text-align: center; }
.login-box .logo { font-size: 56px; }
.login-box h1 { margin: 4px 0 24px; }
.login-box input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; margin-bottom: 12px; }
.login-box .primary { width: 100%; padding: 14px; }
.err { color: var(--warn); min-height: 1.5em; }

.toast { z-index: 20; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--quick-h) + env(safe-area-inset-bottom) + 16px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px); }

/* chips, inline inputs */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--soft); color: var(--ink); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
#reader-memo-wrap { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-input { margin: 10px 0 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
.inline-input textarea { width: 100%; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--ink); font: 15px/1.5 var(--font); }
.inline-input .row { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.inline-input .ghost { font-size: 14px; }

/* todo memos */
.todo { flex-wrap: wrap; }
.todo .body { flex: 1; min-width: 0; }
.todo .memo { font-size: 13px; color: var(--muted); margin-top: 4px; }
.todo .inline-input { flex-basis: 100%; }

/* open questions */
.md ul.questions li { margin: 8px 0; }
.answer-btn { margin-left: 8px; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--soft); color: var(--accent); font-weight: 600; vertical-align: 1px; }
.answer-btn:disabled { color: var(--ok); }
.md ul.questions .inline-input { margin-left: -20px; width: calc(100% + 20px); }

details.archived summary { color: var(--muted); font-size: 14px; padding: 8px 4px; cursor: pointer; }
details.archived .cards { margin-top: 8px; opacity: .7; }

/* quick dump bar (all tabs except 덤프) */
.quick { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); z-index: 10; }
.quick textarea { flex: 1; min-height: 40px; max-height: 120px; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 16px/1.4 var(--font); resize: none; outline: 0; }
.quick .send { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 18px; }
.quick .send:disabled { opacity: .3; }
.tabbar { z-index: 11; }

/* to-do: add form, sources, subtasks */
.todo-add { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; margin-bottom: 4px; }
.todo-add #todo-new { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 16px/1.4 var(--font); padding: 6px 0; }
.todo-add #todo-due { flex: none; width: 118px; border: 0; background: var(--soft); color: var(--muted); border-radius: 8px; padding: 6px; font: 13px var(--font); }
.todo .srcs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.src-chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.subtask { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; font-size: 15px; }
.subtask input { width: 18px !important; height: 18px !important; margin-top: 2px !important; }
.subtask.done span { color: var(--muted); text-decoration: line-through; }
.todo-actions { display: flex; flex-direction: column; gap: 2px; margin: -4px -6px 0 0; }
.todo-actions .ghost { font-size: 16px; padding: 2px 6px; }
.quick textarea, .inline-input textarea { scrollbar-width: none; }
.quick textarea::-webkit-scrollbar, .inline-input textarea::-webkit-scrollbar { display: none; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
