/* 소리노트 — 스타일
   디자인 계획
   - 소재: 좋은 문구(노트 종이)와 필드 레코더(단단한 회색 몸체, 빨간 REC 램프)
   - 레이아웃: 종이가 주인공. 크롬은 조용한 회색, 펜 도구는 왼쪽 세로 레일(펜 없는 손이 닿는 곳),
     녹음기는 아래 왼쪽 '데크'. 세로 모드·폰에서는 레일이 아래 가로 막대가 됨.
   - 색: 잉크 파랑(강조), 녹음 빨강(상태 전용), 종이는 라이트/다크 모두 밝게(잉크 가독성 유지)
   - 글꼴: Pretendard Variable 한 가족. 제목은 굵게·좁게, 숫자는 tabular */
:root {
  --bg: #e9ebe6;
  --surface: #f6f7f3;
  --surface-2: #ffffff;
  --fg: #1d2126;
  --muted: #666c75;
  --line: #d2d5cd;
  --line-strong: #b8bcb3;
  --accent: #3458a3;
  --accent-soft: #e2e8f5;
  --on-accent: #ffffff;
  --rec: #d8321f;
  --rec-soft: #fbe5e1;
  --ok: #2f8f5b;
  --warn: #c7731f;
  --paper: #fcfcf9;
  --paper-line: #d6dae8;
  --paper-margin: #e7a9a9;
  --paper-grid: #e1e3dd;
  --paper-label: #8b909a;
  --paper-ink: #1c2230;
  --select: #3458a3;
  --shadow-1: 0 1px 2px rgba(22, 26, 32, .07), 0 2px 8px -2px rgba(22, 26, 32, .08);
  --shadow-2: 0 2px 6px rgba(22, 26, 32, .08), 0 14px 32px -14px rgba(22, 26, 32, .3);
  --shadow-paper: 0 1px 1px rgba(22, 26, 32, .06), 0 8px 22px -10px rgba(22, 26, 32, .28);
  --radius: 10px;
  --radius-s: 7px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --fs-0: 12px; --fs-1: 13.5px; --fs-2: 15px; --fs-3: 17px; --fs-4: 20px; --fs-5: 26px;
  --rail-w: 60px;
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --deck-h: 64px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1c20; --surface: #23262b; --surface-2: #2b2f35; --fg: #e5e6e2; --muted: #9ba1a9;
    --line: #353a42; --line-strong: #4a505a; --accent: #8fb0ec; --accent-soft: #2b3750; --on-accent: #0f1420;
    --rec: #ef4b36; --rec-soft: #4a2420; --ok: #5cc48a; --warn: #e29a4b;
    --paper: #ebeae4; --paper-line: #c7cbd9; --paper-margin: #d99c9c; --paper-grid: #d3d5cf; --paper-label: #7d828c; --paper-ink: #1c2230;
    --select: #3458a3;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px -2px rgba(0, 0, 0, .3);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 14px 32px -14px rgba(0, 0, 0, .6);
    --shadow-paper: 0 1px 1px rgba(0, 0, 0, .3), 0 10px 26px -10px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1c20; --surface: #23262b; --surface-2: #2b2f35; --fg: #e5e6e2; --muted: #9ba1a9;
  --line: #353a42; --line-strong: #4a505a; --accent: #8fb0ec; --accent-soft: #2b3750; --on-accent: #0f1420;
  --rec: #ef4b36; --rec-soft: #4a2420; --ok: #5cc48a; --warn: #e29a4b;
  --paper: #ebeae4; --paper-line: #c7cbd9; --paper-margin: #d99c9c; --paper-grid: #d3d5cf; --paper-label: #7d828c; --paper-ink: #1c2230;
  --select: #3458a3;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px -2px rgba(0, 0, 0, .3);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 14px 32px -14px rgba(0, 0, 0, .6);
  --shadow-paper: 0 1px 1px rgba(0, 0, 0, .3), 0 10px 26px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: var(--fs-2);
  line-height: 1.45; overflow: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  font-feature-settings: "tnum" 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [contenteditable]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 22px; height: 22px; flex: none; }
