/* Colours taken from the Ginkgo Naturkostladen business card: leaf green, olive-brown lettering, paper cream. */
:root {
  --bg: #f5efe2;
  --card: #fffdf7;
  --text: #3b3221;
  --brand: #5b472a; /* the lettering "Ginkgo Naturkostladen" */
  --muted: #6e604a; /* 5.3:1 on the cream background */
  --border: #e2d7c0;
  --primary: #2e7643; /* leaf green, a shade darker for text/button contrast (logo keeps #3d8b52) */
  --primary-press: #26623a;
  --on-primary: #ffffff;
  --primary-soft: #e4efe0;
  --danger: #b0412b;
  --warn-bg: #fbeccb;
  --warn-text: #7a5300;
  --holiday: #8a6d3b;
  --today: #fff4d6;
  --tap: 48px; /* minimum touch target */
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* Dark: follows the system unless someone picked "Hell"; "Dunkel" forces it (data-theme on <html>, set before first paint). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1f1a;
    --card: #252a23;
    --text: #ece4d2;
    --brand: #d9c7a3;
    --muted: #a89f8a;
    --border: #3a4036;
    --primary: #5fae73;
    --primary-press: #4f9a63;
  --on-primary: #0f1a11;
    --on-primary: #0f1a11;
    --primary-soft: #263a2a;
    --danger: #e0735c;
    --warn-bg: #3a2f14;
    --warn-text: #f0c66b;
    --holiday: #d9b77a;
    --today: #2f3226;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1b1f1a;
  --card: #252a23;
  --text: #ece4d2;
  --brand: #d9c7a3;
  --muted: #a89f8a;
  --border: #3a4036;
  --primary: #5fae73;
  --primary-press: #4f9a63;
  --on-primary: #0f1a11;
  --primary-soft: #263a2a;
  --danger: #e0735c;
  --warn-bg: #3a2f14;
  --warn-text: #f0c66b;
  --holiday: #d9b77a;
  --today: #2f3226;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

/* No 300ms delay / double-tap zoom on interactive elements. */
button, a, input, select, textarea, label, summary { touch-action: manipulation; }

[hidden] { display: none !important; }

h1 { font-size: 1.2rem; margin: 0; color: var(--brand); }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; color: var(--brand); }
h2:focus { outline: none; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; color: var(--brand); }
small { font-size: 0.8em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.25rem 0 0.5rem; }
.error { color: var(--danger); margin: 0.25rem 0; }
.error:empty { display: none; }
.success { color: var(--primary); margin: 0.25rem 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- Buttons & inputs ---------- */

button, .button {
  font: inherit;
  font-weight: 500;
  min-height: 44px;
  border-radius: 12px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  user-select: none;
  -webkit-user-select: none;
}
button:active, .button:active { transform: scale(0.98); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 2px;
}
.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.primary:hover { background: var(--primary-press); }
.ghost { background: transparent; }
.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: transparent; }
.big { min-height: var(--tap); font-size: 1.02rem; }
.small { min-height: 34px; padding: 0.25rem 0.7rem; font-size: 0.88rem; }
.link { border: none; background: none; color: var(--primary); padding: 0.25rem; min-height: 36px; text-decoration: underline; }
.icon-button { width: 44px; padding: 0; font-size: 1.25rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.75rem; }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; margin: 0; color: var(--text); }
input, select, textarea {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--primary); }
input[type="color"] { padding: 0.2rem; height: 44px; }
textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0 0.75rem; }
.copy-row { display: flex; gap: 0.5rem; }
.copy-row input { flex: 1; font-size: 0.85rem; }

/* ---------- Login ---------- */

