:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #6b7570;
  --line: #e4dfd4;
  --brand: #2f4a3a;
  --brand-2: #46694f;
  --free: #5f9a6b;
  --mid: #d9a441;
  --full: #c4553f;
  --lesson: #6b5ca5;
  --lesson-bg: #ece9f7;
  --block: #8a8f8c;
  --block-bg: #ebecea;
  --mine: #1f6f8b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

/* Kopf */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
}
.top h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: .2px; }
.top .sub { font-size: 13px; opacity: .8; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { padding: 12px 12px calc(84px + var(--safe-b)); max-width: 760px; margin: 0 auto; }

/* Navigation unten */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
nav.tabs button {
  flex: 1; border: 0; background: none; padding: 9px 0 8px; font-size: 11.5px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
nav.tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; }
nav.tabs button.on { color: var(--brand); font-weight: 600; }
nav.tabs .dot { position: absolute; margin-left: 18px; background: var(--full); color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; }

/* Auswahl-Leisten */
.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 auto; min-width: 52px; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 6px 8px; text-align: center; cursor: pointer;
}
.day b { display: block; font-size: 17px; }
.day small { font-size: 11.5px; color: var(--muted); }
.day.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.day.on small { color: #dfe8e2; }

.seg { display: flex; background: #e7e2d7; border-radius: 12px; padding: 3px; margin: 4px 0 12px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-size: 14px; cursor: pointer; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

/* Zeitfenster-Liste */
.slots { background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.slot {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 52px;
}
.slot:last-child { border-bottom: 0; }
.slot .t { font-variant-numeric: tabular-nums; font-weight: 600; }
.slot.past { opacity: .45; cursor: default; }
.slot.lesson { background: var(--lesson-bg); }
.slot.block { background: repeating-linear-gradient(135deg, var(--block-bg) 0 10px, #f5f5f3 10px 20px); cursor: default; }
.slot.mine { box-shadow: inset 4px 0 0 var(--mine); }
.slot .info { min-width: 0; }
.slot .names { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; margin-right: 4px; }
.tag.lesson { background: var(--lesson); color: #fff; }
.tag.block { background: var(--block); color: #fff; }
.tag.mine { background: var(--mine); color: #fff; }
.seats { display: flex; gap: 4px; align-items: center; }
.seat { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--free); }
.seat.taken { background: var(--free); }
.seats.mid .seat { border-color: var(--mid); } .seats.mid .seat.taken { background: var(--mid); }
.seats.full .seat { border-color: var(--full); } .seats.full .seat.taken { background: var(--full); }
.seats .count { font-size: 12px; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }

/* Wochenraster */
.week { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; overflow-x: auto; }
.week table { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 330px; }
.week th { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 2px 0; }
.week th.today { color: var(--brand); }
.week td.time { font-size: 11px; color: var(--muted); text-align: right; padding-right: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.week td.c { height: 20px; border-radius: 5px; background: #e8f1ea; cursor: pointer; position: relative; }
.week td.c.l1 { background: #b9d8c0; } .week td.c.l2 { background: #f0d79a; } .week td.c.l3 { background: #e7a596; }
.week td.c.lesson { background: var(--lesson-bg); outline: 1.5px solid var(--lesson); outline-offset: -1.5px; }
.week td.c.block { background: repeating-linear-gradient(135deg, #d6d8d6 0 4px, #eee 4px 8px); cursor: default; }
.week td.c.past { opacity: .35; }
.week td.c.mine::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--mine); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); margin: 10px 2px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* Karten, Formulare */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
.card h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
input:focus, select:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 11px; padding: 12px 16px; font-weight: 600; cursor: pointer;
  background: var(--brand); color: #fff; width: 100%; margin-top: 14px; font-size: 16px;
}
.btn.secondary { background: #e7e2d7; color: var(--ink); }
.btn.danger { background: #fbe9e5; color: var(--full); }
.btn.small { width: auto; padding: 7px 12px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--brand-2); text-decoration: underline; padding: 6px 0; cursor: pointer; font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--full); font-size: 14px; margin-top: 8px; }
.ok { color: var(--free); font-size: 14px; margin-top: 8px; }

.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 13px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 8px; background: #e7e2d7; color: var(--ink); text-transform: uppercase; letter-spacing: .3px; }
.badge.pending { background: #fbefd2; color: #8a5d00; }
.badge.blocked { background: #fbe9e5; color: var(--full); }
.cancelled .title { text-decoration: line-through; color: var(--muted); }

/* Login */
.auth { max-width: 420px; margin: 0 auto; padding: 8vh 16px 40px; }
.auth .logo { width: 64px; height: 64px; margin: 0 auto 10px; display: block; }
.auth h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }
.auth p.center { text-align: center; margin: 0 0 18px; }

/* Bottom Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(20,25,22,.38); z-index: 40; animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: #fff;
  border-radius: 18px 18px 0 0; padding: 10px 16px calc(18px + var(--safe-b));
  max-height: 88vh; overflow-y: auto; animation: up .2s ease-out; max-width: 760px; margin: 0 auto;
}
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 0; font-size: 19px; }
.sheet .when { color: var(--muted); margin: 2px 0 12px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--full); }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.hint { background: #fff8e6; border: 1px solid #f0dfb0; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }

@media (min-width: 700px) {
  main { padding-top: 18px; }
  .slot { padding: 12px 16px; }
}

.seg button:disabled { opacity: .4; cursor: default; }
/* Tag- und Flächenauswahl bleibt beim Scrollen oben */
.planbar { position: sticky; z-index: 5; background: var(--bg); margin: -12px -12px 0; padding: 10px 12px 0; }
