/* Project Electrolyte brand tokens (from the design system) */
:root {
  --ink: #111111;
  --muted: #5f5e5a;
  --paper: #ffffff;
  --hairline: #d3d1c7;
  --f00: #efeae0;
  --f01: #97c459;
  --f02: #f26b5b;
  --f03: #d94f9e;
  --dark: #0b0b0b;
  --sans: "Archivo", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --pad: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; padding: 22px var(--pad) calc(100px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; outline: none; }

/* type */
.eyebrow { font-size: 11px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase; }
h1 { margin: 0; font-size: 30px; line-height: 1; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 10px; letter-spacing: 0.04em; }
.num { font-weight: 700; font-variant-numeric: tabular-nums; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.head .stack { display: flex; flex-direction: column; gap: 6px; }
.back { font-size: 13px; font-weight: 600; text-decoration: none; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--paper); border-top: 1px solid var(--hairline);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding: 6px max(8px, calc((100vw - 560px) / 2)) calc(8px + env(safe-area-inset-bottom)); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px;
  font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabs a.on { color: var(--ink); font-weight: 700; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tabs .scan span { width: 48px; height: 48px; background: var(--ink); color: var(--paper); display: flex; align-items: center; justify-content: center; }
.tabs .scan.on span { outline: 2px solid var(--ink); outline-offset: 3px; }

/* flavor tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; text-decoration: none; color: var(--ink); min-height: 132px; }
.tile .p { font-size: 9px; font-weight: 500; letter-spacing: 0.22em; }
.tile .n { font-size: 40px; line-height: 0.95; font-weight: 700; letter-spacing: -0.04em; }
.tile .f { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.tile .q { margin-top: auto; padding-top: 10px; font-size: 17px; font-weight: 700; }
.tile .q small { font-size: 12px; font-weight: 500; }
.swatch { width: 14px; height: 14px; border: 1px solid var(--ink); flex-shrink: 0; display: inline-block; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px; font-size: 12px; font-weight: 700; }
.chip small { font-weight: 500; font-size: 12px; }
.tag { font-family: var(--mono); font-size: 9px; font-weight: 700; padding: 2px 5px; border: 1px solid var(--ink); white-space: nowrap; }
.tag.solid { background: var(--ink); color: var(--paper); }
.tag.ok { background: var(--f01); border-color: var(--f01); }
.tag.soft { background: var(--f00); border-color: var(--f00); }

/* rows and lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--hairline); text-decoration: none; color: var(--ink); }
.list > .row:last-child { border-bottom: 1px solid var(--hairline); }
.row .l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .l > :first-child { font-size: 14px; font-weight: 500; }
.row .r { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; text-align: right; white-space: nowrap; }
.grid-row { display: grid; gap: 8px; align-items: center; }

.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 2px solid var(--ink); text-decoration: none; color: var(--ink); }
.band { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--hairline); }
.card .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--ink); }
.stats > div { display: flex; flex-direction: column; gap: 2px; padding: 12px; }
.stats > div + div { border-left: 1px solid var(--hairline); }
.stats b { font-size: 22px; }
.empty { padding: 28px 0; text-align: center; font-size: 13px; color: var(--muted); }

/* controls */
.btn { min-height: 48px; padding: 0 16px; border: 0; background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; border-radius: 0; }
.btn.full { width: 100%; min-height: 52px; }
.btn.line { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); }
.btn.sm { min-height: 44px; font-size: 13px; padding: 0 14px; }
.btn:disabled { background: var(--muted); cursor: not-allowed; }
.btn.line:disabled { background: var(--paper); color: var(--muted); border-color: var(--hairline); }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--ink); background: var(--paper); flex-shrink: 0; text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.linkish { background: none; border: 0; padding: 0 4px; min-height: 44px; font-size: 13px; font-weight: 600; text-decoration: underline; }

.seg { display: grid; border: 1px solid var(--ink); }
.seg button { min-height: 44px; border: 0; background: var(--paper); font-size: 13px; font-weight: 600; padding: 4px; }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button .c { display: block; font-size: 16px; font-weight: 700; }
.pills { display: grid; gap: 8px; }
.pill { min-height: 48px; font-size: 18px; font-weight: 700; background: var(--paper); border: 1px solid var(--hairline); }
.pill[aria-pressed="true"] { border: 2px solid var(--ink); }
.pill.text { font-size: 13px; font-weight: 600; min-height: 44px; border-color: var(--ink); }
.pill.text[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--ink); flex-shrink: 0; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--paper); font-size: 20px; }
.stepper output, .stepper input { width: 56px; text-align: center; font-size: 18px; font-weight: 700; border: 0; background: transparent; padding: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; }
.field input, .field select, .field textarea, .input {
  min-height: 44px; padding: 0 12px; font-size: 16px; border: 1px solid var(--hairline); border-radius: 0; background: var(--paper); width: 100%; }