.tnum { font-variant-numeric: tabular-nums; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- 공통 컨트롤 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); font-weight: 500;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-danger { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: var(--fs-1); }
.ibtn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius-s);
  color: var(--fg); transition: background .12s;
}
.ibtn:hover { background: var(--surface-2); }
.ibtn.is-on { background: var(--accent-soft); color: var(--accent); }
.ibtn:disabled { opacity: .4; }
.input, .select, textarea.input {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface-2); color: var(--fg);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; font-size: var(--fs-1); font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); white-space: nowrap;
}
.chip.is-on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip-type { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; }
.toggle { position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--line-strong); transition: background .15s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- 토스트 / 대화상자 / 메뉴 ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: var(--fs-1); font-weight: 500; z-index: 100;
  box-shadow: var(--shadow-2); transition: opacity .18s, transform .18s; max-width: min(90vw, 560px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.is-error { background: var(--rec); color: #fff; }
.dlg-overlay { position: fixed; inset: 0; background: rgba(12, 14, 18, .45); z-index: 90; display: flex; align-items: center; justify-content: center; padding: max(16px, var(--safe-l)) max(16px, var(--safe-r)); }
.dlg { width: min(100%, 440px); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2); padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.dlg-wide { width: min(100%, 640px); }
.dlg-title { margin: 0; font-size: var(--fs-4); font-weight: 700; letter-spacing: -.01em; }
.dlg-msg { margin: 0; color: var(--muted); white-space: pre-line; }
.dlg-body { display: flex; flex-direction: column; gap: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.pick-item { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 10px; border-radius: var(--radius-s); text-align: left; }
.pick-item:hover { background: var(--surface-2); }
.pick-item.is-current { background: var(--accent-soft); color: var(--accent); }
.pick-label { flex: 1; }
.pick-hint { color: var(--muted); font-size: var(--fs-1); }
.menu { position: fixed; z-index: 80; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border-radius: var(--radius-s); text-align: left; white-space: nowrap; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.is-danger { color: var(--rec); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-backdrop { position: fixed; inset: 0; z-index: 79; }

/* ---------- 앱 뼈대 ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---------- 라이브러리 ---------- */
#library { background: var(--bg); }
.lib-body { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-t)) 10px 12px max(10px, var(--safe-l)); gap: 6px; overflow: auto; transition: width .18s, padding .18s;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--paper-ink); position: relative; flex: none; }
.brand-mark::before { content: ""; position: absolute; left: 7px; right: 7px; top: 9px; height: 2px; background: #fff; border-radius: 2px; box-shadow: 0 5px 0 #fff, 0 10px 0 #fff; }
.brand-mark::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--rec); }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: var(--fs-3); }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: var(--radius-s); text-align: left; width: 100%; color: var(--fg); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .nav-count { margin-left: auto; color: var(--muted); font-size: var(--fs-0); font-variant-numeric: tabular-nums; }
.nav-item .ic { width: 20px; height: 20px; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 4px; color: var(--muted); font-size: var(--fs-0); font-weight: 600; }
.nav-head .ibtn { width: 32px; height: 32px; }
.nav-head .ibtn .ic { width: 18px; height: 18px; }
.sidebar-foot { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.lib-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lib-top {
  display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) max(16px, var(--safe-r)) 10px max(16px, var(--safe-l)); flex-wrap: wrap;
}
.lib-title { font-size: var(--fs-5); font-weight: 800; letter-spacing: -.025em; margin: 0 8px 0 0; line-height: 1.2; }
.lib-count { color: var(--muted); font-size: var(--fs-1); font-variant-numeric: tabular-nums; }
.search { position: relative; flex: 1 1 220px; min-width: 160px; max-width: 420px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; pointer-events: none; }
.search input { padding-left: 40px; border-radius: 999px; }
.lib-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.btn-new { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }
.btn-new:hover { border-color: var(--fg); }
.lib-scroll { flex: 1; overflow: auto; padding: 4px max(16px, var(--safe-r)) calc(32px + var(--safe-b)) max(16px, var(--safe-l)); }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 18px 16px; }
.note-card { display: flex; flex-direction: column; gap: 8px; text-align: left; border-radius: var(--radius); padding: 0; position: relative; }
.note-card:focus-visible { outline-offset: 6px; }
.thumb {
  aspect-ratio: 800 / 1131; width: 100%; max-width: 100%; border-radius: 4px; background: var(--paper); box-shadow: var(--shadow-paper); overflow: hidden; position: relative;
  border: 1px solid rgba(0, 0, 0, .06);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-empty { position: absolute; inset: 0; background: repeating-linear-gradient(to bottom, transparent 0 27px, var(--paper-line) 27px 28px); }
.note-card.is-pinned .thumb::before { content: ""; position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; background: var(--accent); border-radius: 50%; z-index: 1; }
.note-card .color-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.thumb-badges { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 6px; background: rgba(28, 34, 48, .82); color: #fff; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge .ic { width: 13px; height: 13px; }
.badge.is-summary { background: var(--accent); color: var(--on-accent); }
.card-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0 2px; }
.card-title { font-weight: 600; font-size: var(--fs-2); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--muted); font-size: var(--fs-0); display: flex; gap: 6px; align-items: center; min-width: 0; }
.card-sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-more { position: absolute; z-index: 2; right: -6px; top: -6px; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); opacity: 0; transition: opacity .12s; }
.note-card:hover .card-more, .note-card:focus-within .card-more, .is-touch .card-more { opacity: 1; }
.note-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.note-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; min-height: 60px; padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; position: relative; }
.note-row:hover { background: var(--surface); }
.note-row .thumb { width: 36px; aspect-ratio: 800 / 1131; border-radius: 2px; }
.note-row .card-more { position: static; opacity: 1; box-shadow: none; background: transparent; }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-main .card-title { -webkit-line-clamp: 1; }
.empty { padding: 64px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty strong { color: var(--fg); font-size: var(--fs-3); }
mark.hit { background: #ffe26a; color: #1c2230; padding: 0 1px; border-radius: 2px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-0); color: var(--muted); }
.tag::before { content: "#"; opacity: .6; }

/* 세로/폰: 사이드바 서랍 */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(12, 14, 18, .4); z-index: 60; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 61; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-2); }
  .sidebar.is-open { transform: none; }
  .lib-top .btn-new span { display: none; }
  .lib-top .btn-new { padding: 0 12px; }
}
@media (min-width: 901px) {
  .drawer-backdrop, #btn-drawer { display: none !important; }
  .sidebar.is-collapsed { width: 0; padding-left: 0; padding-right: 0; overflow: hidden; border: 0; }
}

