@font-face {
  font-family: 'Gowun Batang';
  src: url('../fonts/GowunBatang-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Gowun Batang';
  src: url('../fonts/GowunBatang-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #F5F0E6;
  --surface: #FFFDF8;
  --surface-2: #EEE7D9;
  --ink: #2A251E;
  --ink-2: #5B5247;
  --muted: #877C6D;
  --line: #E1D8C6;
  --accent: #2F5D50;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDE9E3;
  --hl: rgba(255, 214, 74, .55);
  --hl-line: #D9A300;
  --danger: #B3402F;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 14px rgba(60, 45, 20, .06);
  --seq-0: #ECE6DA;
  --seq-1: #CFE2D8;
  --seq-2: #9CC4B2;
  --seq-3: #5F9A84;
  --seq-4: #2F5D50;
  --radius: 14px;
  --sans: system-ui, -apple-system, 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --serif: 'Gowun Batang', 'Noto Serif KR', 'Noto Serif CJK KR', serif;
  --tabbar-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120E;
    --surface: #1E1B16;
    --surface-2: #29251E;
    --ink: #EFE8DB;
    --ink-2: #C8BEAD;
    --muted: #9A8F7E;
    --line: #38322A;
    --accent: #8CC2AE;
    --accent-ink: #0F1E19;
    --accent-soft: #23352E;
    --hl: rgba(232, 182, 40, .38);
    --hl-line: #E8B628;
    --danger: #E58A78;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --seq-0: #26231D;
    --seq-1: #2C433A;
    --seq-2: #3F6A5A;
    --seq-3: #5F9A84;
    --seq-4: #9ED0BC;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14120E;
  --surface: #1E1B16;
  --surface-2: #29251E;
  --ink: #EFE8DB;
  --ink-2: #C8BEAD;
  --muted: #9A8F7E;
  --line: #38322A;
  --accent: #8CC2AE;
  --accent-ink: #0F1E19;
  --accent-soft: #23352E;
  --hl: rgba(232, 182, 40, .38);
  --hl-line: #E8B628;
  --danger: #E58A78;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --seq-0: #26231D;
  --seq-1: #2C433A;
  --seq-2: #3F6A5A;
  --seq-3: #5F9A84;
  --seq-4: #9ED0BC;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── 앱 골격 ───────────────────────────── */
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
}
#topbar.scrolled { border-bottom-color: var(--line); }
#topbar h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .back { margin-left: -8px; }
#view { padding: 4px 16px calc(var(--tabbar-h) + 88px + env(safe-area-inset-bottom)); }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tabs { display: flex; width: 100%; max-width: 640px; }
#tabbar a {
  flex: 1; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600;
}
#tabbar a svg { width: 24px; height: 24px; }
#tabbar a.on { color: var(--accent); }

#timerbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom));
  z-index: 29; width: calc(100% - 32px); max-width: 608px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
}
#timerbar .t { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; }
#timerbar .b { flex: 1; min-width: 0; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#timerbar button { background: var(--bg); color: var(--ink); border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 700; }