.field textarea { padding: 10px 12px; min-height: 72px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--ink); outline: none; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.weights { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.weights input { text-align: center; padding: 0 4px; }
.switch { width: 52px; height: 30px; padding: 3px; border: 1px solid var(--ink); background: var(--paper); display: flex; justify-content: flex-start; flex-shrink: 0; }
.switch span { width: 22px; height: 22px; border: 1px solid var(--ink); background: var(--paper); }
.switch[aria-checked="true"] { background: var(--ink); justify-content: flex-end; }
.switch[aria-checked="true"] span { background: var(--f01); }
.code-box { display: flex; align-items: stretch; border: 1px solid var(--ink); }
.code-box .mono { flex: 1; padding: 12px; font-size: 11px; word-break: break-all; }
.code-box button { width: 72px; border: 0; border-left: 1px solid var(--ink); background: var(--paper); font-size: 12px; font-weight: 700; }
pre.code { margin: 0; padding: 12px; background: var(--f00); font-family: var(--mono); font-size: 11px; line-height: 1.5; overflow-x: auto; }

/* scanner */
.viewfinder { position: relative; background: var(--dark); color: var(--paper); aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; overflow: hidden; margin: 0 calc(-1 * var(--pad)); }
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewfinder .frame { position: relative; width: 55%; aspect-ratio: 1; pointer-events: none; }
.viewfinder .frame i { position: absolute; width: 18%; height: 18%; border: 3px solid var(--paper); }
.viewfinder .frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.viewfinder .frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.viewfinder .frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.viewfinder .frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.viewfinder .msg { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 12px; padding: 0 16px; }
.viewfinder .start { position: absolute; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--paper); padding: 12px 16px; font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.err { background: #b3261e; }
.errbox { padding: 12px 14px; border: 2px solid #b3261e; font-size: 13px; }

/* labels (print) */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dm-label { border: 1px dashed var(--hairline); background: #fff; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; break-inside: avoid; }
.dm-label img { width: 90px; height: 90px; image-rendering: pixelated; }
.dm-label .mono { font-size: 10px; word-break: break-all; }
@media print {
  .tabs, .no-print, #toast { display: none !important; }
  main { padding: 0; }
  .dm-label { border-color: #eee; }
}

/* login */
.login { min-height: 80dvh; justify-content: center; }
.mark { width: 48px; height: 48px; flex-shrink: 0; }

/* changelog */
.release { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--hairline); }
.release.current { border: 2px solid var(--ink); }
.release-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 4px; }
.entries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.entry { width: 100%; display: flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 8px 0; border: 0; background: none; text-align: left; font-size: 14px; line-height: 1.35; }
.entry:disabled { cursor: default; color: var(--ink); }
.entry-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry[aria-expanded="true"] .entry-title { white-space: normal; font-weight: 600; }
.entry-detail { margin: 0 0 10px; padding: 10px 12px; background: var(--f00); font-size: 13px; line-height: 1.5; }
.badge { flex-shrink: 0; font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border: 1px solid var(--ink); position: relative; top: -1px; }
.b-added { background: var(--f01); border-color: var(--f01); }
.b-changed { background: var(--f00); }
.b-fixed { background: var(--f02); border-color: var(--f02); }
.b-removed { background: var(--ink); color: var(--paper); }

/* 0.2.0 */
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack { display: flex; flex-direction: column; gap: 6px; }
.login { display: flex; flex-direction: column; gap: 18px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--ink); }
.btn.danger { background: #b3261e; }
.danger-text { color: #b3261e; }
.as-button { width: 100%; background: none; border: 0; border-top: 1px solid var(--hairline); text-align: left; font: inherit; cursor: pointer; }
.list > .as-button:last-child { border-bottom: 1px solid var(--hairline); }
.undo-row { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; }
.totals { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 2px solid var(--ink); }
.seg.tabs5 { grid-template-columns: repeat(5, 1fr); }
.seg.tabs5 button { font-size: 11px; padding: 4px 2px; }
.custom-price { width: 100%; display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 12px; color: var(--muted); padding-top: 6px; }
.custom-price input { width: 90px; min-height: 40px; border: 1px solid var(--hairline); padding: 0 8px; text-align: right; font-size: 15px; }
.perms, .lotpick { border: 1px solid var(--hairline); padding: 8px 12px; margin: 0; display: flex; flex-direction: column; }
.perms legend, .lotpick legend { padding: 0 4px; }
.lotpick .check { font-size: 13px; flex-wrap: wrap; }
dialog#sheet { border: 0; padding: 0; width: min(520px, 100vw); max-width: 100vw; max-height: 92dvh; margin: auto auto 0; background: var(--paper); color: var(--ink); }
dialog#sheet::backdrop { background: rgba(11, 11, 11, 0.55); }
@media (min-width: 600px) { dialog#sheet { margin: auto; } }
.sheet-form { display: flex; flex-direction: column; gap: 14px; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet-title { font-size: 20px; letter-spacing: -0.01em; text-transform: none; font-weight: 700; margin: 0; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