/* ---------- 편집기 ---------- */
#editor { background: var(--bg); }
.ed-top {
  height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) max(8px, var(--safe-r)) 0 max(8px, var(--safe-l)); display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex: none;
}
.ed-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 4px; }
.ed-title {
  font-weight: 700; font-size: var(--fs-3); letter-spacing: -.01em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 2px 4px; margin: 0 -4px;
  min-height: 28px; outline-offset: 0;
}
.ed-title:focus { white-space: normal; background: var(--surface-2); text-overflow: clip; }
.ed-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-0); min-width: 0; }
.ed-sub .chip { height: 22px; padding: 0 8px; font-size: 11px; }
.ed-sub .ed-date { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.ed-saved { color: var(--muted); font-size: 11px; white-space: nowrap; }
.ed-saved.is-saving { color: var(--warn); }
.ed-tabs { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 999px; }
.ed-tab { min-height: 36px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: var(--fs-1); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.ed-tab.is-on { background: var(--surface-2); color: var(--fg); box-shadow: var(--shadow-1); }
.ed-tab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.ed-body { flex: 1; min-height: 0; display: flex; position: relative; }
.ed-pane { position: absolute; inset: 0; display: flex; }

/* 도구 레일 */
.rail {
  width: var(--rail-w); flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 calc(8px + var(--safe-b)) var(--safe-l); overflow: auto; z-index: 5;
}
.rail .ibtn { width: 48px; height: 48px; border-radius: 12px; position: relative; }
.rail .ibtn .ic { width: 24px; height: 24px; }
.rail .ibtn.is-on { background: var(--fg); color: var(--bg); }
.rail .ibtn.is-on .pen-dot { background: var(--bg); }
.rail .sep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
.pen-dot { position: absolute; right: 8px; bottom: 8px; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--surface); }
.rail .grow { flex: 1; }
.rail .ibtn.is-rec { color: var(--rec); }
.rail .ibtn.is-rec.is-on { background: var(--rec); color: #fff; }

/* 캔버스 영역 */
.canvas-wrap { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
.canvas-area { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.viewport { flex: 1; position: relative; overflow: hidden; touch-action: none; background: var(--bg); cursor: crosshair; user-select: none; -webkit-user-select: none; }
.viewport.tool-text { cursor: text; }
.viewport.tool-lasso, .viewport.tool-playback { cursor: default; }
.viewport.tool-eraser { cursor: cell; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; width: 800px; will-change: transform; }
.page { position: absolute; left: 0; color-scheme: light; background: var(--paper); box-shadow: var(--shadow-paper); border-radius: 2px; overflow: hidden; }
.page canvas.ink { position: absolute; left: 0; top: 0; display: block; }
.page .texts { position: absolute; inset: 0; pointer-events: none; }
.page .page-num { position: absolute; right: 14px; bottom: 10px; font-size: 12px; color: var(--paper-label); font-variant-numeric: tabular-nums; pointer-events: none; }
.live-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }
.sel-box { position: absolute; border: 1.5px dashed var(--select); border-radius: 3px; pointer-events: none; }
.sel-handle { position: absolute; right: -9px; bottom: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--select); border: 2px solid #fff; }

/* 텍스트 상자 */
.tbox { position: absolute; min-width: 120px; pointer-events: auto; color: var(--paper-ink); font-size: 20px; line-height: 1.45; }
.tbox .tbox-body { padding: 6px 8px; border: 1.5px dashed transparent; border-radius: 4px; min-height: 36px; outline: none; word-break: break-word; }
.tbox .tbox-body:focus, .tbox.is-focus .tbox-body { border-color: rgba(52, 88, 163, .55); background: rgba(255, 255, 255, .35); }
.tbox-body h3 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.tbox-body p { margin: 0 0 4px; }
.tbox-body ul { margin: 0 0 4px; padding-left: 24px; }
.tbox-body ul.checklist { list-style: none; padding-left: 0; }
.tbox-body ul.checklist li { display: flex; align-items: flex-start; gap: 8px; }
.tbox-body ul.checklist input { width: 20px; height: 20px; margin: 4px 0 0; accent-color: #3458a3; flex: none; }
.tbox-body mark { background: #ffe26a; color: inherit; padding: 0 2px; }
.tbox-body b, .tbox-body strong { font-weight: 700; }
.tbox-body:empty::before { content: "입력하세요"; color: var(--paper-label); }
.tbox-grip { position: absolute; left: -26px; top: 2px; width: 24px; height: 30px; display: none; align-items: center; justify-content: center; color: var(--select); cursor: move; touch-action: none; border-radius: 4px; background: rgba(255, 255, 255, .7); }
.tbox-del { position: absolute; right: -14px; top: -14px; width: 28px; height: 28px; display: none; align-items: center; justify-content: center; border-radius: 50%; background: var(--select); color: #fff; }
.tbox-del .ic { width: 16px; height: 16px; }
.tbox.is-focus .tbox-grip, .tbox.is-focus .tbox-del { display: flex; }
.tbox-resize { position: absolute; right: -8px; bottom: 0; width: 14px; height: 100%; cursor: ew-resize; touch-action: none; display: none; }
.tbox.is-focus .tbox-resize { display: block; }
.viewport.tool-text .page .texts { pointer-events: none; }
.viewport.tool-text .tbox { pointer-events: auto; }
.viewport:not(.tool-text):not(.tool-playback) .tbox { pointer-events: none; }
.viewport.tool-playback .tbox { pointer-events: auto; cursor: pointer; }
.viewport.tool-playback .tbox .tbox-body { pointer-events: none; }
.tbox.is-future { opacity: .3; }
.tbox.is-current .tbox-body { background: rgba(52, 88, 163, .14); border-color: transparent; }

/* 떠 있는 하위 도구 (색/굵기, 텍스트 서식) */
.subbar {
  position: absolute; left: 12px; top: 10px; z-index: 6; display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow-2); border: 1px solid var(--line); flex-wrap: wrap; max-width: calc(100% - 24px);
}
.subbar .color { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; display: inline-flex; align-items: center; justify-content: center; }
.subbar .color span { width: 22px; height: 22px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.subbar .color.is-on { border-color: var(--fg); }
.subbar .width { width: 40px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.subbar .width.is-on { background: var(--accent-soft); }
.subbar .width i { display: block; background: var(--fg); border-radius: 999px; width: 18px; }
.subbar .vsep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.subbar .ibtn { width: 40px; height: 36px; }
.subbar .ibtn .ic { width: 20px; height: 20px; }
.subbar input[type=color] { width: 36px; height: 36px; border: 0; padding: 0; background: none; border-radius: 50%; overflow: hidden; }
.subbar .seg { display: flex; background: var(--bg); border-radius: 8px; padding: 2px; }
.subbar .seg button { min-height: 32px; padding: 0 10px; border-radius: 6px; font-size: var(--fs-1); font-weight: 500; color: var(--muted); }
.subbar .seg button.is-on { background: var(--surface-2); color: var(--fg); box-shadow: var(--shadow-1); }

/* 페이지 내비 */
.page-nav { position: absolute; right: 12px; bottom: 12px; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-2); border: 1px solid var(--line); }
.page-nav .ibtn { width: 40px; height: 40px; border-radius: 50%; }
.page-nav .ibtn .ic { width: 20px; height: 20px; }
.page-nav .pn-label { padding: 0 8px; font-size: var(--fs-1); font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.zoom-label { position: absolute; left: 12px; bottom: 12px; z-index: 6; font-size: 11px; color: var(--muted); background: var(--surface); padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; }

/* 녹음 데크 */
.deck {
  flex: none; background: var(--surface); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px;
  padding: 8px max(12px, var(--safe-r)) calc(8px + var(--safe-b)) 12px; min-height: var(--deck-h); position: relative;
}
.deck.is-recording { background: linear-gradient(90deg, var(--rec-soft), var(--surface) 60%); }
.deck-transport { display: flex; align-items: center; gap: 6px; }
.deck-btn { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--fg); }
.deck-btn .ic { width: 24px; height: 24px; }
.deck-btn:disabled { opacity: .35; }
.deck-btn.rec { border-color: var(--rec); color: var(--rec); width: 56px; height: 56px; }
.deck-btn.rec .ic { width: 28px; height: 28px; }
.deck.is-recording .deck-btn.rec { background: var(--rec); color: #fff; animation: recpulse 1.6s ease-in-out infinite; }
.deck.is-paused .deck-btn.rec { background: var(--rec); color: #fff; animation: none; opacity: .75; }
@keyframes recpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(216, 50, 31, .45); } 50% { box-shadow: 0 0 0 10px rgba(216, 50, 31, 0); } }
.deck-btn.stop { border-color: var(--fg); }
.deck-btn.sum { border-color: var(--accent); color: var(--accent); }
.deck-btn.sum.is-busy { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.deck-status { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.deck-time { font-size: var(--fs-4); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; line-height: 1.1; }
.deck.is-recording .deck-time { color: var(--rec); }
.deck-label { font-size: var(--fs-0); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-label.is-rec { color: var(--rec); font-weight: 600; }
.deck-label.is-rec::before { content: "●"; margin-right: 4px; animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.deck-wave { flex: 1; height: 44px; min-width: 60px; }
.deck-wave canvas { width: 100%; height: 100%; display: block; }
.deck-recs { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.deck-recs .btn-sm { gap: 6px; }
.deck-caption { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 8px); background: rgba(28, 34, 48, .85); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: var(--fs-1); max-height: 84px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; backdrop-filter: blur(4px); }
.deck-caption .interim { opacity: .6; }

/* 녹음 목록 패널 (데크 위 팝오버) */
.rec-panel { position: absolute; left: 12px; bottom: 12px; z-index: 7; width: min(440px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); padding: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 60%; overflow: auto; }
.rec-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 6px; border-radius: var(--radius-s); }
.rec-item.is-active { background: var(--accent-soft); }
.rec-item .ibtn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.rec-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rec-name { font-weight: 600; font-size: var(--fs-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-meta { font-size: var(--fs-0); color: var(--muted); font-variant-numeric: tabular-nums; }
.rec-seek { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }
.rec-actions { display: flex; gap: 2px; }
.rec-actions .ibtn { width: 36px; height: 36px; border: 0; }
.rec-actions .ibtn .ic { width: 18px; height: 18px; }
.player-bar { display: flex; align-items: center; gap: 8px; }

/* 받아쓰기 / 요약 패널 */
.doc-pane { flex: 1; min-width: 0; overflow: auto; padding: 20px max(16px, var(--safe-r)) calc(40px + var(--safe-b)) max(16px, var(--safe-l)); }
.doc { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.doc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-head h2 { margin: 0; font-size: var(--fs-4); font-weight: 800; letter-spacing: -.02em; }
.doc-head .meta { color: var(--muted); font-size: var(--fs-0); }
.doc-head .spacer { flex: 1; }
.sum-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.sum-card h3 { margin: 0; font-size: var(--fs-1); font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sum-card h3 .ic { width: 16px; height: 16px; }
.sum-card.is-headline { border-color: transparent; background: var(--accent-soft); }
.sum-card.is-headline ol { margin: 0; padding-left: 22px; font-size: var(--fs-3); font-weight: 600; line-height: 1.5; display: flex; flex-direction: column; gap: 6px; }
.sum-card ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.sum-topic { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line); }
.sum-topic:first-of-type { border-top: 0; }
.sum-topic strong { font-size: var(--fs-2); }
.todo { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.todo input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.todo .todo-text { flex: 1; min-width: 0; }
.todo.is-done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo .todo-meta { font-size: var(--fs-0); color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.kw-row { display: flex; flex-wrap: wrap; gap: 6px; }
.kw { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-1); }
.kw .ic { width: 15px; height: 15px; color: var(--muted); }
.kw.is-tagged { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.sum-edit [contenteditable] { outline: 1px dashed var(--line-strong); outline-offset: 2px; border-radius: 3px; }
.progress { display: flex; flex-direction: column; gap: 10px; padding: 24px; background: var(--surface); border-radius: 12px; border: 1px solid var(--line); }
.progress-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.pstep { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: var(--fs-1); font-weight: 500; }
.pstep.is-on { background: var(--accent-soft); color: var(--accent); }
.pstep.is-done { color: var(--ok); }
.pstep .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .9s linear infinite; }
.tr-list { display: flex; flex-direction: column; }
.tr-line { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 8px 6px; border-radius: 8px; text-align: left; align-items: start; }
.tr-line:hover { background: var(--surface); }
.tr-line.is-current { background: var(--accent-soft); }
.tr-line .ts { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: var(--fs-1); padding-top: 2px; }
.tr-line .spk { font-weight: 700; margin-right: 6px; }
.tr-line .txt { line-height: 1.55; }
.tr-line mark.hit { background: #ffe26a; }
.note-box { padding: 14px 16px; border-radius: 10px; background: var(--surface); border: 1px dashed var(--line-strong); color: var(--muted); font-size: var(--fs-1); line-height: 1.5; }
.err-box { padding: 14px 16px; border-radius: 10px; background: var(--rec-soft); color: var(--fg); border: 1px solid var(--rec); display: flex; flex-direction: column; gap: 8px; }
.pill-ex { background: var(--warn); color: #fff; }

/* 설정 */
.settings { display: flex; flex-direction: column; gap: 18px; }
.set-group { display: flex; flex-direction: column; gap: 10px; }
.set-group h3 { margin: 0; font-size: var(--fs-1); color: var(--muted); font-weight: 700; }
.set-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.set-row .set-label { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.set-row .set-hint { color: var(--muted); font-size: var(--fs-0); }
.set-row .input, .set-row .select { max-width: 320px; }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row .input { flex: 1; }
.set-status { font-size: var(--fs-0); color: var(--muted); }
.set-status.is-ok { color: var(--ok); }
.set-status.is-err { color: var(--rec); }

/* ---------- 세로 / 작은 화면 ---------- */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1000px) {
  .ed-tabs .ed-tab { padding: 0 10px; }
  .ed-pane.is-note { flex-direction: column; }
  .rail { width: auto; height: 60px; flex-direction: row; order: 2; border-right: 0; border-top: 1px solid var(--line); padding: 6px max(8px, var(--safe-r)) 6px max(8px, var(--safe-l)); justify-content: flex-start; overflow-x: auto; overflow-y: hidden; }
  .rail .sep { width: 1px; height: 28px; margin: 0 4px; }
  .rail .grow { display: none; }
  .canvas-wrap { order: 1; }
  .deck { order: 3; padding-bottom: calc(8px + var(--safe-b)); }
  .rail { padding-bottom: 6px; }
  .ed-title-wrap .ed-sub .ed-date { display: none; }
}
@media (max-width: 560px) {
  :root { --fs-2: 14px; --fs-3: 16px; }
  .ed-tabs .ed-tab { padding: 0 8px; font-size: 12px; }
  .ed-tabs .ed-tab .tab-text { display: none; }
  .ed-tabs .ed-tab .ic { width: 18px; height: 18px; }
  .deck { flex-wrap: wrap; }
  .deck-wave { order: 5; flex-basis: 100%; height: 28px; }
  .deck-recs .btn-sm span { display: none; }
  .lib-title { font-size: 22px; }
  .note-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 12px; }
  .subbar { left: 6px; right: 6px; top: 6px; max-width: none; }
  .page-nav .pn-label { display: none; }
  .deck-btn { width: 44px; height: 44px; }
  .deck-btn.rec { width: 50px; height: 50px; }
  .ed-top .ibtn[aria-label="실행 취소"], .ed-top .ibtn[aria-label="다시 실행"] { display: none; }
  .ed-title-wrap { min-width: 90px; }
}
