:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --border: #d9d6cc;
  --accent: #2f7d4f;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --tint-obst: #cfe8c9;
  --tint-brot: #fdeec4;
  --tint-naschen: #fbdcc8;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191c;
    --surface: #22272b;
    --text: #e8eaed;
    --muted: #94a0ab;
    --border: #3a4147;
    --accent: #5fbf85;
    --accent-text: #10241a;
    --danger: #ff8a7a;
    --tint-obst: #2f5a36;
    --tint-brot: #5c4a1c;
    --tint-naschen: #6b3d26;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0 auto;
  max-width: 40rem;
  padding: 0.75rem 0.5rem 2rem;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

#help-open {
  width: 2.75rem;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}

/* Kid chooser */

#kids {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#kids button {
  flex: 1;
}

button {
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button[aria-pressed="true"],
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Family code prompt */

#code-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 22rem;
  margin: 1.5rem auto;
}

#code-form label {
  font-weight: 600;
}

#code-form input {
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#code-error {
  min-height: 1.3em;
  margin: 0;
  color: var(--danger);
  font-size: 0.875rem;
}

/* Plan grid */

#grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0.25rem;
  hyphens: auto;
  overflow-wrap: anywhere;
}

#grid th {
  font-size: 0.75rem;
  font-weight: 600;
}

#grid thead th {
  vertical-align: bottom;
  padding-bottom: 0.125rem;
}

#grid .day {
  width: 5.5rem;
  text-align: left;
}

#grid .day .short {
  display: none;
}

#grid td {
  padding: 0;
}

/* A cell shows the chosen item as wrapping text; the native select lies
   invisibly on top of it, so a tap opens the system picker. */
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  font-size: 0.8125rem;
  text-align: center;
}

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

.cell select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 1rem;
  cursor: pointer;
}

.cell:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Saved plan: plain text, no picker */
.cell.readonly {
  border-color: transparent;
}

/* Naschen cell that cannot be chosen because the weekly limit is reached */
.cell.locked {
  border-style: dashed;
  background: transparent;
  opacity: 0.45;
}

.cell.locked select {
  cursor: not-allowed;
}

.cell.invalid {
  border: 2px solid var(--danger);
  color: var(--danger);
}

@media (max-width: 30rem) {
  #grid .day {
    width: 1.75rem;
  }

  #grid .day .long {
    display: none;
  }

  #grid .day .short {
    display: inline;
  }

  #grid thead th {
    font-size: 0.6875rem;
  }

  .cell {
    padding: 0.125rem;
  }
}

/* Status and actions */

#status {
  min-height: 1.3em;
  margin: 0.75rem 0;
  color: var(--muted);
  font-size: 0.875rem;
}

#status.error {
  color: var(--danger);
}

#status p {
  margin: 0;
  font-weight: 600;
}

#status ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.actions button {
  flex: 1;
}

/* Anleitung */

#help {
  width: calc(100% - 1.5rem);
  max-width: 36rem;
  max-height: calc(100% - 1.5rem);
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

#help::backdrop {
  background: rgb(0 0 0 / 0.5);
}

#help h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

#help h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}

#help p {
  margin: 0.25rem 0 0;
}

.help-close {
  float: right;
  margin: -0.25rem -0.25rem 0 0.5rem;
}

.help-close button {
  width: 2.75rem;
  padding: 0;
  border-color: transparent;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
}

.steps li + li {
  margin-top: 0.75rem;
}

mark,
.tint-obst,
.tint-brot,
.tint-naschen {
  color: inherit;
}

mark {
  padding: 0.0625rem 0.25rem;
  border-radius: 0.25rem;
}

.tint-obst {
  background: var(--tint-obst);
}

.tint-brot {
  background: var(--tint-brot);
}

.tint-naschen {
  background: var(--tint-naschen);
}

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

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.help-table th,
.help-table td {
  padding: 0.25rem 0.375rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#help .actions {
  margin-top: 1rem;
}

/* Five columns have to fit a phone: fixed layout, long words may break. */
.help-table.week {
  table-layout: fixed;
  hyphens: auto;
  overflow-wrap: anywhere;
  font-size: 0.75rem;
}

.help-table.week th:first-child {
  width: 2rem;
}
