:root {
  --bg: #f4f5f3; --card: #fff; --ink: #1d2320; --muted: #6b736f; --line: #e2e5e1;
  --brand: #1f6f5c; --brand-ink: #fff; --warn: #b4531a; --ok: #1f7a3f; --danger: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1b201d; --ink: #e8ece9; --muted: #98a19c; --line: #2c332f; --brand: #3a9c82; --warn: #f0975a; --ok: #5ccf86; --danger: #f06a5e; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; padding-bottom: env(safe-area-inset-bottom); }
h1 { font-size: 17px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2 { font-size: 15px; margin: 0 0 10px; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 12px 16px; background: var(--brand); color: var(--brand-ink); padding-top: max(12px, env(safe-area-inset-top)); }
.back { color: inherit; text-decoration: none; white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.hero { text-align: center; margin-top: 24px; }
.hero p { margin: 0 0 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; font-weight: 600; margin: 8px 0; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn:disabled { opacity: .45; }
.btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { margin-top: 10px; resize: vertical; }
.field { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.field span { flex: 0 0 76px; font-size: 14px; color: var(--muted); }

.scroll { overflow-x: auto; margin-bottom: 12px; }
.preview { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.preview th, .preview td { border: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; text-align: left; }
.preview th { background: var(--card); }

.sticky { position: sticky; top: 48px; z-index: 4; background: var(--bg); padding: 12px 16px 8px; border-bottom: 1px solid var(--line); }
.sticky p { margin: 4px 0 8px; }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; background: var(--brand); transition: width .3s; }
.chips { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.row { display: flex; gap: 12px; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; background: var(--card); }
.row.done { opacity: .6; }
.row .main { min-width: 0; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.name.big { font-size: 19px; }
.sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.side { text-align: right; font-size: 14px; white-space: nowrap; }
.badges { display: flex; gap: 6px; justify-content: flex-end; font-size: 13px; }
.actions { display: grid; gap: 8px; }

.item { padding-bottom: 96px; }
.book { margin-top: 8px; }
.stepper { display: flex; gap: 8px; }
.stepper .btn { flex: 0 0 56px; font-size: 22px; }
.stepper input { text-align: center; font-size: 22px; font-weight: 600; }
.row2 { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 10px; flex-wrap: wrap; }
.row2 label.btn { flex: 1; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumb { position: relative; aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 18px; line-height: 1; }
.memo { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.memo audio { flex: 1; min-width: 0; height: 40px; }
#rec { width: 100%; }

.foot { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.foot .btn { flex: 1; min-height: 50px; font-weight: 600; }

/* v2: 샘플링·미분류함 */
.preview th.hl { background: var(--brand); color: var(--brand-ink); }
.opt { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.opt input { width: auto; margin-top: 5px; }
.check-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.check-row input { width: auto; }
.inline { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.inline input { flex: 1; text-align: right; }
.inline span { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; vertical-align: 2px; background: var(--line); color: var(--ink); }
.tag.key { background: #f6dfc8; color: #7a3d0c; }
.tag.rand { background: #d6e6f7; color: #1b4c7a; }
.tag.man { background: #e5dcf5; color: #4b2c86; }
.tag.add { background: #d4efdc; color: #1d5e33; }
.tag.off { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.banner { display: block; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #fff4d6; color: #6b4a00; text-decoration: none; font-size: 14px; }
.hint { background: #e3f1ec; color: #134d3f; padding: 10px 12px; border-radius: 10px; }
.spacer { height: 90px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick .btn { min-height: 64px; font-size: 18px; font-weight: 700; }
.item > .row2 { margin: 8px 0 12px; }
.thumb .mv { right: auto; left: 4px; font-size: 15px; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 18px; line-height: 1; }
details summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.kv { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.kv th { text-align: left; color: var(--muted); font-weight: 400; padding: 4px 8px 4px 0; width: 40%; vertical-align: top; }
.kv td { padding: 4px 0; overflow-wrap: anywhere; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--card); border: 3px solid transparent; cursor: pointer; }
.tile.on { border-color: var(--brand); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .aud { display: flex; flex-direction: column; justify-content: center; gap: 6px; height: 100%; padding: 6px; font-size: 13px; }
.tile .aud audio { width: 100%; height: 32px; }
.tile .time { position: absolute; left: 4px; bottom: 4px; font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 0 5px; border-radius: 4px; }
.tile .ck { position: absolute; right: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: none; align-items: center; justify-content: center; font-size: 14px; }
.tile.on .ck { display: flex; }
button.row { width: 100%; border: 0; border-bottom: 1px solid var(--line); font: inherit; text-align: left; cursor: pointer; }
@media (prefers-color-scheme: dark) {
  .banner { background: #3d3214; color: #f3d98b; }
  .hint { background: #173a31; color: #bfe6d8; }
}

.memo-text { margin: 0 0 12px; font-size: 14px; }
.tile .said { font-size: 11px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
main.pad > label.btn { width: 100%; }

.hidden { display: none !important; }
.stage { position: relative; margin-bottom: 10px; }
.stage img { width: 100%; display: block; border-radius: 10px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; border-radius: 10px; }
.stage.drawing canvas { pointer-events: auto; outline: 3px solid #ff2d2d; }
.thumb > a { display: block; width: 100%; height: 100%; }
.thumb .cap, .tile .cap { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; line-height: 1.3; background: rgba(0,0,0,.6); color: #fff; padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 0 0 8px 8px; }
.tile .cap { bottom: 18px; border-radius: 0; }
.tile .edit { position: absolute; left: 4px; top: 4px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 14px; }

.link { display: inline-block; margin: 4px 0; color: var(--brand); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--bg); border-radius: 18px 18px 0 0; padding: 20px 16px; padding-bottom: max(20px, env(safe-area-inset-bottom)); animation: up .18s ease-out; }
.sheet p { margin: 0 0 12px; font-size: 17px; font-weight: 600; text-align: center; }
@keyframes up { from { transform: translateY(100%); } }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
