:root {
  --page-min: 45rem;
  --selector-row: 4.375rem;
  --panel-head: 3.125rem;
  --input-height: 2.6875rem;
  --outline: 0.1875rem;
  --thin: 0.0625rem;
  --header-height: 4.75rem;
  --imperium-black: #0B0B0A;
  --imperium-ink: #070706;
  --imperium-gold: #D4AF57;
  --imperium-gold-deep: #B08A38;
  --imperium-gold-pale: #EFDCAF;
  --imperium-gold-soft: #E8CF93;
  --imperium-cream: #F1E8D6;
  --imperium-muted: #D8CDB6;
  --color-header: var(--imperium-black);
  --color-hero-base: var(--imperium-black);
  --color-hero-overlay: transparent;
  --color-surface: #14120E;
  --color-surface-muted: #1A1712;
  --color-selected: var(--imperium-gold);
  --color-title: var(--imperium-gold-pale);
  --color-text: var(--imperium-cream);
  --color-text-on-dark: var(--imperium-cream);
  --color-border: var(--imperium-gold);
  --color-input-border: rgba(212, 175, 87, 0.45);
  --color-focus: #0B0B0A;
  --color-focus-ring: #D4AF57;
  --color-danger: #FFB9A9;
  --color-danger-surface: rgba(161, 40, 40, 0.22);
  --font-family: Georgia, "Times New Roman", serif;
  --font-label: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-card: 0 1.25rem 2.75rem rgba(0, 0, 0, 0.55);
  --radius-panel: 1rem;
  --radius-card: 0.75rem;
  --radius-item: 0.5rem;
  /* Dark Imperium glass. The fill is dark and translucent so the gold field
     behind the panels is bent by the blur; cream text keeps >= 4.5:1 even over
     the brightest specular stop of that field (see UI-F01-G01). */
  --glass-surface: rgba(30, 26, 20, 0.62);
  --glass-surface-light: rgba(36, 32, 25, 0.55);
  --glass-surface-inner: rgba(255, 255, 255, 0.05);
  --glass-surface-note: rgba(212, 175, 87, 0.07);
  --glass-gold-band: rgba(212, 175, 87, 0.12);
  --glass-border: rgba(212, 175, 87, 0.52);
  --glass-border-soft: rgba(212, 175, 87, 0.26);
  --glass-glow: rgba(255, 255, 255, 0.16);
  --glass-blur: 14px;
  --glass-blur-light: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 0; }
body {
  color: var(--color-text);
  font-family: var(--font-family);
  background-color: var(--imperium-black);
}

.masthead {
  height: var(--header-height);
  color: var(--imperium-gold);
  background-color: var(--imperium-black);
  border-bottom: var(--thin) solid rgba(212, 175, 87, 0.45);
}
.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(var(--content-max), calc(100% - var(--space-8)));
  height: 100%;
  margin: auto;
  padding: 0;
}
.site-title {
  margin: 0;
  color: var(--imperium-gold);
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: var(--weight-regular);
  letter-spacing: 0.34em;
  line-height: 1;
  text-indent: 0.34em;
}

/* Page field — almost black, warmed by two wide gold blooms and a smoked
   vignette. Kept smooth on purpose: the high-frequency detail lives inside
   .workspace (directly behind the panels), where backdrop-filter can bend it. */
.hero {
  position: relative;
  min-height: calc(var(--page-min) - var(--header-height));
  overflow: hidden;
  background-color: var(--imperium-black);
  background-image:
    radial-gradient(ellipse 62% 48% at 16% 4%, rgba(212, 175, 87, 0.16) 0%, rgba(212, 175, 87, 0.05) 46%, rgba(11, 11, 10, 0) 74%),
    radial-gradient(ellipse 54% 44% at 88% 92%, rgba(176, 138, 56, 0.13) 0%, rgba(176, 138, 56, 0.04) 52%, rgba(11, 11, 10, 0) 78%),
    radial-gradient(circle at 50% 0%, rgba(241, 232, 214, 0.05) 0 1px, transparent 1.5px),
    radial-gradient(circle at 76% 64%, rgba(212, 175, 87, 0.06) 0 1px, transparent 1.5px);
  background-size: auto, auto, 37px 37px, 53px 53px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 1.15rem;
  border: var(--thin) solid rgba(212, 175, 87, 0.28);
  border-radius: 1.25rem;
  pointer-events: none;
}

