/* Unterrichtsmodus: Stoffplan, Stunden-Editor, Präsentation, Timer.
   Farben kommen aus den Variablen in index.html (:root). */

/* ---- Modus ---- */
.header-right { display: flex; align-items: center; gap: 10px; }
.mode-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mode-toggle button {
  min-height: 34px; padding: 6px 12px; font-size: 0.9em; font-family: inherit;
  background: var(--bg); color: var(--fg); border: none; cursor: pointer;
}
.mode-toggle button + button { border-left: 1px solid var(--border); }
.mode-toggle button.active { background: var(--fg); color: var(--bg); }
body[data-mode="unterricht"] .tracking-only { display: none !important; }
body:not([data-mode="unterricht"]) .unterricht-only { display: none !important; }
/* Editor braucht die volle Laptop-Breite */
body.wide { max-width: 1500px; }

.u-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; font-size: 0.85em; color: var(--muted); }
.u-toolbar input[type="date"] { width: auto; padding: 4px 8px; font-size: 14px; }
.u-btn {
  min-height: 30px; padding: 4px 10px; font-size: 0.9em; font-family: inherit; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer;
}
.u-btn:disabled { opacity: 0.4; cursor: default; }
.u-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ---- Stoffplan ---- */
#planTable td.when { color: var(--muted); font-variant-numeric: tabular-nums; }
#planTable tr.week-start td { border-top: 2px solid var(--border); }
#planTable tr.past td { opacity: 0.55; }
#planTable tr.next td { background: var(--ok-bg); }
#planTable tr.cancelled td.topic { color: var(--miss-fg); font-style: italic; }
#planTable tr.before td.topic, #planTable td.topic.empty { color: var(--muted); }
#planTable td.topic { width: 100%; white-space: normal; }
#planTable td.topic.has-lesson { cursor: pointer; }
#planTable td.topic.has-lesson:hover { text-decoration: underline; }
#planTable td.actions { text-align: right; }
#planTable td.actions .u-btn { min-height: 22px; padding: 1px 6px; font-size: 0.8em; margin-left: 4px; }
.part { font-size: 0.8em; color: var(--muted); margin-left: 6px; }
.pin { font-size: 0.8em; margin-left: 4px; }
.local-flag { font-size: 0.75em; color: var(--stale-fg); margin-left: 6px; }

/* ---- Stunden-Editor: alles auf einer Seite ---- */
.editor { display: grid; grid-template-columns: 260px 1fr; gap: 12px; height: calc(100vh - 210px); min-height: 520px; }
.lesson-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lesson-list .list { flex: 1; overflow-y: auto; }
.lesson-list .item {
  display: block; width: 100%; text-align: left; padding: 5px 8px; border: none; border-bottom: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font-family: inherit; font-size: 13px; cursor: pointer;
}
.lesson-list .item small { display: block; color: var(--muted); font-size: 11px; }
.lesson-list .item.active { background: var(--fg); color: var(--bg); }
.lesson-list .item.active small { color: var(--bg); opacity: 0.8; }
.lesson-list .bar { display: flex; gap: 4px; padding: 6px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.lesson-form { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.form-top { display: grid; grid-template-columns: 2fr 90px 110px 3fr; gap: 8px; }
.form-top label, .field label { margin: 0 0 2px; font-size: 12px; }
.form-top input, .form-top select { padding: 6px 8px; font-size: 14px; }
.form-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr 1fr; gap: 8px; }
.field { display: flex; flex-direction: column; min-height: 0; }
.field .box { flex: 1; min-height: 0; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.save-state { font-size: 12px; color: var(--muted); }

/* Eingabefeld mit eingebetteten Formeln */
.rich { min-height: 100%; padding: 6px 8px; font-size: 14px; line-height: 1.45; outline: none; white-space: pre-wrap; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.rich:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rich math-field {
  display: inline-block; vertical-align: middle; min-width: 1.5em; padding: 0 2px; font-size: 1.05em;
  border: none; border-radius: 4px; background: var(--panel); color: inherit; --primary: var(--fg);
}
.rich math-field::part(menu-toggle), .rich math-field::part(virtual-keyboard-toggle) { display: none; }
.rich img, .slide img { max-width: 100%; max-height: 40vh; vertical-align: middle; }
.items .pair { display: grid; grid-template-columns: 1fr 1fr 22px; border-bottom: 1px solid var(--line); }
.items .pair .rich { min-height: 2.2em; }
.items .pair .rich + .rich { border-left: 1px dashed var(--line); }
.items .pair button { border: none; background: none; color: var(--muted); cursor: pointer; }
.items .add { margin: 4px; }
.hint-line { font-size: 11px; color: var(--muted); }

/* ---- Präsentation ---- */
#presentation {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
#presentation[hidden] { display: none; }
.pres-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.pres-head .title { flex: 1; font-weight: 600; font-size: 1.1em; }
.pres-head .book { color: var(--muted); }
.pres-head button { min-width: 40px; height: 40px; font-size: 1.2em; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer; }
.pres-main { flex: 1; min-height: 0; overflow: hidden; padding: 18px 28px; cursor: pointer; }
.slide { height: 100%; overflow: hidden; line-height: 1.4; }
.slide h2 { margin: 0 0 0.5em; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.slide .goal { margin-top: 1em; padding: 0.4em 0.7em; border-left: 4px solid var(--ok-fg); background: var(--ok-bg); }
.slide ol { margin: 0; padding-left: 1.9em; } /* Platz für zweistellige Nummern */
.slide li { margin-bottom: 0.5em; }
.slide .answer { margin-top: 0.2em; color: var(--ok-fg); }
.slide .empty { color: var(--muted); }
.slide a { color: inherit; }
.pres-foot { display: flex; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); overflow-x: auto; }
.pres-foot button {
  flex: 1; min-height: 36px; font-size: 0.9em; font-family: inherit; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer;
}
.pres-foot button.empty { opacity: 0.3; }
.pres-foot button.active { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }

/* ---- Timer ---- */
.timer-bubble {
  position: fixed; z-index: 60; padding: 8px 14px; border-radius: 10px; font-size: 28px; font-weight: 600;
  font-variant-numeric: tabular-nums; background: var(--fg); color: var(--bg); pointer-events: none;
}
.timer-box {
  position: fixed; z-index: 55; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); touch-action: none; cursor: grab;
}
.timer-box .time { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2ch; }
.timer-box.paused .time { opacity: 0.45; }
.timer-box.done { background: var(--miss-bg); border-color: var(--miss-fg); animation: timer-flash 0.8s ease-in-out infinite alternate; }
.timer-box.done .time { color: var(--miss-fg); }
.timer-box button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--fg); font-size: 16px; cursor: pointer; }
@keyframes timer-flash { from { opacity: 1; } to { opacity: 0.55; } }
#timerIcon { touch-action: none; }
.nobr { white-space: nowrap; }

