:root {
  --canvas: #f2f2f2;
  --signal: #fffa00;
  --paper: #ffffff;
  --ink: #191919;
  --muted: #55564f;
  --line: #d3d3ce;
  --panel: #e8eae7;
  --danger: #d6342b;
  --font-display: "Anybody", "Arial Narrow", sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--canvas); color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .95rem;
  line-height: 1.4;
}

a { color: inherit; text-decoration: none; }
button, input, select { color: inherit; font: inherit; }
h1, h2, p, dl, dd { margin: 0; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; box-shadow: 0 0 0 1px var(--ink); }
::selection { background: var(--signal); color: var(--ink); }

/* Header */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem;
  padding: .9rem clamp(1rem, 3vw, 2.5rem);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-variation-settings: "wdth" 110, "wght" 850;
  letter-spacing: -.04em; line-height: 1; text-transform: uppercase;
}
.share { display: flex; align-items: center; gap: .8rem; }

/* Layout: three columns, one screen on desktop */
.layout {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  max-width: 96rem; margin-inline: auto;
}
.inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-content: start; min-width: 0; }
.span-2 { grid-column: 1 / -1; }
.results { display: grid; gap: 1rem; align-content: start; min-width: 0; }

.card { background: var(--paper); border: 1px solid var(--ink); padding: .9rem 1rem; }
h2 {
  display: flex; align-items: center; gap: .55rem; margin-bottom: .3rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
h2 i {
  display: inline-grid; width: 1.4rem; height: 1.4rem; place-items: center;
  background: var(--signal); color: var(--ink); font-style: normal; letter-spacing: 0;
}
h2 em { margin-left: auto; font-style: normal; font-weight: 500; letter-spacing: .06em; color: var(--muted); }
.help { margin-bottom: .6rem; font-size: .84rem; color: var(--muted); }
.note { font-size: .78rem; color: var(--muted); }
.note:empty { display: none; }
.mt { margin-top: .6rem; }

/* Controls */
.row { display: flex; align-items: center; gap: .5rem; }
.row.wrap { flex-wrap: wrap; gap: .8rem 1rem; }
.row.grow { flex: 1 1 16rem; }
.field { display: block; margin-bottom: .8rem; }
.field > span { display: block; margin-bottom: .25rem; font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.unit { font-size: .8rem; font-weight: 700; white-space: nowrap; }

input[type="number"], select {
  width: 100%; min-width: 0; min-height: 2.5rem; border: 1px solid var(--ink); border-radius: 0;
  background: var(--paper); padding: .4rem .6rem; font-size: 1rem; appearance: none; -moz-appearance: textfield;
}
select {
  padding-right: 2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) 50%, calc(100% - .75rem) 50%; background-size: .35rem .35rem; background-repeat: no-repeat;
}
input[type="number"]:focus, select:focus { background-color: #fffff0; }
.inline { display: flex; align-items: center; gap: .6rem; font-size: .8rem; font-weight: 700; }
.inline input { width: 5rem; }

.toggle { display: flex; gap: 0; }
.toggle button {
  flex: 1; min-height: 2.5rem; border: 1px solid var(--ink); background: var(--paper); padding: .3rem .6rem;
  cursor: pointer; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.toggle button + button { border-left: 0; }
.row .toggle { flex: 0 0 11rem; }
.row.wrap > .toggle { flex: 0 0 16rem; }

.filter, .quick { display: flex; flex-wrap: wrap; gap: .4rem; }
.filter button, .quick button {
  border: 1px solid var(--line); background: transparent; padding: .4rem .6rem; cursor: pointer;
  font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; line-height: 1.2;
}
.filter button small { display: block; font-size: .66rem; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.toggle button:hover, .filter button:hover, .quick button:hover { border-color: var(--ink); }
.toggle button.is-active, .filter button.is-active { border-color: var(--ink); background: var(--signal); color: var(--ink); }
.curve-note { margin-top: .6rem; }
.quick { margin-top: .5rem; }

/* Slider */
.slider-head { display: flex; justify-content: space-between; margin-bottom: .2rem; font-size: .84rem; color: var(--muted); }
#slider-out { font-weight: 700; color: var(--ink); }
input[type="range"] { width: 100%; height: 1.8rem; margin: 0; background: transparent; appearance: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: var(--ink); }
input[type="range"]::-moz-range-track { height: 6px; background: var(--ink); border: 0; }
input[type="range"]::-webkit-slider-thumb { width: 1.4rem; height: 1.4rem; margin-top: -.5rem; border: 2px solid var(--ink); border-radius: 0; background: var(--signal); appearance: none; }
input[type="range"]::-moz-range-thumb { width: 1.2rem; height: 1.2rem; border: 2px solid var(--ink); border-radius: 0; background: var(--signal); }

/* Result */
.label { margin-bottom: .2rem; font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.spl { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .5rem; }
.spl b {
  font-family: var(--font-display); font-weight: 400; font-size: clamp(3.6rem, 7vw, 6rem);
  font-variation-settings: "wdth" 110, "wght" 850; letter-spacing: -.06em; line-height: .95;
}
.spl span { font-size: .8rem; font-weight: 700; letter-spacing: .06em; }
.tier { display: flex; align-items: center; gap: .7rem; margin-bottom: .9rem; font-weight: 600; }
.chip { display: inline-grid; min-height: 1.5rem; place-items: center; padding: 0 .7rem; border: 1px solid var(--ink); font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tier-0, .tier-1 { background: var(--panel); }
.tier-2, .tier-3 { background: var(--signal); }
.tier-4 { background: var(--ink); color: var(--paper); }
.tier-5 { background: var(--danger); color: var(--paper); border-color: var(--danger); }

.stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 2px solid var(--ink); }
.stats > div { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.stats > div:nth-child(odd) { padding-right: .8rem; }
.stats > div:nth-child(even) { padding-left: .8rem; border-left: 1px solid var(--line); }
.stats dt { font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stats dd { font-size: 1.15rem; font-weight: 700; }
.stats > div:nth-child(n+5) { border-bottom: 0; }

/* Chart */
.chart-card { padding: .7rem .8rem; }
.chart { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font-body); font-size: 12px; fill: var(--ink); }
.chart .tick { fill: var(--muted); }
.chart .axis-title { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: 1; }

/* Buttons */
.action { display: inline-flex; min-height: 2.4rem; align-items: stretch; border: 1px solid var(--ink); background: var(--paper); padding: 0; cursor: pointer; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.action span { display: grid; place-items: center; padding: .4rem .9rem; }
.action b { display: grid; width: 2.4rem; place-items: center; border-left: 1px solid var(--ink); }
.action:hover { background: var(--signal); }

/* About */
.about-area { position: relative; max-width: 96rem; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2.5rem) 1rem; }
.about { margin: 0; }
.about summary { display: inline-block; cursor: pointer; border-bottom: 2px solid var(--ink); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.about summary:hover { background: var(--signal); }
.about[open] summary { margin-bottom: 1rem; }
.about-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; background: var(--paper); border: 1px solid var(--ink); padding: 1rem 1.2rem; }
.about-body ol, .about-body ul { margin: 0; padding-left: 1.2rem; }
.about-body li { margin-bottom: .5rem; }

@media (max-width: 64rem) {
  .layout { grid-template-columns: 1fr; }
  .results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 44rem) {
  .inputs { grid-template-columns: 1fr; }
  .results { grid-template-columns: 1fr; }
  .about-body { grid-template-columns: 1fr; }
  .row .toggle, .row.wrap > .toggle { flex-basis: 100%; }
}

.row.two { align-items: start; gap: .8rem; }
.row.two > .field { flex: 1 1 0; min-width: 0; margin-bottom: 0; }
.row.grow input { max-width: 14rem; }
.slider-head.second { margin-top: .5rem; }
.row.two + .note { margin-top: .6rem; }
.quick button { text-transform: none; letter-spacing: .02em; }
.slider-ends { display: flex; justify-content: space-between; margin-top: -.2rem; font-size: .7rem; font-weight: 700; color: var(--muted); }
.quick button:disabled { cursor: not-allowed; opacity: .35; }
.quick button:disabled:hover { background: transparent; border-color: var(--line); }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin-top: .6rem; }
.levels button { display: grid; gap: .05rem; border: 1px solid var(--line); background: transparent; padding: .4rem .3rem; cursor: pointer; text-align: center; line-height: 1.2; }
.levels button b { font-size: .95rem; }
.levels button small { font-size: .7rem; font-weight: 500; color: var(--muted); }
.levels button:hover { border-color: var(--ink); background: var(--panel); }
.levels button.is-active { border-color: var(--ink); background: var(--signal); }
.levels button.is-active small { color: var(--ink); }
.levels button:disabled { cursor: not-allowed; opacity: .35; }
.levels button:disabled:hover { border-color: var(--line); background: transparent; }
.limit { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .9rem; }
.limit .label { margin: 0; }
.limit .toggle { flex: 0 0 auto; }
.limit .toggle button { min-height: 2rem; font-size: .66rem; }
.volume-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.vol-presets .label { margin-bottom: 0; }
.levels { margin-top: .4rem; }
.limit .toggle button { text-transform: none; white-space: nowrap; letter-spacing: .02em; }
@media (max-width: 44rem) { .volume-grid { grid-template-columns: 1fr; } }
@media (max-width: 44rem) {
  .sens-row { flex-wrap: wrap; }
  .sens-row > input, .sens-row > .toggle { flex: 1 1 100%; }
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
#limit-note { margin: -.4rem 0 .8rem; }
@media (max-width: 44rem) {
  .toggle button, .filter button, .levels button, .quick button, .limit .toggle button { min-height: 2.75rem; }
  input[type="range"] { height: 2.75rem; }
}
.credit { position: absolute; top: .1rem; right: clamp(1rem, 3vw, 2.5rem); margin: 0; font-size: .72rem; color: var(--muted); }
.credit a { border-bottom: 1px solid var(--line); }
.credit a:hover { color: var(--ink); border-bottom-color: var(--ink); background: var(--signal); }
@media (max-width: 44rem) { .credit { position: static; margin-top: .9rem; } }
.row.two > .field { max-width: 20rem; }
.row.two .row-note { flex: 2 1 0; align-self: end; margin: 0 0 .1rem; }
@media (max-width: 44rem) { .row.two { flex-wrap: wrap; } .row.two .row-note { flex-basis: 100%; margin-top: .4rem; } }

.back { margin-right: .4rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-bottom: 2px solid var(--ink); }
.back:hover { background: var(--signal); }