/* Glass backdrop — a jeweller's workbench field INSIDE .workspace, directly
   behind the panels. Two constraints pull in opposite directions:
   1. Looks: it must read as smoked crystal, not hazard tape. The old light
      version was wide opaque gold bands; this one is a sandblasted screen
      (0.5px reed on a 4.6px pitch: too fine to read as stripes at any zoom)
      under one diagonal reflection streak, over two soft gold blooms and a
      smoked vignette. Single direction only — two crossing hatches read as linen.
   2. Proof: backdrop-filter can only bend HIGH-frequency detail — smooth
      gradients are invariant under blur(). The screen's hairlines are what make
      the blur measurable; the field is never pre-blurred, because a second blur
      would erase exactly that detail. */
.workspace::before {
  display: block;
  content: ""; position: absolute; inset: -3rem; z-index: 0; pointer-events: none;
  background:
    /* sandblasted screen: 0.5px reed per 4.6px — grain, never banding */
    repeating-linear-gradient(115deg,
      rgba(212,175,87,0) 0 4.1px,
      rgba(212,175,87,0.42) 4.1px 4.6px,
      rgba(212,175,87,0) 4.6px 4.8px),
    /* the reflection streak: what actually says "glass" */
    linear-gradient(112deg,
      rgba(241,232,214,0) 4%, rgba(241,232,214,0.30) 22%, rgba(241,232,214,0.44) 27%, rgba(241,232,214,0.10) 40%, rgba(241,232,214,0) 56%),
    /* smoked depth — one soft vignette, no rim, no edge */
    radial-gradient(ellipse 52% 58% at 64% 4%, rgba(7,7,6,0.72) 0%, rgba(7,7,6,0.28) 46%, rgba(7,7,6,0) 78%),
    /* gold bloom, wide falloff */
    radial-gradient(ellipse 46% 54% at 20% 26%, rgba(212,175,87,0.55) 0%, rgba(212,175,87,0.20) 50%, rgba(212,175,87,0) 76%),
    radial-gradient(ellipse 42% 48% at 82% 74%, rgba(176,138,56,0.46) 0%, rgba(176,138,56,0.16) 54%, rgba(176,138,56,0) 80%),
    var(--imperium-ink);
}
.workspace > * { position: relative; z-index: 1; }
.hero-inner {
  position: relative;
  z-index: 1;
  width: min(var(--content-max), calc(100% - var(--space-8)));
  margin: auto;
  padding: var(--space-8) 0 var(--space-12);
}
h1 {
  margin: 0;
  color: var(--imperium-cream);
  font-size: clamp(2.4rem, 5.2vw, var(--font-hero));
  font-weight: var(--weight-regular);
  line-height: var(--line-tight);
  text-align: center;
  letter-spacing: -0.025em;
}
h1::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: var(--thin);
  margin: var(--space-4) auto 0;
  background: var(--imperium-gold);
}
.intro {
  max-width: 49rem;
  margin: var(--space-4) auto var(--space-8);
  color: var(--imperium-muted);
  font-size: var(--font-md);
  line-height: 1.65;
  text-align: center;
}
.workspace {
  display: grid;
  grid-template-columns: var(--selector-width) var(--calculator-width) minmax(0, 1fr);
  gap: var(--column-gap);
  align-items: stretch;
  /* Own backdrop root: the blurred field is ::before inside this box, so every
     panel samples it. overflow: clip keeps the -3rem bleed off the scroll axis. */
  position: relative;
  isolation: isolate;
  overflow: clip;
  z-index: 1;
}

/* Fruit selector — a lighter pane so the gold selection state stays dominant.
   4px of inner padding + overflow:hidden keep the first/last pill clear of the
   panel curve; each pill carries its own 8px radius with a 2px gutter. */
