:root {
  --bg: #eef1f4; --surface: #ffffff; --ink: #1f2731; --muted: #5d6875; --line: #d3d9e0;
  --red: #a83232; --red-ink: #ffffff; --soul: #2d7f7a; --gold: #b7861f; --tag: #f6ecd9; --tag-ink: #3a2a14;
  --focus: #2d63c8; --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a2027; --surface: #232b34; --ink: #e6eaee; --muted: #9aa5b1; --line: #36414d;
    --red: #e06464; --red-ink: #1a1012; --soul: #5cc2ba; --gold: #e0b04a; --tag: #3b3122; --tag-ink: #f3e3c6;
    --focus: #7aa7ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a2027; --surface: #232b34; --ink: #e6eaee; --muted: #9aa5b1; --line: #36414d;
  --red: #e06464; --red-ink: #1a1012; --soul: #5cc2ba; --gold: #e0b04a; --tag: #3b3122; --tag-ink: #f3e3c6;
  --focus: #7aa7ff; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Rubik, system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  padding-bottom: 96px;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 1rem; font-weight: 500; margin-bottom: 8px; }
p { margin: 0; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.small { font-size: .875rem; color: var(--muted); }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.head { border-bottom: 1px solid var(--line); background: var(--surface); }
.head-in { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding-top: 20px; padding-bottom: 18px; }
.lede { color: var(--muted); margin-top: 6px; max-width: 60ch; }
select, input[type=text] {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; min-height: 42px;
}
#lang { flex: none; }

.intro { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; margin: 24px 0; }
.promo, .filebox, .group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }

/* promo codes as butcher shop tags hanging from a string */
.tags { display: flex; gap: 18px; flex-wrap: wrap; padding: 14px 4px 10px; }
.tag {
  position: relative; background: var(--tag); color: var(--tag-ink);
  border-radius: 6px 6px 6px 6px; padding: 14px 16px 12px 34px; min-width: 150px;
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
  transform: rotate(-2deg); transform-origin: 0 50%;
  display: flex; align-items: center; gap: 12px;
}
.tag:nth-child(2) { transform: rotate(1.5deg); }
.tag::before { content: ""; position: absolute; left: 14px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px rgba(0,0,0,.18); }
.code { font-size: 1.7rem; font-weight: 700; letter-spacing: .14em; }
.tag button { margin-left: auto; }
.promo .small + .small { margin-top: 6px; }

.steps { margin: 0 0 14px; padding-left: 20px; color: var(--muted); }
.steps li { margin: 2px 0; }
.pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 500; cursor: pointer; border: 0; border-radius: 8px; min-height: 42px; padding: 9px 16px;
  background: var(--red); color: var(--red-ink); display: inline-flex; align-items: center;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.mini { min-height: 34px; padding: 5px 10px; font-size: .875rem; }
.btn:disabled { opacity: .55; cursor: default; }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--bg); }
.msg.err { color: var(--red); }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--line); margin-bottom: 16px; scrollbar-width: thin; }
.tabs button {
  font: inherit; background: none; border: 0; color: var(--muted); padding: 10px 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -2px; display: inline-flex; gap: 8px; align-items: center;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); font-weight: 500; }
.badge { background: var(--red); color: var(--red-ink); border-radius: 999px; font-size: .75rem; padding: 0 7px; line-height: 1.5; }
.panel { display: grid; gap: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 500; font-size: .95rem; }
.field input, .field select { width: 100%; }
.field .was { font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.field.changed input, .field.changed select { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.field.bad input { border-style: dashed; }
.soul label::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--soul); margin-right: 7px; vertical-align: 1px; }

.islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin: 12px 0; }
.islands button {
  font: inherit; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
}
.islands button.on { background: color-mix(in srgb, var(--soul) 22%, var(--surface)); border-color: var(--soul); }
.islands button.sel { background: var(--soul); color: var(--surface); font-weight: 700; }
.islands button.orig { text-decoration: underline; text-underline-offset: 3px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 10px 0 14px; flex-wrap: wrap; }
.seg button { font: inherit; border: 0; background: var(--surface); color: var(--ink); padding: 9px 14px; cursor: pointer; min-height: 42px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.sw { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.sw:first-child { border-top: 0; }
.sw .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sw .txt b { font-weight: 500; }
.sw.changed .txt b::after { content: " •"; color: var(--red); }
.toggle { appearance: none; flex: none; width: 48px; height: 28px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; margin-top: 2px; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.toggle:checked { background: var(--soul); }
.toggle:checked::after { transform: translateX(20px); }

.mythic { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.card { border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; padding: 12px; display: grid; gap: 10px; background: var(--surface); }
.card.changed { border-color: var(--red); border-left-color: var(--red); }
.card .nm { font-weight: 500; overflow-wrap: anywhere; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card select { min-width: 84px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(20, 30, 40, .12); }
.bar-in { display: flex; gap: 10px; align-items: center; padding-top: 12px; padding-bottom: 12px; }
#count { margin-right: auto; font-weight: 500; }
.foot { margin: 28px 0 12px; }

@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; }
  .head-in { flex-direction: column; }
  h1 { font-size: 1.35rem; }
  .bar-in { flex-wrap: wrap; }
  #count { width: 100%; }
  #save { flex: 1; justify-content: center; }
  .seg { display: flex; }
  .seg button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- shared: how-to guide ---------- */
.guide { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.guide > summary, .guide details > summary { cursor: pointer; padding: 11px 14px; font-weight: 500; list-style-position: inside; }
.guide > summary { color: var(--ink); }
.guide .gbody { padding: 0 12px 12px; display: grid; gap: 8px; }
.guide details { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.guide details[open] > summary { border-bottom: 1px solid var(--line); }
.guide .gin { padding: 12px 14px; font-size: .95rem; }
.guide .gin p { margin: 0 0 10px; }
.guide ol { margin: 0; padding-left: 20px; }
.guide li { margin: 0 0 10px; }
.guide a { color: var(--red); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.cmd { position: relative; margin: 8px 0 4px; }
.cmd pre { margin: 0; background: #1f2731; color: #e6eaee; border-radius: 8px; padding: 12px 74px 12px 12px; overflow-x: auto; font: 13px/1.55 ui-monospace, Consolas, monospace; }
.cmd .btn { position: absolute; top: 6px; right: 6px; }
.guide .note { font-size: .875rem; color: var(--muted); }
.cmd .btn { background: #2c3642; color: #e6eaee; border-color: #3b4652; }

/* ---------- XP Hero ---------- */
.filebox.solo { margin: 24px 0; }
.drop { display: grid; justify-items: start; gap: 6px; border: 2px dashed var(--line); border-radius: var(--r); padding: 20px; cursor: pointer; background: var(--bg); }
.drop b { font-weight: 500; font-size: 1.05rem; }
.drop.over { border-color: var(--soul); background: color-mix(in srgb, var(--soul) 10%, var(--surface)); }
.drop .btn { margin-top: 6px; }
#status { margin-top: 10px; }
#again { margin-top: 16px; }
.intro-p { color: var(--muted); font-size: .95rem; max-width: 72ch; }
.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr); gap: 10px; }
.filters input, .filters select { width: 100%; }
.fline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 4px; }
.fline label { display: inline-flex; gap: 6px; align-items: center; }
input[type=search] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 42px; }
.prod { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.prod input[type=checkbox] { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--red); }
.prod .pn { font-weight: 500; }
.prod .pc { font-size: .85rem; color: var(--muted); }
.prod.sel { background: color-mix(in srgb, var(--red) 6%, transparent); }
.prod .side { display: grid; gap: 6px; justify-items: end; }
.prod .qty { width: 76px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.chip.u { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border-color: var(--gold); }
.pill { font-size: .75rem; border-radius: 999px; padding: 2px 8px; background: color-mix(in srgb, var(--soul) 18%, var(--surface)); color: var(--ink); white-space: nowrap; }
.pill.no { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); }
.wrow { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.wrow label { min-width: 0; }
.wrow .pc { display: block; font-size: .85rem; color: var(--muted); }
.wrow input, .hero input[type=text] { width: 100%; }
.wrow.changed input, .hero .changed input, .field.changed input { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.wrow.bad input, .hero .bad input { border-style: dashed; border-color: var(--red); }
.addrow { display: flex; gap: 10px; flex-wrap: wrap; }
.addrow select { flex: 1 1 260px; min-width: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1.6fr) 60px repeat(3, minmax(70px, 1fr)); gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.hero.hd { font-size: .8rem; color: var(--muted); border-top: 0; padding-bottom: 0; }
.hero .cn { font-weight: 500; min-width: 0; }
.hero .cn small { display: block; font-weight: 400; color: var(--muted); }
.hero .cell span { display: none; font-size: .75rem; color: var(--muted); }
.hero.changed .cn::after { content: " •"; color: var(--red); }
.sumlist { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr; }
  .hero { grid-template-columns: repeat(3, minmax(0, 1fr)) 52px; }
  .hero.hd { display: none; }
  .hero .cn { grid-column: 1 / 4; }
  .hero .ownc { grid-column: 4; grid-row: 1; justify-self: end; }
  .hero .cell span { display: block; }
  .prod { grid-template-columns: 26px minmax(0, 1fr); }
  .prod .side { grid-column: 2; justify-items: start; }
}
.guide .gbody { grid-template-columns: minmax(0, 1fr); }
.guide details, .guide .gin, .guide li { min-width: 0; }
.cmd { display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
.cmd pre { width: 100%; padding-right: 12px; }
.cmd .btn { position: static; }
