:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece7dc;
  --ink: #1f1d1a;
  --muted: #6f695e;
  --faint: #a29b8e;
  --line: #e2dccf;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #dfe9e4;
  --danger: #b23a2b;
  --st-seed: #8a6a12;
  --st-seed-bg: #f3e9c9;
  --st-growing: #2f6b4f;
  --st-growing-bg: #d9ece1;
  --st-used: #3d5878;
  --st-used-bg: #dce5ef;
  --st-hold: #6f695e;
  --st-hold-bg: #e8e3d9;
  --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 4px 14px rgb(40 30 10 / .06);
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #2b2925;
    --ink: #ece7dd;
    --muted: #aaa397;
    --faint: #6f695e;
    --line: #35322d;
    --accent: #8fc1ae;
    --accent-ink: #12221c;
    --accent-soft: #233630;
    --danger: #e48474;
    --st-seed: #e2c06a;
    --st-seed-bg: #3a321c;
    --st-growing: #8fd0ad;
    --st-growing-bg: #1f3a2d;
    --st-used: #9fbbe0;
    --st-used-bg: #22303f;
    --st-hold: #aaa397;
    --st-hold-bg: #2f2c27;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- 머리줄 ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  margin: 0 -16px; padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.top h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 0; flex: 1; }
.top.sub h1 { font-size: 17px; font-weight: 700; text-align: center; }
.top.sub { justify-content: space-between; }
.top.sub > :last-child { min-width: 44px; text-align: right; }
.count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.code { flex: none; white-space: nowrap; font-weight: 700; font-size: 12px; letter-spacing: .02em; color: var(--muted); font-variant-numeric: tabular-nums; }
.code.big { font-size: 15px; color: var(--ink); flex: 1; text-align: center; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; color: var(--muted); }
.icon-btn.small svg { width: 19px; height: 19px; }
.text-btn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 8px 4px; cursor: pointer; text-decoration: none; font-size: 15px; }
.text-btn.center { display: block; margin: 14px auto 0; color: var(--muted); font-weight: 500; font-size: 14px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 12px;
  border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 > :only-child { grid-column: 1 / -1; }

/* ---------- 다시 꺼내보기 ---------- */
.resurface {
  margin: 4px 0 16px; padding: 16px 16px 14px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 4px solid var(--accent);
}
.resurface-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 600; margin: -6px -8px 2px 0; }
.resurface-kw { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.3; text-decoration: none; margin-bottom: 4px; word-break: keep-all; overflow-wrap: anywhere; }
.resurface-ref { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.resurface-actions { display: flex; gap: 8px; }

/* ---------- 검색 / 필터 ---------- */
.searchbar {
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--faint);
}
.searchbar svg { width: 19px; height: 19px; flex: none; }
.searchbar input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; min-width: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 6px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- 목록 ---------- */
.list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: block; padding: 12px 14px 13px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); text-decoration: none;
}
.item:active { background: var(--surface-2); }
.item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.item-icons { display: inline-flex; gap: 2px; color: var(--faint); }
.item-icons i { display: inline-grid; }
.item-icons svg { width: 16px; height: 16px; }
.item-icons .on { color: var(--accent); }
.item-icons .queued { color: var(--st-seed); }
.item-date { margin-left: auto; color: var(--faint); font-size: 12px; }
.item-kw { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.35; overflow-wrap: anywhere; }
.item-ref { color: var(--muted); font-size: 13.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-ref em { font-style: normal; color: var(--faint); }

.pill { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; line-height: 1.6; }
/* 상태는 분류 안의 보조 정보라 작은 글자로 */
.st { font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-seed { color: var(--st-seed); }
.st-growing { color: var(--st-growing); }
.st-used { color: var(--st-used); }
.st-hold { color: var(--st-hold); }

/* 분류 색 (설정의 분류 순서대로 8색 반복) */
.cat-0 { --cat: #2f6b4f; --cat-bg: #d9ece1; }
.cat-1 { --cat: #3d5878; --cat-bg: #dce5ef; }
.cat-2 { --cat: #8a5a12; --cat-bg: #f3e4c9; }
.cat-3 { --cat: #8a3b5e; --cat-bg: #f2dce6; }
.cat-4 { --cat: #4f5a2a; --cat-bg: #e5e9d0; }
.cat-5 { --cat: #5b4a8a; --cat-bg: #e4def3; }
.cat-6 { --cat: #1f6a72; --cat-bg: #d5ecee; }
.cat-7 { --cat: #8a4a32; --cat-bg: #f1ddd3; }
.cat-none { --cat: var(--muted); --cat-bg: var(--surface-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cat-0 { --cat: #8fd0ad; --cat-bg: #1f3a2d; }
  :root:not([data-theme="light"]) .cat-1 { --cat: #9fbbe0; --cat-bg: #22303f; }
  :root:not([data-theme="light"]) .cat-2 { --cat: #e2c06a; --cat-bg: #3a321c; }
  :root:not([data-theme="light"]) .cat-3 { --cat: #e3a3c0; --cat-bg: #3b2430; }
  :root:not([data-theme="light"]) .cat-4 { --cat: #c4d08a; --cat-bg: #2e3320; }
  :root:not([data-theme="light"]) .cat-5 { --cat: #bcaeea; --cat-bg: #2c2740; }
  :root:not([data-theme="light"]) .cat-6 { --cat: #8ad0d8; --cat-bg: #1c3538; }
  :root:not([data-theme="light"]) .cat-7 { --cat: #e5ab92; --cat-bg: #3b2820; }
}
.pill[class*="cat-"] { color: var(--cat); background: var(--cat-bg); }
.chip.cat-chip.on { background: var(--cat); border-color: var(--cat); color: var(--surface); }
.chip b { font-weight: 700; opacity: .6; margin-left: 2px; font-variant-numeric: tabular-nums; }
/* ---------- 홈: 분류 서랍 ---------- */
.block-head { display: flex; align-items: baseline; justify-content: space-between; }
.block-head h3 { margin-bottom: 8px; }
.text-btn.small { font-size: 13.5px; padding: 4px 2px; }
.drawer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.drawer-tile {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 8px;
  padding: 11px 14px 12px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); text-decoration: none;
  border-left: 4px solid var(--cat);
}
.drawer-tile:active { background: var(--surface-2); }
.drawer-name { font-size: 15px; font-weight: 700; color: var(--cat); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-count { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.drawer-sum { grid-column: 1 / -1; margin-top: 2px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-btn.muted { color: var(--muted); font-weight: 500; }
/* 모든 서랍을 한꺼번에 여는 칸: 분류 색과 섞이지 않게 진한 잉크색 */
.drawer-tile.cat-all { --cat: var(--ink); background: var(--surface-2); }
.drawer-tile.wide { grid-column: 1 / -1; }
.more-link {
  display: block; margin-top: 8px; padding: 12px; border-radius: var(--radius);
  text-align: center; color: var(--accent); font-size: 14px; font-weight: 700; text-decoration: none;
}
.more-link:active { background: var(--surface-2); }
#home-main > .block:first-child, #home-main > .resurface:first-child { margin-top: 14px; }
#results { margin-top: 12px; }

/* ---------- 목록 카드의 라벨 대기열 버튼 ---------- */
.item-wrap { position: relative; }
.item-wrap .item { padding-right: 58px; }
.qtoggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
  border: 0; background: transparent; color: var(--faint); cursor: pointer;
}
.qtoggle:active { background: var(--surface-2); }
.qtoggle.on { color: var(--st-seed); background: var(--st-seed-bg); }
.qtoggle.done { color: var(--accent); }

/* ---------- 선택 모드 ---------- */
.selecting .qtoggle { display: none; }
.selecting .item-wrap::after {
  content: ''; position: absolute; right: 18px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border-radius: 50%; border: 2px solid var(--line); background: var(--surface); pointer-events: none;
}
.selecting .item-wrap.sel::after {
  border-color: var(--accent); background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.selecting .item-wrap.sel .item { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.view.selecting { padding-bottom: calc(var(--tabbar-h) + 100px + env(safe-area-inset-bottom)); }
.select-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 9;
  bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 536px);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 8px 24px rgb(0 0 0 / .14);
}
.select-bar[hidden] { display: none; }
.select-bar .text-btn { font-size: 14px; padding: 6px 0; white-space: nowrap; }
.select-actions { display: flex; gap: 6px; }
.select-actions .btn { padding: 0 11px; white-space: nowrap; }

/* ---------- 라벨 탭 대기열 ---------- */
.queue-head h3 small { font-weight: 500; color: var(--faint); margin-left: 4px; }
.queue li { display: flex; align-items: center; padding-right: 6px; }
.queue li label { flex: 1; min-width: 0; }

/* ---------- 분류 화면 ---------- */
.top.sub h1 small.count { font-size: 14px; font-weight: 600; margin-left: 4px; }
.top.sub h1 .cat-dot { display: inline-block; vertical-align: 2px; margin-right: 8px; }
.status-tabs { padding-top: 2px; padding-bottom: 8px; }
.detail-cat { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.detail-cat + .detail-kw { margin-top: 8px; }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; list-style: none; }
.empty-hero { list-style: none; text-align: center; color: var(--muted); padding: 48px 16px; font-size: 15px; }
.empty-hero .empty-title { color: var(--ink); font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.empty-hero .btn { margin-top: 12px; }

/* ---------- 상세 ---------- */
.detail { padding-top: 4px; }
.photo {
  position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in;
  border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow);
}
.photo img { display: block; width: 100%; max-height: 300px; object-fit: cover; object-position: top; }
.photo span {
  position: absolute; left: 10px; bottom: 10px; padding: 3px 9px; border-radius: 999px;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; font-weight: 600;
}
.detail-kw { font-size: 28px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.3; margin: 18px 0 6px; word-break: keep-all; overflow-wrap: anywhere; }
.block { margin-top: 18px; }
.block h3, .panel h3 { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 8px; }
.refs { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.ref { display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 14px; min-height: 48px; }
.ref + .ref { border-top: 1px solid var(--line); }
.ref-text { flex: 1; font-weight: 500; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; text-decoration: none; }
a.ref-text { color: var(--accent); }
.ref-text svg { width: 18px; height: 18px; flex: none; }
.memo { margin: 0; white-space: pre-wrap; padding: 12px 14px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.meta { color: var(--faint); font-size: 13px; margin: 18px 0 0; }
.actions { display: grid; gap: 8px; margin-top: 14px; }

.seg { display: flex; background: var(--surface-2); padding: 3px; border-radius: 12px; gap: 3px; }
.seg button { flex: 1; height: 38px; border: 0; background: transparent; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg.wide { margin-top: 16px; }

/* ---------- 입력 폼 ---------- */
body[data-route="new"] .tabbar, body[data-route="edit"] .tabbar { display: none; }
.form { display: grid; gap: 16px; padding-top: 4px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.field small { font-weight: 500; color: var(--faint); margin-left: 4px; }
.field input:not([type="range"]), .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 11px 13px; font-size: 16px; outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .kw-input { font-size: 20px; font-weight: 700; padding: 13px 14px; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-foot {
  position: sticky; bottom: 0; margin: 4px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
body[data-route="new"] .view, body[data-route="edit"] .view { padding-bottom: 0; }

.photo-empty { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-empty p { grid-column: 1 / -1; margin: 0; color: var(--faint); font-size: 13px; text-align: center; }
.photo-btn {
  display: grid; place-items: center; gap: 4px; height: 92px; border-radius: var(--radius);
  border: 1.5px dashed var(--line); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer;
}
.photo-btn svg { width: 26px; height: 26px; color: var(--accent); }
.photo-preview { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.photo-preview img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.photo-preview-actions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.photo-preview-actions .btn { background: var(--surface); }

/* ---------- 라벨 ---------- */
.queue { list-style: none; margin: 4px 0 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.queue li + li { border-top: 1px solid var(--line); }
.queue label { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 50px; cursor: pointer; }
.queue input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.queue-kw { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { color: var(--muted); font-size: 13.5px; margin: 8px 2px 0; }
.customize { margin-top: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.customize summary {
  display: flex; align-items: baseline; gap: 8px; padding: 14px 16px; cursor: pointer; list-style: none;
  font-weight: 700; font-size: 15px;
}
.customize summary::-webkit-details-marker { display: none; }
.customize summary span { color: var(--faint); font-size: 13px; font-weight: 500; flex: 1; }
.customize summary::after { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-3px); transition: transform .15s; }
.customize[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.cz-body { display: grid; gap: 14px; padding: 2px 16px 12px; }
.slider { display: grid; grid-template-columns: 78px 1fr 46px; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); }
.slider output { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.cz-row { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.cz-text { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font-size: 15px; outline: none; }
.cz-text:focus { border-color: var(--accent); }
.cz-block { display: grid; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chips.wrap { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
.seg.compact button { height: 34px; font-size: 13.5px; }
.seg button:disabled { opacity: .4; }
.cz-body .text-btn { justify-self: start; color: var(--muted); font-weight: 500; font-size: 14px; padding: 4px 0; }
.previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.label-canvas {
  width: 100%; height: auto; display: block; background: #fff; border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.print-box { margin-top: 18px; padding: 14px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 10px; }
.print-box .hint { margin: 0; }
.printer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.printer-state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.on { background: #3aa76d; box-shadow: 0 0 0 3px rgb(58 167 109 / .2); }

/* ---------- 설정 ---------- */
.panel { margin-top: 12px; padding: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.panel .hint { margin: 0; }
.stat { margin: 0; }
.foot { color: var(--faint); font-size: 12px; text-align: center; margin: 24px 0 0; }

/* ---------- 하단 탭 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; flex: 1; max-width: 120px; display: grid; justify-items: center; gap: 1px;
  text-decoration: none; color: var(--faint); font-size: 11.5px; font-weight: 600; padding: 6px 0;
}
.tabbar a.active { color: var(--ink); }
.tabbar .tab-add { flex: none; width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); place-items: center; padding: 0; box-shadow: var(--shadow); }
.tabbar .tab-add svg { width: 26px; height: 26px; stroke-width: 2.2; }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--st-seed); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ---------- 토스트 / 사진 보기 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); width: max-content;
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--accent-soft); font-weight: 800; padding: 4px 0; cursor: pointer; white-space: nowrap; }
.viewer { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .92); display: grid; place-items: center; overflow: auto; }
.viewer[hidden] { display: none; }
.viewer img { max-width: 100%; max-height: 100%; }

/* ---------- 라벨 종류 탭 / QR 라벨 ---------- */
.mode-tabs { margin: 0 0 12px; }
.seg a {
  flex: 1; display: grid; place-items: center; height: 38px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.qr-form { margin-top: 0; }
.qr-form .seg.compact button { font-size: 13.5px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; min-width: 0; width: 0; }
.input-row .btn { flex: none; }
.qr-preview { display: grid; place-items: center; margin-top: 16px; }
.qr-preview .label-canvas { width: min(62%, 240px); }
.qr-empty {
  width: min(62%, 240px); aspect-ratio: 54 / 67; display: grid; place-items: center; padding: 20px;
  border: 1.5px dashed var(--line); border-radius: 8px; color: var(--faint); font-size: 14px; text-align: center;
}
.hint.center { text-align: center; }
.warn { color: var(--danger); }
.qr-history { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.qr-history li { display: flex; align-items: center; gap: 4px; padding-right: 6px; }
.qr-history li + li { border-top: 1px solid var(--line); }
.qr-h-main { flex: 1; min-width: 0; display: grid; gap: 1px; padding: 10px 14px; border: 0; background: none; text-align: left; cursor: pointer; }
.qr-h-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-h-sub { color: var(--faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 설정: 분류 관리 ---------- */
.cat-edit { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cat-edit li { display: flex; align-items: center; gap: 4px; }
.cat-edit input {
  width: 0;
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: 15px; font-weight: 600; outline: none;
}
.cat-edit input:focus { border-color: var(--accent); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat); flex: none; margin-right: 6px; }
.cat-n { min-width: 26px; text-align: right; color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; margin-right: 2px; }
.cat-edit .icon-btn:disabled { opacity: .3; }

/* ---------- 인쇄 미리보기 ---------- */
.label-canvas.tappable { cursor: zoom-in; }
body.sheet-open { overflow: hidden; }
.sheet {
  position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column;
  background: var(--bg); padding-top: env(safe-area-inset-top);
}
.sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 800; text-align: center; }
.pv-count { min-width: 40px; text-align: right; padding-right: 4px; color: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pv-stage {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.pv-stage::-webkit-scrollbar { display: none; }
.pv-page { flex: 0 0 100%; scroll-snap-align: center; display: grid; place-items: center; padding: 12px 24px; min-height: 0; }
.pv-paper {
  position: relative; height: 100%; max-height: 440px; max-width: 100%;
  background: #fbfaf5; border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 10px 30px rgb(40 30 10 / .16), 0 0 0 1px rgb(0 0 0 / .06);
}
.pv-paper img { position: absolute; mix-blend-mode: multiply; image-rendering: auto; }
.pv-cut {
  position: absolute;
  background: repeating-linear-gradient(-45deg, rgb(178 58 43 / .16) 0 4px, transparent 4px 9px);
}
.pv-meta { margin: 0; padding: 4px 16px 0; text-align: center; color: var(--muted); font-size: 12.5px; }
.pv-legend {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 6px;
  background: repeating-linear-gradient(-45deg, rgb(178 58 43 / .35) 0 3px, transparent 3px 6px);
  box-shadow: 0 0 0 1px var(--line);
}
.pv-controls { display: grid; gap: 10px; padding: 14px 16px 4px; max-width: 560px; width: 100%; margin: 0 auto; }
.pv-row { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; justify-self: start; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.stepper button { width: 40px; height: 34px; border: 0; border-radius: 9px; background: var(--surface); color: var(--ink); font-size: 20px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.stepper output { min-width: 52px; text-align: center; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-foot {
  display: grid; gap: 10px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  max-width: 560px; width: 100%; margin: 0 auto;
}
.pv-progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.pv-progress[hidden] { display: none; }
.pv-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

@media (min-width: 600px) {
  .previews { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