/* ── 공통 요소 ─────────────────────────── */
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 22px 2px 8px; letter-spacing: .02em; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty > svg { width: 46px; height: 46px; opacity: .5; margin-bottom: 8px; }
.empty p { margin: 4px 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .x { opacity: .6; margin-left: 2px; }
.tag { color: var(--accent); font-size: 13px; font-weight: 600; }

.seg { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.seg::-webkit-scrollbar { display: none; }
.seg .chip { flex: none; }
.seg .chip .n { opacity: .7; font-weight: 500; }

/* 폼 */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 2px 5px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 11px 13px; font-size: 16px; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.textarea.serif { font-family: var(--serif); font-size: 17px; word-break: keep-all; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: 5px 2px 0; }

/* ── 서재 ─────────────────────────────── */
.goal-strip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; text-decoration: none; color: inherit; }
.goal-strip .meter { flex: 1; }
.goal-strip strong { font-size: 15px; }
.meter-bar { height: 8px; border-radius: 99px; background: var(--seq-0); overflow: hidden; margin-top: 6px; }
.meter-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.book-list { display: flex; flex-direction: column; gap: 10px; }
.book-item { display: flex; gap: 14px; padding: 12px; text-decoration: none; color: inherit; align-items: stretch; }
.book-item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.book-item .title { font-weight: 700; font-size: 16px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-item .author { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-item .meta { margin-top: auto; padding-top: 8px; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.book-item .meter-bar { margin-top: 6px; height: 6px; }

.cover {
  position: relative; flex: none; width: 64px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden;
  background: var(--surface-2); box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.ph { display: flex; align-items: flex-end; padding: 6px; color: #fff; font-family: var(--serif); font-size: 11px; line-height: 1.25; font-weight: 700; }
.cover.ph::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.18); }
.cover.lg { width: 104px; border-radius: 8px; }
.cover.lg.ph { font-size: 14px; padding: 10px; }

.fab {
  position: fixed; z-index: 28; right: max(16px, calc(50% - 304px));
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  height: 54px; padding: 0 20px 0 16px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15.5px;
  display: flex; align-items: center; gap: 6px; box-shadow: 0 6px 20px rgba(30, 60, 50, .3);
}
.fab svg { width: 22px; height: 22px; }
body.timer-on .fab { bottom: calc(var(--tabbar-h) + 80px + env(safe-area-inset-bottom)); }

/* ── 책 상세 ──────────────────────────── */
.book-head { display: flex; gap: 16px; align-items: flex-start; margin: 6px 0 14px; }
.book-head .info { flex: 1; min-width: 0; }
.book-head h2 { font-family: var(--serif); font-size: 21px; line-height: 1.35; margin: 0 0 4px; }
.book-head .sub { font-size: 14px; color: var(--ink-2); }
.book-head .dates { font-size: 13px; color: var(--muted); margin-top: 8px; }
.status-pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.status-pill.done { background: var(--ink); color: var(--bg); }
.status-pill.want, .status-pill.stopped { background: var(--surface-2); color: var(--ink-2); }

.progress-card { padding: 14px 16px; }
.progress-card .top { display: flex; justify-content: space-between; align-items: baseline; }
.progress-card .pct { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress-card .meter-bar { height: 10px; }
.progress-card .eta { font-size: 13px; color: var(--ink-2); margin-top: 8px; }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.action-grid .btn { flex-direction: column; gap: 3px; min-height: 66px; padding: 8px 4px; font-size: 13px; }
.action-grid .btn svg { width: 22px; height: 22px; }

.tabs-inline { display: flex; border-bottom: 1px solid var(--line); margin: 18px -16px 14px; padding: 0 8px; position: sticky; top: calc(60px + env(safe-area-inset-top)); background: var(--bg); z-index: 10; }
.tabs-inline button { flex: 1; border: 0; background: transparent; padding: 12px 4px 10px; font-weight: 700; color: var(--muted); border-bottom: 2.5px solid transparent; font-size: 15px; }
.tabs-inline button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs-inline button .n { font-weight: 500; font-size: 13px; opacity: .8; }

/* 문장 카드 */
.quote {
  position: relative; padding: 16px 16px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.quote blockquote {
  margin: 0; font-family: var(--serif); font-size: 16.5px; line-height: 1.75; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere;
  border-left: 3px solid var(--hl-line); padding-left: 12px;
}
.quote .memo { margin-top: 10px; font-size: 14px; color: var(--ink-2); background: var(--surface-2); padding: 8px 11px; border-radius: 10px; white-space: pre-wrap; }
.quote .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.quote .foot .src { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote .foot .more { margin: -8px -8px -8px 0; }
.quote-list { display: flex; flex-direction: column; gap: 12px; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }

/* 느낀점 */
.review-q { font-weight: 700; font-size: 14px; color: var(--ink-2); margin: 16px 2px 6px; }
.stars { display: flex; gap: 4px; align-items: center; }
.stars button { border: 0; background: transparent; padding: 2px; width: 40px; height: 40px; color: var(--line); position: relative; }
.stars button svg { width: 36px; height: 36px; }
.stars button.on, .stars button.half { color: #E3A008; }
.stars .val { margin-left: 8px; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.note-item { padding: 12px 14px; }
.note-item .d { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; }
.note-item p { margin: 4px 0 0; white-space: pre-wrap; }

/* 기록 */
.session-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.session-item .d { font-weight: 700; font-size: 14px; width: 74px; flex: none; }
.session-item .v { flex: 1; font-size: 14px; color: var(--ink-2); }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.author-info { font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; }

/* ── 통계 ─────────────────────────────── */
.year-nav { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 12px; }
.year-nav strong { font-size: 18px; min-width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
.goal-hero { display: flex; align-items: center; gap: 18px; }
.goal-hero .ring { flex: none; }
.goal-hero .num { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.goal-hero .num small { font-size: 16px; font-weight: 600; color: var(--muted); }
.goal-hero .desc { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { padding: 12px 14px; }
.tile .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.tile .v small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.chart-card { padding: 14px 12px 10px; }
.chart-card .head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; margin-bottom: 6px; }
.chart-card .head strong { font-size: 15px; }
.chart-card svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tip { font-size: 13px; color: var(--ink-2); min-height: 20px; padding: 2px 4px 0; font-variant-numeric: tabular-nums; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11.5px; color: var(--muted); padding-bottom: 2px; }
.cal .day { aspect-ratio: 1; border-radius: 8px; background: var(--seq-0); display: flex; align-items: flex-start; justify-content: flex-start; padding: 4px 5px; font-size: 11px; color: var(--ink-2); border: 0; font-variant-numeric: tabular-nums; }
.cal .day.l1 { background: var(--seq-1); }
.cal .day.l2 { background: var(--seq-2); }
.cal .day.l3 { background: var(--seq-3); color: #fff; }
.cal .day.l4 { background: var(--seq-4); color: var(--bg); }
.cal .day.today { outline: 2px solid var(--ink); outline-offset: -2px; }
.cal .blank { background: transparent; }
.legend-seq { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend-seq i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-list .r { display: grid; grid-template-columns: 92px 1fr 36px; gap: 8px; align-items: center; font-size: 13.5px; }
.bar-list .r .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.bar-list .r .b { height: 10px; border-radius: 0 4px 4px 0; background: var(--seq-3); }
.bar-list .r .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ── 검색 ─────────────────────────────── */
.search-box { position: relative; margin-bottom: 12px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.search-box .input { padding-left: 40px; }
.result-group h3 { font-size: 14px; color: var(--muted); margin: 18px 2px 8px; }

/* ── 설정 ─────────────────────────────── */
.set-list { padding: 4px 0; }
.set-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 0; background: transparent; width: 100%; text-align: left; text-decoration: none; color: inherit; }
.set-item + .set-item { border-top: 1px solid var(--line); }
.set-item .t { flex: 1; min-width: 0; }
.set-item .t b { display: block; font-weight: 600; font-size: 15px; }
.set-item .t span { display: block; font-size: 12.5px; color: var(--muted); }
.set-item svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.badge-ok { color: var(--accent); font-weight: 700; font-size: 13px; }

/* ── 바텀시트·오버레이 ───────────────────── */
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20, 16, 10, .45); opacity: 0; transition: opacity .18s; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; margin: 0 auto; max-width: 640px;
  background: var(--surface); border-radius: 20px 20px 0 0; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .22s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.show { transform: none; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 2px; flex: none; }
.sheet header { display: flex; align-items: center; padding: 6px 8px 6px 18px; flex: none; }
.sheet header h3 { flex: 1; margin: 0; font-size: 17px; }
.sheet .body { padding: 4px 18px 18px; overflow-y: auto; flex: 1; }
.sheet .foot { padding: 10px 18px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex: none; }
.sheet .foot .btn { flex: 1; }
.menu-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 4px; border: 0; background: transparent; font-size: 16px; text-align: left; }
.menu-list button + button { border-top: 1px solid var(--line); }
.menu-list button svg { width: 21px; height: 21px; color: var(--ink-2); }
.menu-list button.danger, .menu-list button.danger svg { color: var(--danger); }

.overlay {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
.overlay > header {
  display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex: none;
}
.overlay > header h3 { flex: 1; margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay > .body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.overlay > .foot { flex: none; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 8px; }
.overlay > .foot .btn { flex: 1; }
.overlay .inner { max-width: 640px; margin: 0 auto; width: 100%; }

/* 사진 고르기 */
.pick-area { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick-area .btn { min-height: 92px; flex-direction: column; font-size: 15px; }
.pick-area .btn svg { width: 28px; height: 28px; }
.pick-area .btn.primary svg { color: var(--accent-ink); }

/* OCR 줄 선택기 */
.sel-wrap { position: relative; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 10px; overflow: hidden; background: #000; }
.sel-wrap img, .sel-wrap canvas { width: 100%; height: 100%; display: block; }
.sel-wrap .ln { position: absolute; border-radius: 3px; outline: 1px dashed rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .06); }
.sel-wrap .ln.on { background: rgba(255, 210, 40, .45); outline: 2px solid #F2B600; mix-blend-mode: multiply; }
.sel-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; align-items: center; }
.sel-tools .muted { font-size: 12.5px; flex: 1 0 100%; }
.line-list { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow-y: auto; }
.line-list button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: 14.5px; line-height: 1.45; }
.line-list button.on { background: var(--hl); border-color: var(--hl-line); }
.progress-line { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 10px 0; }
.progress-line i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.busy { text-align: center; padding: 30px 10px; color: var(--ink-2); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.ocr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ocr-chips button { border: 1px dashed var(--ink-2); background: var(--surface); border-radius: 10px; padding: 6px 10px; font-size: 14px; text-align: left; max-width: 100%; }
.ocr-chips button.big { font-weight: 700; font-size: 15.5px; border-style: solid; }
.photo-preview { border-radius: 12px; overflow: hidden; max-height: 280px; display: flex; justify-content: center; background: var(--surface-2); }
.photo-preview img { max-height: 280px; width: auto; object-fit: contain; }
.result-item { display: flex; gap: 12px; padding: 10px; align-items: center; text-align: left; width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; }
.result-item + .result-item { margin-top: 8px; }
.result-item .cover { width: 44px; }
.result-item b { display: block; font-size: 15px; line-height: 1.35; }
.result-item span { display: block; font-size: 12.5px; color: var(--muted); }

/* 바코드 스캐너 */
.scanner { position: fixed; inset: 0; z-index: 70; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .guide { position: absolute; left: 50%; top: 42%; width: min(80vw, 420px); height: min(34vw, 180px); transform: translate(-50%, -50%); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5); border: 2px solid rgba(255,255,255,.9); }
.scanner .guide::after { content: ''; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #FF5A4E; box-shadow: 0 0 8px #FF5A4E; animation: scanline 1.6s ease-in-out infinite; }
@keyframes scanline { 0%,100% { transform: translateY(-40px); } 50% { transform: translateY(40px); } }
.scanner .top { position: relative; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
.scanner .top .icon-btn { color: #fff; background: rgba(0,0,0,.35); }
.scanner .msg { position: absolute; left: 0; right: 0; top: calc(42% + min(17vw, 90px) + 18px); text-align: center; font-size: 15px; padding: 0 20px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.scanner .bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.scanner .bottom .btn { flex: 1; background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }

/* 문장 카드 이미지 */
.card-preview { border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); margin: 0 auto; max-width: 420px; }
.card-preview canvas { width: 100%; height: auto; display: block; }
.theme-dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0 6px; }
.theme-dots button { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); }
.theme-dots button.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg) inset; }

/* 토스트 */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  width: max-content; max-width: calc(100% - 32px); transition: opacity .2s, transform .2s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.timer-on #toast { bottom: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom)); }
.update-bar { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 95; background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 8px 8px 8px 14px; display: flex; gap: 10px; align-items: center; font-size: 14px; box-shadow: var(--shadow); }
.update-bar button { border: 0; border-radius: 8px; padding: 6px 10px; font-weight: 700; background: var(--accent-ink); color: var(--accent); }

@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
