:root {
  color-scheme: light;
  --ink: #1d2321;
  --ink-soft: #3d4743;
  --paper: #fbf7ef;
  --surface: #fffdf7;
  --surface-2: #edf4ef;
  --line: rgba(29, 35, 33, .14);
  --muted: #69716d;
  --leaf: #2f7659;
  --tomato: #d44f3d;
  --saffron: #ebb94f;
  --blue: #476c8c;
  --plum: #6d5a7e;
  --shadow: 0 18px 42px rgba(29, 35, 33, .16);
}

:root.dark {
  color-scheme: dark;
  --ink: #f7f2e7;
  --ink-soft: #ded8ca;
  --paper: #171c1b;
  --surface: #202826;
  --surface-2: #24332e;
  --line: rgba(247, 242, 231, .15);
  --muted: #a9b0ab;
  --leaf: #85c5a5;
  --tomato: #ef7d67;
  --saffron: #f2cc67;
  --blue: #8eb1cb;
  --plum: #b5a0c4;
  --shadow: 0 18px 42px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: #111615;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #111615;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.mobile-shell {
  width: min(100%, 500px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  overflow: hidden;
  position: relative;
}

.hero {
  min-height: 620px;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 16px 22px;
  color: #fff9ee;
}

.hero-media,
.hero-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-media {
  object-fit: cover;
  z-index: -3;
}

.hero-shade {
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(8, 14, 13, .32) 0%, rgba(8, 14, 13, .12) 34%, rgba(8, 14, 13, .86) 100%),
    linear-gradient(90deg, rgba(8, 14, 13, .46), rgba(8, 14, 13, .04));
}

.topbar,
.brand,
.top-actions,
.source-strip,
.section-head.inline,
.filter-title,
.control-actions,
.recipe-kicker,
.stat-row,
.action-row,
.footer {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 12px;
}

.brand {
  min-width: 0;
  gap: 9px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 900;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff9ee;
  color: #1d2321;
  font-weight: 900;
}

.top-actions {
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff9ee;
  backdrop-filter: blur(10px);
  font-weight: 900;
}

.hero-copy {
  padding-top: 150px;
}

.eyebrow {
  margin: 0 0 10px;
  color: currentColor;
  opacity: .7;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: 340px;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 950;
  letter-spacing: 0;
}

.hero-copy > p:not(.eyebrow) {
  margin: 16px 0 0;
  max-width: 29ch;
  color: rgba(255, 249, 238, .82);
  font-size: 15px;
  line-height: 1.7;
}

.source-strip {
  gap: 8px;
  overflow-x: auto;
  padding: 18px 0 2px;
  scrollbar-width: none;
}

.source-strip::-webkit-scrollbar,
.recipe-rail::-webkit-scrollbar,
.chip-row::-webkit-scrollbar {
  display: none;
}

.source-strip a {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  color: #fff9ee;
  background: rgba(255, 255, 255, .12);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 900;
}

main {
  padding: 0 14px 20px;
}

.control-band,
.spotlight-section,
.queue-section,
.planner-section,
.sources-section {
  margin-top: 14px;
}

.control-band {
  margin-top: -20px;
  position: relative;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-head {
  margin-bottom: 14px;
}

.section-head h2,
.recipe-body h3 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

.section-head h2 {
  font-size: 23px;
  font-weight: 950;
}

.section-head p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.section-head.inline {
  justify-content: space-between;
  gap: 12px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mode-button,
.chip,
.tab-button,
.text-button,
.primary-button,
.secondary-button,
.icon-text-button,
.source-link,
.week-slot button,
.rail-card,
.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-button {
  min-height: 46px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.mode-button.is-active,
.chip.is-active,
.tab-button.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: transparent;
}

.range-card {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface-2);
}

.range-card span,
.filter-title span,
.pantry-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.range-card strong {
  font-size: 24px;
  line-height: 1;
}

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

.filter-group {
  margin-top: 14px;
}

.filter-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.text-button {
  min-height: 32px;
  background: transparent;
  color: var(--leaf);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 850;
}

.chip[data-tone="leaf"].is-active {
  background: var(--leaf);
}

.chip[data-tone="tomato"].is-active {
  background: var(--tomato);
}

.chip[data-tone="blue"].is-active {
  background: var(--blue);
}

.chip[data-tone="plum"].is-active {
  background: var(--plum);
}

.chip[data-tone="saffron"].is-active {
  background: var(--saffron);
  color: #1d2321;
}

.pantry-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.pantry-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.pantry-field input:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--leaf) 18%, transparent);
}

.control-actions {
  gap: 9px;
  margin-top: 16px;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding: 0 13px;
  font-weight: 950;
}

.primary-button {
  flex: 1;
  border: 0;
  background: var(--tomato);
  color: #fffaf2;
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
}

.score-badge {
  min-width: 76px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  background: var(--saffron);
  color: #1d2321;
  font-weight: 950;
}

.score-badge strong {
  font-size: 25px;
}

.score-badge span {
  font-size: 12px;
}

.recipe-spotlight {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.recipe-spotlight > img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-2);
}

.recipe-body {
  padding: 15px;
}

.recipe-kicker {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.recipe-kicker span:last-child {
  color: var(--leaf);
}

.recipe-body h3 {
  font-size: 28px;
  font-weight: 950;
}

.recipe-body p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.stat-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.stat-row span {
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 900;
}

.action-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.icon-text-button,
.source-link {
  min-height: 40px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}

.icon-text-button.is-active {
  background: var(--saffron);
  color: #1d2321;
  border-color: transparent;
}

.source-link {
  margin-left: auto;
  background: var(--ink);
  color: var(--paper);
}

.recipe-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.tab-button {
  min-height: 42px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 900;
}

.detail-panel {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.detail-panel ul,
.detail-panel ol {
  margin: 0;
  padding-left: 19px;
}

.detail-panel li {
  margin: 8px 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

.detail-note {
  margin: 12px 0 0;
  border-left: 4px solid var(--leaf);
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.mini-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.recipe-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(188px, 72%);
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
}

.rail-card {
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  color: var(--ink);
  padding: 0;
}

.rail-card img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.rail-card div {
  padding: 10px;
}

.rail-card strong {
  display: block;
  min-height: 42px;
  font-size: 15px;
  line-height: 1.35;
}

.rail-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.week-grid {
  display: grid;
  gap: 8px;
}

.week-slot {
  display: grid;
  grid-template-columns: 48px 1fr 42px;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface);
}

.week-slot span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.week-slot strong {
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
}

.week-slot em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
}

.week-slot button {
  width: 38px;
  height: 38px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 950;
}

.source-list {
  display: grid;
  gap: 9px;
}

.source-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  background: var(--surface);
  padding: 10px;
  text-decoration: none;
}

.source-card img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
}

.source-card strong {
  display: block;
  font-size: 15px;
}

.source-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.footer {
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px max(20px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.footer a {
  text-decoration: none;
  color: var(--leaf);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 10;
  width: min(92%, 430px);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #1d2321;
  color: #fffaf2;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 850;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 540px) {
  body {
    padding: 24px 0;
  }

  .mobile-shell {
    min-height: calc(100vh - 48px);
    border-radius: 18px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .38);
  }
}

@media (max-width: 380px) {
  .hero h1 {
    font-size: 37px;
  }

  .control-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .recipe-body h3 {
    font-size: 24px;
  }
}

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