:root {
  --bg: #f4f8f4;
  --surface: #ffffff;
  --surface-2: #e9f2ea;
  --text: #17301f;
  --muted: #5b7263;
  --border: #d3e2d6;
  --primary: #2e7d4f;
  --primary-dark: #22603c;
  --primary-soft: #e1f1e6;
  --accent: #6cbf5a;
  --primary-text: #ffffff;
  --ok: #2f855a;
  --warn: #b7791f;
  --danger: #c53030;
  --path: #e6dcc8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 48, 31, .06), 0 4px 14px rgba(23, 48, 31, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a13;
    --surface: #182620;
    --surface-2: #1f3128;
    --text: #e6f0e8;
    --muted: #9db8a5;
    --border: #2b4436;
    --primary: #5fc084;
    --primary-dark: #45a86b;
    --primary-soft: #1d3a2a;
    --accent: #8ad47a;
    --primary-text: #08190f;
    --path: #4a4030;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(64px + var(--safe-bottom));
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 .35rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
.count { font-size: .8rem; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 0 .55rem; font-weight: 500; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }
.center { text-align: center; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
code { font-size: .85em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; word-break: break-all; }
pre { background: var(--surface-2); padding: .6rem .8rem; border-radius: 8px; overflow: auto; font-size: .85rem; white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Kopfzeile und Navigation */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem; padding-top: calc(.5rem + env(safe-area-inset-top, 0px));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand-icon { width: 34px; height: 34px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text small { font-size: .62rem; letter-spacing: .18em; color: var(--accent); font-weight: 600; }
.topnav { display: none; gap: .15rem; flex: 1; }
.topnav a { padding: .45rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topnav a.active { background: var(--primary-soft); color: var(--primary); }
.topnav a:hover { color: var(--primary); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.userbox .role { font-size: .72rem; background: var(--surface-2); padding: .1rem .45rem; border-radius: 999px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: .55rem 0 .5rem; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.tabbar a .ic { font-size: 1.25rem; line-height: 1; font-style: normal; }
.tabbar a.active { color: var(--primary); font-weight: 600; }
.tabbar:empty { display: none; }
/* Schmale Handys: bis zu acht Reiter (Admin) nebeneinander, Beschriftung etwas kleiner mit Luft dazwischen */
@media (max-width: 480px) { .tabbar a { font-size: .62rem; padding-left: 2px; padding-right: 2px; letter-spacing: -.01em; } }

main { max-width: 760px; margin: 0 auto; padding: 1rem; }
main.wide { max-width: 1600px; }
main.wide.full { max-width: none; }
main.wide form.box, main.wide .auth { max-width: 1000px; }

/* ---------- Bausteine */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; cursor: pointer;
  text-align: center; line-height: 1.2;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .32rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn.big { padding: .7rem 1.3rem; font-size: 1.02rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.filepick { position: relative; overflow: hidden; }
.btn.filepick input[type=file] { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 100px; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; align-items: center; }
.row.tight { margin-top: .35rem; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.row2 > label, .row3 > label { min-width: 0; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; box-shadow: var(--shadow); }
.box h2 { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.badge { display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: #dff5e8; color: var(--ok); }
.badge.orange { background: #fdf0d8; color: var(--warn); }
.badge.red { background: #fde1e1; color: var(--danger); }
.badge.grey { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .badge.green { background: #1c3b2c; } .badge.orange { background: #3d2f14; } .badge.red { background: #43201f; }
}
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--sw, var(--surface-2)); vertical-align: -1px; margin-right: .35rem; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }

/* ---------- Formulare */
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .86rem; color: var(--muted); margin: .55rem 0; }
.form label > span.hint { font-size: .75rem; }
.form input, .form select, .form textarea {
  padding: .55rem .65rem; font: inherit; font-size: 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%; min-width: 0;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form textarea { min-height: 96px; resize: vertical; }
.form input[type=date], .form select {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; max-width: 100%; min-width: 0;
  min-height: 2.7rem; text-align: left;
}
.form input[type=date]::-webkit-date-and-time-value { text-align: left; }
.form select { padding-right: 1.8rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.form label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: .45rem; margin: .4rem 1rem .4rem 0; color: var(--text); font-size: .95rem; }
.form label.inline input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 .9rem; }
.form-grid label.wide { grid-column: 1 / -1; }
.form input[type=color] { padding: .1rem; height: 2.4rem; width: 3.2rem; }

/* ---------- Anmeldung */
.auth { max-width: 420px; margin: 2rem auto; }
.auth .logo { display: block; width: 100%; max-width: 340px; margin: 0 auto 1.5rem; }
.auth .box { padding: 1.4rem; }
.auth .links { margin-top: 1rem; text-align: center; font-size: .9rem; }
.legal-links { margin-top: .8rem; }
.legal-links a { color: var(--muted); }
/* Impressum und Datenschutz: gut lesbare Textbreite */
.legal { max-width: 760px; margin: 0 auto; }
.legal .box { line-height: 1.55; }
.legal h2 { font-size: 1.05rem; margin: 1.3rem 0 .35rem; }
.legal p, .legal ul { margin: 0 0 .6rem; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin-bottom: .3rem; }
.legal mark { background: #ffe08a; color: #3a2a00; padding: 0 .15em; border-radius: 3px; }

/* ---------- Werkzeugleiste, Listen, Tabellen */
/* Werkzeugleiste (Suche, Filter, Knöpfe) bleibt beim Scrollen unter der Kopfzeile stehen; --topbar-h setzt app.js */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 .5rem; padding: .5rem 0; position: sticky; top: var(--topbar-h, 51px); z-index: 4; background: var(--bg); }
.searchwrap { position: relative; flex: 1 1 220px; min-width: 0; display: flex; }
.searchwrap input[type=search] { width: 100%; padding: .55rem 2.4rem .55rem .7rem; font: inherit; font-size: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); -webkit-appearance: none; appearance: none; }
.searchwrap input[type=search]::-webkit-search-cancel-button, .searchwrap input[type=search]::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.searchwrap .clear { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); width: 1.9rem; height: 1.9rem; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: inherit; font-size: 1.35rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.searchwrap .clear:hover { background: var(--surface-2); color: var(--text); }
.toolbar select { padding: .5rem .6rem; font: inherit; font-size: .92rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); max-width: 100%; }
.summary { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: .25rem 0 .5rem; }

.cards { display: grid; gap: .6rem; }
.card { display: grid; grid-template-columns: 52px 1fr auto; gap: .7rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; box-shadow: var(--shadow); color: var(--text); }
.card .sw { width: 52px; height: 52px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .95rem; background: var(--sw, var(--surface-2)); text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.card .name { font-weight: 600; line-height: 1.25; }
.card .meta { font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.card .side { text-align: right; font-size: .85rem; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: .8rem; color: var(--muted); white-space: nowrap; cursor: pointer; user-select: none; }
.table th.sorted { color: var(--primary); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--primary-soft); }
.table td.num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; white-space: nowrap; }
.table td.name { font-weight: 600; }
.table td.wrap { white-space: normal; min-width: 160px; font-size: .85rem; color: var(--muted); }
.table td .sub { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.table.compact th, .table.compact td { padding: .4rem .5rem; }
.table.static th, .table.static tbody tr { cursor: default; }
.table td.wrap.change { color: var(--text); min-width: 240px; overflow-wrap: anywhere; }
.table input, .table select { padding: .3rem .45rem; font: inherit; font-size: .9rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.table input[type=checkbox] { width: 18px; height: 18px; }
.table input.short { width: 4.5rem; }

/* ---------- Detail */
.detail-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.detail-head .img { width: 180px; height: 180px; border-radius: var(--radius); object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 2.5rem; cursor: pointer; flex: none; overflow: hidden; }
.detail-head .img img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }
.detail-head .titles { flex: 1; min-width: 240px; }
.detail-head .number { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--muted); font-size: .95rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem .9rem; }
.kv div { padding: .45rem .6rem; background: var(--surface-2); border-radius: 8px; min-width: 0; }
.kv div span { display: block; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv div strong { font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.kv div.hl { background: var(--primary-soft); }
.kv div.wide { grid-column: 1 / -1; }
.notes { white-space: pre-wrap; background: var(--surface-2); padding: .7rem .8rem; border-radius: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); }
.tile strong { display: block; font-size: 1.5rem; color: var(--primary); }
.tile span { font-size: .82rem; color: var(--muted); }
ul.list { list-style: none; padding: 0; margin: .5rem 0; }
ul.list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
ul.list li:last-child { border-bottom: 0; }
ul.list li > span:first-child { flex: 1; min-width: 200px; }
ul.list.compact li { justify-content: flex-start; padding: .3rem 0; }
.bars .bar-row { display: grid; grid-template-columns: 130px 1fr 40px; gap: .5rem; align-items: center; font-size: .85rem; margin: .25rem 0; }
.bars .bar { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--primary); }

/* ---------- Historie */
.timeline { list-style: none; padding: 0; margin: .5rem 0; }
.timeline li { display: grid; grid-template-columns: 6.2rem 1fr auto; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); align-items: start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .what { white-space: pre-wrap; }
.timeline .what .kind { display: inline-block; margin-right: .4rem; }
.timeline .who { font-size: .75rem; color: var(--muted); }
.timeline .evphoto img { display: block; max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--border); margin-top: .4rem; }
.timeline .evactions { white-space: nowrap; }
.btn.small.filepick { padding: .32rem .6rem; }
@media (max-width: 599px) { .timeline li { grid-template-columns: 1fr auto; } .timeline .when { grid-column: 1 / -1; } }

/* ---------- Plan der Wiese */
.plan-wrap { overflow-x: auto; padding: .5rem 0 1rem; }
.plan { display: inline-flex; flex-direction: column; gap: 0; min-width: 100%; }
/* Raster in halben Plätzen: jede Zelle belegt zwei halbe Zeilen und lässt unten 3 px frei (statt row-gap) */
.plan .block { display: grid; column-gap: 3px; row-gap: 0; align-items: start; }
.plan .block > .rowlabel { margin-top: 3px; }
/* Anordnungsmodus: Bäume senkrecht ziehen (auch per Finger: touch-action none, sonst scrollt das iPad) */
.plan.editing .cell[data-ids]:not([data-ids=""]) { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.plan.editing .cell.dragging { cursor: grabbing; z-index: 6; opacity: .9; outline: 2px dashed var(--text); outline-offset: 1px; animation: none !important; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.plan .cell .manual { position: absolute; left: 2px; top: 0; font-size: .55rem; text-shadow: none; opacity: .95; }
.plan-editbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; background: var(--primary-soft); border: 1px solid var(--primary); border-radius: 10px; padding: .55rem .8rem; margin: .4rem 0; font-size: .88rem; }
.plan .block > .path.v { align-self: stretch; }
/* Neuer Baum: Kästchen aus der Werkzeugleiste auf einen freien Platz (gestrichelt, +) oder einen leeren Platz ziehen */
.new-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border: 2px dashed var(--accent); border-radius: 9px; background: var(--surface-2); color: var(--text); font-weight: 600; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; animation: chippulse 1.6s ease-in-out infinite; }
.new-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; cursor: grabbing; animation: none; opacity: .92; box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
@keyframes chippulse { 50% { box-shadow: 0 0 0 5px rgba(108, 191, 90, .35); } }
.plan .slot { width: var(--cw, 46px); height: var(--ch, 34px); border: 1.5px dashed var(--accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--accent); font-weight: 700; font-size: .8rem; opacity: .5; cursor: copy; }
.plan .slot:hover, .plan .slot.over { opacity: 1; background: rgba(108, 191, 90, .28); }
.plan.adding .cell.fehlt[data-ids] { border-color: var(--accent); cursor: copy; }
.plan.adding .cell.over, .plan .slot.over { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 4; }
.modal.wide { width: min(760px, 100%); }
/* Rechte je Benutzer: Dialog in der Verwaltung, Übersicht unter „Mehr“ */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; }
.perm-grid label.diff select { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.perm-grid select:disabled { opacity: .55; }
.perm-head { margin: 1.2rem 0 .4rem; font-size: 1rem; }
.perm-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .3rem 1.2rem; }
.perm-list li { display: flex; justify-content: space-between; gap: .6rem; border-bottom: 1px solid var(--border); padding: .25rem 0; font-size: .9rem; }
.perm-list li span { color: var(--muted); }
@media (max-width: 599px) { .perm-grid { grid-template-columns: 1fr; } }
.plan .cell {
  width: var(--cw, 46px); height: var(--ch, 34px); border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 600; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .3); cursor: pointer; text-decoration: none;
  background: var(--sw, #90a4ae); border: 1px solid rgba(0, 0, 0, .12); white-space: nowrap; overflow: hidden; letter-spacing: -.01em;
  position: relative;
}
.plan .cell:hover { outline: 2px solid var(--text); outline-offset: 1px; z-index: 2; }
.plan .cell.empty { background: transparent; border: 0; cursor: default; }
.plan .cell.empty:hover { outline: 0; }
.plan .cell.fehlt { background: transparent; border: 1.5px dashed var(--border); color: var(--muted); text-shadow: none; }
.plan .cell.tot { background: repeating-linear-gradient(135deg, #8a8a8a 0 4px, #6d6d6d 4px 8px); }
.plan .cell.kein_baum { background: var(--surface-2); color: var(--muted); text-shadow: none; border-style: dotted; font-size: .62rem; }
.plan .cell.foreign { background: var(--surface-2); border: 1px solid var(--border); cursor: default; }
.plan .cell.foreign::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.plan .cell.mine { box-shadow: 0 0 0 3px var(--accent); }
/* „Im Plan zeigen“ / „in der Liste zeigen“: Baum blinkt ein paar Sekunden rot und bleibt danach rot umrandet */
.plan .cell.focus { outline: 3px solid #ff3b30; outline-offset: 2px; z-index: 3; animation: cellblink .5s steps(1) 16; }
@keyframes cellblink {
  0% { outline-color: #ff3b30; box-shadow: 0 0 0 8px rgba(255, 59, 48, .45); transform: scale(1.3); }
  50% { outline-color: transparent; box-shadow: none; transform: scale(1); }
}
/* Dropdown „Hervorheben“: Treffer blinken dauerhaft, bis die Auswahl aufgehoben wird */
.plan .cell.hl { outline: 3px solid #ff3b30; outline-offset: 2px; z-index: 3; animation: cellblink .8s steps(1) infinite; }
.table tbody tr.focus td { background: #ffe1df; animation: rowblink .5s steps(1) 16; }
.card.focus { outline: 3px solid #ff3b30; animation: cardblink .5s steps(1) 16; }
@keyframes rowblink { 0% { background: #ff8a80; } 50% { background: #ffe1df; } }
@keyframes cardblink { 0% { outline-color: #ff3b30; box-shadow: 0 0 0 6px rgba(255, 59, 48, .4); } 50% { outline-color: transparent; box-shadow: none; } }
@media (prefers-color-scheme: dark) { .table tbody tr.focus td { background: #4a2320; } @keyframes rowblink { 0% { background: #a33a32; } 50% { background: #4a2320; } } }
.plan .cell.dim { opacity: .18; }
.plan .cell .nest { position: absolute; right: 1px; top: 0; font-size: .6rem; text-shadow: none; }
.plan .cell .nosp { position: absolute; left: 2px; bottom: -1px; font-size: .55rem; text-shadow: none; opacity: .9; }
.plan .rowlabel { width: var(--cw, 46px); height: 26px; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; color: var(--text); background: #d6d6d6; border-radius: 5px; }
@media (prefers-color-scheme: dark) { .plan .rowlabel { background: #3a4a40; } }
.plan .path { background: var(--path); border-radius: 4px; }
.plan .path.v { width: 14px; }
.plan .path.h { height: 22px; display: flex; align-items: center; justify-content: center; font-size: .72rem; color: #6b5d45; letter-spacing: .2em; margin: 6px 0; }
.plan .poslabel { width: 20px; height: var(--ch, 34px); display: flex; align-items: center; justify-content: center; font-size: .65rem; color: var(--muted); }
/* Jahreszeiten-Deko unter dem unteren Teil (Laub, Blüten, Kirschen, Schnee) */
.plan .season { position: relative; height: 44px; margin-top: 4px; overflow: hidden; pointer-events: none; }
.plan .season svg { position: absolute; width: var(--s); height: var(--s); fill: currentColor; opacity: .9; transform: rotate(var(--r)); }
.plan .season svg.sway { animation: leafsway 6s ease-in-out infinite alternate; }
@keyframes leafsway { from { transform: rotate(calc(var(--r) - 12deg)); } to { transform: rotate(calc(var(--r) + 12deg)) translateY(-2px); } }
/* Zweige an den Ecken der Terminkarten (gleiche Jahreszeit wie unter dem Plan) */
.appt, .appt-empty { position: relative; }
.sprigs { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sprig { position: absolute; overflow: visible; transform-origin: var(--ox) var(--oy); filter: drop-shadow(0 1px 1px rgba(0,0,0,.28)); }
.sprig.bl { transform: rotate(180deg); }
.sprig .sw { transform-box: fill-box; transform-origin: 50% 100%; animation: sprigsway 5s ease-in-out infinite alternate; }
@keyframes sprigsway { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@media (max-width: 599px) { .sprig.tr { transform: scale(.8); } .sprig.bl { transform: rotate(180deg) scale(.8); } }
@media (min-width: 900px) { .sprig.tr { transform: scale(1.2); } .sprig.bl { transform: rotate(180deg) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .plan .season svg.sway, .sprig .sw { animation: none; } }
/* Termine */
/* Abstand zwischen den Karten so groß, dass die Zweige (ragen oben rechts und unten links über den Rand) die Nachbarkarte
   nicht berühren; die Monatsüberschrift rückt näher an ihre erste Karte als an die vorige */
.appt-list { display: grid; gap: 1.75rem; max-width: 860px; }
.appt-month { margin: .4rem 0 -.75rem; font-size: .95rem; color: var(--muted); font-weight: 600; }
@media (max-width: 599px) { .appt-list { gap: 1.5rem; } .appt-month { margin-bottom: -.6rem; } }
.appt { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: .9rem; align-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem 1rem; }
.appt .cal { text-align: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); padding: .3rem 0 .35rem; line-height: 1.15; }
.appt .cal .w { display: block; font-size: .7rem; color: var(--muted); }
.appt .cal .d { display: block; font-size: 1.5rem; font-weight: 700; }
.appt .cal .m { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.appt h3 { margin: 0 0 .25rem; font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.appt .when { display: flex; flex-wrap: wrap; gap: .15rem 1rem; color: var(--muted); font-size: .88rem; }
.appt .text { margin-top: .45rem; overflow-wrap: anywhere; }
.appt .text p, .appt .text ul { margin: .35rem 0; }
.appt .text ul { padding-left: 1.2rem; }
.appt .text h2 { font-size: .98rem; margin: .7rem 0 .2rem; }
.appt .actions { margin: .5rem 0 0; }
.appt.past { opacity: .72; }
.appt-past { margin-top: 1.2rem; max-width: 860px; }
.appt-past > summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: .4rem 0; }
.appt-past > .appt-list { margin-top: 1.2rem; }
.appt-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; max-width: 860px; margin: .3rem 0 .4rem; }
.notify-toggle { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .45rem .75rem; cursor: pointer; overflow-wrap: anywhere; }
.notify-toggle input { width: auto; margin: 0; flex: none; }
.next-appt { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem; max-width: 100%; margin: -.2rem 0 .7rem; padding: .45rem .85rem; border-radius: 10px; background: var(--primary-soft); border: 1px solid var(--primary); color: var(--text); font-size: .9rem; text-decoration: none; }
.next-appt:hover { text-decoration: none; filter: brightness(1.06); }
.next-appt .ic { font-size: 1.05rem; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .82rem; color: var(--muted); margin: .4rem 0; align-items: center; }
.legend .dot { width: 14px; height: 14px; }
.plan-size { display: inline-flex; gap: .2rem; }
.plan-size .chip { padding: .2rem .6rem; }

/* ---------- Dialoge und Hinweise */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 25, 15, .5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal { background: var(--surface); border-radius: 14px; padding: 1.2rem; width: min(440px, 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 .5rem; }
.modal p { margin: 0 0 .5rem; white-space: pre-line; }
.modal-input { width: 100%; padding: .55rem .65rem; font: inherit; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.modal-actions { justify-content: flex-end; }
#toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .92rem; z-index: 60; max-width: 90vw; box-shadow: var(--shadow); }
#toast.error { background: var(--danger); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }

/* ---------- Verwaltung */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.tabs button { padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; cursor: pointer; }
.tabs button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.userrow select { padding: .35rem .5rem; font: inherit; font-size: .88rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); max-width: 220px; }

.desktop-only { display: none; }
.mobile-only { display: initial; }
@media (min-width: 900px) {
  body { padding-bottom: 1rem; }
  .topnav { display: flex; }
  .tabbar { display: none; }
  .desktop-only { display: initial; }
  .mobile-only { display: none; }
  main { padding: 1.25rem 2rem; }
  .table th, .table td { padding: .55rem .8rem; }
}
@media (max-width: 599px) {
  .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .detail-head .img { width: 100%; height: 220px; }
}

/* ---------- Druck */
@media print {
  .topbar, .tabbar, .no-print, #toast, .toolbar, .summary { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  main { max-width: none; padding: 0; }
  .box { border: 0; box-shadow: none; padding: 0; }
  .table-wrap { border: 0; box-shadow: none; overflow: visible; }
  .table th { position: static; }
  .plan-wrap { overflow: visible; }
  .plan .cell { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  h1 { font-size: 1.2rem; }
}
