:root {
  --bg: #e8dcc0;
  --surface: #f6efdd;
  --text: #2b2420;
  --text-muted: #6b5f4f;
  --brick: #a23b3b;
  --brick-text: #fff7ec;
  --leaf: #51643f;
  --border: rgba(43, 36, 32, 0.15);
  --chip-bg: #ded0ab;
  --danger: #a23b3b;
  --ready-bg: #d9f0c6;
  --ready-text: #1f3d14;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #211d18;
    --surface: #2c2620;
    --text: #efe6d6;
    --text-muted: #b6a890;
    --brick: #c4524f;
    --brick-text: #fff7ec;
    --leaf: #8bab6f;
    --border: rgba(239, 230, 214, 0.15);
    --chip-bg: #3a332a;
    --danger: #c4524f;
    --ready-bg: #3f5a2e;
    --ready-text: #d9f0c6;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Public Sans", system-ui, sans-serif;
  padding-bottom: 3rem;
}

h1, h2, h3 {
  font-family: "Fraunces", serif;
  margin: 0;
}

.topbar {
  padding: 1.5rem 1.25rem 0;
  max-width: 640px;
  margin: 0 auto;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar h1 {
  font-size: 1.9rem;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-add-top {
  background: var(--brick);
  color: var(--brick-text);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-duel {
  background: var(--leaf);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  flex: none;
  background: none;
  border: none;
  font-family: "Public Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.6rem 0.2rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--brick);
  border-bottom-color: var(--brick);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem;
}

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.notes {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 0.7rem;
}

.last-eaten {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.availability-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.4rem;
}

.availability-badge.ready {
  color: var(--ready-text);
  background: var(--ready-bg);
}

.ingredients-list {
  font-size: 0.85rem;
  opacity: 0.85;
  margin: 0 0 0.8rem;
  padding-left: 1.1rem;
}

.recipe {
  font-size: 0.85rem;
  margin: 0 0 0.8rem;
}

.recipe-link,
.recipe summary {
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}

.recipe-text p {
  white-space: pre-wrap;
  margin: 0.4rem 0 0;
  opacity: 0.9;
}

.shopping-window {
  background: var(--chip-bg);
  border-radius: 18px;
  padding: 0.6rem 0.6rem 0.1rem;
  margin-bottom: 1rem;
}

.shopping-window-heading,
.later-divider {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0.3rem 0.4rem 0.6rem;
}

.later-divider {
  border-top: 1px dashed var(--border);
  padding-top: 0.9rem;
  margin: 0 0.4rem 0.6rem;
}

.shopping-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.day-card {
  padding: 0;
  overflow: hidden;
}

.day-card-body {
  padding: 0.9rem 1.1rem 1.1rem;
}

.day-card-photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--chip-bg);
  overflow: hidden;
}

.day-card-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.photo-placeholder:hover {
  background: var(--bg);
}

.photo-placeholder-icon {
  font-size: 2.2rem;
}

.photo-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  line-height: 1;
}

.day-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

button {
  font-family: "Public Sans", sans-serif;
  cursor: pointer;
}

