:root {
  color-scheme: light;
  --bg: #fff8f2;
  --paper: rgba(255, 255, 255, 0.88);
  --ink: #2f2925;
  --muted: #7d7067;
  --peach: #ff8f70;
  --peach-soft: #ffe0d2;
  --green: #54b788;
  --blue: #5aa9e6;
  --yellow: #ffd166;
  --line: rgba(86, 65, 52, 0.12);
  --shadow: 0 18px 50px rgba(111, 69, 45, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 209, 102, 0.3), transparent 26%),
    linear-gradient(135deg, #fff6ec 0%, #eef8f2 48%, #f7fbff 100%);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}

.app {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

.status-bar {
  height: 34px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 22px 0;
  font-size: 13px;
  font-weight: 700;
}

.signal {
  font-size: 12px;
}

.hero {
  position: relative;
  height: 226px;
  margin: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(33, 22, 16, 0.6));
}

.hero-copy {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 1;
  color: #fff;
  text-shadow: 0 2px 12px rgba(42, 22, 12, 0.36);
}

.hero-copy p,
.hero-copy span {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.hero-copy h1 {
  margin: 4px 0 7px;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  flex-shrink: 0;
}

.tab {
  min-height: 38px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: #2f2925;
  color: #fff;
}

.content {
  flex: 1;
  overflow: auto;
  padding: 0 14px;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card,
.dish-card,
.shopping-group,
.danger {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(79, 53, 36, 0.08);
}

.card {
  padding: 16px;
  margin-bottom: 12px;
}

.warm-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(255, 224, 210, 0.9), rgba(255, 255, 255, 0.92));
}

.eyebrow {
  margin: 0 0 6px;
  color: #c85e44;
  font-size: 12px;
  font-weight: 900;
}

h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
}

p {
  line-height: 1.55;
}

#menuReason,
.soft {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 19px;
  background: #fff;
  color: var(--peach);
  font-size: 20px;
  font-weight: 900;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.primary,
.secondary,
.danger {
  min-height: 46px;
  border-radius: 18px;
  font-weight: 900;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--peach), #ff6f8a);
  box-shadow: 0 10px 22px rgba(255, 111, 112, 0.26);
}

.secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.danger {
  width: 100%;
  color: #b83246;
  background: #fff5f6;
  border-color: rgba(184, 50, 70, 0.18);
}

.input-row,
.switch-row {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin: 12px 0;
}

.compact-panel {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.compact-panel .input-row,
.compact-panel .switch-row {
  margin: 0;
}

.compact-field {
  gap: 5px;
}

.compact-field span,
.compact-switch span {
  font-size: 12px;
}

.compact-field input {
  min-height: 38px;
  border-radius: 15px;
  padding: 0 12px;
}

.compact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.compact-segment {
  min-height: 40px;
}

.compact-segment button {
  height: 30px;
  min-height: 30px;
}

.compact-switch {
  grid-template-columns: auto auto;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.compact-switch input[type="checkbox"] {
  appearance: none;
  width: 42px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 2px;
  background: #e8ded7;
  position: relative;
  transition: background 0.18s ease;
}

.compact-switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(62, 42, 30, 0.22);
  transition: transform 0.18s ease;
}

.compact-switch input[type="checkbox"]:checked {
  background: var(--green);
}

.compact-switch input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.compact-hint {
  display: block;
  padding: 3px 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input[type="checkbox"] {
  width: 48px;
  height: 28px;
  accent-color: var(--green);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.segmented button {
  height: 38px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.segmented button.active {
  background: var(--peach-soft);
  color: #9a4435;
}

.summary-grid,
.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.summary-grid div,
.memory-grid div {
  padding: 12px 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.summary-grid strong,
.memory-grid strong {
  display: block;
  font-size: 18px;
}

.summary-grid span,
.memory-grid span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dish-list {
  display: grid;
  gap: 12px;
}

.dish-card {
  padding: 14px;
}

.dish-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.dish-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.dish-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.badge-row,
.chip-wrap,
.dish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge-row {
  margin-top: 10px;
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 13px;
  background: #fff5ed;
  color: #9a5742;
  font-size: 12px;
  font-weight: 850;
}

.badge.green {
  background: #e9f8ef;
  color: #27734f;
}

.badge.blue {
  background: #edf7ff;
  color: #246a9d;
}

.dish-actions {
  margin-top: 12px;
}

.dish-actions button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 15px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.dish-actions button.active {
  background: #2f2925;
  color: #fff;
}

.shopping-list {
  display: grid;
  gap: 10px;
}

.cook-menu-card {
  background: linear-gradient(135deg, rgba(233, 248, 239, 0.92), rgba(255, 255, 255, 0.9));
}

.cook-dish-list {
  display: grid;
  gap: 8px;
}

.cook-dish {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.cook-dish strong {
  font-size: 15px;
}

.cook-dish span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cook-dish small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.generate-card h2 {
  padding-right: 34px;
}

.generate-results {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.shopping-group {
  padding: 14px;
}

.shopping-group h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.shopping-group ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.log-list {
  display: grid;
  gap: 8px;
}

.memory-manage {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.manage-block h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.memory-manage button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.log-item {
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(390px, calc(100vw - 28px));
  max-height: 86vh;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(47, 41, 37, 0.42);
}

.dialog-card {
  position: relative;
  max-height: 86vh;
  overflow: auto;
  padding: 20px;
  background: #fffdfa;
  border-radius: 26px;
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 17px;
  background: #f5eee8;
  color: var(--ink);
  font-size: 22px;
}

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

.detail-grid div {
  padding: 10px 6px;
  text-align: center;
  border-radius: 16px;
  background: #fff5ed;
}

.detail-grid strong {
  display: block;
  font-size: 16px;
}

.detail-grid span {
  color: var(--muted);
  font-size: 12px;
}

.detail-section {
  margin-top: 14px;
}

.detail-section h4 {
  margin: 0 0 8px;
}

.detail-section ol,
.detail-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 520px) {
  .shell {
    padding: 0;
  }

  .app {
    max-width: 100%;
    border-radius: 0;
  }
}
