:root {
  color-scheme: dark;
  --background: #000;
  --surface-1: #0a0a0a;
  --surface-2: #1a1a1a;
  --surface-3: #1f1f1f;
  --border: #ffffff24;
  --border-hover: #ffffff3d;
  --primary: #ededed;
  --secondary: #a0a0a0;
  --tertiary: #6b6b6b;
  --accent: #006efe;
  --accent-bright: #47a8ff;
  --font-sans: "Geist Sans", "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--primary);
  background:
    radial-gradient(circle at 50% -20%, #1b1b1b 0, transparent 38rem),
    var(--background);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
label,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button,
input,
a {
  outline: none;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
.checkbox-row:has(input:focus-visible) {
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--accent-bright);
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 64px;
}

.masthead {
  height: 64px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 540;
  letter-spacing: -0.01em;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.wordmark svg {
  width: 24px;
  height: 24px;
}

.intro {
  max-width: 720px;
  padding: 96px 0 48px;
}

.intro h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 580;
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.intro p {
  max-width: 600px;
  margin: 24px 0 0;
  color: var(--secondary);
  font-size: 18px;
  line-height: 1.55;
  letter-spacing: -0.02em;
}

.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.controls {
  min-width: 0;
  padding: 32px;
}

.control-group {
  min-width: 0;
  margin: 0;
  padding: 0 0 32px;
  border: 0;
}

.control-group + .control-group {
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.control-group legend {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 24px;
  padding: 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 520;
  letter-spacing: -0.01em;
}

.control-group legend span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--border-hover);
  border-radius: 50%;
  color: var(--secondary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.value-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.number-field,
.flour-field {
  min-width: 0;
}

.number-field > label,
.flour-field > label {
  display: block;
  margin-bottom: 8px;
  color: var(--secondary);
  font-size: 12px;
}

.number-input-wrap {
  display: flex;
  align-items: center;
  width: 190px;
  height: 48px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 160ms ease, background-color 160ms ease;
}

.number-input-wrap:hover,
.number-input-wrap:focus-within {
  border-color: var(--border-hover);
  background: var(--surface-3);
}

.number-input-wrap input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 4px 0 14px;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.number-input-wrap input:focus-visible {
  box-shadow: none;
}

.number-input-wrap span {
  flex: none;
  padding-right: 14px;
  color: var(--secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 48px);
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented-control label {
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--secondary);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  transition: color 160ms ease, background-color 160ms ease;
}

.segmented-control input:checked + label {
  color: var(--primary);
  background: #343434;
  box-shadow: 0 1px 2px #0008;
}

.segmented-control input:focus-visible + label {
  box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--accent-bright);
}

.range {
  --range-progress: 50%;
  width: 100%;
  height: 20px;
  margin: 28px 0 0;
  appearance: none;
  cursor: pointer;
  background: transparent;
  border-radius: 999px;
}

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--range-progress), #333 var(--range-progress));
}

.range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: #333;
}

.range::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  appearance: none;
  border: 2px solid var(--background);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--border-hover);
}

.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--background);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--border-hover);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.optional-input {
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin: -12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.checkbox-control {
  position: relative;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.checkbox-control input {
  width: 18px;
  height: 18px;
  margin: 0;
  appearance: none;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  background: var(--surface-2);
  cursor: pointer;
}

.checkbox-control input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.checkbox-control svg {
  position: absolute;
  inset: 2px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  pointer-events: none;
  opacity: 0;
}

.checkbox-control input:checked + svg {
  opacity: 1;
}

.checkbox-row strong,
.checkbox-row small {
  display: block;
}

.checkbox-row strong {
  font-size: 14px;
  font-weight: 520;
}

.checkbox-row small {
  margin-top: 2px;
  color: var(--secondary);
  font-size: 12px;
}

.flour-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.flour-field > label {
  margin: 0;
  color: var(--primary);
  font-size: 14px;
}

.number-input-wrap.compact {
  width: 144px;
  height: 40px;
}

.results {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 32px;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
}

.results-heading p,
.primary-result p,
.result-note {
  margin: 0;
}

.results-heading p {
  margin-bottom: 6px;
  color: var(--accent-bright);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.results-heading h2 {
  margin: 0;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.results-heading h2 span {
  color: var(--primary);
}

.primary-result {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-height: 176px;
  padding: 40px 0 32px;
}

.primary-result p:first-child {
  margin-bottom: 8px;
  color: var(--secondary);
  font-size: 13px;
}

.primary-result strong {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(42px, 5vw, 64px);
  font-weight: 450;
  line-height: 1;
  letter-spacing: -0.07em;
  font-variant-numeric: tabular-nums;
}

.primary-result .gram-value {
  padding-bottom: 5px;
  color: var(--secondary);
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.yeast-list-label {
  margin: 0 0 8px;
  color: var(--tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.yeast-list {
  margin: 0;
  border-top: 1px solid var(--border);
}

.yeast-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  border-bottom: 1px solid var(--border);
}

.yeast-list dt {
  color: var(--secondary);
  font-size: 13px;
}

.yeast-list dd {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.yeast-list dd strong {
  color: var(--primary);
  font-size: 15px;
  font-weight: 500;
}

.yeast-list dd span {
  color: var(--secondary);
  font-size: 12px;
}

.result-note {
  margin-top: 24px;
  color: var(--tertiary);
  font-size: 12px;
  line-height: 1.6;
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: auto;
  padding: 0 18px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  color: #000;
  background: var(--primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 540;
  transition: background-color 160ms ease, transform 120ms ease;
}

.share-button:hover {
  background: #fff;
}

.share-button:active {
  transform: translateY(1px);
}

.share-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.method-note {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 0.65fr);
  gap: 40px;
  margin-top: 40px;
  padding: 32px 0;
}

.method-note h2,
.method-note p {
  margin: 0;
}

.method-note h2 {
  font-size: 14px;
  font-weight: 520;
}

.method-note p {
  max-width: 680px;
  color: var(--secondary);
  line-height: 1.65;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  padding: 10px 14px;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--primary);
  background: var(--surface-3);
  box-shadow: 0 12px 32px #000a;
  font-size: 13px;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 32px, 680px);
  }

  .intro {
    padding: 64px 0 40px;
  }

  .calculator {
    grid-template-columns: 1fr;
  }

  .results {
    min-height: 560px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: calc(100% - 24px);
    padding-bottom: 32px;
  }

  .intro {
    padding: 48px 4px 32px;
  }

  .intro h1 {
    font-size: 44px;
  }

  .intro p {
    margin-top: 16px;
    font-size: 16px;
  }

  .controls,
  .results {
    padding: 24px 20px;
  }

  .value-row {
    align-items: end;
  }

  .number-input-wrap {
    width: 160px;
  }

  .segmented-control {
    grid-template-columns: repeat(2, 42px);
  }

  .primary-result {
    min-height: 152px;
  }

  .primary-result strong {
    font-size: 46px;
  }

  .yeast-list > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 14px 0;
  }

  .method-note {
    grid-template-columns: 1fr;
    gap: 12px;
    padding-inline: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