/* The login page is a <main> too: it must not inherit the content max-width, or the card drifts left on wide screens. */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; max-width: none; width: 100%; }
.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.75rem 1.5rem;
  width: min(400px, 100%);
  box-shadow: 0 10px 30px rgb(91 71 42 / 0.08);
}
.card h1 { text-align: center; font-size: 1.6rem; letter-spacing: 0.01em; }
.login-icon { display: block; margin: 0 auto 0.5rem; }
.card > input { margin-bottom: 0.75rem; }
.card > label { margin-bottom: 0.25rem; }
.card .primary { margin-top: 0.5rem; }

/* ---------- App frame ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--brand); /* like the rule under "Naturkostladen" */
}
.home-link { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--brand); text-decoration: none; font-size: 1.2rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }
.avatar { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-weight: 700; font-size: 0.9rem; border: 2px solid var(--card); }
.refresh { position: relative; }
.refresh.live::after { content: ""; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.refresh.spinning span { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status:empty { display: none; }
.status { margin: 0.5rem 1rem 0; padding: 0.6rem 0.8rem; border-radius: 10px; }
.status.error { background: color-mix(in srgb, var(--danger) 12%, var(--card)); color: var(--danger); }

.banner {
  margin: 0.6rem 1rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tabs { display: flex; gap: 0.25rem; padding: 0.6rem 1rem 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: none; background: transparent; color: var(--muted); border-radius: 999px; padding: 0.4rem 0.9rem; min-height: 40px; white-space: nowrap; }
.tabs button[aria-current="page"] { background: var(--brand); color: var(--bg); }
.tab-icon { font-size: 1rem; }

/* Phones: the views live in an app-style bar at the bottom, within thumb reach. */
@media (max-width: 759px) {
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    gap: 0;
    padding: 0.3rem 0.3rem calc(0.3rem + var(--safe-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgb(0 0 0 / 0.06);
    overflow: visible;
  }
  .tabs button { flex: 1 1 0; flex-direction: column; gap: 0.05rem; min-height: 52px; padding: 0.2rem 0; border-radius: 12px; font-size: 0.72rem; }
  .tabs button[aria-current="page"] { background: var(--primary-soft); color: var(--brand); font-weight: 700; }
  .tab-icon { font-size: 1.25rem; line-height: 1.1; }
  #fab { bottom: calc(4.9rem + var(--safe-bottom)); }
  #toast { bottom: calc(9.2rem + var(--safe-bottom)); }
  body #app-view { padding-bottom: calc(10.5rem + var(--safe-bottom)); }
  .pager h2 { font-size: 1rem; }
  #toolbar { flex-wrap: nowrap; padding-inline: 0.75rem; }
  .pager .icon-button { width: 38px; flex: none; }
  .toolbar-actions button { padding-inline: 0.7rem; }
  .day.quiet { padding-block: 0; }
  .day.quiet .day-head { min-height: 36px; }
}

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 1rem; }
.pager { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.pager h2 { margin: 0; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager h2 small { color: var(--muted); font-weight: 500; }
@media (max-width: 420px) { .pager h2 small { display: none; } }
.toolbar-actions { display: flex; gap: 0.4rem; }

main { padding: 0 1rem; max-width: 1400px; }
/* Room for the floating "+ Schicht" button (and the bottom bar on phones) below the content and the footer. */
#app-view { display: block; padding-bottom: calc(6rem + var(--safe-bottom)); }
#app-view[hidden] { display: none; }
.t-short { display: none; }
@media (max-width: 420px) { .t-long { display: none; } .t-short { display: inline; } }
.empty-state { color: var(--muted); text-align: center; padding: 2rem 1rem; }

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + var(--safe-bottom));
  z-index: 6;
  min-height: 56px;
  padding: 0 1.3rem;
  border-radius: 28px;
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-size: 1.05rem;
  box-shadow: 0 6px 18px rgb(61 139 82 / 0.35);
}
.fab span { font-size: 1.4rem; line-height: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.2rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100% - 2rem);
  padding: 0.5rem 0.6rem 0.5rem 1rem;
  border-radius: 14px;
  background: var(--brand);
  color: var(--bg);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
}
.toast .link { color: var(--bg); font-weight: 700; }

.desktop-only { display: none !important; }
@media (min-width: 760px) {
  .desktop-only { display: inline-flex !important; }
  .mobile-only { display: none !important; }
  .toast { bottom: 1.5rem; }
}

/* ---------- People chips ---------- */
/*
 * Every chip carries the first name and the short code. Containers that get narrow (a week column on a
 * small phone, a month cell) switch to the code – the rule is about available space, not about the view.
 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--c);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.chip-name { overflow: hidden; text-overflow: ellipsis; }
.chip-short { display: none; letter-spacing: 0.02em; }
.chip .own-time { font-weight: 500; opacity: 0.9; }

.shift, .mday, .absent { container-type: inline-size; }
@container (max-width: 100px) {
  .chip { padding: 0.05rem 0.35rem; font-size: 0.78rem; }
  .chip-name { display: none; }
  .chip-short { display: inline; }
}

/* ---------- Week ---------- */

.week { display: grid; gap: 0.6rem; }
.day { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.6rem 0.6rem; }
.day.is-today { background: var(--today); border-color: color-mix(in srgb, var(--holiday) 45%, var(--border)); }
.day.quiet { padding-block: 0.25rem; background: transparent; border-style: dashed; }
.day.quiet .day-head { color: var(--muted); }
.day-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; color: var(--brand); min-height: 40px; }
.day-name { font-weight: 700; }
.day-date { color: var(--muted); }
.day-add { margin-left: auto; width: 36px; min-height: 36px; padding: 0; border-radius: 50%; color: var(--primary); font-size: 1.3rem; background: transparent; }
.badge { font-size: 0.78rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--warn-bg); color: var(--warn-text); }
.badge.holiday::before { content: "Feiertag · "; }
.absent { margin: 0 0 0.4rem; font-size: 0.8rem; color: var(--muted); }
.absent .chip { opacity: 0.55; font-weight: 500; font-size: 0.75rem; }

