/* Stundenpläne FB 2 — styles
   House style of hwr-berlin.de (values measured there on 2026-10-14): DIN with letter-spacing
   .3px, bold black headings, 15px meta text in #4a4d50, Crimson Text for sheet titles, HWR red
   #d50c2f with white sentence-case labels, square corners, white page, hairlines #c4c5c7.
   Fonts: HWR's DIN is licensed to hwr-berlin.de only, so we ship Barlow (free, DIN-inspired)
   and the original Crimson Text, both self-hosted (SIL OFL, see fonts/OFL-*.txt).
   Logo: HWR's own files from hwr-berlin.de, as a sprite (img/hwr-logo.svg).

    1. Fonts              6. Toolbar & buttons       11. Phones: week strip, day, month
    2. Colours & sizes    7. Calendar area, notices  12. Sheets
    3. Base               8. Week grid               13. Footer
    4. Header             9. Lesson blocks           14. Small screens
    5. Course band       10. All weeks               15. Print, motion              */

/* ================================================================ 1. Fonts */

@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/barlow-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Crimson Text"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/crimson-text-latin-400-normal.woff2") format("woff2"); }

/* ================================================================ 2. Colours & sizes */

:root {
  --red: #d50c2f;           /* HWR red, for red text and lines */
  --red-fill: #d50c2f;      /* red surfaces with white text (5.1:1) */
  --red-dark: #a50924;      /* HWR pressed / hover red */
  --on-red: #ffffff;
  --page: #ffffff;
  --grey: #f7f8f8;          /* HWR page grey */
  --ink: #000000;           /* headings, times */
  --text: #222426;
  --muted: #4a4d50;         /* HWR meta text */
  --line: #c4c5c7;          /* HWR hairline */
  --line-soft: #e3e4e5;
  --grid-hour: #c4c5c7;     /* full hours: clearly visible */
  --grid-half: #dcdddf;     /* half hours: dashed, quieter */
  --focus: #2c5697;
  --tint: 13%;              /* module colour share of a block's fill */
  --edge-mix: 100%;         /* module colour share of a block's edge */
  --edge-l: l; --edge-c: 1;  /* where supported: a block's edge = the module colour at this lightness / chroma share */
  --fill-l: .965; --fill-c: .2;   /* … and its fill */
  --shadow: 0 18px 48px rgba(0, 0, 0, .18);
  --logo-red: #d50c2f;      /* the logo keeps HWR red; dark mode lightens it a little */
  --logo-grey: #6b6f73;     /* the logo's grey type */

  --font: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --serif: "Crimson Text", Georgia, "Times New Roman", serif;
  --hour: 64px;             /* height of every hour; main.js sizes it so a day fits the screen */
  --band-h: 42px;           /* one row of the red band */
  --bar: 40px;              /* the toolbar row (‹ Heute ›, Woche / Alle Wochen) */
  --bar-gap: 12px;          /* between toolbar and calendar */
  --bar-buttons: 360px;     /* Woche | Alle Wochen | Klausuren, right of a docked week title */
  --main-pad: 12px;         /* above the toolbar, below the calendar */
  --gutter: 64px;           /* time column */
  --hour-pad: 12px;         /* space right of the hour labels */
  color-scheme: light;
}

/* Dark, easy on the eyes: soft dark grey instead of black, one off-white for text, logo and band
   (less glare), quiet lines, a full HWR red a step darker for red surfaces, module colours kept vivid.
   Same values twice: once for "follow the device", once for "chosen with the button". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --red: #ff7d91; --red-fill: #a8132f; --red-dark: #8a0f27; --on-red: #ececee;
    --page: #18191b; --grey: #1f2023; --ink: #ececee; --text: #dcdde0; --muted: #a2a5aa;
    --line: #393b40; --line-soft: #2a2c30; --grid-hour: #3f4247; --grid-half: #303237; --focus: #8fb2ff;
    --tint: 30%; --edge-mix: 85%; --edge-l: .72; --edge-c: 1.15; --fill-l: .31; --fill-c: .5; --shadow: 0 18px 48px rgba(0, 0, 0, .55);
    --logo-red: #f0445d; --logo-grey: #ececee;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --red: #ff7d91; --red-fill: #a8132f; --red-dark: #8a0f27; --on-red: #ececee;
  --page: #18191b; --grey: #1f2023; --ink: #ececee; --text: #dcdde0; --muted: #a2a5aa;
  --line: #393b40; --line-soft: #2a2c30; --grid-hour: #3f4247; --grid-half: #303237; --focus: #8fb2ff;
  --tint: 30%; --edge-mix: 85%; --edge-l: .72; --edge-c: 1.15; --fill-l: .31; --fill-c: .5; --shadow: 0 18px 48px rgba(0, 0, 0, .55);
  --logo-red: #f0445d; --logo-grey: #ececee;
  color-scheme: dark;
}

/* ================================================================ 3. Base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* A fixed frame, like an app: header, band and the bottom line stand still and the page itself
   never scrolls. The calendar (#cal, see 7.) fills the rest and is the only part that can. */
