:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --border: #e2e0d8;
  --border-strong: #cfcdc4;
  --text: #2c2c2a;
  --text-2: #63625b;
  --text-3: #83817a;
  --info-bg: #ecedf7; --info: #37489c; --info-txt: #262d63;
  --good-bg: #eaf3de; --good: #639922; --good-txt: #27500a;
  --warn-bg: #faeeda; --warn: #ef9f27; --warn-txt: #633806;
  --bad-bg: #fcebeb; --bad: #e24b4a; --bad-txt: #791f1f;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
/* Dark Mode: neutrale & semantische Tokens umdefiniert; Fach-Kärtchen bleiben hell (farbige Notizzettel) */
:root[data-theme="dark"] {
  --bg: #1a1917;
  --surface: #24231f;
  --surface-2: #2d2b26;
  --border: #383630;
  --border-strong: #4a473f;
  --text: #eae7dd;
  --text-2: #b3afa3;
  --text-3: #8b877b;
  --info-bg: #2d3056; --info: #4657b5; --info-txt: #bcc3ee;
  --good-bg: #2b3a1e; --good: #8fbf4f; --good-txt: #bcd98d;
  --warn-bg: #3d3016; --warn: #eba43a; --warn-txt: #f0c88a;
  --bad-bg:  #3d201f; --bad:  #ec6b6a; --bad-txt:  #f0a5a4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--info); cursor: pointer; }
::selection { background: var(--info-bg); color: var(--info-txt); }

/* Sichtbarer Tastatur-Fokus (nur bei Keyboard, nicht bei Maus) */
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 3px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Navigation ---------- */
#nav {
  width: 172px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
}
.nav-brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 14px; }
.nav-logo {
  width: 30px; height: 30px;
  color: var(--info);
  display: flex; align-items: center; justify-content: center;
}
.nav-logo svg { width: 28px; height: 28px; }
.nav-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.nav-title { font-weight: 600; font-size: 15px; }
.nav-tagline { font-size: 10px; color: var(--text-3); letter-spacing: 0.02em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; color: var(--text-2);
  padding: 8px 10px; border-radius: var(--radius);
  font-size: 13px; text-align: left; width: 100%;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:active { background: var(--border); }
.nav-item.active { background: var(--info-bg); color: var(--info-txt); font-weight: 500; box-shadow: inset 2.5px 0 0 var(--info); }
/* Werkzeuge (kein data-view) sind sekundär – zurückgestuft */
.nav-item:not([data-view]) { font-size: 12.5px; padding: 6px 10px; color: var(--text-3); }
.nav-item:not([data-view]):hover { color: var(--text); }
.nav-item:not([data-view]) .nav-ic { font-size: 14px; }
.nav-ic { width: 18px; height: 18px; flex: none; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 15px; }
.nav-ic svg { width: 17px; height: 17px; display: block; }
.nav-spacer { flex: 1; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 6px; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; color: var(--text-3); padding: 8px 10px 3px; }
.nav-item:disabled { opacity: 0.35; cursor: default; }
.nav-item:disabled:hover { background: transparent; color: var(--text-2); }

/* ---------- Hauptbereich ---------- */
#main { flex: 1; overflow: auto; padding: 20px 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 20px; font-weight: 600; margin: 0; }
.section-h { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.section-hint { font-size: 11px; font-weight: 400; color: var(--text-3); margin-left: 6px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }

/* Segmented control */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; flex: none; }
.seg button { border: none; background: var(--surface); padding: 6px 12px; font-size: 13px; color: var(--text-2); border-left: 1px solid var(--border); white-space: nowrap; flex: none; transition: background 0.12s ease, color 0.12s ease; }
.seg button:first-child { border-left: none; }
.seg button:hover:not(.active) { background: var(--surface-2); color: var(--text); }
.seg button.active { background: var(--info-bg); color: var(--info-txt); font-weight: 500; }
.seg.board-mode button.active { background: var(--info); color: #fff; }
/* „Aus" als aktiver Zustand ist eine Deaktivierung → neutral statt Akzent */
.seg button.active[data-sev="off"] { background: var(--surface-2); color: var(--text-3); font-weight: 400; }

/* Regel-Zeilen */
.rule-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.rule-body { flex: 1; min-width: 0; font-size: 13px; }
.rule-kind { font-weight: 600; margin-bottom: 6px; }
.rule-dim { display: flex; align-items: baseline; gap: 8px; margin: 5px 0; flex-wrap: wrap; }
.rule-dim-lbl { font-size: 12px; color: var(--text-2); width: 138px; flex: none; }
.rule-dim .chips { flex: 1; }
.rule-scalars { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rule-body input { flex: none; }
.rule-row .x { flex: none; cursor: pointer; color: var(--text-3); background: none; border: none; font-size: 17px; line-height: 1; }

.select {
  padding: 6px 30px 6px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background-color: var(--surface); font-size: 13px; color: var(--text);
  min-width: 160px;
}
.btn {
  padding: 6px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); font-size: 13px; color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* ---------- Steckbrett ---------- */
.board-layout { display: flex; flex-direction: column; gap: 12px; }
.board-hint { font-size: 12.5px; color: var(--info-txt); background: var(--info-bg); border: 1px solid var(--info); border-radius: var(--radius); padding: 7px 12px; }
.board-note { font-size: 12.5px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

.pool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.pool-head { font-size: 12px; color: var(--text-2); margin-bottom: 8px; display:flex; flex-wrap: wrap; gap: 6px 10px; justify-content:space-between; align-items: center; }
.pool.collapsed .pool-head { margin-bottom: 0; }
.pool-toggle { border: none; background: transparent; color: var(--text-2); font-size: 12px; cursor: pointer; padding: 2px 4px 2px 0; display: flex; align-items: center; gap: 6px; border-radius: 5px; }
.pool-toggle:hover { color: var(--text); }
.pool-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; }
.pool-tools-lbl { font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.pool-tools-lbl:not(:first-child) { margin-left: 8px; }
.pool-sel { width: auto; font-size: 12px; padding: 4px 26px 4px 9px; border-radius: var(--radius-sm); }
.pool-cards { display: flex; flex-wrap: wrap; gap: 7px; min-height: 46px; background: var(--surface-2); border-radius: var(--radius); padding: 8px; }
.pool-group { flex: 1 1 100%; }
.pool-group + .pool-group { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 8px; }
.pool-group-h { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 6px; }
.pool-group-n { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 0 6px; font-size: 10px; font-weight: 600; color: var(--text-3); }
.pool-group-cards { display: flex; flex-wrap: wrap; gap: 7px; }
.pool-empty { flex: 1 1 100%; text-align: center; padding: 12px 0; }

.card {
  border-radius: var(--radius-sm); padding: 5px 8px; min-width: 86px;
  cursor: grab; user-select: none; line-height: 1.25;
  border: 1px solid var(--c-accent, transparent);
  background: var(--c-bg, var(--surface));
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: box-shadow 0.12s ease, transform 0.08s ease;
}
.card .c-main { color: var(--c-text); }
.card .c-sub  { color: color-mix(in srgb, var(--c-accent) 55%, var(--c-text)); }
.card:not(.mini):hover { box-shadow: 0 4px 10px rgba(0,0,0,0.13); transform: translateY(-1px); }
.card:active { cursor: grabbing; transform: none; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
/* Stapel identischer Kärtchen: statische Karten dahinter (::before/::after), Ränder unten & links sichtbar */
/* eigener Stacking-Context, damit die z-index:-1-Sheets NICHT hinter dem Container-Hintergrund verschwinden */
.card.stacked { isolation: isolate; }
.card.stacked::before, .card.stacked::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: inherit;
  border: 1px solid var(--c-accent, var(--border-strong));
}
.card.stacked::before { transform: translate(-3px, 3px); }
.card.stacked::after  { transform: translate(-6px, 6px); }
/* Stapel bleiben beim Hovern statisch – kein Anheben, kein wachsender Schatten */
.card.stacked:not(.mini):hover { transform: none; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
/* Schrift leicht nach unten versetzt → wirkt wie das oberste Blatt des Stapels */
.card.stacked .c-main, .card.stacked .c-sub { transform: translateY(2px); }
/* Dark-Mode: Kärtchen einheitlich dunkel; Fachfarbe wird zur Akzentkante + Schriftfarbe */
[data-theme="dark"] .card:not(.coupling) {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--c-accent) 45%, var(--border));
  border-left: 3px solid var(--c-accent);
}
[data-theme="dark"] .card:not(.coupling) .c-main { color: color-mix(in srgb, var(--c-accent), white 45%); }
[data-theme="dark"] .card:not(.coupling) .c-sub  { color: color-mix(in srgb, var(--c-accent), white 20%); }
.card .c-main { font-size: 12px; font-weight: 600; }
.card .c-corner { position: absolute; top: -10px; right: -8px; display: flex; align-items: center; font-size: 23px; line-height: 1; pointer-events: none; z-index: 2; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.3)); }
.card .c-corner span + span { margin-left: -8px; }
/* Stapel-Anzahl: knalliges Rot mit dünnem Rand (dunkel/hell je nach Theme) */
.card .c-corner .c-count { font-size: 16px; font-weight: 800; line-height: 1; color: #ff1f1f; -webkit-text-stroke: 0.6px rgba(255,255,255,0.8); paint-order: stroke fill; }
.card .c-corner .c-count + span { margin-left: 3px; }
[data-theme="dark"] .card .c-corner .c-count { -webkit-text-stroke: 0.6px rgba(0,0,0,0.6); }
.card.mini .c-corner { font-size: 19px; top: -8px; right: -6px; }
.card .c-sub { font-size: 10px; }
.card.selected { outline: 2px solid var(--info); outline-offset: 2px; box-shadow: 0 0 0 4px var(--info-bg), 0 4px 12px rgba(0,0,0,0.16); }
.card.mini { min-width: 0; width: 100%; padding: 4px 7px; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.card.mini .c-main { font-size: 12.5px; }
.card.mini .c-sub { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.9; }

/* Kopplung (klassenübergreifende Stunde) */
.card.coupling { background: var(--surface); border: 1px solid var(--border-strong); min-width: 108px; }
.card.coupling.mini { min-width: 0; }
.cpl-edit { position: absolute; top: 3px; right: 4px; border: none; background: transparent; color: var(--text-3); font-size: 13px; line-height: 1; cursor: pointer; padding: 2px; }
.cpl-edit:hover { color: var(--info); }
.cpl-head { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 3px; padding-right: 14px; display: flex; align-items: center; gap: 4px; }
.cpl-ic { width: 13px; height: 13px; flex: none; }
.cpl-groups { display: flex; flex-direction: column; gap: 3px; }
.cpl-g { border: 1px solid transparent; border-radius: 5px; padding: 2px 5px; font-size: 11px; line-height: 1.2; }
.cpl-g .cpl-s { font-weight: 600; }
.cpl-g .cpl-t { opacity: 0.9; }
.cpl-g .cpl-lbl { display: block; font-size: 10px; opacity: 0.8; }
.cpl-class { margin-bottom: 10px; }
.cpl-class-h { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.cpl-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--border); }
.cpl-row:first-child { border-top: none; }
.cpl-row select { flex: 1; min-width: 0; }
.cpl-row .x { flex: none; cursor: pointer; color: var(--text-3); background: none; border: none; font-size: 15px; }

.legend { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-3); }
.legend.show { color: var(--text-2); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.legend .hint { margin-left: auto; color: var(--text); font-weight: 500; }

/* Raster */
.grid { display: grid; gap: 4px; }
.grid .colhead { text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-2); padding: 2px 0 6px; border-bottom: 1px solid var(--border); }
.grid .rowhead { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; color: var(--text-3); }
.cell {
  min-height: 52px; background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 3px; display: flex; align-items: stretch; justify-content: center; gap: 3px;
  transition: background 0.08s, border-color 0.08s;
  position: relative;
}
.cell.filled { border-style: solid; padding: 2px; }
/* gesteckte Karten füllen die Zelle aus, statt klein in der Mitte zu sitzen */
.cell.filled > .card { flex: 1; align-self: stretch; }
/* nur bearbeitbare (klassengebundene) leere Zellen zeigen Ablage-Feedback */
.cell[data-cls]:not(.filled):hover { border-color: var(--info); background: var(--info-bg); }
.cell.bad { background: var(--bad-bg); border-color: var(--bad); }
.cell.warn { background: var(--warn-bg); border-color: var(--warn); }
.cell.heat-good { background: var(--good-bg); border-color: var(--good); }
.cell.heat-warn { background: var(--warn-bg); border-color: var(--warn); }
.cell.heat-bad { background: var(--bad-bg); border-color: var(--bad); }
.cell.dim { opacity: 0.35; }
.cell .warnmark { position: absolute; top: 0; left: 2px; font-size: 12px; line-height: 1; z-index: 3; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
[data-theme="dark"] .cell .warnmark { text-shadow: 0 0 2px var(--surface), 0 0 3px var(--surface); }
.grid-break { grid-column: 1 / -1; text-align: center; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border-radius: 4px; padding: 1px 0; }
.grid-daysep { grid-column: 1 / -1; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); background: var(--surface-2); border-radius: 4px; padding: 3px 8px; margin-top: 6px; position: sticky; top: 0; z-index: 1; }
.grid-all .cell { min-height: 40px; }
.grid-all .colhead { position: sticky; top: 0; background: var(--bg); z-index: 2; }

/* ---------- Gesundheits-Panel (immer sichtbar) ---------- */
/* Lehrkräfte-Leiste + Plan-Gesundheit kleben gemeinsam unten und liegen über dem Raster */
.board-footer {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg); padding-top: 8px; margin-top: 2px;
}
#health {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 10px 14px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
#health.bad { border-color: var(--bad); background: var(--bad-bg); }
#health.warn { border-color: var(--warn); }
.health-score { text-align: center; min-width: 60px; }
.health-score .lbl { font-size: 11px; color: var(--text-2); }
.health-score .val { font-size: 24px; font-weight: 600; }
.health-score .delta { font-size: 12px; margin-left: 4px; }
.health-sep { width: 1px; align-self: stretch; background: var(--border-strong); }
.health-issues { font-size: 12px; color: var(--text-2); flex: 1; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.health-issues .ok { color: var(--good-txt); }
.pill { display:inline-flex; align-items:center; gap:5px; }
.pill .d { width: 8px; height: 8px; border-radius: 50%; }

/* Zufriedenheits-Panel */
#satisfaction { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 14px; box-shadow: 0 -2px 10px rgba(0,0,0,0.06); max-height: 40vh; overflow: auto; }
.sat-head { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-2); position: sticky; top: -10px; background: var(--surface); padding: 2px 0 9px; margin: -2px 0 0; z-index: 1; }
.tinfo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 9px; }
.tinfo-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; cursor: help; transition: border-color 0.12s ease, box-shadow 0.12s ease; }
.tinfo-card:hover { border-color: var(--border-strong); box-shadow: 0 2px 6px rgba(0,0,0,0.07); }
.tinfo-head { display: flex; align-items: center; gap: 6px; }
.tinfo-emoji { font-size: 16px; line-height: 1; }
.tinfo-k { font-weight: 600; font-size: 13px; }
.tinfo-lbl { margin-left: auto; font-size: 11px; font-weight: 500; }
.tinfo-name { font-size: 11px; color: var(--text-2); margin: 1px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tinfo-num { font-size: 21px; font-weight: 600; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tinfo-den { font-size: 13px; color: var(--text-3); font-weight: 400; }
.tinfo-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* ---------- Tabellen / Listen ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.tile h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); display:flex; align-items:center; justify-content:center; font-weight:600; font-size:12px; }
.t-emoji { font-size: 24px; line-height: 1; flex: none; }
.emoji-current { font-size: 30px; line-height: 1.1; height: 38px; display: flex; align-items: center; justify-content: center; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-opt { font-size: 19px; line-height: 1; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0; transition: background 0.1s ease, transform 0.08s ease, border-color 0.1s ease; }
.emoji-opt:hover { background: var(--surface-2); border-color: var(--text-3); transform: translateY(-1px); }
.emoji-opt:active { transform: translateY(0); }
.emoji-opt.sel { border-color: var(--info); box-shadow: 0 0 0 2px var(--info-bg); }
.hint-warn { font-size: 11px; color: var(--warn-txt); background: var(--warn-bg); border-radius: var(--radius); padding: 5px 8px; margin-top: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 32px; height: 32px; border-radius: 8px; border: 1px solid; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: box-shadow 0.12s ease, transform 0.08s ease; }
.swatch:hover { transform: translateY(-1px); }
.swatch span { width: 12px; height: 12px; border-radius: 50%; display: block; }
.swatch:hover { box-shadow: 0 0 0 2px var(--border-strong); }
.swatch.sel { box-shadow: 0 0 0 2px var(--info); }
.swatch-custom { position: relative; overflow: hidden; }
.swatch-custom input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: none; }
.swatch-custom span { box-shadow: 0 0 0 1px rgba(0,0,0,0.15) inset; }
.row { display: flex; align-items: center; gap: 10px; }
.tag { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 8px; }
.wish { display:flex; align-items:center; gap:8px; font-size:12px; padding: 3px 0; }
.wish .d { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.placeholder { color: var(--text-2); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 40px; text-align: center; }

/* Formularelemente */
input[type=text], input[type=number], select, textarea {
  font-family: inherit; font-size: 13px; padding: 7px 9px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; background: var(--surface-2); }
/* einheitlicher Dropdown-Chevron statt OS-Default */
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2363625b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
  padding-right: 26px;
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23b3afa3' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.btn.primary { background: var(--info); color: #fff; border-color: var(--info); font-weight: 500; }
.btn.primary:hover { background: color-mix(in srgb, var(--info), #000 16%); border-color: color-mix(in srgb, var(--info), #000 16%); }
.btn.danger  { color: var(--bad-txt); border-color: var(--bad); }
.btn.danger:hover  { background: var(--bad-bg); border-color: var(--bad); }
.tile.clickable { cursor: pointer; transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, transform 0.1s ease; }
.tile.clickable:hover { border-color: var(--border-strong); box-shadow: 0 4px 10px rgba(0,0,0,0.1); transform: translateY(-2px); }
.tile.clickable:active { transform: translateY(0); box-shadow: 0 2px 5px rgba(0,0,0,0.08); }
.tile-edit { font-size: 11px; color: var(--text-3); opacity: 0.8; transition: color 0.12s ease, opacity 0.12s ease; }
.tile.clickable:hover .tile-edit { color: var(--info); opacity: 1; }

/* Dialog (Modal) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(30,28,24,0.4); backdrop-filter: blur(2px); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in 0.12s ease; }
/* KEINE Animation auf .modal: Editoren bauen ihren Inhalt bei jeder Änderung neu
   auf (draw() erzeugt ein neues .modal), sonst würde die Animation neu starten und
   flackern. Die sanfte Entrance macht der Backdrop (fade-in, bleibt bestehen). */
.modal { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 400px; max-width: 100%; max-height: calc(100vh - 48px); overflow: auto; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.28); }
.modal-x { position: absolute; top: 10px; right: 12px; width: 28px; height: 28px; border: none; background: transparent; color: var(--text-3); font-size: 15px; line-height: 1; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.12s ease, color 0.12s ease; }
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal h3 { padding-right: 28px; }
.modal-section { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.help-body ul { margin: 4px 0 6px; padding-left: 18px; }
.help-body li { margin: 4px 0; font-size: 13px; }
.help-keys td { padding: 3px 12px 3px 0; font-size: 13px; }
kbd { font-family: var(--font); font-size: 11px; background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--text); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
.modal.wide { width: 580px; padding: 22px 26px; }
.modal.classwide { width: 680px; }
.modal.teacherwide { width: min(1500px, 96vw); }
/* Verfügbarkeit & Wünsche nebeneinander; brechen auf schmalen Screens untereinander um */
.te-cols { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.te-col { min-width: 0; }
.te-col-avail { flex: 1 1 360px; }
.te-col-wishes { flex: 1 1 300px; }
.modal.wide .field { margin-bottom: 16px; }
.modal.wide .avail-cell { height: 26px; }
.modal.wide .wish-edit { padding: 7px 0; }
.modal h3 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.hint, .field .hint { font-size: 11px; color: var(--text-3); margin-top: 4px; line-height: 1.4; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 18px; }
.modal-actions .right { display: flex; gap: 8px; }
.modal-actions .btn { min-width: 92px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack .btn { text-align: center; padding: 9px 12px; }
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 8px; margin: 0 -8px; cursor: pointer; border-radius: 7px; transition: background 0.12s ease; }
.radio-row:hover { background: var(--surface-2); }
.radio-row input { width: auto; margin: 2px 0 0; flex: none; }
.radio-row + .radio-row { border-top: 1px solid var(--border); }

/* Chips (Mehrfachauswahl) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle { font-size: 12px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); cursor: pointer; user-select: none; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease; }
.chip-toggle:hover { border-color: var(--text-3); background: var(--surface-2); }
.chip-toggle.on { background: var(--info-bg); border-color: var(--info); color: var(--info-txt); }
.chip-toggle.on:hover { background: color-mix(in srgb, var(--info-bg), var(--info) 20%); }

/* Verfügbarkeits-Raster im Dialog */
.avail-grid { display: grid; gap: 3px; }
.avail-grid .h { font-size: 11px; color: var(--text-2); text-align: center; }
.avail-grid .rh { font-size: 11px; color: var(--text-3); display: flex; align-items: center; justify-content: center; }
.avail-grid .clickable { cursor: pointer; border-radius: 4px; transition: background 0.1s ease, color 0.1s ease; }
.avail-grid .clickable:hover { background: var(--surface-2); color: var(--text); }
.avail-cell { height: 22px; border-radius: 4px; cursor: pointer; background: var(--surface-2); border: 1px solid var(--border); user-select: none; }
.avail-cell:hover { border-color: var(--text-3); }
.avail-cell.like    { background: var(--good-bg); border-color: var(--good); }
.avail-cell.dislike { background: var(--warn-bg); border-color: var(--warn); }
.avail-cell.blocked { background: var(--bad-bg);  border-color: var(--bad); }
.avail-legend { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--text-2); margin: 6px 0 8px; }
.avail-legend .brush { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 10px 3px 8px; cursor: pointer; transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease; }
.avail-legend .brush:hover { border-color: var(--text-3); }
.avail-legend .brush.on { border-color: var(--info); background: var(--info-bg); color: var(--info-txt); box-shadow: 0 0 0 1px var(--info); font-weight: 600; }
.avail-legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; border: 1px solid var(--border); }
.avail-legend .sw.like    { background: var(--good-bg); border-color: var(--good); }
.avail-legend .sw.dislike { background: var(--warn-bg); border-color: var(--warn); }
.avail-legend .sw.block   { background: var(--bad-bg);  border-color: var(--bad); }

/* Deputat-Liste */
.dep-list { margin: 4px 0 10px; }
.dep-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.dep-row:first-child { border-top: none; }
.dep-row .dep-subj { width: 118px; flex: none; }
.dep-row .dep-subj .tag { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.dep-row select { flex: 1; min-width: 0; }
.dep-count { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.dep-count .n { min-width: 16px; text-align: center; }
.dep-count button { width: 24px; height: 24px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); line-height: 1; padding: 0; transition: background 0.12s ease, border-color 0.12s ease; }
.dep-count button:hover { background: var(--surface-2); border-color: var(--text-3); }
.dep-count button:active { transform: translateY(1px); }
.dep-row .x { flex: none; cursor: pointer; color: var(--text-3); background: none; border: none; font-size: 15px; transition: color 0.12s ease; }
.dep-row .x:hover, .rule-row .x:hover, .cpl-row .x:hover { color: var(--bad); }
.dep-more { flex: none; cursor: pointer; width: 24px; height: 24px; padding: 0; line-height: 1; font-size: 14px; color: var(--text-3); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease; }
.dep-more:hover { background: var(--surface-2); color: var(--text-2); }
.dep-more.on { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.dep-row.sub { border-top: none; padding: 0 0 4px; margin-top: -4px; }
.dep-row.sub .dep-dbl { text-align: right; color: var(--text-3); font-size: 14px; padding-right: 4px; }
.dep-row.sub select { flex: none; width: 132px; font-size: 12px; padding: 4px 8px; }
.dep-row.sub .dep-fill { flex: 1; }
.add-dep { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.add-dep select { flex: 1; }
.wish-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 5px 0; font-size: 12px; }
.wish-edit + .wish-edit { border-top: 1px solid var(--border); }
.wish-edit .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 15px; }
.wish-edit .x:hover { color: var(--bad); }

/* Merkpunkte */
.cp-list { margin-top: 6px; max-height: 300px; overflow: auto; }
.cp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.cp-row:first-child { border-top: none; }
.cp-row .right { display: flex; gap: 6px; align-items: center; }

/* Offene Karten (Lehrkraft noch nicht gewählt) */
.card.open { border-style: dashed; }
.card.open .c-main { font-style: italic; }

/* Lehrer-Auswahlfenster (Popover) */
.pop-backdrop { position: fixed; inset: 0; z-index: 50; background: transparent; }
.popover {
  position: fixed; z-index: 51; width: 264px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(0,0,0,0.16); padding: 10px 12px;
  animation: pop-in 0.11s ease;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } to { opacity: 1; transform: none; } }
.popover h4 { margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.popover .pop-sub { font-size: 11px; color: var(--text-2); margin-bottom: 8px; }
.pop-list { display: flex; flex-direction: column; gap: 2px; max-height: 230px; overflow: auto; }
.pop-teacher { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; transition: background 0.1s ease; }
.pop-teacher:hover { background: var(--surface-2); }
.pop-teacher .d { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pop-teacher .nm { font-weight: 500; }
.pop-teacher .why { font-size: 11px; color: var(--text-2); margin-left: auto; text-align: right; }
.pop-teacher.current { background: var(--info-bg); }
.pop-slot-label { font-size: 11px; color: var(--text-2); margin: 8px 0 4px; display: flex; align-items: center; gap: 6px; }
.pop-mini { margin-left: auto; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 4px; width: 20px; height: 20px; line-height: 1; color: var(--text-3); cursor: pointer; }
.dbl-badge { font-size: 11px; opacity: 0.75; }
.card.double { border-style: double; border-width: 3px; }
.pop-empty { font-size: 12px; color: var(--text-2); padding: 6px 8px; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.pop-actions .btn { flex: 1 1 auto; text-align: center; font-size: 12px; padding: 5px 8px; white-space: nowrap; }

/* ---------- Drucken / PDF ---------- */
#print-area { display: none; }
.print-preview { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.print-plan { margin-bottom: 18px; }
.print-plan h2 { font-size: 15px; margin: 0 0 6px; }
.print-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.print-grid th, .print-grid td { border: 1px solid var(--border-strong); padding: 4px 5px; vertical-align: top; text-align: left; }
.print-grid thead th { background: var(--surface-2); font-size: 11px; text-align: center; }
.print-grid tbody th { width: 42px; font-size: 10px; color: var(--text-2); text-align: center; font-weight: 500; }
.print-grid .pcorner { width: 42px; }
.print-grid .pcell { font-size: 10px; line-height: 1.3; padding: 1px 0 1px 5px; }
.print-grid .pcell + .pcell { border-top: 1px dashed var(--border); margin-top: 3px; padding-top: 3px; }
.print-foot { font-size: 10px; color: var(--text-3); margin-top: 6px; }
.print-grid .pcell b { display: block; font-size: 11px; }
.print-grid .pcell span { display: block; color: var(--text-2); }

@media print {
  #app { display: none !important; }
  .modal-backdrop { display: none !important; }
  #print-area { display: block !important; color: #1a1a1a; background: #fff; }
  #print-area, #print-area * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-area .print-plan { page-break-after: always; break-after: page; }
  #print-area .print-plan:last-child { page-break-after: auto; break-after: auto; }
  #print-area h2 { font-size: 17px; margin: 0 0 10px; }
  /* Zeilen füllen die Seite (Höhe kommt aus --print-rowh, in JS nach Stundenzahl berechnet) */
  #print-area .print-grid tbody tr { height: var(--print-rowh, 2cm); }
  #print-area .print-grid th, #print-area .print-grid td { border: 1px solid #999; vertical-align: top; }
  #print-area .print-grid td { padding: 4px 5px; }
  #print-area .print-grid thead th { background: #eee; height: auto; }
  #print-area .print-grid tbody th { color: #555; }
  #print-area .pcell { font-size: 11px; }
  #print-area .pcell b { font-size: 12.5px; }
  #print-area .pcell span { color: #333; }
  #print-area .print-foot { color: #777; margin-top: 8px; }
}

/* ---------- Responsive: schmale Bildschirme ---------- */
@media (max-width: 720px) {
  #nav { width: 54px; padding: 10px 6px; }
  .nav-brand-text, .nav-lbl, .nav-section, .nav-tagline { display: none; }
  .nav-brand { justify-content: center; padding: 4px 0 10px; }
  .nav-item { justify-content: center; padding: 9px 6px; gap: 0; }
  #main { padding: 14px 12px; }
  .card-grid { grid-template-columns: 1fr; }
  #health { flex-wrap: wrap; gap: 10px 14px; }
  .modal.wide { width: 100%; padding: 18px 16px; }
  .page-head { gap: 8px; }
  .page-head .row { flex-wrap: wrap; width: 100%; }
  .page-head .select { min-width: 0; flex: 1 1 100%; }
}
