:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255,255,255,.86);
  --surface-solid: #fff;
  --surface-soft: #eeeef2;
  --ink: #181715;
  --muted: #6e6e73;
  --line: rgba(20,18,16,.09);
  --accent: #e44924;
  --accent-dark: #b72e15;
  --accent-soft: #fff0ea;
  --green: #188756;
  --green-soft: #e8f7ef;
  --blue: #276bd1;
  --blue-soft: #eaf2ff;
  --yellow: #ad6a00;
  --yellow-soft: #fff4d8;
  --shadow: 0 20px 50px rgba(27,22,18,.08), 0 2px 8px rgba(27,22,18,.04);
  --radius: 26px;
  --radius-sm: 17px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100%; color: var(--ink); background: radial-gradient(circle at 80% 0%, #fff2eb 0, transparent 34rem), var(--bg); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(228,73,36,.24); outline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.15rem, 5vw, 4.6rem); line-height: .98; letter-spacing: -.055em; margin-bottom: 1rem; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.08; letter-spacing: -.04em; margin-bottom: .7rem; }
h3 { font-size: 1.05rem; letter-spacing: -.015em; margin-bottom: .45rem; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .65rem; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .14em; }
.caption { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.hidden, [hidden] { display: none !important; }

.login-shell { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(540px, 100%); padding: clamp(28px, 6vw, 58px); border: 1px solid rgba(255,255,255,.8); border-radius: 38px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); backdrop-filter: blur(24px); }
.login-card h1 { font-size: clamp(2.3rem, 7vw, 4rem); }
.brand-mark { display: grid; width: 42px; height: 42px; flex: none; place-items: center; border-radius: 13px; background: #181715; box-shadow: 0 5px 15px rgba(0,0,0,.16); font-size: 24px; }
.brand-mark--large { width: 72px; height: 72px; margin-bottom: 28px; border-radius: 22px; font-size: 40px; transform: rotate(-3deg); }

.app-shell { min-height: 100svh; }
.topbar { position: sticky; z-index: 30; top: 0; height: 78px; display: flex; align-items: center; gap: 28px; padding: 0 max(26px, calc((100vw - 1240px) / 2)); border-bottom: 1px solid rgba(0,0,0,.055); background: rgba(250,250,251,.76); backdrop-filter: saturate(170%) blur(24px); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.brand strong, .brand small { display: block; line-height: .94; letter-spacing: -.025em; }
.brand strong { font-size: 1.05rem; }
.brand small { color: var(--muted); font-size: .74rem; font-weight: 600; }
.desktop-nav { display: flex; gap: 4px; margin-left: auto; }
.desktop-nav button, .bottom-nav button { border: 0; background: transparent; cursor: pointer; }
.desktop-nav button { padding: 10px 14px; border-radius: 999px; color: var(--muted); font-size: .88rem; font-weight: 650; }
.desktop-nav button:hover, .desktop-nav button.active { color: var(--ink); background: rgba(0,0,0,.055); }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.7); cursor: pointer; }
.bottom-nav { display: none; }
#app { width: min(1180px, calc(100% - 36px)); min-height: calc(100svh - 78px); margin: 0 auto; padding: 52px 0 90px; }

.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h1 { max-width: 780px; margin-bottom: 0; }
.page-head p { max-width: 620px; margin: 8px 0 0; color: var(--muted); }
.hero { position: relative; overflow: hidden; min-height: 390px; display: grid; align-items: end; padding: clamp(28px, 5vw, 60px); border-radius: 38px; background: #171411; color: #fff; box-shadow: var(--shadow); }
.hero::before { content: ""; position: absolute; width: 520px; height: 520px; top: -220px; right: -80px; border-radius: 50%; background: radial-gradient(circle at 35% 65%, rgba(255,180,105,.95), rgba(229,69,28,.73) 36%, transparent 68%); filter: blur(2px); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(17,14,12,.02), rgba(17,14,12,.2)); }
.hero-content { position: relative; z-index: 1; max-width: 700px; }
.hero h1 { max-width: 670px; margin-bottom: 1.15rem; }
.hero p { max-width: 570px; color: rgba(255,255,255,.67); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero .button--secondary { color: #fff; border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.1); }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section { margin-top: 38px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.section-head h2 { margin: 0; }
.section-head button { padding: 7px 0; border: 0; color: var(--accent); background: none; font-weight: 700; cursor: pointer; }
.card { border: 1px solid rgba(255,255,255,.9); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px rgba(30,22,17,.05); backdrop-filter: blur(16px); }
.card--padded { padding: 24px; }
.card--dark { border-color: #24201c; background: #171411; color: white; }
.card--accent { border-color: #ffddd1; background: linear-gradient(145deg, #fff7f2, #ffe9df); }
.stat-card { min-height: 135px; padding: 22px; }
.stat-card strong { display: block; margin-top: 13px; font-size: 2rem; line-height: 1; letter-spacing: -.045em; }
.stat-card small { color: var(--muted); font-weight: 650; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 10px 17px; border: 1px solid transparent; border-radius: 999px; background: var(--surface-solid); font-weight: 720; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button--primary { border-color: var(--accent); background: var(--accent); color: white; box-shadow: 0 9px 20px rgba(228,73,36,.2); }
.button--primary:hover { background: var(--accent-dark); }
.button--secondary { border-color: var(--line); background: rgba(255,255,255,.7); }
.button--ghost { border-color: transparent; background: transparent; color: var(--accent); }
.button--danger { border-color: #ffd4cd; background: #fff0ed; color: #b72e15; }
.button--large { width: 100%; min-height: 52px; }
.button[disabled] { opacity: .5; pointer-events: none; }

.stack { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field > span { color: #4e4e52; font-size: .78rem; font-weight: 730; letter-spacing: .01em; }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid rgba(0,0,0,.11); border-radius: 14px; background: rgba(255,255,255,.88); color: var(--ink); transition: border .16s ease, box-shadow .16s ease; }
.field textarea { min-height: 110px; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: rgba(0,0,0,.2); }
.form-error { min-height: 1.2rem; margin: 0; color: #b42318; font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.range-row { display: grid; grid-template-columns: 1fr 88px; align-items: center; gap: 12px; }
input[type="range"] { accent-color: var(--accent); }

.recipe-card { position: relative; overflow: hidden; min-height: 260px; display: flex; flex-direction: column; padding: 24px; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.recipe-card::after { content: ""; position: absolute; width: 170px; height: 170px; right: -76px; bottom: -78px; border-radius: 50%; background: var(--accent-soft); }
.recipe-card > * { position: relative; z-index: 1; }
.recipe-card h3 { margin-top: 18px; font-size: 1.35rem; letter-spacing: -.035em; }
.recipe-card p { color: var(--muted); font-size: .9rem; }
.recipe-card footer { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.badge { display: inline-flex; width: fit-content; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: var(--surface-soft); color: #55545a; font-size: .7rem; font-weight: 760; }
.badge--accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--blue { background: var(--blue-soft); color: var(--blue); }
.badge--yellow { background: var(--yellow-soft); color: var(--yellow); }

.filter-row { display: flex; gap: 8px; margin: 16px 0 24px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row button { flex: none; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.74); color: var(--muted); font-weight: 700; cursor: pointer; }
.filter-row button.active { border-color: #292622; background: #292622; color: white; }

.calculator-layout { display: grid; grid-template-columns: minmax(0, .86fr) minmax(360px, 1.14fr); gap: 22px; align-items: start; }
.calculator-panel { position: sticky; top: 98px; padding: 26px; }
.calculator-result { min-height: 580px; padding: 26px; }
.result-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.result-hero strong { display: block; font-size: clamp(2.2rem, 5vw, 4rem); letter-spacing: -.06em; line-height: .9; }
.result-hero small { color: var(--muted); }
.ingredient-stage { margin-top: 24px; }
.ingredient-stage h3 { display: flex; align-items: center; gap: 8px; }
.ingredients { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; }
.ingredient { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.ingredient:last-child { border-bottom: 0; }
.ingredient span { color: #47464a; }
.ingredient strong { font-variant-numeric: tabular-nums; }
.reverse-row { grid-template-columns: minmax(120px, 1fr) minmax(90px, .45fr) 56px; }
.reverse-row .field { align-self: end; }
.reverse-row input[type="checkbox"] { width: 24px; min-height: 24px; margin: 12px auto; accent-color: var(--accent); }
.result-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; }
.empty-state { min-height: 430px; display: grid; place-items: center; padding: 40px; text-align: center; }
.empty-state-icon { width: 90px; height: 90px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 27px; background: var(--accent-soft); font-size: 48px; transform: rotate(-4deg); }

.timeline { position: relative; display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 66px 28px 1fr; gap: 14px; min-height: 112px; }
.timeline-time { padding-top: 2px; color: var(--muted); font-size: .77rem; font-variant-numeric: tabular-nums; text-align: right; }
.timeline-rail { position: relative; display: flex; justify-content: center; }
.timeline-rail::before { content: ""; position: absolute; width: 2px; top: 0; bottom: 0; background: #dedde0; }
.timeline-item:first-child .timeline-rail::before { top: 12px; }
.timeline-item:last-child .timeline-rail::before { bottom: calc(100% - 14px); }
.timeline-dot { z-index: 1; width: 15px; height: 15px; margin-top: 3px; border: 4px solid var(--surface-solid); border-radius: 50%; background: #bbb9bd; box-shadow: 0 0 0 1px #ccc9cc; }
.timeline-item.current .timeline-dot { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.timeline-item.done .timeline-dot { background: var(--green); }
.timeline-content { padding-bottom: 28px; }
.timeline-content p { margin: 5px 0 0; color: var(--muted); font-size: .86rem; }
.timeline-content label { display: flex; align-items: start; gap: 10px; cursor: pointer; }
.timeline-content input { margin-top: 3px; accent-color: var(--green); }

.active-bake { display: grid; grid-template-columns: 1.25fr .75fr; overflow: hidden; }
.active-bake-main { padding: 28px; }
.active-bake-side { display: grid; align-content: space-between; padding: 28px; background: #181512; color: white; }
.active-bake-side strong { font-size: 2.4rem; letter-spacing: -.055em; }
.progress { height: 7px; overflow: hidden; margin: 18px 0 8px; border-radius: 999px; background: rgba(0,0,0,.08); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.journal-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 18px; align-items: center; padding: 17px; border-bottom: 1px solid var(--line); cursor: pointer; }
.journal-row:last-child { border-bottom: 0; }
.date-tile { display: grid; min-height: 66px; place-items: center; padding: 8px; border-radius: 16px; background: var(--surface-soft); text-align: center; }
.date-tile strong { display: block; font-size: 1.55rem; line-height: 1; }
.date-tile small { color: var(--muted); font-weight: 700; text-transform: uppercase; }
.journal-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.stars { color: #ef9d10; letter-spacing: 1px; white-space: nowrap; }

.tool-card { padding: 24px; }
.tool-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 15px; background: var(--accent-soft); font-size: 24px; }
.tool-output { margin-top: 18px; padding: 17px; border-radius: 15px; background: #191613; color: white; }
.tool-output strong { display: block; font-size: 1.75rem; letter-spacing: -.04em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }

.detail-grid { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
.detail-sidebar { position: sticky; top: 98px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 1; border-radius: 14px; object-fit: cover; }
.rating-input { display: flex; gap: 6px; }
.rating-input button { padding: 0; border: 0; background: none; color: #c8c6c8; font-size: 30px; cursor: pointer; }
.rating-input button.selected { color: #ef9d10; }

.coach { margin-top: 24px; padding: 22px; border: 1px solid #d9e5ff; border-radius: 21px; background: linear-gradient(145deg, #f6f9ff, #edf3ff); }
.coach-head { display: flex; align-items: center; gap: 12px; }
.coach-orb { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #477fff, #885cf6); color: white; box-shadow: 0 8px 20px rgba(74,104,224,.25); }
.coach-response { margin-top: 18px; }
.coach-response ul { padding-left: 20px; color: #3f4350; }
.coach-response li { margin: 8px 0; line-height: 1.45; }

.sheet { position: fixed; z-index: 100; inset: 0; display: grid; place-items: end center; padding: 20px; background: rgba(15,13,11,.42); backdrop-filter: blur(7px); }
.sheet-panel { width: min(700px, 100%); max-height: min(88svh, 900px); overflow-y: auto; padding: 26px; border-radius: 30px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.sheet-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.sheet-close { width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: var(--surface-soft); cursor: pointer; }

.toast { position: fixed; z-index: 200; left: 50%; bottom: calc(28px + var(--safe-bottom)); max-width: min(90vw, 520px); padding: 12px 17px; border-radius: 999px; background: rgba(25,22,19,.94); color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: opacity .22s ease, transform .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { opacity: .55; pointer-events: none; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .desktop-nav { display: none; }
  .topbar { height: 68px; padding: 0 18px; }
  .topbar .icon-button { margin-left: auto; }
  #app { min-height: calc(100svh - 68px); padding-top: 28px; padding-bottom: calc(112px + var(--safe-bottom)); }
  .bottom-nav { position: fixed; z-index: 40; left: 10px; right: 10px; bottom: calc(10px + var(--safe-bottom)); height: 69px; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding: 4px 7px; border: 1px solid rgba(255,255,255,.78); border-radius: 23px; background: rgba(248,248,249,.9); box-shadow: 0 14px 44px rgba(20,18,16,.18); backdrop-filter: blur(24px); }
  .bottom-nav button { display: grid; place-items: center; gap: 1px; color: var(--muted); }
  .bottom-nav button span { font-size: 1.28rem; line-height: 1; }
  .bottom-nav button small { font-size: .62rem; font-weight: 700; }
  .bottom-nav button.active { color: var(--accent); }
  .bottom-nav .new-dough span { width: 43px; height: 43px; display: grid; place-items: center; margin-top: -25px; border-radius: 50%; background: var(--accent); color: white; box-shadow: 0 9px 23px rgba(228,73,36,.3); font-size: 1.7rem; }
  .bottom-nav .new-dough small { margin-top: -1px; }
  .calculator-layout, .detail-grid { grid-template-columns: 1fr; }
  .calculator-panel, .detail-sidebar { position: static; }
  .active-bake { grid-template-columns: 1fr; }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  #app { width: min(100% - 24px, 1180px); }
  .page-head { align-items: start; flex-direction: column; }
  .page-head h1 { font-size: 2.45rem; }
  .hero { min-height: 440px; padding: 28px 24px; border-radius: 30px; }
  .hero::before { right: -250px; }
  .grid--2, .grid--3, .grid--4, .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .recipe-card { min-height: 220px; }
  .calculator-panel, .calculator-result, .card--padded { padding: 20px; }
  .result-hero { flex-direction: column; }
  .timeline-item { grid-template-columns: 48px 22px 1fr; gap: 9px; }
  .journal-row { grid-template-columns: 62px 1fr; gap: 12px; }
  .journal-row > .stars { grid-column: 2; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .reverse-row { grid-template-columns: 1fr 100px 48px; padding: 12px; }
  .sheet { padding: 0; align-items: end; }
  .sheet-panel { max-height: 92svh; border-radius: 28px 28px 0 0; padding-bottom: calc(26px + var(--safe-bottom)); }
}

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