body {
  margin: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 15px/20px var(--font);
  letter-spacing: .3px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; letter-spacing: inherit; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }   /* wins over any element's own display */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* grows with the window (and so do the side margins) up to 1800px */
.wrap { width: 100%; max-width: 1800px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 48px); }

/* ================================================================ 4. Header */

/* HWR's logo (bear + type, as on hwr-berlin.de), then this page's name in the same build:
   serif line in the logo's grey, sans line in red */
.masthead-inner { display: flex; align-items: center; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.logo { display: flex; flex: none; gap: 12px; color: var(--logo-grey); }
.logo svg { width: auto; fill: currentColor; stroke: none; }
.logo-bear { height: 50px; aspect-ratio: 40 / 66; }
.logo-type { height: 49px; aspect-ratio: 247 / 65; }
.wordmark {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 46px; margin-left: 8px; padding-left: 24px;
  border-left: 1px solid var(--line);
  line-height: 1.1; text-decoration: none;
}
.wm-title { font-family: var(--serif); font-size: 23px; letter-spacing: 0; color: var(--logo-grey); }
.wm-sub { margin-top: 2px; font-size: 13px; color: var(--red); white-space: nowrap; }
.wm-short { display: none; }

/* short laptop screens: a slimmer header leaves more room for the week */
@media (min-width: 701px) and (max-height: 820px) {
  .masthead-inner { padding-top: 8px; padding-bottom: 8px; }
  .logo-bear { height: 40px; }
  .logo-type { height: 39px; }
  .wordmark { min-height: 38px; }
}
@media (min-width: 701px) and (max-height: 720px) {   /* very short: tighter around the toolbar */
  :root { --bar-gap: 8px; --main-pad: 8px; }
}

.metanav { display: flex; align-items: center; margin: 0 0 0 auto; padding: 0; list-style: none; }
.metanav li + li { border-left: 1px solid var(--line); }
.metanav li:has(> [hidden]) + li { border-left: 0; }
.metalink {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 12px;
  border: 0; background: none;
  color: var(--muted); font-size: 15px; white-space: nowrap;
  cursor: pointer;
  transition: color .15s ease;
}
.metalink:hover { color: var(--red); }

.theme-toggle { gap: 8px; }
.print-course { display: none; }   /* paper only, see 15. */
@media (max-width: 1180px) {   /* narrower: the HWR logo and the page's name keep their room, the header links become icons */
  .metalabel { display: none; }
  .metanav li + li { border-left: 0; }
}
.theme-label { min-width: 3.4em; text-align: left; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* ================================================================ 5. Course band (like HWR's main navigation) */

.picker { display: flex; flex-wrap: wrap; background: var(--red-fill); }   /* narrow: group and electives on a second row */
.pick { position: relative; display: flex; min-width: 0; }
.pick + .pick { border-left: 1px solid rgba(255, 255, 255, .35); }
.pick select {
  appearance: none; -webkit-appearance: none;
  height: var(--band-h); max-width: 100%;
  field-sizing: content;   /* as wide as the chosen entry, not the longest one */
  padding: 0 40px 0 16px;
  border: 0; border-radius: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.2'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center / 16px;
  color: var(--on-red); font-size: 16px;
  cursor: pointer;
  transition: background-color .15s ease;
}
.pick select:not(:disabled):hover { background-color: var(--red-dark); }
.pick select:focus-visible { outline: 2px solid var(--on-red); outline-offset: -3px; }
.pick select:disabled { cursor: default; background-image: none; padding-right: 16px; }
.pick select option { color: var(--text); background: var(--page); }
.pick-prog select { min-width: 15ch; }
/* group and electives (added by controls.js), on the right of the band */
.pick:not(.pick-choice) + .pick-choice { margin-left: auto; }
.picker.wrapped .pick-choice { margin-left: 0; }   /* a second row after all: from the left */
.pick-button {
  height: var(--band-h); padding: 0 16px;
  border: 0; background: transparent;
  color: var(--on-red); font-size: 16px; white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease;
}
.pick-button:hover { background: var(--red-dark); }
.pick-button:focus-visible { outline: 2px solid var(--on-red); outline-offset: -3px; }

/* ================================================================ 6. Toolbar & buttons */

main.wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: var(--main-pad); padding-bottom: var(--main-pad); }
/* One toolbar row, as in calendar apps: ‹ Heute › and the week left, the views right. The buttons
   live in .controls (the bottom toolbar on phones); here they join the row (display: contents). */
.plan-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: var(--bar-gap); }
.plan-title { flex: 1; min-width: 0; }
.plan-head h1 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -.2px; color: var(--ink); }
.plan-head h1 .range { font-weight: 400; color: var(--muted); }
.status { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
@media (min-width: 701px) { .status:not(.message) { display: none; } }   /* facts: in the bottom line */
.controls { display: contents; }
.weeknav { order: -1; display: flex; gap: 6px; }
main.all-weeks .plan-title { display: none; }   /* the week titles dock here instead */
main.all-weeks .seg { margin-left: auto; }
/* narrower screens: the dates go (they are in the day names); too narrow for one row, the views wrap */
@media screen and (max-width: 1180px) {
  .plan-head h1 .range, .week-block h2 .range { display: none; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 0;
  background: var(--page); color: var(--ink);
  text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--grey); border-color: var(--muted); }
.btn.primary { background: var(--red-fill); border-color: var(--red-fill); color: var(--on-red); }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.icon { width: 40px; padding: 0; }
.btn.plain { border-color: transparent; }
.btn.wide { width: 100%; justify-content: flex-start; }

.seg { display: flex; }
.seg-btn {
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--page); color: var(--ink);
  cursor: pointer;
  transition: background-color .15s ease;
}
.seg-btn + .seg-btn { border-left: 0; }
.seg-btn:hover { background: var(--grey); }
.seg-btn[aria-pressed="true"] { background: var(--red-fill); border-color: var(--red-fill); color: var(--on-red); }

