:root {
  --bg: #f7f5fb;
  --surface: #ffffff;
  --surface-2: #f1edf8;
  --ink: #1d1726;
  --ink-2: #6b6478;
  --line: #e2dcec;
  --brand: #5b21b6;
  --brand-bar: #4c1d95;
  --brand-ink: #ffffff;
  --brand-soft: #ede9fe;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --focus: #7c3aed;
  --tap: #ddd6fe;
  --shadow: 0 1px 2px rgba(40, 20, 70, .06), 0 2px 8px rgba(40, 20, 70, .06);
  --radius: 14px;
  --topbar-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #120e18; --surface: #1c1724; --surface-2: #251f2f; --ink: #f1eef6; --ink-2: #aaa2b8; --line: #352d42;
    --brand: #8b5cf6; --brand-bar: #2e1a52; --brand-ink: #ffffff; --brand-soft: #2d2340; --accent: #fbbf24; --accent-soft: #3a2c10;
    --danger: #f28b82; --danger-soft: #3b1d1b; --focus: #a78bfa; --tap: #3b2d5c; --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #120e18; --surface: #1c1724; --surface-2: #251f2f; --ink: #f1eef6; --ink-2: #aaa2b8; --line: #352d42;
  --brand: #8b5cf6; --brand-bar: #2e1a52; --brand-ink: #ffffff; --brand-soft: #2d2340; --accent: #fbbf24; --accent-soft: #3a2c10;
  --danger: #f28b82; --danger-soft: #3b1d1b; --focus: #a78bfa; --tap: #3b2d5c; --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-top: 90px; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
body.counter-page { height: 100vh; height: 100dvh; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; }
p { margin: .4rem 0; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ---------- layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.narrow { max-width: 560px; }
main, main.wrap { padding-top: 16px; padding-bottom: calc(env(safe-area-inset-bottom) + 48px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand-bar); color: var(--brand-ink);
  padding-top: env(safe-area-inset-top);
}
.topbar .bar { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.topbar .grow { flex: 1; min-width: 0; }
.topbar .title { font-weight: 750; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: .85rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.barbtn {
  background: rgba(255, 255, 255, .14); border: 0; color: inherit; border-radius: 10px;
  padding: 0 14px; height: 42px; font-size: .95rem; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
}
.barbtn:active { background: rgba(255, 255, 255, .26); }
.barbtn.more { width: 46px; padding: 0; font-size: 1.4rem; line-height: 1; }
.netbadge { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; border-radius: 999px; padding: 4px 10px; flex: none; }

.popback { position: fixed; inset: 0; z-index: 40; }
.popmenu {
  position: fixed; z-index: 41; min-width: 210px; padding: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(20, 10, 40, .22); display: flex; flex-direction: column;
}
.popmenu button { text-align: left; padding: 12px 14px; border: 0; background: transparent; border-radius: 9px; font-size: 1rem; white-space: nowrap; }
.popmenu button:hover, .popmenu button:focus-visible { background: var(--surface-2); }

/* ---------- counter: menu + tickets ---------- */
.cpage { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.counter { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(240px, 25vw, 320px); }
.editbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--brand); color: var(--brand-ink);
}
.editbar-t { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-size: 1.05rem; }
.editbar-time { opacity: .85; font-variant-numeric: tabular-nums; }
.btn.light { background: #fff; color: var(--brand); border-color: #fff; }
.btn.ghost.light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }
.menu-area {
  --bw: 150px; --bh: 80px; --fs: 17px;
  min-width: 0; overflow: hidden; padding: 12px 14px;
  display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: 8px; row-gap: 12px;
  transition: box-shadow .15s ease;
}
.menu-area.scroll { overflow-y: auto; }
.counter.editing .menu-area { box-shadow: inset 0 0 0 3px var(--brand); background: color-mix(in srgb, var(--brand-soft) 45%, var(--bg)); }
.mcat { --n: 1; width: calc(var(--n) * var(--bw) + (var(--n) - 1) * 8px); }
.mcat > h2 {
  font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2);
  margin: 0 0 5px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mbtns { display: grid; grid-template-columns: repeat(var(--n), var(--bw)); grid-auto-rows: var(--bh); gap: 8px; }
.mbtn {
  min-width: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow); font-size: var(--fs); font-weight: 650; line-height: 1.2; text-align: center;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: background-color .12s ease, transform .06s ease;
}
.mbtn:active { transform: scale(.97); }
.mbtn { position: relative; -webkit-touch-callout: none; }
.mbtn.inticket { background: color-mix(in srgb, var(--brand-soft) 70%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.mbadge {
  position: absolute; top: 5px; right: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font-size: .78rem; font-weight: 800; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}
.mbadge:empty { display: none; }
@media (min-width: 701px) { .mbtn.opt { touch-action: none; } }

/* option chips (drag or tap) */
.chips-layer { position: fixed; inset: 0; z-index: 45; pointer-events: none; }
.chips-layer.interactive { pointer-events: auto; background: rgba(20, 10, 35, .18); }
.chips-center {
  position: fixed; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-size: .8rem; font-weight: 750; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.ochip {
  position: fixed; min-width: 112px; max-width: 220px; min-height: 56px; padding: 8px 16px; border-radius: 16px;
  border: 2px solid var(--brand); background: var(--surface); color: var(--ink); box-shadow: 0 8px 24px rgba(40, 20, 70, .25);
  font-size: 1.05rem; font-weight: 700; line-height: 1.2; text-align: center; display: flex; align-items: center; justify-content: center;
  overflow-wrap: anywhere; transition: transform .08s ease, background-color .08s ease;
}
.ochip.on { background: var(--brand); color: var(--brand-ink); transform: scale(1.08); }
.ochip.current { background: var(--brand-soft); }
.mname { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
.flash { background: var(--tap) !important; border-color: var(--brand) !important; }

.tix { min-height: 0; display: flex; flex-direction: column; background: var(--surface-2); border-left: 1px solid var(--line); }
.cur { padding: 12px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.cur.is-editing { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.curhead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.curlabel { font-size: .8rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.cur.is-editing .curlabel { color: var(--brand); font-size: .95rem; text-transform: none; letter-spacing: 0; }
.curno { font-size: 1.9rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1; }
.curtime { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lines { min-height: 56px; max-height: 36vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.line { display: flex; gap: 4px; }
.lmain {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 6px;
  padding: 8px 10px; min-height: 44px; border: 0; border-radius: 10px; background: var(--surface-2); text-align: left;
}
.cur.is-editing .lmain { background: var(--surface); }
.lmain:disabled { color: inherit; }
.lname { flex: 1 1 auto; min-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lchips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 100%; }
.curcount { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.chip { flex: none; font-size: .78rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.lx { flex: none; width: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-size: 1.3rem; }
.lx:active { background: var(--danger-soft); color: var(--danger); }
.hint { color: var(--ink-2); font-size: .9rem; padding: 10px 2px; }
.hint.pad { padding: 16px 8px; text-align: center; }
.curactions { display: flex; gap: 6px; }
.curactions .btn { padding: 8px 12px; }

.tlist { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.trow {
  text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: none;
}
.trow.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.trow.fresh { animation: fresh .9s ease; }
@keyframes fresh { 0% { background: var(--tap); } 100% { background: var(--surface); } }
.tline1 { display: flex; align-items: baseline; gap: 8px; }
.tno { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ttime { margin-left: auto; color: var(--ink-2); font-size: .9rem; font-variant-numeric: tabular-nums; }
.tcats { font-size: .85rem; color: var(--ink-2); overflow-wrap: anywhere; }
.vtag { font-size: .7rem; font-weight: 800; text-transform: uppercase; color: var(--danger); background: var(--danger-soft); border-radius: 6px; padding: 2px 6px; }
.trow.void .tno, .trow.void .tcats { text-decoration: line-through; opacity: .6; }

/* ---------- buttons & forms ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 16px; min-height: 48px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn.big { min-height: 56px; font-size: 1.1rem; }
.btn.grow { flex: 1; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.nowrap { flex-wrap: nowrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
label.field { display: block; }
label.field > span { display: block; font-weight: 650; font-size: .9rem; margin-bottom: 4px; }
label.field > small { display: block; color: var(--ink-2); font-size: .8rem; margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 1rem; min-width: 0;
}
.err { color: var(--danger); font-size: .875rem; margin-top: 4px; }
.err:empty { display: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list.panel { padding: 4px 16px; }
.lrow { display: flex; align-items: center; gap: 12px; }
.lrow > :first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lacts { display: flex; gap: 6px; flex: none; align-items: center; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.pagehead h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); vertical-align: middle; white-space: nowrap; }
.badge.warn { background: var(--brand-soft); color: var(--brand); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 9px 16px; border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); font-weight: 650; font-size: .92rem; }
.tabs a.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font: 1.05rem ui-monospace, Menlo, Consolas, monospace; }
.codes div { background: var(--surface-2); border-radius: 8px; padding: 8px; text-align: center; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); }
.bigchoice { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 14px 0; }
.bigchoice button { min-height: 84px; font-size: 1.25rem; font-weight: 750; white-space: normal; }
.footer-ver { margin-top: 24px; }
.picker { max-width: 1200px; padding-top: 28px; }
.shopgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 270px)); justify-content: center; gap: 16px; }
@media (max-width: 460px) { .shopgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.shopcard {
  position: relative; min-height: 180px; padding: 34px 16px 22px; border-radius: 20px; border: 2px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform .06s ease, border-color .12s ease;
}
.shopcard:active { transform: scale(.98); }
.shopcard:hover { border-color: var(--brand); }
.shopcard.current { border-color: var(--brand); background: var(--brand-soft); }
.shopname { font-size: 1.9rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.shopmeta { color: var(--ink-2); font-size: 1rem; }
.shoptag { position: absolute; top: 14px; left: 0; right: 0; text-align: center; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }

.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px 20px; }

/* ---------- totals ---------- */
.totals-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.totals-head .field { min-width: 240px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.statn { font-size: 1.8rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.statl { color: var(--ink-2); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.tgroups .panel + .panel { margin-top: 0; }
.tgroup h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 4px; }
.tlines { list-style: none; margin: 0; padding: 0; }
.tlines li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tlines li:last-child { border-bottom: 0; }
.tl-main { display: flex; justify-content: space-between; gap: 10px; font-weight: 650; }
.tl-name { min-width: 0; overflow-wrap: anywhere; }
.tl-n { font-weight: 800; font-variant-numeric: tabular-nums; }
.tl-parts { font-size: .85rem; color: var(--ink-2); }

/* ---------- editor ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.catlist { display: flex; flex-direction: column; gap: 10px; }
.edcat { padding: 8px 12px; }
.rowhead { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.handle {
  flex: none; width: 32px; height: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); font-size: 1.3rem; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 8px;
}
.handle:active { cursor: grabbing; background: var(--surface-2); }
.caret { flex: none; width: 38px; height: 38px; border: 0; border-radius: 9px; background: var(--surface-2); font-size: 1.4rem; line-height: 1; transition: transform .15s ease; }
.caret.open { transform: rotate(90deg); }
.catname { flex: 1 1 160px; font-weight: 700; }
.edbody { padding: 8px 0 6px 40px; }
.optedit { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.optchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.optchip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; max-width: 100%; }
.optchip.first { border-color: var(--brand); }
.optchip input { border: 0; min-height: 34px; width: auto; padding: 4px 6px; background: transparent; }
.deftag { font-size: .7rem; font-weight: 750; background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 2px 6px; margin-left: 3px; white-space: nowrap; }
.chipbtn { flex: none; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; color: var(--ink-2); }
.chipbtn:hover { background: var(--surface-2); }
.itemlist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.edrow { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px 4px 2px; }
.itemname { flex: 1 1 140px; min-height: 42px !important; border-color: transparent !important; background: transparent !important; font-weight: 600; }
.itemname:focus { border-color: var(--line) !important; background: var(--surface) !important; }
.dragging { opacity: .85; box-shadow: 0 8px 24px rgba(40, 20, 70, .25); position: relative; z-index: 3; }
.is-hidden .catname, .is-hidden .itemname { opacity: .5; text-decoration: line-through; }
.iconbtn { flex: none; min-width: 64px; min-height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.iconbtn.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.edrow .barbtn.more, .rowhead .barbtn.more { background: var(--surface-2); color: var(--ink); height: 40px; width: 40px; font-size: 1.2rem; }
.morespacer { flex: none; width: 40px; }
.switch { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 6px; min-height: 40px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.knob { width: 34px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background-color .15s ease; }
.knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s ease; }
.switch.on .knob { background: var(--brand); }
.switch.on .knob::after { left: 17px; }
.switch:not(.on) .swlabel { color: var(--ink-2); }
.pv { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.pvcat h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 6px; }
.pvopts { text-transform: none; letter-spacing: 0; font-weight: 500; }
.pvbtns { display: flex; flex-wrap: wrap; gap: 6px; }
.pvbtn { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface); font-weight: 600; }
.pvbtn.opt { border-color: var(--brand); }
.pvsets { color: var(--brand); font-weight: 600; }
.savebar { position: sticky; bottom: 0; z-index: 5; background: var(--bg); border-top: 1px solid var(--line); margin-top: 16px; padding: 10px 0 calc(env(safe-area-inset-bottom) + 10px); }
.savebar-in { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 10, 35, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 18px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal h2 { margin-bottom: 10px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- small screens (phones are a fallback, tablets are the target) ---------- */
@media (max-width: 700px) {
  body.counter-page { height: auto; overflow: auto; }
  .cpage { height: auto; }
  .counter { grid-template-columns: 1fr; }
  .editbar { flex-wrap: wrap; position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 19; }
  .menu-area { overflow: visible; }
  .tix { border-left: 0; border-top: 1px solid var(--line); }
  .lacts { flex-wrap: wrap; justify-content: flex-end; }
  .edbody { padding-left: 0; }
  .edrow { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .topbar, .tabs, .savebar, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ---------- stores, option sets (1.2) ---------- */
.sortlist { display: flex; flex-direction: column; padding: 4px 12px; }
.srow { padding: 10px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.srow:last-child { border-bottom: 0; }
.srow > .sinfo { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.srow > .handle { align-self: stretch; height: auto; }
.lrow > .handle:first-child { flex: none; }
.pagehead .grow { flex: 1; min-width: 0; }
.pagehead .grow h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sectitle { margin: 6px 2px 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.setused { padding: 0 0 6px 80px; }
.setpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.setchip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 650; font-size: .92rem;
}
.setchip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.setno { width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: .75rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.dirtag { flex: none; width: 30px; text-align: center; font-weight: 800; color: var(--brand); font-size: 1.05rem; }
.optbtn {
  flex: 0 1 auto; max-width: 42%; min-height: 40px; padding: 4px 12px; border-radius: 9px; border: 1px dashed var(--line);
  background: transparent; font-size: .85rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.optbtn.set { border-style: solid; border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.seg { display: flex; flex-direction: column; gap: 6px; }
.segbtn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; font-weight: 650; }
.segbtn.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); color: var(--brand); }
@media (max-width: 700px) {
  .setused { padding-left: 0; }
  .optbtn { max-width: 100%; }
}
