:root {
  --bg: #f6f1ea;
  --bg-soft: #efe6da;
  --card: #fffdfa;
  --text: #241a16;
  --muted: #7a6a60;
  --border: #e6dacd;
  --accent: #9d1c20;
  --accent-strong: #7d1418;
  --accent-soft: #f9e7e5;
  --ok: #2f6f4f;
  --shadow: 0 10px 30px rgba(70, 40, 20, 0.08);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110f;
    --bg-soft: #201815;
    --card: #231a16;
    --text: #f4ece4;
    --muted: #b3a094;
    --border: #3a2b24;
    --accent: #e0605b;
    --accent-strong: #f0837e;
    --accent-soft: #3a1f1d;
    --ok: #74b893;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 16px 132px;
  background:
    radial-gradient(circle at 100% 0%, var(--bg-soft), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- Header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 4px 12px;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
  backdrop-filter: blur(10px);
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand h1 {
  font-size: 1.65rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.icon-btn {
  flex: none;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.loading {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

main {
  max-width: 760px;
  margin: 0 auto;
}

/* ----------------------------------------------------------------- Karten */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  margin-bottom: 22px;
}

.fact {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
}

.fact-icon {
  font-size: 1.15rem;
  line-height: 1.3;
}

.fact strong {
  display: block;
  font-size: 0.95rem;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

@media (max-width: 520px) {
  .facts {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .fact span {
    font-size: 0.82rem;
  }
}

/* --------------------------------------------------------------- Wochenkopf */

.week-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 4px 14px;
}

.week-head h2 {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.link {
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.link:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ Tage */

.days {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.day {
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.day.past {
  opacity: 0.6;
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
}

.day-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.day-title h3 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.day-date {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (prefers-color-scheme: dark) {
  .badge {
    color: #1a0f0c;
  }
}

.day-toggle {
  flex: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.day-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.dishes {
  list-style: none;
  margin: 0;
  padding: 0 8px 6px;
}

.dish-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dish-row + .dish-row {
  border-top: 1px solid var(--border);
}

.dish {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.dish:hover {
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.dish.selected {
  background: var(--accent-soft);
}

.dish input {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dish input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.dish input:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

@media (prefers-color-scheme: dark) {
  .dish input:checked::after {
    border-color: #fff;
  }
}

.dish input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.dish-name {
  font-size: 0.95rem;
  line-height: 1.4;
}

.dish.selected .dish-name {
  font-weight: 600;
}

.dish-price {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dish-gcal {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.dish-gcal:hover,
.dish-gcal:focus-visible {
  opacity: 1;
  background: var(--accent-soft);
}

.dish-gcal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dish-gcal svg {
  display: block;
  width: 20px;
  height: 20px;
}

.day-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

.day-ics {
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.day-ics:hover {
  text-decoration: underline;
}

.day-empty {
  padding: 4px 18px 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* -------------------------------------------------------------- Einstellungen */

.settings {
  margin-bottom: 24px;
}

.settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}

.settings summary::-webkit-details-marker {
  display: none;
}

.settings summary::after {
  content: "›";
  font-size: 1.3rem;
  color: var(--muted);
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.settings details[open] summary::after {
  transform: rotate(-90deg);
}

.summary-hint {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.settings-body {
  padding: 0 18px 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.setting-row input[type="time"] {
  flex: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h3 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.small {
  font-size: 0.78rem;
  line-height: 1.6;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.settings hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ----------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .btn.primary {
    color: #1a0f0c;
  }
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ------------------------------------------------------------- Actionbar */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.actionbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
}

.selection-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.selection-info strong {
  font-size: 1.15rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.actionbar .btn.primary {
  flex: none;
  padding: 12px 20px;
}

/* --------------------------------------------------------------- Hinweise */

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d9a441;
  background: #fdf3dd;
  color: #6b4a0d;
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  .notice {
    background: #33270f;
    border-color: #7a5a1d;
    color: #f0d9a8;
  }
}

.loading {
  padding: 30px 10px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  background: #2a211d;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.18s ease;
}

.toast.error {
  background: var(--accent-strong);
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