/* ================================================================ 7. Calendar area, notices */

/* The only scroll area. In the week view it doesn't need to: fitHours() in main.js sizes the hours
   so the whole week fits. "Alle Wochen" scrolls in here, under a header that stays put. */
#cal {
  flex: 1; min-height: 0;
  overflow: hidden auto;            /* x hidden: the week slides in */
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
#cal:empty { display: none; }
.day-top, .choice-hint, .empty { flex: none; }
#open-course { display: none; }   /* phones only, see 14. */
.tool-credit { display: none; }   /* phones only: the credit in the bottom toolbar */
/* "HWR nicht erreichbar", "Alter Plan": in the red bottom line (.foot-alert); phones, which have no
   bottom line, show it here, on a line of its own (14.) */
.notice {
  margin: 0; padding: 4px 12px;
  border-left: 4px solid var(--red); background: var(--grey); color: var(--text);
  font-size: 13px; line-height: 16px;
}
.plan-head .notice { flex-basis: 100%; order: 5; }
@media (min-width: 701px) { .plan-head .notice { display: none; } }
.empty { padding: 48px 20px; background: var(--grey); text-align: center; color: var(--muted); }
.empty p { margin: 0 0 16px; font-size: 18px; line-height: 24px; color: var(--text); }
.empty .empty-mark { margin: -8px 0 16px; font-size: 15px; font-weight: 700; color: var(--red); }
#cal.loading { opacity: .5; transition: opacity .2s ease; }
.choice-hint { display: none; }   /* phones only, see 14. */

/* ================================================================ 8. Week grid
   One grid row per 5 minutes, every hour the same height (--hour). Built in js/grid.js. */

.cal-week { border: 1px solid var(--line-soft); background: var(--page); }
.week {
  display: grid;
  /* defined here, not on :root, so they follow the --hour that main.js sets on #cal */
  --slot: calc(var(--hour) / 12);   /* one row = 5 minutes */
  --slot-max: var(--slot);          /* fixed on screen; "auto" in print */
}

.corner, .day-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--grey);
  border-bottom: 1px solid var(--line);
}
.day-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  padding: 8px 10px 7px;
  border-left: 1px solid var(--grid-hour);
  color: var(--ink);
}
.day-head .dw { font-weight: 700; }
.day-head .dd { color: var(--muted); }
.day-head.today .dw { color: var(--red); }
.day-head.today .dd { margin: -1px 0; padding: 1px 5px; background: var(--red-fill); color: var(--on-red); font-weight: 700; }
/* a deadline from the study year's schedule ("Abgabe der Studienarbeit"), under the date */
.day-head .mark {
  flex-basis: 100%; min-width: 0; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;   /* two lines, then "…" (full text: tooltip) */
  font-size: 12px; line-height: 15px; font-weight: 700; color: var(--red);
  overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto;
}

