:root {
  --rice: #eef1e9;
  --paper: #fbfcf7;
  --ink: #15251f;
  --muted: #68756f;
  --wok: #176b78;
  --wok-dark: #0d4c56;
  --chili: #df5b3f;
  --yolk: #f3c653;
  --line: rgba(21, 37, 31, 0.16);
  --shadow: 0 18px 48px rgba(18, 47, 42, 0.1);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--rice);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(21, 37, 31, 0.035) 1px, transparent 1px),
    var(--rice);
  background-size: 100% 32px;
}

button, textarea, input, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--yolk);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 18px 40px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.topbar nav { display: flex; gap: 4px; }
.brand-button, .nav-button {
  min-height: 44px;
  padding: 6px 9px;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.brand-button { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand-button span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--wok);
  font: 800 13px/1 "STKaiti", "KaiTi", serif;
}
.nav-button { color: var(--muted); font-size: 14px; }

.panel {
  display: grid;
  gap: 20px;
  padding: 38px 0 48px;
}

.eyebrow, .small-label {
  margin: 0;
  color: var(--wok);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", serif;
  font-size: clamp(32px, 8vw, 48px);
  font-weight: 800;
  line-height: 1.13;
  letter-spacing: -.035em;
}
h1 em { color: var(--chili); font-style: normal; }
h2 { margin: 0 0 10px; font-size: 17px; }
.lede { max-width: 37em; margin: -8px 0 4px; color: var(--muted); line-height: 1.7; }

form { display: grid; gap: 20px; }
label, legend { font-weight: 750; line-height: 1.5; }
label { display: grid; gap: 8px; }
fieldset { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--paper);
}
textarea { min-height: 156px; resize: vertical; line-height: 1.65; }

.primary, .secondary, .voice {
  min-height: 50px;
  border-radius: 5px;
  padding: 11px 18px;
  font-weight: 850;
  cursor: pointer;
}
.primary { border: 1px solid var(--wok); color: white; background: var(--wok); box-shadow: 0 6px 0 var(--wok-dark); }
.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--wok-dark); }
.secondary, .voice { border: 1px solid var(--wok); color: var(--wok); background: transparent; }
.voice { border-style: dashed; }
button:disabled { cursor: wait; opacity: .55; }
.error { min-height: 20px; margin: 0; color: #a83925; line-height: 1.55; overflow-wrap: anywhere; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 34px;
  padding: 44px 0;
}
.auth-intro { display: grid; gap: 18px; }
.auth-intro > p:not(.eyebrow) { max-width: 34em; margin: 0; color: var(--muted); line-height: 1.7; }
.kitchen-ticket {
  width: fit-content;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--wok);
  background: rgba(255,255,255,.44);
  transform: rotate(-1deg);
}
.kitchen-ticket span, .kitchen-ticket strong { padding: 6px 10px; font-size: 13px; }
.kitchen-ticket strong { color: white; background: var(--chili); }
.auth-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-top: 6px solid var(--wok);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.auth-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; padding: 4px; background: #e5ebe5; }
.auth-switch button { min-height: 44px; border: 0; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.auth-switch button[aria-selected="true"] { color: var(--wok-dark); background: var(--paper); box-shadow: 0 2px 8px rgba(21,37,31,.08); }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { min-height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); }
.choice input:checked + span { border-color: var(--wok); color: var(--wok-dark); background: rgba(23, 107, 120, .1); box-shadow: inset 4px 0 var(--wok); }
.choice input:focus-visible + span { outline: 3px solid var(--yolk); outline-offset: 3px; }
.fixed-rules { display: flex; flex-wrap: wrap; gap: 8px; }
.fixed-rules span { padding: 7px 10px; border-radius: 3px; color: var(--wok-dark); background: rgba(243,198,83,.32); font-size: 14px; font-weight: 750; }

.decision-panel { align-content: center; min-height: calc(100vh - 73px); }
.decision-actions, .split-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--ink);
  background: rgba(243,198,83,.24);
  cursor: pointer;
}
.extraction-board { border-top: 1px solid var(--line); }
.extraction-board > div { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.extraction-board strong { color: var(--wok); }
.extraction-board p { margin: 0; line-height: 1.6; }

.recipe-ticket {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 28px 22px 24px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: ticket-in 220ms ease-out;
}
.recipe-ticket::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -7px;
  left: 0;
  height: 8px;
  background: linear-gradient(135deg, var(--paper) 5px, transparent 0) 0 0 / 10px 8px repeat-x;
}
.ticket-stamp {
  width: fit-content;
  justify-self: end;
  margin-bottom: -10px;
  padding: 5px 9px;
  border: 2px solid var(--chili);
  color: var(--chili);
  font-weight: 900;
  letter-spacing: .2em;
  transform: rotate(5deg);
}
.match { margin: -8px 0 0; color: var(--wok); font-weight: 850; }
.fact-row { display: flex; flex-wrap: wrap; gap: 7px; }
.fact-row span { min-height: 36px; display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 3px; background: rgba(243,198,83,.3); font-size: 14px; }
.reason { margin: 0; line-height: 1.7; }

.adopted-banner { display: grid; gap: 3px; padding: 14px; border-left: 5px solid var(--wok); background: rgba(23,107,120,.1); }
.adopted-banner span { color: var(--muted); font-size: 14px; }
.steps { display: grid; gap: 12px; margin: 0; padding-left: 28px; line-height: 1.7; }
.steps li::marker { color: var(--chili); font-weight: 900; }
.tips { padding: 16px; border: 1px dashed var(--line); background: rgba(255,255,255,.36); }
.tips ul { margin: 0; padding-left: 21px; line-height: 1.7; }

.history-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.history-list li { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.history-list time { color: var(--muted); white-space: nowrap; }
.empty-state { padding: 28px 18px; border: 1px dashed var(--line); color: var(--muted); text-align: center; line-height: 1.7; }

.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; color: var(--muted); }
.pan-mark { width: 46px; height: 46px; border: 6px solid var(--wok); border-radius: 50%; position: relative; animation: pan 900ms ease-in-out infinite alternate; }
.pan-mark::after { content: ""; position: absolute; width: 28px; height: 7px; right: -27px; top: 13px; border-radius: 4px; background: var(--wok); transform: rotate(-12deg); transform-origin: left; }

@keyframes ticket-in { from { opacity: 0; transform: translateY(12px) rotate(-.5deg); } to { opacity: 1; transform: translateY(0) rotate(0); } }
@keyframes pan { to { transform: rotate(10deg); } }

@media (min-width: 760px) {
  .auth-layout { grid-template-columns: 1.15fr .85fr; align-items: center; }
  .auth-card { padding: 28px; }
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 380px) {
  .app-shell { padding-inline: 14px; }
  .panel { padding-top: 30px; }
  .choice-grid, .decision-actions, .split-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
