:root {
  color-scheme: light;
  --paper: #fffaf2;
  --surface: #ffffff;
  --ink: #25231f;
  --muted: #6d685f;
  --line: #e5d9ca;
  --green: #557860;
  --green-dark: #2f563b;
  --rose: #b85f55;
  --gold: #d79d3f;
  --shadow: 0 18px 48px rgba(72, 56, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(246, 239, 229, 0.96)),
    url("./assets/kitchen-pattern.svg");
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 8vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.icon-button,
.nav-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 8px 20px rgba(67, 53, 37, 0.08);
}

.icon-button span {
  font-size: 1.4rem;
  font-weight: 800;
}

.week-panel,
.filters,
.source-panel,
.manual-panel,
.safety,
.drawer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.week-panel {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.week-label {
  margin-bottom: 4px;
  font-weight: 800;
}

.week-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
}

.source-panel {
  margin-top: 12px;
  padding: 14px;
}

.source-panel h2 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.source-panel p {
  color: var(--muted);
  line-height: 1.4;
}

.source-url {
  display: grid;
  gap: 6px;
  color: var(--green-dark);
  font-weight: 800;
}

.source-url input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffdfa;
  color: var(--ink);
}

#refreshSource {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 850;
}

#refreshSource:disabled {
  opacity: 0.65;
}

.source-status {
  min-height: 1.3em;
  margin: 10px 0 0;
  color: var(--green-dark);
  font-weight: 750;
}

.source-status.error {
  color: #8d3129;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f5efe6;
  color: var(--green-dark);
  font-weight: 750;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green-dark);
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  gap: 6px;
  margin: 14px 0;
}

.day-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.day-tabs button.active {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.day-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 2px 10px;
}

.day-heading p {
  margin-bottom: 0;
  color: var(--green-dark);
  font-weight: 800;
}

.day-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
  color: var(--muted);
}

.dish {
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(62, 47, 28, 0.1);
}

.dish-heading {
  padding: 14px 14px 12px;
  background: linear-gradient(90deg, rgba(85, 120, 96, 0.13), rgba(215, 157, 63, 0.13));
}

.dish-heading span {
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dish-heading h3 {
  margin: 5px 0;
  font-size: 1.18rem;
  line-height: 1.18;
}

.dish-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.swap {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #fff7e8;
  color: #664a16;
  font-weight: 700;
}

.source-box {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f7f1e9;
}

.source-box h4 {
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 0.82rem;
}

.source-meal {
  margin-bottom: 0;
  color: var(--ink);
  line-height: 1.35;
}

.source-meal.empty {
  color: var(--muted);
}

.source-ingredients {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.source-options {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-options li {
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #eadfD3;
}

.source-options li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.source-options strong,
.source-options span {
  display: block;
}

.source-options strong {
  margin-bottom: 4px;
}

.source-options span {
  color: var(--muted);
  line-height: 1.35;
}

.dairy-alert {
  margin: 8px 0 0;
  color: #8d3129;
  font-weight: 800;
  line-height: 1.35;
}

.detail-grid {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.detail-grid h4 {
  margin-bottom: 8px;
  color: var(--green-dark);
  font-size: 0.9rem;
}

ul,
ol {
  margin: 0;
  padding-left: 20px;
}

li {
  margin-bottom: 6px;
  line-height: 1.35;
}

.drawer {
  margin-top: 16px;
  overflow: hidden;
}

.drawer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 850;
}

.drawer-toggle span:last-child {
  color: var(--green-dark);
  font-size: 0.86rem;
}

.shopping-list {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
}

.shopping-list ul {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.shopping-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0e7dc;
}

.manual-panel,
.safety {
  margin-top: 16px;
  padding: 14px;
}

.manual-panel h2,
.safety h2 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.manual-panel p,
.safety p {
  color: var(--muted);
  line-height: 1.45;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
  color: var(--ink);
}

.note-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.note-actions button {
  min-height: 46px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 850;
}

.note-actions button:last-child {
  border-color: var(--line);
  background: white;
  color: var(--muted);
}

.warnings {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #fff0ed;
  color: #8d3129;
  line-height: 1.35;
}

@media (min-width: 680px) {
  .detail-grid {
    grid-template-columns: 0.8fr 1.2fr;
  }
}

@media (max-width: 380px) {
  .shell {
    padding-left: 10px;
    padding-right: 10px;
  }

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

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

  .day-tabs {
    gap: 4px;
  }

  .day-tabs button {
    min-width: 0;
    font-size: 0.84rem;
  }
}