.hour { align-self: start; padding: 4px var(--hour-pad) 0 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.hour.near-now { visibility: hidden; }
.hour-line { border-top: 1px solid var(--grid-hour); }
.half-line { border-top: 1px dashed var(--grid-half); }
.day-col { border-left: 1px solid var(--grid-hour); pointer-events: none; }
.day-col.today { background: color-mix(in srgb, var(--red) 4%, transparent); }
.now-line { position: relative; z-index: 4; align-self: start; height: 2px; background: var(--red); pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: 0; top: -3px; width: 8px; height: 8px; background: var(--red); }
.now-time {
  z-index: 4; align-self: start;
  padding-right: var(--hour-pad);
  transform: translateY(-50%);
  text-align: right;
  background: var(--page); color: var(--red);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}


/* ================================================================ 9. Lesson blocks
   One calm colour per module (--c): light tint, strong left edge, thin frame so the start and
   end of every lesson read at a glance. All of HWR's fields, nothing behind a click. */

.ev {
  --c: #4a4d50;
  position: relative;
  z-index: 2;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
  margin: 2px 3px 2px 4px;
  padding: 5px 8px 6px 11px;
  overflow: hidden;
  --fill: color-mix(in oklch, var(--c) var(--tint), var(--page));
  background: var(--fill);
  box-shadow:
    inset 4px 0 0 color-mix(in oklch, var(--c) var(--edge-mix), #fff),
    inset 0 0 0 1px color-mix(in srgb, color-mix(in oklch, var(--c) var(--edge-mix), #fff) 55%, transparent);
  color: var(--text);
  font-size: 13px; line-height: 17px; letter-spacing: .2px;
  overflow-wrap: break-word;
  hyphens: auto; -webkit-hyphens: auto;   /* lang="de": "Wirtschafts-englisch", not "Wirtschaftsen|glisch" */
  hyphenate-limit-chars: 7 3 3;           /* never split short parts ("Syst.analyse" → "Sys-t") */
}
.ev .t { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.ev .tag { padding: 0 4px; border: 1px solid var(--line); font-size: 11px; line-height: 14px; font-weight: 400; color: var(--muted); }
.ev .tag.exam { border-color: var(--red-fill); background: var(--red-fill); font-weight: 700; color: var(--on-red); }
.ev .n { font-size: 14px; line-height: 18px; font-weight: 700; color: var(--ink); }
.ev .m { color: var(--muted); hyphens: manual; -webkit-hyphens: manual; }   /* names and rooms stay whole */

/* Over and running (updated every 30 s, see updateNow() in grid.js): what is over steps back,
   the running lesson gets a full frame in its colour. Screen only, print shows every lesson alike. */
@media screen {
  .ev.past {
    --fill: color-mix(in srgb, var(--c) 5%, var(--page));
    box-shadow: inset 4px 0 0 color-mix(in srgb, var(--c) 35%, var(--page)), inset 0 0 0 1px var(--line-soft);
  }
  .ev.past .t, .ev.past .n { color: var(--muted); }
  .ev.now { box-shadow: inset 4px 0 0 color-mix(in oklch, var(--c) var(--edge-mix), #fff), inset 0 0 0 2px color-mix(in oklch, var(--c) var(--edge-mix), #fff); }
}

/* Browsers with relative colours: the same lightness for every module, its saturation kept
   (dark mode: bright edges and clearly coloured fills instead of a grey wash) */
@supports (color: oklch(from red l c h)) {
  .ev {
    --edge: oklch(from var(--c) var(--edge-l) calc(c * var(--edge-c)) h);
    --fill: oklch(from var(--c) var(--fill-l) calc(c * var(--fill-c)) h);
    box-shadow: inset 4px 0 0 var(--edge), inset 0 0 0 1px color-mix(in oklch, var(--edge) 55%, transparent);
  }
  @media screen { .ev.now { box-shadow: inset 4px 0 0 var(--edge), inset 0 0 0 2px var(--edge); } }
}

/* "‹" / "›" on screens: the new week slides in from that side */
.cal-week.from-next { animation: from-next .22s ease-out; }
.cal-week.from-prev { animation: from-prev .22s ease-out; }
@keyframes from-next { from { opacity: .4; transform: translateX(32px); } }
@keyframes from-prev { from { opacity: .4; transform: translateX(-32px); } }

/* Parallel offerings not chosen yet, listed in one grey block (stackChoices in hwr.js, stackBlock in
   grid.js): one item per line, a click chooses. */
.ev.stack { --c: var(--muted); cursor: pointer; container-type: inline-size; }
/* narrow (many days, small screens): the names only; the whole block still opens the choice */
@container (max-width: 200px) {
  .ev.stack .choose, .ev.stack .item b { display: none; }
}
.ev.stack .t { flex-wrap: nowrap; }   /* one line: the name gives way ("…"), "Auswählen" stays */
.ev.stack .stack-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ev.stack .choose { flex: none; margin-left: auto; font-weight: 400; color: var(--red); white-space: nowrap; }
.ev.stack:hover .choose { text-decoration: underline; text-underline-offset: 2px; }
.ev.stack .item { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); }
.ev.stack .item b { font-variant-numeric: tabular-nums; }

/* tight hours (a long day on a small screen): smaller text, see fitHours() in main.js */
.dense .week .ev { padding: 3px 7px 4px 10px; gap: 1px; font-size: 12px; line-height: 15px; }
.dense .week .ev .n { font-size: 13px; line-height: 16px; }
.dense .week .ev .tag { font-size: 10px; line-height: 12px; }

/* under an hour: time, type and title as one paragraph, then lecturer · room */
.week .ev.short { display: block; padding-top: 4px; padding-bottom: 4px; }
.week .ev.short .t, .week .ev.short .n { display: inline; }
.week .ev.short .t { margin-right: 5px; }
.week .ev.short .tag { margin-left: 5px; vertical-align: 1px; }
.week .ev.short .m { display: block; }

/* Text longer than its slot (see markOverflow() in grid.js): first a smaller type (.tight); if it
   still doesn't fit, it fades out where the lesson ends (.clipped, the tooltip has all of it).
   A block always ends at its real end time. */
.week .ev.tight { padding-top: 2px; padding-bottom: 2px; gap: 0; font-size: 11px; line-height: 13px; }
.week .ev.tight .n { font-size: 12px; line-height: 14px; }
.week .ev.tight .tag { font-size: 10px; line-height: 12px; }
.week .ev.clipped::after {
  content: "";
  position: absolute; left: 4px; right: 1px; bottom: 1px; height: 14px;
  background: linear-gradient(to bottom, transparent, var(--fill));
  pointer-events: none;
}

/* ================================================================ 10. All weeks */

/* Each week's title stands above it and, scrolled up, docks in the toolbar row beside the buttons
   (sticky); the next week's title pushes it out, as in iOS lists. The toolbar lets it show through:
   it overlaps the top of the calendar by one row. The gap after a week belongs to the week, so its
   title stays until the next one arrives. */
main.all-weeks:not(:has(> .empty:not([hidden]))) .plan-head {
  position: relative; z-index: 7; margin-bottom: calc(-1 * var(--bar)); pointer-events: none;
}
main.all-weeks .plan-head button { pointer-events: auto; }
.week-block { position: relative; }
.week-block::after { content: ""; display: block; height: 40px; }   /* the gap, inside the week (not padding: sticky stops at the content box) */
.week-block h2 {
  position: sticky; top: 0; z-index: 6;
  height: calc(var(--bar) + var(--bar-gap)); margin: 0;
  padding: calc((var(--bar) - 28px) / 2) var(--bar-buttons) 0 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: var(--page);
  font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -.2px; color: var(--ink);
}
.week-block h2 .range { font-weight: 400; color: var(--muted); }
main.all-weeks .corner, main.all-weeks .day-head { top: calc(var(--bar) + var(--bar-gap)); }   /* below the title */
/* "Alle Wochen": practice weeks HWR doesn't list, one line per phase */
.phase-gap { margin: 0 0 40px; padding: 12px 16px; border-left: 4px solid var(--line); background: var(--grey); color: var(--muted); }
.week-free {
  position: absolute; z-index: 3; top: 50%; left: 50%;
  margin: 0; padding: 6px 14px; transform: translate(-50%, -50%);
  background: var(--page); color: var(--muted);
}
.this-week {   /* "Diese Woche" after the week's name in the toolbar */
  margin-left: 6px; padding: 2px 8px;
  background: var(--red-fill); color: var(--on-red);
  font-size: 13px; line-height: 18px; font-weight: 400; letter-spacing: .3px; vertical-align: 3px; white-space: nowrap;
}

/* ================================================================ 11. Phones: week strip, day, month
   Like the iOS calendar, in HWR style: the week's days in a strip and the full date above the
   day's timeline, which is the only part that scrolls (see 14.). Strip and timeline are swipe
   pagers (js/pager.js): three pages side by side, the middle one shown. */

.pager-track { display: flex; width: 300%; transform: translateX(calc(-100% / 3)); }
.pager-pane { flex: none; width: calc(100% / 3); min-width: 0; }

.weekstrip { margin: 0 0 2px; overflow: hidden; touch-action: pan-y; }
.strip-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.strip-day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 0 0 6px;
  border: 0; background: none; color: var(--ink);
  cursor: pointer;
}
.strip-w { font-size: 11px; color: var(--muted); }
.strip-d { display: grid; place-items: center; width: 34px; height: 34px; font-size: 18px; font-variant-numeric: tabular-nums; }
/* as in iOS: today in red; the chosen day filled (red when it is today) */
.strip-day.today .strip-d { color: var(--red); font-weight: 700; }
.strip-day[aria-selected="true"] .strip-d { background: var(--ink); color: var(--page); font-weight: 700; }
.strip-day.today[aria-selected="true"] .strip-d { background: var(--red-fill); color: var(--on-red); }
.strip-day.busy .strip-d { box-shadow: inset 0 -3px 0 -1px var(--muted); }   /* days with lessons */
.strip-day.busy[aria-selected="true"] .strip-d { box-shadow: none; }

.day-line { margin: 0; padding: 4px 0 8px; text-align: center; font-size: 15px; color: var(--ink); }
#cal:has(> .pager-track) { touch-action: pan-y; }
.day-page { position: relative; }
.day-free { position: absolute; z-index: 3; top: 10px; left: 50%; margin: 0; padding: 2px 8px; transform: translateX(-50%); background: var(--page); color: var(--muted); }

/* day view: "‹ Oktober" back to the month overview, red like an iOS back button */
.back {
  display: inline-flex; align-items: center;
  min-height: 44px; margin: -6px 0 0 -2px; padding: 0 4px 0 0;
  border: 0; background: none;
  color: var(--red); font-size: 20px; font-weight: 400;
  cursor: pointer;
}

/* month overview (js/month.js): weekday letters pinned, months one below the other */
.month-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 2px 0 6px; text-align: center; font-size: 11px; color: var(--muted); }
.month + .month { margin-top: 20px; }
.month-title { margin: 8px 0 6px; font-size: 22px; line-height: 28px; font-weight: 700; color: var(--ink); }
.month-title.current { color: var(--red); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 54px; padding: 6px 0 0;
  border: 0; border-top: 1px solid var(--line-soft); background: none; color: var(--ink);
  cursor: pointer;
}
.month-day:disabled { color: var(--muted); cursor: default; }
.month-num { display: grid; place-items: center; width: 32px; height: 32px; font-size: 17px; font-variant-numeric: tabular-nums; }
.month-day.today .month-num { color: var(--red); font-weight: 700; }
.month-day[aria-pressed="true"] .month-num { background: var(--ink); color: var(--page); font-weight: 700; }
.month-day.today[aria-pressed="true"] .month-num { background: var(--red-fill); color: var(--on-red); }
.month-day.busy::after { content: ""; width: 5px; height: 5px; background: var(--muted); }   /* has lessons */

/* ================================================================ 12. Sheets: Kurs, Wahlfächer, Klausuren, Kalender-Abo */

.sheet {
  width: min(480px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  padding: 28px;
  border: 0; border-top: 4px solid var(--red); border-radius: 0;
  background: var(--page); color: var(--text);
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet[open] { animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.sheet h2 { margin: 0 44px 8px 0; font-family: var(--serif); font-size: 28px; line-height: 32px; font-weight: 400; letter-spacing: 0; color: var(--ink); }
.sheet-x { position: absolute; top: 14px; right: 14px; margin: 0; }
.hint { margin: 0 0 16px; color: var(--muted); }
.hint.small { margin: 16px 0 0; font-size: 13px; line-height: 18px; }
.hint a { color: var(--text); }
.copy-row { display: flex; }
.copy-row input {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-right: 0; border-radius: 0;
  background: var(--grey); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; letter-spacing: 0;
}
.sub-grid { display: grid; gap: 8px; margin-top: 14px; }

/* the "Kurs" sheet: the red band's dropdowns as plain rows */
.course-slot .picker { flex-direction: column; background: none; border-top: 1px solid var(--line-soft); }
.course-slot .pick { margin: 0; border: 0; border-bottom: 1px solid var(--line-soft); }
.course-slot .pick select, .course-slot .pick-button {
  width: 100%; height: 50px; padding: 0 28px 0 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 4px center / 16px;
  color: var(--ink); font-size: 16px; text-align: left;
}
.course-slot .pick select:hover, .course-slot .pick-button:hover { background-color: transparent; }
.course-slot .pick select:disabled { background-image: none; color: var(--muted); }
.course-slot .pick.pick-choice { margin-left: 0; }
.course-slot .pick select:focus-visible, .course-slot .pick-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the electives sheet */
.check-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-soft); }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--red-fill); }
.check-name { flex: 1; color: var(--ink); }
.check-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.sheet-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.sheet-actions form { margin: 0; }

/* the exams sheet (js/exams.js): date left, module and every field right, how long until on the
   right; over ones quieter */
.sheet.wide { width: min(600px, calc(100vw - 32px)); }
.exam-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-soft); }
.exam-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 2px 14px; align-items: baseline;
  width: 100%; padding: 11px 0 12px;
  border: 0; border-bottom: 1px solid var(--line-soft); background: none;
  color: var(--text); text-align: left; cursor: pointer;
}
.exam-date { grid-row: span 3; display: flex; flex-direction: column; align-self: start; line-height: 1.15; }
.exam-dw { font-size: 13px; color: var(--muted); }
.exam-dd { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.exam-title { font-weight: 700; color: var(--ink); overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; transition: color .15s ease; }
.exam-row:hover .exam-title { color: var(--red); }
.exam-when { grid-column: 3; grid-row: 1; font-size: 13px; color: var(--muted); white-space: nowrap; }
.exam-when.soon { font-weight: 700; color: var(--red); }   /* within a week */
.exam-meta { grid-column: 2 / 4; font-size: 14px; color: var(--muted); }
.exam-row.past .exam-dd, .exam-row.past .exam-title { font-weight: 400; color: var(--muted); }

/* the study year's schedule (js/zeitplan.js), like HWR's PDF: a block per half-year, a row per
   phase (dates · kind · weeks) with the deadlines between them; theory with a red edge, deadlines in
   red, the running phase on grey, what is over quieter */
#zeitplan-sheet { width: min(640px, calc(100vw - 32px)); }
.zp-term { margin-top: 18px; }
.zp-term h3 { margin: 0 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; color: var(--ink); }
.zp-row {
  display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; gap: 0 14px; align-items: baseline;
  padding: 6px 8px 6px 10px;
  border-left: 3px solid transparent; border-bottom: 1px solid var(--line-soft);
  color: var(--text); font-variant-numeric: tabular-nums;
}
.zp-row.zp-theorie { border-left-color: var(--red); }
.zp-row.zp-praxis { border-left-color: var(--line); }
.zp-theorie .zp-what { font-weight: 700; color: var(--ink); }
.zp-date .zp-what { font-weight: 700; color: var(--red); }
.zp-weeks { font-size: 13px; color: var(--muted); white-space: nowrap; }
.zp-row.now { background: var(--grey); }
.zp-row.past { opacity: .5; }
@media (max-width: 600px) {
  .zp-row { grid-template-columns: minmax(0, 1fr) auto; }
  .zp-when { grid-column: 1 / 3; font-size: 13px; color: var(--muted); }
}
.zp-notes { margin: 14px 0 0; padding: 12px 0 0 18px; border-top: 1px solid var(--line-soft); font-size: 13px; line-height: 18px; color: var(--muted); }

/* "Räume" (js/rooms.js): a row per room, name · what's on · a bar of the day (lessons dark,
   the now-line red); rooms without a lesson now come first */
#rooms-sheet { width: min(760px, calc(100vw - 32px)); }
#rooms-hint { margin: 0 0 10px; }
.seg.rooms-days { display: flex; flex-wrap: wrap; margin: 4px 0 14px; }   /* also on phones */
.rooms { margin: 0; padding: 0; list-style: none; }
.room {
  display: grid; grid-template-columns: 130px minmax(0, 1fr) 40%; gap: 2px 14px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums;
}
.room-name { font-weight: 700; color: var(--ink); white-space: nowrap; }
.room-text { min-width: 0; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room.busy .room-name, .room.busy .room-text { color: var(--muted); font-weight: 400; }
.room-bar { position: relative; height: 14px; background: var(--grey); }
.room-lesson { position: absolute; top: 0; bottom: 0; background: var(--muted); }
.room-now { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--red); }
.room-scale { padding: 0 0 4px; border-bottom: 1px solid var(--line); }
.room-house { padding: 14px 0 4px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.room-scale .room-bar { height: 16px; background: none; }
.room-scale .room-bar span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
@media (max-width: 600px) {
  .room { grid-template-columns: auto minmax(0, 1fr); }
  .room-bar { grid-column: 1 / 3; }
  .room-scale { display: none; }
}

/* ================================================================ 13. Footer */

.foot { background: var(--red-fill); color: var(--on-red); font-size: 13px; line-height: 18px; }
.foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 24px; padding-top: 7px; padding-bottom: 7px; }
.foot a { text-underline-offset: 2px; }
.credit { opacity: .78; }
/* HWR not reachable / an old plan: stands out in the bottom line, before the plan's "Stand" */
.foot-alert {
  display: inline-flex; align-items: center; gap: 6px;
  margin-right: 10px; padding: 0 8px;
  background: var(--on-red); color: var(--red-dark); font-weight: 600;
}
.foot-alert[hidden] { display: none; }
.nowrap { white-space: nowrap; }
.foot-alert::before { content: "!"; display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: var(--red-dark); color: var(--on-red); font-size: 10px; line-height: 1; }

/* ================================================================ 14. Small screens */

/* phones held upright (= SMALL in main.js); small phones turned sideways get the week (below) */
@media (max-width: 700px) and (orientation: portrait), (max-width: 700px) and (min-height: 501px), (max-width: 700px) and (pointer: fine) {
  .wrap { padding-left: 16px; padding-right: 16px; }   /* the -16px edges below assume exactly this */
  /* An app shell, as in the iOS calendar: header and toolbar stand still and the calendar
     (#cal) is the only part that scrolls. The course picker lives in the "Kurs" sheet. */
  .masthead-inner { gap: 10px; padding-top: 8px; padding-bottom: 6px; }
  .logo-bear { height: 36px; }
  .logo-type { display: none; }
  .wordmark { min-height: 0; margin-left: 0; padding-left: 0; border-left: 0; }
  .wm-title { font-size: 21px; }
  .wm-sub { font-size: 12px; }
  .metanav { flex: none; }
  .metalink { min-width: 36px; min-height: 44px; padding: 0 2px; justify-content: center; }
  .wm-long { display: none; }   /* five icons beside it: "FB 2 · Duales Studium" */
  .wm-short { display: inline; }
  .metalink svg { width: 22px; height: 22px; }
  .picker-wrap, .foot { display: none; }
  /* the smallest phones (320 px, iPhone SE 1st gen): five icons and the name only fit a bit tighter */
  @media (max-width: 359px) {
    .masthead-inner { gap: 8px; }
    .logo-bear { height: 32px; }
    .wm-title { font-size: 19px; }
    .wm-sub { font-size: 11px; }
    .metalink { min-width: 30px; }
    .metalink svg { width: 20px; height: 20px; }
  }

  main.wrap { padding-top: 0; padding-bottom: calc(61px + env(safe-area-inset-bottom)); }   /* the toolbar */
  .day-top { margin: 0 -16px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); }
  .plan-head { margin-bottom: 4px; }
  #cal { margin: 0 -16px; padding: 10px 16px; }
  /* the day pager fills the full width; each page keeps the side margin itself, so the
     neighbouring days stay out of sight until swiped in */
  #cal:has(> .pager-track) { padding-left: 0; padding-right: 0; }
  .pager-pane { padding: 0 16px; }
  .weekstrip .pager-pane { padding: 0; }
  .empty { margin-top: 10px; }
  .plan-head .notice { margin-bottom: 6px; }   /* phones: its own line under the date */
  .choice-hint {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 8px 0 0; padding: 6px 6px 6px 12px;
    border-left: 4px solid var(--red); background: var(--grey);
  }
  .choice-hint .btn { height: 36px; flex: none; }

  /* bottom toolbar, as in the iOS calendar: "Heute" left, "Kurs" right */
  .controls {
    display: flex;
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    justify-content: space-between; align-items: center;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    background: var(--page); border-top: 1px solid var(--line);
  }
  .weeknav #prev, .weeknav #next, .seg { display: none; }         /* swipe instead; no view switch */
  #open-course { display: inline-flex; }
  .btn { height: 44px; }
  /* toolbar buttons as in iOS: plain words in the tint colour, here HWR red */
  .controls .btn { padding: 0 4px; border: 0; background: none; color: var(--red); font-size: 17px; }
  .controls .btn:hover { background: none; }
  .tool-credit {
    display: flex; flex-direction: column; justify-content: center; position: absolute; left: 50%; top: 8px;
    height: 44px; transform: translateX(-50%); text-align: center;
    line-height: 14px; font-size: 11px; color: var(--muted); white-space: nowrap; pointer-events: none;
  }
  .btn.icon { width: 44px; }

  /* the day timeline */
  :root { --gutter: 48px; --hour-pad: 8px; }
  .day-col.today { background: none; }
  .hour { font-size: 12px; font-weight: 400; color: var(--muted); }
  .week .ev { margin-left: 6px; font-size: 14px; line-height: 18px; }
  .week .ev .n { font-size: 15px; line-height: 19px; }
  .sheet { padding: 22px 20px; }
}