.shift {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.5rem 0.6rem;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
}
.shift.type-warenannahme { border-left-color: #e69f00; }
.shift.type-putzen { border-left-color: #0072b2; }
.shift.type-sonstiges { border-left-color: #cc79a7; }
.shift.closed { opacity: 0.55; }
.shift.closed .shift-time { text-decoration: line-through; }
.shift-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.5rem; }
.shift-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.shift-type { color: var(--muted); font-size: 0.88rem; }
.sym { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.members { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.unstaffed { color: var(--danger); font-size: 0.85rem; font-style: italic; }
.shift-note { font-size: 0.85rem; color: var(--muted); white-space: pre-line; }
.closed-label { font-size: 0.8rem; color: var(--warn-text); }

/* Large screens: the whole week side by side; days without shifts take less room. */
@media (min-width: 1000px) {
  .week { display: flex; align-items: flex-start; }
  .day { flex: 1 1 0; min-width: 0; }
  .day.quiet { flex-grow: 0.62; }
}

/* ---------- Month ---------- */

.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.month-head span { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0.25rem 0; }
.mday {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 2px;
  min-height: 78px;
  padding: 0.25rem;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  text-align: left;
  font-weight: 400;
  overflow: hidden;
}
.mday.blank { background: transparent; border: none; }
.mday.is-today { background: var(--today); }
.mday.closed { opacity: 0.6; }
.mnum { font-size: 0.85rem; font-weight: 700; color: var(--brand); display: flex; align-items: center; gap: 0.2rem; }
.mabsent { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.6; }
.mholiday { font-size: 0.68rem; color: var(--holiday); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mshift { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 0.72rem; }
.mtime { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 1px; }
.mday .chip { font-size: 0.72rem; padding: 0 0.35rem; }
@media (min-width: 760px) { .mday { min-height: 110px; padding: 0.35rem; } }

/* ---------- My shifts ---------- */

.mine-toolbar { max-width: 760px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.mine-toolbar .button-row { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.segmented button { border: none; border-radius: 0; min-height: 40px; background: transparent; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--brand); color: var(--bg); }

.mine-month { max-width: 760px; margin-bottom: 0.75rem; }
.mine-month h3 { margin: 0.75rem 0 0.25rem; font-size: 0.95rem; }
.mine-table { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 0.92rem; }
.mine-table tr { cursor: pointer; }
.mine-table tr + tr td { border-top: 1px solid var(--border); }
.mine-table tr:hover td { background: var(--primary-soft); }
.mine-table tr.closed td { opacity: 0.55; }
.mine-table td { padding: 0.45rem 0.6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mine-table td:nth-child(1) { width: 6.5rem; font-weight: 600; color: var(--brand); }
.mine-table td:nth-child(2) { width: 10rem; }
.mine-table td:nth-child(3) { width: 7.5rem; font-variant-numeric: tabular-nums; }
.mine-table td:nth-child(4) { color: var(--muted); }
/* Phones: the "with whom" column is left out instead of squeezing the others (the week view shows it). */
@media (max-width: 520px) {
  .mine-table { font-size: 0.88rem; }
  .mine-table td { padding-inline: 0.45rem; }
  .mine-table td:nth-child(1) { width: 5.3rem; }
  .mine-table td:nth-child(2) { width: auto; }
  .mine-table td:nth-child(3) { width: 7.4rem; text-align: right; }
  .mine-table td:nth-child(4) { display: none; }
  .mine-toolbar .button { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
  .mine-toolbar .button-row { gap: 0.35rem; }
}

.mine-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.mine-item { width: 100%; flex-direction: column; align-items: flex-start; gap: 0.15rem; text-align: left; padding: 0.7rem 0.9rem; border-left: 4px solid var(--primary); }
.mine-item.closed { opacity: 0.6; }
.mine-date { font-weight: 700; color: var(--brand); }
.mine-what { color: var(--text); font-weight: 500; }
.mine-with { color: var(--muted); font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }

/* ---------- Hours ---------- */

.hours { display: grid; gap: 0.4rem; max-width: 760px; }
.hours-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; }
.hours-actions [aria-pressed="true"] { background: var(--primary-soft); color: var(--brand); border-color: transparent; }
.hours-hidden { margin: 0; padding: 0 0.8rem; }
.hours-person { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0 0.8rem; }
.hours-person summary { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 0.6rem; min-height: 52px; cursor: pointer; list-style: none; }
.hours-person summary::-webkit-details-marker { display: none; }
.hours-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hours-count { color: var(--muted); font-size: 0.85rem; }
/* Same fixed column widths in every person's table, so dates, types, times and hours line up across the list. */
.hours-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 0 0 0.6rem; font-size: 0.9rem; }
.hours-table td { padding: 0.25rem 0.3rem; border-top: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hours-table td:nth-child(1) { width: 22%; }
.hours-table td:nth-child(2) { width: 32%; }
.hours-table td:nth-child(3) { width: 26%; font-variant-numeric: tabular-nums; }
.hours-table td:nth-child(4) { width: 20%; padding-right: 0; }
@media (max-width: 420px) { .hours-table { font-size: 0.82rem; } }
.hours-total { display: flex; justify-content: space-between; font-weight: 700; padding: 0.5rem 0.8rem; margin: 0; border-top: 2px solid var(--brand); color: var(--brand); }
@media (max-width: 420px) {
  .hours-count { display: none; }
  .hours-person summary { grid-template-columns: auto 1fr auto; }
}

/* ---------- Change log ---------- */

.log-filter { flex-direction: row; align-items: center; gap: 0.5rem; max-width: 320px; white-space: nowrap; }
.log-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.log-entry {
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas: "when who action" "what what what";
  gap: 0.15rem 0.6rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.log-when { grid-area: when; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.log-who { grid-area: who; font-weight: 700; color: var(--brand); }
.log-what { grid-area: what; }
.log-entry > button, .log-state { grid-area: action; justify-self: end; }
.log-state { color: var(--muted); font-size: 0.8rem; font-style: italic; }
.log-entry.undone .log-what { color: var(--muted); text-decoration: line-through; }
#log-more { margin: 0.75rem auto 0; display: flex; }

/* ---------- Bottom sheets (dialogs) ---------- */

dialog.sheet {
  border: none;
  padding: 0.5rem 1.1rem calc(1rem + var(--safe-bottom));
  margin: auto auto 0;
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  background: var(--card);
  color: var(--text);
  transition: transform 0.15s ease-out;
}
dialog.sheet::backdrop { background: rgb(30 25 15 / 0.45); }
@media (min-width: 760px) {
  dialog.sheet { margin: auto; border-radius: 20px; padding-bottom: 1.25rem; }
}
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: var(--border); margin: 0.25rem auto 0.75rem; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.sheet-actions > * { flex: 1 1 auto; }
.sheet-actions .primary { flex-basis: 100%; }
.sheet-section { border-top: 1px solid var(--border); padding: 0.75rem 0; }
.sheet-section summary { cursor: pointer; color: var(--brand); font-weight: 600; min-height: 36px; }
.inline-form { display: flex; flex-direction: column; }
.inline-form .primary { align-self: flex-start; }
.plain-list { list-style: none; padding: 0; margin: 0 0 0.75rem; display: grid; gap: 0.35rem; }
.plain-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.plain-list li > button { margin-left: auto; }

.series-info { background: var(--primary-soft); padding: 0.5rem 0.7rem; border-radius: 10px; margin: 0 0 0.6rem; font-size: 0.92rem; }
.scope-switch { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-bottom: 0.75rem; }
.scope-switch label { flex-direction: row; align-items: center; gap: 0.4rem; color: var(--text); margin: 0; min-height: 40px; }

.people-field { border: none; padding: 0; margin: 0 0 0.75rem; }
.people-field legend { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.35rem; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pick { min-height: 40px; border-radius: 999px; padding: 0.3rem 0.9rem; border: 2px solid var(--c); background: transparent; color: var(--text); }
.pick small { color: var(--muted); }
.pick[aria-pressed="true"] { background: var(--c); color: var(--fg); }
.pick[aria-pressed="true"] small { color: inherit; opacity: 0.85; }
.pick[aria-pressed="true"]::before { content: "✓"; }
.member-time { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; margin-top: 0.5rem; font-size: 0.9rem; }
.own-fields { display: inline-flex; align-items: center; gap: 0.3rem; }
.own-fields input { width: 7.5rem; }

/* ---------- Install guide ---------- */

.install-banner { background: var(--card); border-color: var(--border); }
.banner-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.help p { margin: 0 0 0.75rem; }
.help-tabs { display: flex; width: 100%; margin-bottom: 0.75rem; }
.help-tabs button { flex: 1 1 0; padding-inline: 0.4rem; font-size: 0.92rem; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 0.75rem; display: grid; gap: 0.6rem; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0.7rem 0.8rem 0.7rem 3.1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  line-height: 1.5;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0.75rem;
  top: 0.65rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}
.help-note { display: block; margin-top: 0.35rem; color: var(--muted); font-size: 0.9rem; }
/* Drawn icons inline in the text, the size of a letter, so people recognise what to tap. */
.ico { display: inline-block; width: 1.35em; height: 1.35em; vertical-align: -0.3em; padding: 0.1em; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--primary); }
.ico-app { padding: 0; border: none; border-radius: 0.3em; }
.help-trouble { background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; }
.help-trouble summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.help-trouble ul { margin: 0.4rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.4rem; color: var(--text); }
.install-now { margin-bottom: 0.75rem; }
.login .card .link { align-self: center; }

.app-footer { max-width: 760px; margin: 1.5rem 1rem 0; padding-top: 0.75rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; }
.app-footer .link { min-height: 0; padding: 0; }
.theme-switch { display: flex; width: 100%; }
.theme-switch button { flex: 1 1 0; }

/* ---------- Design layer: softer surfaces, line icons, calmer week ---------- */
/* Comes after the base rules on purpose; the phone overrides at its end win again. */

:root {
  --shadow-sm: 0 1px 2px rgb(60 45 20 / 0.06), 0 2px 8px rgb(60 45 20 / 0.05);
  --shadow-md: 0 6px 24px rgb(60 45 20 / 0.12);
  --radius: 16px;
  --track: color-mix(in srgb, var(--brand) 8%, transparent);
}
:root[data-theme="dark"] { --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35); --shadow-md: 0 8px 28px rgb(0 0 0 / 0.45); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35); --shadow-md: 0 8px 28px rgb(0 0 0 / 0.45); }
}

body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
button, .button { transition: background-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.1s; }
.primary { box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.ui-icon { width: 1.3em; height: 1.3em; flex: none; }

/* Header */
.topbar {
  padding: 0.55rem 1rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.home-link { font-weight: 700; letter-spacing: -0.01em; }
.icon-button { border-color: transparent; background: var(--card); box-shadow: var(--shadow-sm); border-radius: 12px; color: var(--brand); }
.icon-button:hover { color: var(--primary); }
.refresh.spinning .spin-wrap { display: inline-flex; animation: spin 0.8s linear infinite; }
.avatar { box-shadow: var(--shadow-sm); }

/* View tabs (desktop): a rail with the active view raised */
.tabs { width: fit-content; max-width: calc(100% - 2rem); margin: 0.75rem 1rem 0; padding: 4px; gap: 2px; background: var(--track); border-radius: 14px; }
.tabs button { min-height: 38px; gap: 0.4rem; padding: 0.35rem 0.85rem; border-radius: 10px; font-weight: 500; }
.tabs button[aria-current="page"] { background: var(--card); color: var(--brand); font-weight: 650; box-shadow: var(--shadow-sm); }
.tab-icon { width: 1.15em; height: 1.15em; }

.segmented { background: var(--track); border: none; border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border-radius: 9px; min-height: 36px; }
.segmented button + button { border-left: none; }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--brand); font-weight: 650; box-shadow: var(--shadow-sm); }

.banner { border-radius: 14px; box-shadow: var(--shadow-sm); }

/* Week */
.week { gap: 0.75rem; }
.day { border: 1px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 0.6rem 0.75rem 0.75rem; }
.day.is-today { background: var(--card); border-color: color-mix(in srgb, var(--primary) 55%, transparent); }
.day.quiet { background: transparent; box-shadow: none; border: 1px dashed var(--border); }
.day-head { gap: 0.45rem; }
.day-name { font-size: 1.02rem; }
.today-pill { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--primary); color: var(--on-primary); }
.day-add { border: none; color: var(--primary); }
.day-add:hover { background: var(--primary-soft); }

/* Day header: the "+" always sits top right, level with the date. If space runs out the title wraps, never the "+". */
.day-head { flex-wrap: nowrap; align-items: flex-start; }
.day-title { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.45rem; min-height: 44px; }
.day-add { flex: none; margin-left: 0.25rem; }
.day-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0 0 0.35rem; }
/* Empty days are narrow on large screens: keep "Mo 26.10." on one line next to the "+". */
@media (min-width: 1000px) { .day.quiet { padding-inline: 0.6rem 0.3rem; } .day.quiet .day-title { flex-wrap: nowrap; gap: 0.35rem; } .day.quiet .day-add { margin-left: 0; } }

/* Shift cards: colour bar for the type, soft surface, no hard frame */
.shift { --type: var(--primary); border: none; border-radius: 12px; padding: 0.55rem 0.7rem 0.6rem 0.9rem; box-shadow: inset 4px 0 0 var(--type); background: var(--bg); }
.shift:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--bg)); }
.shift.type-warenannahme { --type: #e69f00; }
.shift.type-putzen { --type: #0072b2; }
.shift.type-sonstiges { --type: #cc79a7; }
.shift-time { letter-spacing: -0.01em; }
.sym { display: inline-flex; color: var(--muted); }
.sym .ui-icon { width: 1.05em; height: 1.05em; }
.type-dot { display: inline-block; width: 0.55em; height: 0.55em; margin-right: 0.35em; border-radius: 50%; vertical-align: 0.05em; background: var(--primary); }
.dot-warenannahme { background: #e69f00; }
.dot-putzen { background: #0072b2; }
.dot-sonstiges { background: #cc79a7; }

.chip { padding: 0.12rem 0.55rem; font-size: 0.82rem; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06); }

/* Month */
.month-head, .month-grid { gap: 4px; }
.mday { border: 1px solid transparent; border-radius: 10px; box-shadow: var(--shadow-sm); }
.mday.blank { box-shadow: none; }
.mday.is-today { background: var(--card); border-color: color-mix(in srgb, var(--primary) 55%, transparent); }

/* Lists and tables */
.hours-person, .log-entry, .mine-item { border-color: transparent; border-radius: 14px; box-shadow: var(--shadow-sm); }
.mine-table { border: none; border-radius: 14px; box-shadow: var(--shadow-sm); }
.mine-item { border-left: none; box-shadow: var(--shadow-sm), inset 4px 0 0 var(--primary); }

/* Floating button, toast, sheets */
.fab { border-radius: 18px; font-weight: 600; box-shadow: var(--shadow-md); }
.toast { border-radius: 16px; box-shadow: var(--shadow-md); }
dialog.sheet { box-shadow: var(--shadow-md); }
@media (min-width: 760px) { dialog.sheet { border-radius: 24px; } }

/* The page fills the screen so the footer sits at the bottom even when the content is short. */
#app-view:not([hidden]) { display: flex; flex-direction: column; min-height: 100dvh; }
#app-view > main { flex: 1 0 auto; width: 100%; }
/* No floating button on large screens, so no extra room is needed below the footer. */
@media (min-width: 760px) { #app-view:not([hidden]) { padding-bottom: 0; } }

/* Slim full-width hint at the very bottom while the planner runs in a browser */
.app-footer { max-width: none; margin: 2rem 0 0; padding: 0.5rem 1rem; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--card) 65%, transparent); color: var(--muted); font-size: 0.8rem; text-align: center; }
.app-footer .link { font-size: inherit; }

/* Phones: bottom bar, frosted, the active view marked by a pill behind its icon */
@media (max-width: 759px) {
  .tabs {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0.35rem 0.3rem calc(0.35rem + var(--safe-bottom));
    border-radius: 0;
    background: color-mix(in srgb, var(--card) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
  }
  .tabs button { gap: 0.15rem; padding: 0.15rem 0; font-size: 0.7rem; }
  .tabs button[aria-current="page"] { background: transparent; box-shadow: none; color: var(--brand); }
  .tabs .tab-icon { box-sizing: content-box; width: 1.35rem; height: 1.35rem; padding: 0.2rem 0.9rem; border-radius: 999px; }
  .tabs button[aria-current="page"] .tab-icon { background: var(--primary-soft); color: var(--primary); }
}

/* ---------- Mobile usability & accessibility ---------- */

/* Text only for screen readers (e.g. the full name next to a visible short code). */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* The date in "Meine Schichten" is the real (keyboard/screen-reader reachable) button; the whole row stays tappable. */
.row-link { all: unset; cursor: pointer; font: inherit; color: inherit; }
.row-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 4px; }

/* Touch targets: at least 44×44 px for everything you tap. */
.day-add, .pager .icon-button { min-width: 44px; min-height: 44px; }
.small, .segmented button { min-height: 44px; }
.link { min-height: 44px; }
.app-footer .link { min-height: 32px; }
.mine-table td { padding-block: 0.6rem; }

@media (max-width: 759px) {
  .tabs button { font-size: 0.75rem; min-height: 56px; }
  /* The week navigation stays reachable while scrolling through the days. */
  #toolbar { position: sticky; top: var(--topbar-h, 3.85rem); z-index: 4; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  /* Date on its own line, start and end side by side. */
  .date-time-row { grid-template-columns: 1fr 1fr; }
  .date-time-row > label:first-child { grid-column: 1 / -1; }
  /* "Speichern" full width, the secondary actions share one row. */
  .sheet-actions > :not(.primary) { flex: 1 1 0; min-width: 0; padding-inline: 0.5rem; font-size: 0.92rem; }
  /* Long dialogs: "Speichern" stays in reach at the bottom of the sheet. */
  dialog.sheet .sheet-actions { position: sticky; bottom: calc(-1rem - var(--safe-bottom)); margin-inline: -1.1rem; padding: 0.75rem 1.1rem calc(0.75rem + var(--safe-bottom)); background: var(--card); border-top: 1px solid var(--border); }
}

/* "Live" dot: small, bottom right, with a ring, so it never covers the refresh arrow. */
.refresh.live::after { top: auto; left: auto; right: 6px; bottom: 6px; width: 9px; height: 9px; border: 2px solid var(--card); box-sizing: content-box; }

/* Light person colours (yellow, sky blue) need a visible edge on white to read as a button. */
.pick { box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.14); }

/* Month: the weekday row (Mo … So) stays visible while scrolling, right below the header (and the sticky month
   navigation on phones). The heights are measured in app.js (--topbar-h, --toolbar-h). */
.month-head {
  position: sticky;
  top: calc(var(--topbar-h, 3.85rem) + var(--toolbar-h, 0px));
  z-index: 3;
  padding-block: 0.15rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Connection lost: a full-width warning inside the (sticky) header, and a red dot on the refresh button. */
.topbar { flex-wrap: wrap; }
.topbar > h1 { flex: 1 1 auto; min-width: 0; }
.home-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Very narrow phones (≈320–380 px): logo without name, no print button, tighter month list – nothing gets cut off. */
@media (max-width: 380px) {
  .home-link span { display: none; }
  #print { display: none; }
  #toolbar { gap: 0.35rem; padding-inline: 0.5rem; }
  .toolbar-actions button { padding-inline: 0.6rem; }
  .mine-table { font-size: 0.82rem; }
  .mine-table td { padding-inline: 0.4rem; }
  .mine-table td:nth-child(1) { width: 4.9rem; }
  .mine-table td:nth-child(3) { width: 7.6rem; }
}
.conn-banner {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
  margin: 0.25rem -1rem -0.55rem;
  padding: 0.55rem 1rem;
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
}
.conn-banner button { background: #fff; color: var(--danger); border-color: #fff; font-weight: 700; }
:root[data-theme="dark"] .conn-banner { color: #1b1f1a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .conn-banner { color: #1b1f1a; } }
.refresh.offline::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--card); box-sizing: content-box; }

/* Respect "reduce motion": no spinning, sliding or animated transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Print / PDF ---------- */

.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; padding: 0; font-size: 10pt; }
  .topbar, .tabs, .toolbar, .fab, .toast, .banner, .status, .no-print, dialog { display: none !important; }
  .print-only { display: block; margin: 0 0 5mm; color: #5b472a; border-bottom: 1.5pt solid #5b472a; padding-bottom: 2mm; }
  .print-meta { margin: -3mm 0 5mm; padding: 0; border: none; font-size: 8pt; color: #555; }
  main { padding: 0; max-width: none; }
  .day, .shift, .hours-person, .log-entry, .mday { break-inside: avoid; background: #fff !important; }
  .week { grid-template-columns: repeat(7, 1fr) !important; gap: 2mm; }
  .chip { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
