:root {
  --bg: #fdf0ed;
  --surface: #fadad1;
  --border: #d8cdcb;
  --text: #403c3d;
  --muted: #8f8886;
  --primary: #1a9b9d;
  --secondary: #079f70;
  --accent: #e95678;
  --primary-dark: oklch(45% 0.105 196);
  --secondary-dark: oklch(43% 0.13 158);
  --accent-dark: oklch(48% 0.16 7);
  --paper: oklch(98% 0.012 28);
  --shadow: rgba(64, 60, 61, 0.12);
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(26, 155, 157, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 155, 157, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(233, 86, 120, 0.025) 12px, transparent 12px),
    linear-gradient(90deg, rgba(233, 86, 120, 0.025) 12px, transparent 12px);
  background-size: 12px 12px, 12px 12px, 24px 24px, 24px 24px;
  font-family: var(--sans);
  line-height: 1.5;
}

button, input, select { font: inherit; color: inherit; }

.haze {
  position: fixed;
  z-index: -1;
  width: 38rem;
  height: 38rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.24;
  pointer-events: none;
}

.haze-one { top: -19rem; right: -10rem; background: var(--surface); }
.haze-two { bottom: -22rem; left: -12rem; background: color-mix(in oklch, var(--primary) 18%, transparent); }

.page-shell { width: min(100% - 32px, 760px); margin: 0 auto; padding: 48px 0 32px; }

.masthead { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.masthead h1 { margin: 2px 0 0; font-size: clamp(2rem, 7vw, 3.15rem); line-height: 1; letter-spacing: -0.055em; }
.eyebrow, .step-label { margin: 0; color: var(--primary-dark); font-family: var(--mono); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }

.brand-mark { position: relative; width: 52px; height: 52px; flex: 0 0 52px; }
.cup-fill { position: absolute; left: 5px; bottom: 5px; width: 35px; height: 34px; background: var(--primary); border: 3px solid var(--text); clip-path: polygon(0 0, 100% 0, 100% 83%, 83% 83%, 83% 100%, 17% 100%, 17% 83%, 0 83%); }
.cup-handle { position: absolute; right: 1px; bottom: 13px; width: 14px; height: 19px; border: 3px solid var(--text); border-left: 0; }
.cup-tick { position: absolute; left: 12px; width: 10px; height: 3px; background: var(--bg); }
.tick-one { top: 25px; } .tick-two { top: 32px; }
.steam { position: absolute; left: 27px; top: 1px; width: 7px; height: 7px; background: var(--accent); box-shadow: -7px 7px 0 var(--accent); }

.converter-panel, .result-card {
  position: relative;
  border: 2px solid var(--text);
  box-shadow: 7px 7px 0 var(--shadow);
  clip-path: polygon(0 10px, 10px 10px, 10px 0, calc(100% - 10px) 0, calc(100% - 10px) 10px, 100% 10px, 100% 100%, 0 100%);
}

.converter-panel {
  padding: clamp(20px, 5vw, 34px);
  background-color: var(--surface);
  background-image: linear-gradient(rgba(255,255,255,.22) 50%, transparent 50%), linear-gradient(90deg, rgba(255,255,255,.22) 50%, transparent 50%);
  background-size: 22px 22px;
}

.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.panel-heading h2 { margin: 5px 0 0; font-size: clamp(1.35rem, 4vw, 1.8rem); letter-spacing: -0.025em; }
.instant-badge { padding: 5px 9px; border: 2px solid var(--secondary-dark); background: var(--paper); color: var(--secondary-dark); font-family: var(--mono); font-size: .72rem; font-weight: 800; text-transform: uppercase; }

label { display: block; margin-bottom: 7px; font-family: var(--mono); font-size: .78rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
input, select {
  width: 100%; min-height: 50px; border: 2px solid var(--text); border-radius: 0; padding: 10px 13px; background: var(--paper); box-shadow: 3px 3px 0 rgba(64,60,61,.1); outline: 0;
}
input { font-family: var(--mono); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
select { cursor: pointer; }
input:hover, select:hover { border-color: var(--primary-dark); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 4px solid color-mix(in oklch, var(--primary) 45%, white); outline-offset: 3px; }
input[aria-invalid="true"] { border-color: var(--accent-dark); }
.amount-field { margin-bottom: 19px; }
.field-error { min-height: 1.25em; margin: 6px 0 0; color: var(--accent-dark); font-size: .82rem; font-weight: 700; }
.units-row { display: grid; grid-template-columns: 1fr 50px 1fr; align-items: end; gap: 12px; }
.swap-button { min-width: 50px; min-height: 50px; border: 2px solid var(--text); background: color-mix(in oklch, var(--accent) 38%, var(--paper)); color: var(--text); box-shadow: 3px 3px 0 rgba(64,60,61,.18); cursor: pointer; font-size: 1.55rem; font-weight: 900; line-height: 1; transition: transform 150ms ease, box-shadow 150ms ease; }
.swap-button:hover { background: color-mix(in oklch, var(--accent) 50%, var(--paper)); transform: translate(1px, 1px); box-shadow: 2px 2px 0 rgba(64,60,61,.18); }
.swap-button.is-swapping span { display: inline-block; transform: scaleX(-1); }

.ingredient-field { margin-top: 22px; padding: 15px; border: 2px dashed var(--border); background: rgba(253,240,237,.52); transition: border-color 150ms ease, background 150ms ease; }
.ingredient-field.is-relevant { border-color: var(--secondary-dark); background: color-mix(in oklch, var(--secondary) 8%, var(--paper)); }
.density-note { margin: 8px 0 0; color: var(--secondary-dark); font-size: .85rem; font-weight: 750; }
.ingredient-field:not(.is-relevant) .density-note { color: var(--muted); }

.result-card { margin-top: 28px; padding: clamp(22px, 6vw, 40px); background: var(--paper); border-color: var(--primary-dark); box-shadow: 8px 8px 0 color-mix(in oklch, var(--primary) 28%, transparent); }
.result-card::after { content: ""; position: absolute; right: 0; bottom: 0; width: 15px; height: 15px; background: var(--primary); }
.result-topline { display: flex; justify-content: space-between; gap: 18px; color: var(--primary-dark); font-family: var(--mono); font-size: .75rem; font-weight: 800; letter-spacing: .08em; }
.pixel-dots { color: var(--accent-dark); letter-spacing: .16em; }
.equation { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1em .28em; margin: 24px 0 17px; font-family: var(--mono); font-size: clamp(2.05rem, 8vw, 4.25rem); font-weight: 850; letter-spacing: -.07em; line-height: 1.05; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.equals { color: var(--accent-dark); }
.result-context { margin: 0; color: var(--text); font-size: clamp(.9rem, 2.7vw, 1rem); font-weight: 650; }
.result-card.is-empty .equation { color: var(--muted); }

footer { margin-top: 28px; padding: 0 8px; color: var(--muted); font-size: .79rem; }
footer p { margin: 8px 0; }
footer strong { color: var(--text); }
.standards { font-family: var(--mono); }
.noscript { border: 2px solid var(--accent-dark); padding: 12px; background: var(--paper); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 560px) {
  .page-shell { width: min(100% - 24px, 760px); padding-top: 28px; }
  .masthead { margin-bottom: 22px; }
  .units-row { grid-template-columns: 1fr; gap: 9px; }
  .swap-button { justify-self: center; transform: rotate(90deg); }
  .swap-button:hover { transform: rotate(90deg) translate(1px, 1px); }
  .control-field:last-child { grid-row: 3; }
  .equation { letter-spacing: -.055em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