/* phones turned sideways: only the week, as in the iOS calendar (course: turn the phone upright) */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .plan-head .notice:not([hidden]) { display: block; }   /* no bottom line here */
  .masthead, .picker-wrap, .seg, .status:not(.message), .foot, .tool-credit { display: none; }
  main.wrap { padding-top: 6px; }
  .plan-head { margin-bottom: 6px; }
  .plan-head h1 { font-size: 18px; line-height: 22px; }
  .plan-title { order: 0; flex-basis: auto; }   /* one toolbar row: the height is precious here */
  .btn { height: 34px; }
  .btn.icon { width: 34px; }
}

/* ================================================================ 15. Print (always light, every line, one week per page), motion */

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  :root:not(#print) {   /* id-level specificity: beats the dark-mode rules */
    --page: #fff; --grey: #f7f8f8; --ink: #000; --text: #222426; --muted: #4a4d50;
    --line: #c4c5c7; --line-soft: #e3e4e5; --grid-hour: #c4c5c7; --grid-half: #dcdddf;
    --red: #d50c2f; --red-fill: #d50c2f; --on-red: #fff; --tint: 13%; --edge-mix: 100%;
    --logo-red: #d50c2f; --logo-grey: #6b6f73;
    color-scheme: light;
  }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* no controls, nothing about "now"; the course in words instead of the red band */
  .metanav, .picker-wrap, .controls, .weekstrip, .notice, .foot-alert, .choice-hint, dialog,
  .now-line, .now-time, .this-week, .ev.stack .choose, main.all-weeks .plan-head { display: none !important; }
  body, main.wrap { display: block; height: auto; overflow: visible; }   /* paper: everything, no frame */
  .wrap { max-width: none; padding: 0; }
  #cal { overflow: visible; }
  main.wrap { padding: 0; }
  .masthead-inner { padding: 0 0 10px; }
  .logo-bear { height: 40px; }
  .logo-type { height: 39px; }
  .wordmark { min-height: 38px; }
  .print-course { display: block; margin: 0 0 0 auto; text-align: right; font-size: 13px; line-height: 18px; color: var(--text); }
  .plan-head { margin-bottom: 8px; }
  .day-col.today { background: none; }
  .day-head.today .dw { color: inherit; }
  .day-head.today .dd { margin: 0; padding: 0; background: none; font-weight: 400; color: var(--muted); }
  .corner, .day-head { position: static; }
  .hour.near-now { visibility: visible; }   /* no now-time on paper */
  /* one week per page: hours sized for A4 landscape (--print-hour, main.js); rows may still grow,
     so every line prints */
  .week { --hour: var(--print-hour, 46px); --slot-max: auto; }
  .cal-week, .ev { break-inside: avoid; }
  .week .ev.clipped::after { display: none; }
  /* the bottom line on every page: draft notice, group, "Stand", source */
  .foot { position: fixed; left: 0; right: 0; bottom: 0; background: none; color: var(--muted); font-size: 10px; line-height: 14px; }
  .foot-inner { padding: 0; }
  .foot a { text-decoration: none; }
  .week-block + .week-block { break-before: page; }
  .week-block::after { display: none; }
  .week-block h2 { height: auto; padding: 0 0 8px; }
}

.no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important; }   /* theme switch */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