/* ---- HA-Besprechung (Folie nach Orga) ---- */
.slide.ha-slide { display: flex; flex-direction: column; }
.ha-task { flex: 0 0 25%; min-height: 0; display: flex; flex-direction: column; gap: 6px; overflow: hidden; line-height: 1.3; }
.ha-text { flex: 0 1 auto; min-height: 0; overflow: hidden; }
.ha-text:empty { display: none; }
.ha-task:not(.with-img) .ha-text { flex: 1 1 auto; }
.ha-task.with-img .ha-text { max-height: 35%; }
/* Aufgaben-Bild füllt den eingestellten Platz, ohne verzerrt oder abgeschnitten zu werden */
.ha-shots { flex: 1 1 0; min-height: 0; display: flex; gap: 10px; }
.ha-shots > div { position: relative; flex: 1 1 0; min-width: 0; }
.ha-shots img { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; object-fit: contain; object-position: left top; }
/* Trennbalken: Höhe der Aufgabe einstellen */
.ha-split { flex: 0 0 auto; height: 22px; margin: 2px 0 -6px; cursor: row-resize; touch-action: none; position: relative; }
.ha-split::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 1px; background: var(--line); }
.ha-split::after {
  content: ""; position: absolute; left: 50%; top: 6px; width: 56px; height: 9px; margin-left: -28px;
  border-radius: 5px; background: var(--border);
}
.ha-split.active::after { background: var(--fg); }
.ha-from { font-size: 0.55em; color: var(--muted); margin-top: 0.3em; }
.ha-picks { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0; font-size: 16px; }
.ha-picks button {
  min-height: 34px; padding: 4px 10px; font-size: 16px; font-family: inherit; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer;
}
.ha-picks button:disabled { opacity: 0.3; cursor: default; }
.ha-picks button.active { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }
.ha-note { margin: 0; font-size: 16px; color: var(--muted); }
.ha-viewer {
  flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom; padding-top: 4px; font-size: 16px; cursor: zoom-in;
}
.ha-viewer.zoomed { cursor: zoom-out; }
.ha-who { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.ha-file + .ha-file { margin-top: 12px; }
/* Standard: ganze Seite/ganzes Foto sichtbar; angetippt: auf volle Breite vergrößert */
.ha-viewer .ha-file img { display: block; margin: 0 auto; max-width: 100%; max-height: var(--fit-h, 55vh); }
.ha-viewer .ha-file canvas { display: block; margin: 0 auto 8px; box-shadow: 0 0 0 1px var(--border); max-width: 100%; max-height: var(--fit-h, 55vh); }
.ha-viewer.zoomed .ha-file img, .ha-viewer.zoomed .ha-file canvas { max-height: none; width: 100%; height: auto; }

/* Editor: Bild der HA-Aufgabe */
.img-drop {
  position: relative; margin-top: 6px; min-height: 54px; max-height: 120px; padding: 6px 8px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; color: var(--muted);
  border: 1.5px dashed var(--border); border-radius: 6px; outline: none;
}
.img-drop:focus, .img-drop.over { border-color: var(--fg); color: var(--fg); }
.img-drop.filled { border-style: solid; padding: 4px; }
.img-drop img { max-width: 100%; max-height: 108px; }
.img-drop .img-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); cursor: pointer;
}
.img-drop .link-btn { border: none; background: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* ---- Simulationen (Menü unter Stoffplan/Stunden) ---- */
.sim-box { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.sim-box[hidden] { display: none; }
.sim-box select { flex: 1 1 0; min-width: 0; padding: 7px 8px; font-size: 16px; }
.sim-box a.u-btn { flex: 0 0 auto; min-height: 36px; box-sizing: border-box; display: inline-flex; align-items: center; text-decoration: none; }
.sim-box a.u-btn.disabled { opacity: 0.4; pointer-events: none; }