.fruit-selector {
  min-width: 0; margin: 0; padding: var(--space-1); border: 0;
  border-radius: var(--radius-card);
  overflow: hidden;
  background-color: var(--glass-surface-light);
  -webkit-backdrop-filter: blur(var(--glass-blur-light)) saturate(115%);
  backdrop-filter: blur(var(--glass-blur-light)) saturate(115%);
  box-shadow:
    inset 0 0 0 var(--thin) var(--glass-border-soft),
    inset 0 1px 0 var(--glass-glow),
    0 1rem 2rem rgba(0, 0, 0, 0.5);
}
.fruit-selector legend {
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-3);
  border: var(--thin) solid var(--glass-border-soft);
  border-radius: var(--radius-item);
  color: var(--imperium-gold-pale);
  background: rgba(11, 11, 10, 0.55);
  font-family: var(--font-label);
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}
.fruit-selector label {
  position: relative;
  display: block;
  height: var(--selector-row);
  margin-top: 2px;
  border: var(--thin) solid var(--glass-border-soft);
  border-radius: var(--radius-item);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  cursor: pointer;
}
.fruit-selector input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.fruit-selector span {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--space-3);
  color: var(--imperium-cream);
  font-size: var(--font-sm);
  letter-spacing: 0.04em;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.fruit-selector input:checked + span {
  color: var(--imperium-black);
  background-color: var(--imperium-gold);
  box-shadow: inset 0.25rem 0 var(--imperium-black);
  font-weight: var(--weight-bold);
}
.fruit-selector input:checked + span::after {
  content: '';
  display: block;
  flex: 0 0 0.65rem;
  width: 0.65rem;
  height: 0.65rem;
  margin-inline-start: auto;
  background-color: var(--imperium-black);
  transform: rotate(45deg);
}
.fruit-selector label:hover span { background-color: rgba(212, 175, 87, 0.14); }
.fruit-selector input:checked + span,
.fruit-selector label:hover input:checked + span { background-color: var(--imperium-gold); }
.fruit-selector input:focus-visible + span {
  position: relative;
  z-index: 2;
  border-radius: inherit;
  outline: var(--outline) solid var(--color-focus);
  outline-offset: calc(var(--outline) * -1);
}

/* Main panels — smoked gold glass. The 1px gold hairline is drawn as an inset
   ring (it follows the 16px radius for free) plus a single specular sweep so
   the slab reads as a pane instead of a flat tint. overflow:hidden clips the
   header band to the panel curve. */
.calculator, .auxiliary {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  position: relative;
  border-radius: var(--radius-panel);
  overflow: hidden;
  background-color: var(--glass-surface);
  background-image:
    linear-gradient(158deg, rgba(255,255,255,0.13) 0%, rgba(255,255,255,0.03) 26%, rgba(255,255,255,0) 52%),
    linear-gradient(0deg, rgba(212,175,87,0.09) 0%, rgba(212,175,87,0) 30%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(120%);
  backdrop-filter: blur(var(--glass-blur)) saturate(120%);
  box-shadow:
    inset 0 0 0 var(--thin) var(--glass-border),
    inset 0 1px 0 var(--glass-glow),
    0 1.25rem 2.75rem rgba(0, 0, 0, 0.55),
    0 0.25rem 0.75rem rgba(0, 0, 0, 0.35);
}
.calculator h2, .auxiliary h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--panel-head);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-bottom: var(--thin) solid var(--glass-border-soft);
  color: var(--imperium-gold-pale);
  background: linear-gradient(180deg, rgba(212, 175, 87, 0.16), rgba(212, 175, 87, 0.04));
  font-size: var(--font-md);
  font-weight: var(--weight-regular);
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-align: center;
}
.calculator-body {
  min-height: 19rem;
  padding: var(--space-4);
  border: 0;
  background: transparent;
}
#weight-label { display: block; margin: 0 0 var(--space-2); color: var(--imperium-muted); font-size: var(--font-sm); }
.weight-row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
#weight {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: var(--input-height);
  padding: 0 var(--space-3);
  border: var(--thin) solid var(--color-input-border);
  border-radius: var(--radius-item);
  color: var(--imperium-cream);
  background: rgba(7, 7, 6, 0.55);
  caret-color: var(--imperium-gold);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
#weight:focus-visible { outline: var(--outline) solid var(--color-focus-ring); outline-offset: var(--space-1); }
#weight[aria-invalid="true"] { border-color: var(--color-danger); background: var(--color-danger-surface); }
#unit { flex: 0 0 auto; color: var(--imperium-muted); font-size: var(--font-result); }
.error { min-height: 1.125rem; margin: var(--space-1) 0; color: var(--color-danger); font-size: var(--font-xs); }
.results { display: grid; gap: var(--space-2); margin: var(--space-3) 0 0; }

/* Result rows read as dashboard stat cards: tiny tracked label, large cream
   figure, both on a nested pane of the same glass. */
