:root {
  color-scheme: light;
  --plum: #391e46;
  --ink: #302237;
  --secondary: #67596d;
  --canvas: #f6f2f8;
  --surface: #ffffff;
  --line: #dbd1df;
  --control-edge: #9886a0;
  --violet: #694281;
  --lilac: #eadcf4;
  --apricot: #ffb981;
  --peach: #ffeadb;
  --burnt: #803c1e;
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
header { background: var(--plum); color: var(--surface); }
.bar, main { max-width: 1140px; margin: auto; }
.bar { min-height: 72px; display: flex; align-items: center; gap: 18px; padding: 0 28px; }
.brand { color: var(--surface); font-weight: 750; text-decoration: none; letter-spacing: -1px; font-size: 25px; white-space: nowrap; }
.mark { background: var(--apricot); color: var(--plum); padding: 1px 5px; border-radius: 4px; }
.tag { font-size: 12px; color: var(--lilac); border-left: 1px solid var(--control-edge); padding-left: 16px; }
.bar button { background: transparent; color: var(--surface); border-color: var(--control-edge); }
.bar button:hover { background: #51335e; }
.bar #reload, .bar #reload[hidden] + #session { margin-left: auto; }
main { padding: 48px 28px; }
.heading, .filters, .dialog-top, .row { display: flex; align-items: center; gap: 18px; }
.heading, .dialog-top { justify-content: space-between; }
.eyebrow, .badge, .caption { font: 600 11px ui-monospace, monospace; letter-spacing: .09em; }
.eyebrow { color: var(--violet); }
.intro, .row p, .caption, #count { color: var(--secondary); }
.heading h1 { color: var(--plum); font-size: clamp(36px,6vw,60px); font-weight: 620; letter-spacing: -.065em; margin: 5px 0; }
button, select, input { font: inherit; }
button { border: 1px solid var(--control-edge); border-radius: 6px; padding: 10px 15px; background: var(--surface); color: var(--plum); font-weight: 600; cursor: pointer; }
button:hover { background: var(--canvas); border-color: var(--violet); }
button.primary { background: var(--apricot); color: var(--plum); border-color: #ad6741; }
button.primary:hover { background: #ffa965; }
button:disabled { opacity: .65; cursor: wait; }
nav { display: flex; margin: 30px 0 24px; border-bottom: 1px solid var(--line); gap: 20px; overflow: auto; }
nav button { border: 0; background: transparent; border-radius: 0; padding: 12px 0; white-space: nowrap; font-size: 14px; color: var(--secondary); }
nav button:hover { color: var(--plum); }
nav button[aria-pressed=true] { border-bottom: 3px solid var(--violet); color: var(--plum); }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
input, select { border: 1px solid var(--control-edge); border-radius: 5px; background: var(--surface); color: var(--ink); padding: 10px 12px; max-width: 100%; }
input::placeholder { color: var(--secondary); opacity: 1; }
.filters { flex-wrap: wrap; align-items: end; }
.filters label:first-child { width: min(290px,100%); }
#count { margin-left: auto; font-size: 13px; padding: 10px 0; }
.row { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.row .details { flex: 1; }
.badge { display: inline-block; padding: 5px 8px; background: var(--lilac); color: var(--plum); border-radius: 3px; }
.badge.buy { background: var(--peach); color: var(--burnt); }
.row h3 { font-size: 20px; letter-spacing: -.04em; margin: 8px 0 4px; }
.row p { margin: 5px 0; font-size: 14px; }
.measure { border-left: 1px solid var(--line); padding-left: 22px; min-width: 94px; }
.measure strong { display: block; font-size: 27px; color: var(--plum); }
.empty { background: var(--surface); padding: 24px; border: 1px solid var(--line); border-radius: 8px; }
.dialog-top h2 { margin: 0; color: var(--plum); }
.dialog-top { margin-bottom: 18px; }
dialog { width: min(580px,94vw); max-height: 90vh; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px; }
dialog::backdrop { background: rgb(44 20 54 / 55%); }
form { display: grid; gap: 15px; }
.line { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.line select, .line input { width: 100%; }
p { line-height: 1.5; }
#feedback, #status { color: var(--burnt); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
header :focus-visible { outline-color: var(--apricot); }
nav button:focus-visible { outline-offset: -3px; }
::selection { background: var(--lilac); color: var(--plum); }

:root { --safe-left: max(16px,env(safe-area-inset-left)); --safe-right: max(16px,env(safe-area-inset-right)); }
body { min-height: 100vh; min-height: 100dvh; }
header { padding-top: env(safe-area-inset-top); }
.bar { padding: 8px var(--safe-right) 6px var(--safe-left); display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 0 6px; }
.brand { grid-column: 1 / 3; font-size: clamp(18px,5.7vw,25px); }
#session { grid-column: 3; grid-row: 1; }
.tag { grid-row: 2; border: 0; padding: 0; }
#install, #reload { grid-row: 2; padding: 4px 8px; border-color: transparent; }
#install { grid-column: 2; }
#reload { grid-column: 3; }
.bar button { font-size: 14px; padding: 8px 10px; }
.bar button[hidden] { display: none; }
main { padding: 22px var(--safe-right) calc(86px + env(safe-area-inset-bottom)) var(--safe-left); }
.heading { display: block; }
.intro { margin: 6px 0 12px; }
.eyebrow { margin: 0 0 4px; }
button, input, select, .retry { min-height: 44px; }
button { touch-action: manipulation; }
input, select { font-size: 16px; min-width: 0; }
#dismiss { min-width: 44px; }
nav { position: fixed; z-index: 2; bottom: 0; inset-inline: 0; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0; margin: 0; overflow: visible; background: var(--surface); border: 0; border-top: 1px solid var(--line); padding: 3px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 5px 0; min-height: 52px; font-size: 12px; }
nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
nav button[aria-pressed=true] { background: var(--lilac); border: 0; border-radius: 8px; color: var(--plum); }
.wide-label { display: none; }
.filters { display: grid; grid-template-columns: minmax(0,3fr) minmax(0,2fr); gap: 8px; margin-top: 20px; }
.filters label:first-child { width: auto; }
#count { grid-column: 1/-1; margin: 0; padding: 2px 0; }
#network { background: var(--peach); color: var(--burnt); padding: 10px 14px; border-radius: 6px; }
#status:empty { margin: 10px 0; }
.row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 12px; padding: 16px; }
.row .details { min-width: 0; overflow-wrap: anywhere; }
.row .details:only-child, .row .details:has(+ button), .row > button { grid-column: 1/-1; }
.measure { min-width: 54px; padding-left: 10px; }
.line { grid-template-columns: repeat(2,minmax(0,1fr)); }
.line label:first-child { grid-column: 1/-1; }
.line + .line { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
dialog { position: fixed; inset: auto 0 0; margin: 0 auto; width: 100%; max-width: 100%; max-height: 88vh; max-height: 88dvh; overflow: auto; overscroll-behavior: contain; border-radius: 18px 18px 0 0; padding: 18px var(--safe-right) calc(18px + env(safe-area-inset-bottom)) var(--safe-left); }
.dialog-top { position: sticky; z-index: 1; top: -18px; background: var(--surface); padding-block: 6px; }
dialog input, dialog select { width: 100%; }
.retry { display: inline-flex; align-items: center; background: var(--apricot); color: var(--plum); padding: 8px 16px; border-radius: 6px; font-weight: 600; }

@media (min-width: 720px) {
  .bar { display: flex; gap: 16px; padding: 0 max(28px,env(safe-area-inset-right)) 0 max(28px,env(safe-area-inset-left)); }
  .brand { font-size: 25px; }
  .tag { border-left: 1px solid var(--control-edge); padding-left: 16px; margin-right: auto; }
  .bar #reload, .bar #reload[hidden] + #session { margin-left: 0; }
  main { padding: 48px max(28px,env(safe-area-inset-right)) 48px max(28px,env(safe-area-inset-left)); }
  .heading { display: flex; }
  nav { display: flex; position: static; margin: 30px 0 24px; gap: 20px; padding: 0; border: 0; background: transparent; border-bottom: 1px solid var(--line); }
  nav button { font-size: 14px; padding: 12px 0; min-height: 44px; }
  nav svg, .short-label { display: none; }
  .wide-label { display: inline; }
  nav button[aria-pressed=true] { background: transparent; border-radius: 0; border-bottom: 3px solid var(--violet); }
  .filters { display: flex; gap: 18px; margin: 0; }
  .filters label:first-child { width: min(290px,100%); }
  #count { margin-left: auto; padding: 10px 0; }
  .row { display: flex; align-items: center; flex-wrap: wrap; padding: 20px; }
  .measure { min-width: 94px; padding-left: 22px; }
  .line { grid-template-columns: 2fr 1fr 1fr; }
  .line label:first-child { grid-column: auto; }
  dialog { inset: 0; margin: auto; width: min(580px,94vw); border-radius: 12px; padding: 26px; }
}
@media (max-width: 359px) {
  .filters { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); }
  .filters input, .filters select { padding-inline: 8px; font-weight: 400; }
}
body:has(dialog[open]) { overflow: hidden; }

.trade-panel { background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:clamp(16px,3vw,28px); margin-block:12px; }
.trade-panel h3 { margin:8px 0; }
.trade-panel h4 { color:var(--violet); margin:12px 0 0; }
.figures { display:grid; gap:0; margin:12px 0; }
.figure { display:flex; align-items:baseline; justify-content:space-between; gap:16px; border-bottom:1px solid var(--line); padding:8px 0; }
.figure span { color:var(--secondary); }
.figure strong { text-align:right; font-variant-numeric:tabular-nums; }
.actions { display:flex; flex-wrap:wrap; gap:8px; }
.calculator { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,195px),1fr)); gap:12px; }
fieldset { min-width:0; border:1px solid var(--line); border-radius:8px; display:grid; gap:10px; }
legend, .match-note { color:var(--violet); font-weight:650; }
details summary { min-height:44px; padding:10px 0; cursor:pointer; }
