:root {
  --bg: #f4f5f8; --card: #fff; --text: #1b1f27; --muted: #667085; --line: #e1e4ea;
  --accent: #2f6fed; --ok: #1f9d55; --warn: #c62f2f; --soft-l: 95%; --ink-l: 32%;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12141a; --card: #1c1f27; --text: #e8eaf0; --muted: #98a1b3; --line: #2c313c; --accent: #6f9bff; --ok: #4cc38a; --warn: #ff7b7b; --soft-l: 20%; --ink-l: 78%; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .error { color: var(--warn); }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; }
.topbar nav a.active { background: var(--accent); color: #fff; }
.topbar .who { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; }
.flash.notice { background: hsl(145 55% var(--soft-l)); } .flash.alert { background: hsl(0 75% var(--soft-l)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0 0 14px; }
.card.narrow { max-width: 520px; margin: 24px auto; }
.stack { display: grid; gap: 12px; } .stack.spaced { margin-top: 16px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; min-width: 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; } legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 1rem; }
.button { display: inline-block; font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; cursor: pointer; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.warn { color: var(--warn); border-color: var(--warn); }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
form.inline { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.copy { display: flex; gap: 8px; margin: 8px 0; } .copy input { font-size: .85rem; }
details summary { cursor: pointer; }

.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.weeknav h1 { margin: 0; flex: 1; text-align: center; font-size: 1.1rem; }
.week { display: grid; gap: 12px; }
@media (min-width: 900px) { .week { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); align-items: start; } }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; scroll-margin-top: 60px; min-width: 0; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.day.past { opacity: .75; }
.day h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: hsl(35 90% var(--soft-l)); color: hsl(30 80% var(--ink-l)); }
.badge.ok { background: hsl(145 55% var(--soft-l)); color: var(--ok); }

.slot { border-left: 4px solid hsl(var(--hue, 220) 60% 55%); padding: 4px 0 4px 8px; margin: 6px 0; }
.slot-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.slot .hour { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 1.6em; }
.slot .subject { font-weight: 600; overflow-wrap: break-word; hyphens: auto; min-width: 0; }
.slot .room { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.slot .tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--warn); }
.slot .tag.change { color: hsl(30 80% var(--ink-l)); }
.slot.cancelled { border-left-color: var(--line); } .slot.cancelled .subject { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.slot.event { border-left-style: dashed; } .slot.loose { border-left-color: var(--muted); }

.task { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; padding: 8px; border-radius: 10px; background: hsl(var(--hue, 220) 70% var(--soft-l)); }
.task.done { background: transparent; outline: 1px dashed var(--line); }
.task.done .task-text { text-decoration: line-through; color: var(--muted); }
.check-form { flex: none; }
.check { width: 28px; height: 28px; border-radius: 8px; border: 2px solid hsl(var(--hue, 220) 45% 50%); background: var(--card); color: #fff; font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer; padding: 0; }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task.before-start { background: transparent; outline: 1px dashed var(--line); color: var(--muted); }
.task-body { min-width: 0; flex: 1; }
.task-text { overflow-wrap: anywhere; }
.task-meta { color: var(--muted); font-size: .75rem; margin-top: 2px; }
.subject-tag { display: inline-block; font-size: .75rem; font-weight: 700; color: hsl(var(--hue, 220) 55% var(--ink-l)); }

.list { margin: 0 0 18px; max-width: 720px; } .list.overdue h2 { color: var(--warn); }
.footer-line { margin-top: 16px; }
.card.danger h2 { color: var(--muted); }
.warning { margin: 8px 0; padding: 8px 12px; border-radius: 10px; border-left: 4px solid var(--warn); background: hsl(0 75% var(--soft-l)); }
.warning strong { color: var(--warn); }

.log { max-width: 720px; }
.log-day { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 14px; overflow: hidden; }
.log-day h2 { margin: 0; padding: 8px 12px; text-align: center; font-size: .95rem; background: var(--accent); color: #fff; }
.log-day.today h2::after { content: " · heute"; font-weight: 400; }
.log-body { padding: 4px 12px 10px; }
.log-body h3 { font-size: .95rem; margin: 10px 0 2px; color: hsl(var(--hue, 220) 55% var(--ink-l)); }
@media (max-width: 520px) { .topbar .who { display: none; } .topbar nav a { padding: 6px 8px; } }

.protocol table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.protocol td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.protocol tr:first-child td { border-top: 0; }
.protocol .time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; }
.protocol .system strong { color: var(--muted); } .protocol .failed .detail { color: var(--warn); }
.protocol .detail { color: var(--muted); }

.note { margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--card); border-left: 3px solid hsl(45 90% 55%); font-size: .9rem; overflow-wrap: anywhere; }
.note-edit { margin-top: 4px; }
.note-open { color: var(--muted); font-size: .8rem; text-decoration: none; }
.task-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / .25); }
.task-dialog::backdrop { background: rgb(0 0 0 / .45); }
.task-dialog-body { display: grid; gap: 12px; padding: 16px; }
.task-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task-dialog .subject-tag { font-size: .9rem; }
.dialog-close { font: inherit; line-height: 1; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.dialog-close:hover { background: var(--bg); }
.dialog-task { max-height: 9rem; overflow-y: auto; padding: 8px 10px; border-radius: 10px; background: hsl(var(--hue, 220) 70% var(--soft-l)); overflow-wrap: anywhere; }
.note-edit textarea { font: inherit; font-weight: 400; width: 100%; min-height: 9rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); resize: vertical; }
.note-edit .row { align-items: center; margin-top: 8px; }
.small-button { padding: 5px 12px; font-size: .85rem; }