.result-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
  gap: var(--space-3);
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: var(--thin) solid rgba(212, 175, 87, 0.18);
  border-radius: var(--radius-card);
  background: var(--glass-surface-inner);
}
.result-item dt {
  color: var(--imperium-gold-pale);
  font-family: var(--font-label);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  line-height: 1.3;
  text-transform: uppercase;
}
.result-item dd {
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: var(--imperium-cream);
  font-size: var(--font-result);
  font-weight: var(--weight-regular);
  font-variant-numeric: tabular-nums;
  line-height: var(--line-tight);
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}
.auxiliary {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
}
.formula-note {
  display: flex;
  align-items: center;
  min-height: var(--panel-head);
  margin: 0;
  padding: var(--space-3);
  border: var(--thin) solid var(--glass-border-soft);
  border-radius: var(--radius-card);
  background: var(--glass-surface-note);
  color: var(--imperium-muted);
  font-size: var(--font-sm);
  font-style: italic;
  line-height: var(--line-tight);
}
.auxiliary h2 {
  min-height: 2.75rem;
  border: var(--thin) solid var(--glass-border-soft);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, rgba(212, 175, 87, 0.16), rgba(212, 175, 87, 0.04));
  font-family: var(--font-label);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.ingredient-card {
  min-height: 11.6875rem;
  padding: var(--space-6);
  border: var(--thin) solid var(--glass-border-soft);
  border-radius: var(--radius-card);
  background: var(--glass-surface-inner);
  text-align: center;
}
.ingredient-card p { max-width: 18rem; margin: var(--space-4) auto 0; color: var(--imperium-cream); font-size: var(--font-sm); line-height: var(--line-normal); }
.ingredient-art { display: flex; justify-content: center; align-items: end; height: 5.5rem; gap: var(--space-2); }
.ingredient-art i { display: block; width: 3.5rem; border: var(--thin) solid rgba(212, 175, 87, 0.55); border-radius: 0.125rem; background: linear-gradient(to bottom, rgba(241, 232, 214, 0.22) 0 20%, var(--imperium-gold) 20% 75%, rgba(11, 11, 10, 0.92) 75%); }
.ingredient-art i:first-child { height: 4rem; transform: rotate(-8deg); }
.ingredient-art i:nth-child(2) { height: 5.5rem; }
.ingredient-art i:last-child { height: 3.5rem; transform: rotate(8deg); }
.decor { position: absolute; pointer-events: none; }
.decor-pencil { width: 11rem; height: var(--thin); top: 3rem; left: -1.5rem; background: rgba(212, 175, 87, 0.55); }
.decor-compass { width: 11rem; height: 11rem; right: -4rem; top: 1.5rem; border: var(--thin) solid rgba(212, 175, 87, 0.28); border-radius: 50%; }

/* Fallback: browsers without backdrop-filter get an opaque smoked surface with
   the same gold hairline and radius, so contrast never depends on what sits
   behind the panel. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .calculator, .auxiliary { background-color: #14120E; }
  .fruit-selector { background-color: #1A1712; }
  .fruit-selector label { background: rgba(255, 255, 255, 0.03); }
  .calculator h2 { background: #1D1913; }
  .calculator-body, .ingredient-card { background: #17140F; }
  .formula-note { background: #1A1712; }
  /* Opacity carries no information without the blur, so the colour field is dropped. */
  .workspace::before { display: none; }
}

@media (max-width: 63.99rem) {
  .workspace { grid-template-columns: minmax(14rem, 30%) minmax(18rem, 1fr); }
  .auxiliary { grid-column: 1 / -1; }
}
@media (max-width: 44.99rem) {
  .masthead { height: 4.25rem; }
  .hero::before { inset: 0.65rem; border-radius: 1rem; }
  .hero-inner { width: min(100% - var(--space-6), var(--content-max)); padding: var(--space-8) 0; }
  .intro { margin: var(--space-4) auto var(--space-6); line-height: var(--line-normal); }
  .workspace { display: flex; flex-direction: column; }
  .fruit-selector, .calculator, .auxiliary { width: 100%; }
  .fruit-selector label { min-height: var(--touch-min); height: 3.5rem; }
  .decor-compass { right: -8rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: 0ms !important; }
  /* Glass is a static surface: no animation, no transition, no parallax. */
  .calculator, .auxiliary, .fruit-selector { animation: none !important; }
}
