:root {
  color-scheme: light;
  --ink: #18211d;
  --muted: #66706a;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --line: #dfded7;
  --tomato: #c43d2a;
  --tomato-dark: #8f2d22;
  --basil: #2e6f55;
  --basil-dark: #194637;
  --steel: #506477;
  --gold: #c9982d;
  --shadow: 0 18px 50px rgba(32, 29, 22, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-icon,
.ingredient-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--tomato);
  box-shadow: 0 10px 24px rgba(196, 61, 42, 0.28);
}

.brand-icon svg,
.ingredient-icon svg,
.icon-button svg,
.mode-button svg,
.method-note svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--basil);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.2rem;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.icon-button:hover {
  border-color: var(--tomato);
  color: var(--tomato-dark);
}

.hero-photo {
  min-height: clamp(118px, 24vw, 220px);
  margin: 10px 0 18px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(24, 33, 29, 0.68), rgba(24, 33, 29, 0.16)),
    url("https://images.unsplash.com/photo-1574071318508-1cdbab80d002?auto=format&fit=crop&w=1600&q=80");
  background-position: center 46%;
  background-size: cover;
  box-shadow: var(--shadow);
}

.calculator-layout,
.secondary-layout {
  display: grid;
  gap: 18px;
}

.calculator-layout {
  grid-template-columns: minmax(280px, 0.82fr) minmax(340px, 1.18fr);
  align-items: start;
}

.secondary-layout {
  grid-template-columns: minmax(310px, 0.88fr) minmax(340px, 1.12fr);
  align-items: stretch;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(32, 29, 22, 0.08);
}

.controls-panel,
.result-panel,
.yeast-panel,
.guide-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-heading p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  text-align: right;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-button,
.guide-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #f5f3ee;
}

.mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 800;
}

.mode-button.is-active {
  border-color: var(--basil);
  color: #fff;
  background: var(--basil);
}

.mode-button[data-mode="quick"].is-active {
  border-color: var(--tomato);
  background: var(--tomato);
}

.control-row,
.range-control {
  display: block;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

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

.control-row span,
.range-control label span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.control-row strong,
.range-control strong {
  font-size: 0.96rem;
}

.control-row small,
.range-control small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.control-row input[type="number"] {
  width: 94px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  text-align: right;
  background: #fff;
}

.range-control label {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

output {
  min-width: 72px;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
  background: #f0eee8;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--tomato);
}

.advanced,
.baker-settings {
  border-top: 1px solid var(--line);
}

.baker-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 14px;
}

.baker-settings div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8f7f2;
}

.baker-settings span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.baker-settings strong {
  display: block;
  margin-top: 3px;
  font-size: 1.05rem;
}

.advanced summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  color: var(--ink);
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced[open] summary svg {
  transform: rotate(180deg);
}

.advanced .compact {
  padding-top: 6px;
}

.result-panel {
  position: sticky;
  top: 16px;
}

.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ingredient-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.ingredient-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.ingredient-card p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.25;
}

.ingredient-card strong {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.accent-flour .ingredient-icon {
  color: #7c5b16;
  background: rgba(201, 152, 45, 0.16);
}

.accent-water .ingredient-icon {
  color: var(--steel);
  background: rgba(80, 100, 119, 0.14);
}

.accent-salt .ingredient-icon {
  color: #6b6259;
  background: rgba(107, 98, 89, 0.13);
}

.accent-yeast .ingredient-icon {
  color: var(--tomato-dark);
  background: rgba(196, 61, 42, 0.14);
}

.baker-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.baker-strip div {
  min-width: 0;
  padding: 12px;
  background: #f8f7f2;
}

.baker-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.baker-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

.method-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: 14px;
  border-radius: 8px;
  padding: 13px;
  color: #fff;
  background: var(--basil-dark);
}

.method-note p {
  font-size: 0.92rem;
  line-height: 1.45;
}

.method-note.quick {
  background: var(--tomato-dark);
}

.yeast-table {
  display: grid;
  gap: 8px;
}

.yeast-row {
  display: grid;
  grid-template-columns: 92px 1fr 86px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.yeast-label {
  display: grid;
  gap: 2px;
}

.yeast-row span,
.yeast-label small {
  color: var(--muted);
  font-weight: 800;
}

.yeast-label b {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.1;
}

.yeast-label small {
  font-size: 0.76rem;
  line-height: 1.1;
}

.yeast-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee9df;
}

.yeast-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--basil), var(--tomato));
}

.yeast-row strong {
  text-align: right;
}

.tips-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.tips-list li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.tips-list li::before {
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.guide-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.guide-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.guide-tab {
  min-height: 42px;
  font-weight: 900;
}

.guide-tab.is-active {
  border-color: var(--ink);
  color: #fff;
  background: var(--ink);
}

.guide-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: guide;
}

.guide-list li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  counter-increment: guide;
}

.guide-list li::before {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: var(--tomato);
  content: counter(guide);
}

.guide-list h3 {
  margin: 1px 0 4px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.guide-list p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  transform: translateY(18px);
  opacity: 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  font-weight: 800;
  background: var(--ink);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .calculator-layout,
  .secondary-layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 520px);
    padding-top: 12px;
  }

  .app-header {
    align-items: flex-start;
  }

  .brand-icon {
    width: 40px;
    height: 40px;
  }

  .header-actions {
    flex: 0 0 auto;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .hero-photo {
    min-height: 116px;
    margin-top: 8px;
  }

  .controls-panel,
  .result-panel,
  .yeast-panel,
  .guide-panel {
    padding: 14px;
  }

  .panel-heading {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .panel-heading p {
    max-width: 44%;
    font-size: 0.82rem;
  }

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

  .ingredient-card {
    min-height: 88px;
  }

  .ingredient-card strong {
    font-size: 1.55rem;
  }

  .baker-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .control-row {
    gap: 10px;
  }

  .control-row input[type="number"] {
    width: 86px;
  }

  .yeast-row {
    grid-template-columns: 82px 1fr 76px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .hero-photo,
  .header-actions,
  .controls-panel,
  .toast {
    display: none;
  }

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

  .panel {
    box-shadow: none;
    break-inside: avoid;
  }
}