.btn-primary {
  background: var(--leaf);
  color: #fff7ec;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}

.queue-item-main .name {
  font-weight: 600;
  font-size: 1.05rem;
}

.queue-controls {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border: none;
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}

.icon-btn.danger {
  color: var(--danger);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

form .field {
  margin-bottom: 0.8rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-family: "Public Sans", sans-serif;
  font-size: 0.95rem;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 1rem;
}

.day-date {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pantry-category {
  margin-bottom: 0.9rem;
}

.pantry-category:last-of-type {
  margin-bottom: 0.6rem;
}

.pantry-category-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

.chip {
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.item-icon {
  font-size: 1rem;
  line-height: 1;
}

.shopping-item-main .item-icon {
  font-size: 1.15rem;
  margin-top: 0.1rem;
  flex-shrink: 0;
}

.chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0;
}

button.chip {
  border: none;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

.ingredient-suggestions {
  margin: 0.4rem 0 0;
}

.pantry-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.pantry-add input {
  flex: 1;
}

.shopping-item-main {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.shopping-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.shopping-item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.shopping-item:last-child {
  border-bottom: none;
}

.shopping-item .for {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.dialog-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.2rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.duel-dialog-card {
  max-width: 480px;
}

.duel-progress {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
}

.duel-arena {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.duel-option {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
  text-align: center;
  font-family: "Public Sans", sans-serif;
  color: var(--text);
  cursor: pointer;
}

.duel-option:hover {
  border-color: var(--leaf);
}

.duel-option-image {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  display: block;
}

.duel-option-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  color: var(--text-muted);
  font-size: 1.5rem;
}

.duel-option-name {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.duel-vs {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.duel-result-list {
  padding-left: 1.3rem;
  margin: 0.6rem 0 1rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pantry-check-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.8rem 0 1rem;
  max-height: 40vh;
  overflow-y: auto;
}

.pantry-check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.pantry-check-item input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.history-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}

.history-row {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.history-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.history-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--chip-bg);
}

.history-name {
  padding: 0.4rem 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.history-delete {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.history-delete:hover {
  background: var(--danger);
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.week-day.selected {
  background: var(--brick);
  color: var(--brick-text);
  border-color: var(--brick);
}

.week-count {
  font-weight: 700;
}

.week-count.empty {
  opacity: 0.45;
}

.history-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-form input,
.history-form select {
  padding: 0.5rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.history-submit {
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: var(--brick);
  color: var(--brick-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.history-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.history-group {
  margin-top: 0.8rem;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.login-card h1 {
  font-size: 1.8rem;
  margin-bottom: 1.2rem;
}

.login-card form {
  text-align: left;
}

.login-card .btn-primary {
  width: 100%;
}

.login-error {
  color: var(--danger);
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.logout-form {
  display: contents;
}

.calendar-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.calendar-toggle .btn-secondary.active {
  background: var(--brick);
  border-color: var(--brick);
  color: var(--brick-text);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 1rem;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calendar-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 6.5rem;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.calendar-cell.past {
  opacity: 0.45;
}

.calendar-cell.in-window {
  background: var(--chip-bg);
}

.calendar-cell.today {
  border: 2px solid var(--brick);
}

.calendar-day {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.calendar-meal {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: none;
  text-align: left;
  color: var(--text);
}

.calendar-meal img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}

.calendar-meal-name {
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.calendar-hint {
  margin-bottom: 0.6rem;
  color: var(--text-muted);
}

.calendar-meal {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.calendar-meal.drag-source {
  opacity: 0.35;
}

.calendar-grid.dragging {
  cursor: grabbing;
}

.calendar-cell.drop-target {
  outline: 3px dashed var(--leaf);
  outline-offset: -3px;
}

.calendar-ghost {
  position: fixed;
  z-index: 100;
  transform: translate(-50%, -120%);
  max-width: 10rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: var(--brick);
  color: var(--brick-text);
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.health-pill {
  display: inline-block;
  font-weight: 700;
  margin: 0 0.5rem 0.5rem 0;
}

.strength {
  display: inline-block;
  margin: 0 0.35rem 0.25rem 0;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--leaf);
  color: var(--leaf);
  font-size: 0.85rem;
  font-weight: 700;
}

.strength[data-strength="rundum"] {
  background: var(--leaf);
  color: var(--bg, #fff);
}

.health-info {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.dict-list {
  flex-direction: column;
  align-items: stretch;
}

.dict-list .chip {
  border-radius: 12px;
  flex-wrap: wrap;
}

.dict-name {
  flex: 1 1 8rem;
}

.tag-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

/* Eigenschaft als Badge im Stil der Stärken-Badges auf den Gerichten */
.tag-badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--leaf);
  background: none;
  color: var(--leaf);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.tag-badge[data-tone="minus"] {
  border-color: #c4553d;
  color: #c4553d;
}

.tag-badge[data-tone="neutral"] {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

/* Auswahl über "+": gestrichelt, noch nicht vergeben */
.tag-option,
.tag-add {
  border-style: dashed;
  font-weight: 400;
}

.tag-add {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

/* Die geöffnete Auswahl bekommt als Einziges eine eigene Zeile */
.tag-picker {
  flex-basis: 100%;
  padding-top: 0.25rem;
}

.health-details summary {
  cursor: pointer;
  list-style: none;
}

.health-reasons {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  font-weight: 400;
  font-size: 0.85rem;
}

.health-reasons li {
  margin-bottom: 0.2rem;
}

.health-points {
  display: inline-block;
  min-width: 1.8rem;
  font-weight: 700;
  color: var(--leaf);
}

.health-reasons .minus .health-points {
  color: var(--danger);
}

.health-cap,
.health-unknown {
  color: var(--text-muted);
}

.health-help {
  margin: 0.4rem 0 0.8rem;
  font-size: 0.9rem;
}

.health-help summary {
  cursor: pointer;
  font-weight: 700;
}

/* ---------- Statistik ---------- */

.muted {
  color: var(--text-muted);
}

.card h4 {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stats-streaks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.2rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brick);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-bars li {
  display: grid;
  grid-template-columns: minmax(5rem, 9rem) 1fr 2.2rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.stat-bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bar-track {
  background: var(--chip-bg);
  border-radius: 999px;
  height: 0.6rem;
  overflow: hidden;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  background: var(--leaf);
  border-radius: 999px;
}

.stat-bar-count {
  text-align: right;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.stat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.stat-list li {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.stat-list li > :last-child {
  margin-left: auto;
}

.stat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.stat-head h3 {
  margin: 0;
}

.stat-toggle,
.stat-period {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--chip-bg);
}

.stat-period {
  margin-bottom: 1rem;
}

.stat-toggle button,
.stat-period button {
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.stat-toggle button.active,
.stat-period button.active {
  background: var(--brick);
  color: var(--brick-text);
}

.stat-hint {
  font-size: 0.8rem;
  margin: 0.5rem 0 0;
}

.chart-box {
  position: relative;
  height: 14rem;
}

.heatmap-scroll {
  overflow-x: auto;
}

.heatmap {
  display: flex;
  gap: 3px;
  min-width: max-content;
}

.heatmap-col {
  display: grid;
  grid-template-rows: 0.9rem repeat(7, 1fr);
  gap: 3px;
}

.heatmap-month {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.heat-cell {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  background: color-mix(in srgb, var(--leaf) calc(var(--level, 0) * 85%), var(--chip-bg));
}

.heat-cell.future {
  visibility: hidden;
}