.termin { font-weight: 700; color: var(--text); } .termin.urgent { color: var(--warn); }
.termin-hint { font-weight: 700; color: hsl(30 80% var(--ink-l)); }
.termin-form { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.termin-form label { font-size: .8rem; } .termin-form input[type=date] { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); max-width: 200px; }
.watch-strip { max-width: 1280px; margin: 0 0 14px; padding: 8px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; background: var(--card); }
.watch-strip h2 { font-size: .9rem; margin: 0 0 4px; color: var(--muted); }
.watch-strip ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.watch-strip li a { display: block; padding: 5px 10px; border-radius: 10px; background: hsl(var(--hue, 220) 70% var(--soft-l)); color: var(--text); text-decoration: none; font-size: .9rem; }
.watch-strip .when { color: var(--muted); font-size: .8rem; white-space: nowrap; } .watch-strip .urgent .when { color: var(--warn); font-weight: 700; }
.watch-strip h2 .muted { font-weight: 400; } .watch-strip .done a { background: transparent; outline: 1px dashed var(--line); } .watch-strip .done .what { text-decoration: line-through; color: var(--muted); }
.task:target { outline: 2px solid var(--accent); }
.brand { font-weight: 800; letter-spacing: -.02em; color: var(--accent); text-decoration: none; margin-right: 4px; }
.brand.big { font-size: 1.8rem; margin: 0 0 4px; }
.topbar { justify-content: flex-start; } .topbar .who { margin-left: auto; }
@media (max-width: 520px) { .topbar .brand { display: none; } }

.site-footer { max-width: 1280px; margin: 8px auto 24px; padding: 0 16px; color: var(--muted); font-size: .8rem; }
.site-footer a { color: var(--muted); }
.prose { max-width: 720px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.prose h2 { margin-top: 22px; } .prose h3 { font-size: .95rem; margin: 14px 0 4px; } .prose ul { padding-left: 20px; } .prose li { margin: 4px 0; }

.help h2 { scroll-margin-top: 60px; padding-top: 14px; border-top: 1px solid var(--line); }
.help h3 { font-size: 1rem; margin: 16px 0 2px; } .help h3 + p { margin-top: 2px; }
.help dt { font-weight: 700; margin-top: 8px; } .help dd { margin: 0 0 0 0; color: var(--text); }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.help-toc a { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; font-size: .85rem; color: var(--text); }

.regenerate { margin: 6px 0; }

.exam-kind { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--warn); }
.watch-strip li.exam a { outline: 2px solid hsl(var(--hue, 220) 55% 55%); outline-offset: -2px; }
.later-exams { margin-top: 8px; font-size: .9rem; } .later-exams summary { color: var(--text); font-weight: 600; } .later-exams ul { margin-top: 6px; }
.exam-line { margin: 6px 0; padding: 6px 8px; border-radius: 10px; border: 2px solid hsl(var(--hue, 220) 55% 55%); background: hsl(var(--hue, 220) 70% var(--soft-l)); scroll-margin-top: 60px; }
.exam-line:target { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }

.stats section { max-width: 720px; margin: 0 0 18px; } .stats section.wide { max-width: 960px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; max-width: 960px; margin: 14px 0 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.tile dt { color: var(--muted); font-size: .85rem; } .tile dd { margin: 2px 0 0; font-size: 1.9rem; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile.bad { border-color: var(--warn); } .tile .mark { color: var(--warn); font-size: 1.2rem; }
.stats table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stats th, .stats td { padding: 7px 10px; border-top: 1px solid var(--line); text-align: left; font-weight: 400; overflow-wrap: anywhere; }
.stats tr:first-child th, .stats tr:first-child td { border-top: 0; }
.stats td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.stats .failed th, .stats td.failed { color: var(--warn); } .stats td.zero { color: var(--muted); font-weight: 400; }
.stats .scroll { overflow-x: auto; } .stats .daily { min-width: 620px; }
.stats thead th { color: var(--muted); font-size: .8rem; text-align: right; vertical-align: bottom; overflow-wrap: normal; } .stats thead th:first-child { text-align: left; }
.stats .daily tbody th { white-space: nowrap; }

.hint { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.hint::after, .hint-mark { content: "?"; display: inline-block; width: 1.25em; height: 1.25em; margin-left: .3em; border-radius: 50%; border: 1px solid currentColor; font-size: .7em; font-weight: 700; line-height: 1.15em; text-align: center; vertical-align: .1em; text-decoration: none; opacity: .75; }
.hint-mark { margin: 0 .1em; }
.hint:hover::after { opacity: 1; }
.hint-pop { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / .25); }
.hint-pop::backdrop { background: rgb(0 0 0 / .3); }
.hint-pop h2 { margin: 0 0 8px; } .hint-pop p { margin: 0 0 10px; } .hint-pop .row { align-items: center; margin-top: 4px; }
/* Browsers without popovers would show every explanation at the end of the page. */
@supports not selector(:popover-open) { .hint-pop { display: none; } }
