/* App-only styles on top of stroodle.css: page basics, form validation, Blazor UI. */

html, body { margin: 0; }
body { background: var(--bg); }

/* FocusOnNavigate moves focus to the page heading for screen readers; no visible ring needed there */
h1:focus { outline: none; }

/* Tokens the design file doesn't have */
:root {
    --amber: #B07A00;
    /* Field borders with 3:1 contrast (accessibility fix below) */
    --field-border: #7B8494;
    --knob-off: var(--muted);
    --stripes: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, var(--surface) 6px 12px);
}

:root[data-theme="dark"] {
    --amber: #E2B04A;
    --field-border: #6B717C;
    --knob-off: #5A606B;
}

/* NavLink marks the current page with .active, the design uses aria-current */
.nav a.active { color: var(--text); font-weight: 500; border-bottom-color: var(--accent); }

/* Segmented controls keep their natural width inside flex columns */
.seg { align-self: flex-start; max-width: 100%; }
@media (max-width: 480px) {
    /* Too narrow for the buttons side by side: stack them */
    .seg { flex-direction: column; align-self: stretch; }
    .seg button { border-left: 0; border-top: 1px solid var(--field-line); text-align: left; }
    .seg button:first-child { border-top: 0; }
}

/* Step-by-step guides (setup step 2) */
kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--field-line); border-bottom-width: 2px; border-radius: 3px; background: var(--surface); font: 500 12px/1.6 var(--mono); white-space: nowrap; }
.guide { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.55; }
.guide li::marker { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.troubleshooting summary { padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: 15px; }
.troubleshooting dl { margin: 0; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; line-height: 1.55; }
.troubleshooting dt { font-weight: 500; }
.troubleshooting dd { margin: 2px 0 0; color: var(--text-2); }
/* A fallback inside a step, folded away: e.g. the developer tools on the Moodle step */
.troubleshooting-inline { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.troubleshooting-inline summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-2); }

/* Drawing of the browser's Network panel */
.sketch { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.sketch-tabs { display: flex; gap: 16px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); background: var(--surface-3); font: 12px var(--mono); color: var(--muted); }
.sketch-tabs span { padding-bottom: 7px; }
.sketch-tabs .on { color: var(--text); border-bottom: 2px solid var(--accent); padding-bottom: 5px; }
.sketch-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); font: 12px var(--mono); color: var(--text); }
.sketch-check { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 2px; background: var(--accent); color: #FFFFFF; font-size: 10px; outline: 2px solid #E8B400; outline-offset: 1px; }
.sketch-body { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); font: 12px/1.5 var(--mono); }
.sketch-list { border-right: 1px solid var(--line); }
.sketch-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; overflow: hidden; }
.sketch-filter { color: var(--muted); background: var(--surface-2); }
.sketch-row.selected { background: var(--accent-soft); }
.sketch-row.failed { color: var(--danger); }
.sketch-detail { display: flex; flex-direction: column; gap: 4px; padding: 6px 12px; min-width: 0; }
.sketch-head { color: var(--muted); }
.sketch .mark { padding: 2px 4px; border-radius: 2px; background: #FFF3BF; color: #15181D; outline: 2px solid #E8B400; overflow-wrap: anywhere; }
/* The highlight stays light in dark mode too, so its text stays dark */
.sketch .sketch-link.mark { color: #1A37A8; }
/* Moodle's key page with the context menu on its link (MoodleLinkSketch) */
.sketch-address { padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface-3); font: 12px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sketch-page { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 12px 18px; font-size: 13px; }
.sketch-notice { align-self: stretch; padding: 6px 10px; border: 1px solid var(--ok-line); border-radius: var(--radius); background: var(--ok-soft); color: var(--ok-ink); }
.sketch-button { padding: 4px 10px; border-radius: var(--radius); background: var(--surface-3); color: var(--text); }
.sketch-link-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 100%; }
.sketch-link { color: var(--accent); text-decoration: underline; text-align: center; }
.sketch-menu { display: flex; flex-direction: column; min-width: 190px; padding: 4px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 18px var(--shadow); font-size: 12.5px; }
.sketch-menu span { padding: 3px 12px; color: var(--text); white-space: nowrap; }
.sketch-menu .on { background: var(--accent-fill); color: #FFFFFF; }
.sketch-menu .sketch-menu-line { height: 1px; margin: 4px 0; padding: 0; background: var(--line); }
@media (min-width: 641px) {
  .sketch-link-wrap .sketch-menu { position: absolute; top: calc(100% - 4px); left: 55%; }
  .sketch-page { padding-bottom: 150px; }
}
@media (max-width: 560px) {
    .sketch-body { grid-template-columns: minmax(0, 1fr); }
    .sketch-list { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Semester week strip (setup step 3) */
.weeks-scroll { overflow-x: auto; }
.weeks { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(48px, 1fr); gap: 4px; }
.week { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: 3px; background: var(--bg); }
.week .num:first-child { font-weight: 500; }
.week .num:last-child { font-size: 11px; color: var(--muted); }
.week.current { background: var(--text); color: var(--on-strong); }
.week.current .num:last-child { color: var(--on-strong-muted); }
.week.break { background: transparent; border: 1px dashed var(--field-line); }
.week.break .num { color: var(--muted); }

/* Validation */
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.validation-message { font-size: 13px; line-height: 1.45; color: var(--danger); }
.callout.error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger-ink); }

/* Loading screen before the WebAssembly app has started */
.loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); font-family: var(--sans); color: var(--muted); }
.loading .brand { font-size: 18px; }
.loading-text::after { content: var(--blazor-load-percentage-text, "Loading"); font-family: var(--mono); font-size: 12px; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; z-index: 1000; width: 100%; box-sizing: border-box; padding: 12px 24px; background: var(--warn-soft); border-top: 1px solid var(--warn-line); color: var(--warn); font: 400 14px var(--sans); }
#blazor-error-ui .dismiss { position: absolute; right: 16px; top: 10px; cursor: pointer; border: 0; background: transparent; color: inherit; font: inherit; }


/* Warning callout (design: App-Materials) */
.callout.warn { border-color: var(--warn-line); background: var(--warn-faint); }
.callout.warn svg { color: var(--warn); }

/* Materials table: the week picker fits the row height */
.week-select { min-height: 36px; width: 136px; }
@media (max-width: 480px) {
    /* Filters one below the other, each full width */
    .filters > .field { flex: 1 1 100% !important; }
}

/* Instructions preview on the Summaries screen */
.instructions-toggle { cursor: pointer; font-size: 14px; font-weight: 500; min-height: 32px; }
.code.instructions { margin-top: 8px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Text preview under a file on the Materials page */
.text-row td { background: var(--surface-2); }
.extract { display: flex; flex-direction: column; gap: 16px; max-height: 520px; overflow: auto; }
.extract-text { margin: 6px 0 0; padding: 12px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 var(--mono); }


/* Summaries mixer (design: App-Module-Summaries) */
.tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; background: var(--surface); border: 1px solid var(--field-line); border-radius: var(--radius); font-size: 13px; cursor: grab; user-select: none; }
.chip:hover { border-color: var(--muted); }
.chip-name { font-weight: 500; }
.chip-hint { color: var(--muted); font-size: 12px; }
.mixrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding: 14px 16px; border-top: 1px solid var(--line-soft); }
.mixrow.is-head { border-top: 0; padding-top: 10px; padding-bottom: 6px; }
.mixrow.is-muted .who { opacity: 0.6; }
.who { flex: 0 0 190px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.track-wrap { flex: 1 1 380px; min-width: 0; }
.track { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; height: 56px; cursor: pointer; touch-action: pan-y; border-radius: var(--radius); }
.track-line { position: absolute; left: 12.5%; right: 12.5%; top: 50%; height: 2px; margin-top: -1px; background: var(--line); }
.track-fill { position: absolute; left: 12.5%; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; transition: width 0.15s ease; }
.track-labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); text-align: center; }
.track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stop { position: absolute; top: 50%; width: 12px; height: 12px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--surface); border: 2px solid var(--field-line); pointer-events: none; }
.knob { position: absolute; top: 50%; transform: translate(-50%, -50%); min-width: 64px; height: 36px; padding: 0 10px; border-radius: var(--radius); color: #FFFFFF; font: 500 12px var(--mono); letter-spacing: 0.04em; display: flex; align-items: center; justify-content: center; user-select: none; white-space: nowrap; box-shadow: 0 1px 2px var(--shadow); pointer-events: none; transition: left 0.15s ease; }
.track.is-sliding .knob, .track.is-sliding .track-fill { transition: none; }
.track.is-sliding .knob { box-shadow: 0 2px 6px rgba(21, 24, 29, 0.3); }
.addons { flex: 1 1 260px; min-height: 48px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; border: 1px dashed var(--line); border-radius: var(--radius); }
.addons.is-target { border-color: var(--accent-mid); }
.addons.is-over { background: var(--accent-soft); border-color: var(--accent); border-style: solid; }
.tag { display: inline-flex; align-items: center; gap: 2px; padding-left: 8px; background: var(--chip); border-radius: 3px; font-size: 12px; font-weight: 500; min-height: 28px; }
.tag button { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 3px; font-size: 14px; }
.tag button:hover { background: var(--line); color: var(--text); }
.tag-add { min-height: 28px; padding: 0 8px; border: 1px dashed var(--field-line); border-radius: 3px; background: none; font: 500 12px var(--sans); color: var(--muted); cursor: pointer; }
.tag-add:hover { border-color: var(--muted); color: var(--text); }
.tag-offer { min-height: 28px; padding: 0 8px; border: 1px solid var(--accent); border-radius: 3px; background: var(--surface); font: 500 12px var(--sans); color: var(--accent-ink); cursor: pointer; }
.total { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.total-num { font-size: 28px; line-height: 1; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
    /* One column: only the level labels above the faders still line up with something */
    .mixrow.is-head > .who, .mixrow.is-head > .eyebrow:last-child { display: none; }
}

/* "i" next to add-ons and the dialog it opens */
.info-btn { width: 24px; height: 24px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--field-line); border-radius: 50%; background: var(--surface); color: var(--muted); font: italic 600 12px/1 var(--serif, Georgia, serif); cursor: pointer; }
.info-btn:hover { border-color: var(--muted); color: var(--text); }
.tag .info-btn { margin: 0 4px 0 6px; }
.dialog { width: calc(100% - 32px); max-width: 480px; flex-direction: column; gap: 14px; padding: 20px; border: 0; background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: 0 10px 30px var(--shadow); }
.dialog[open] { display: flex; }
.dialog::backdrop { background: rgba(21, 24, 29, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Dialogs with whole tools in them (mixer, module picker, calendar) instead of a setup page */
.dialog { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.dialog-medium { max-width: 720px; }
.dialog-wide { max-width: 1100px; }
.dialog-foot { justify-content: flex-end; gap: 8px; }
.link { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

/* Accessibility fixes from the review (WCAG 2.2 AA) */
/* Field borders need 3:1 against the background; the design token (var(--field-line)) has 1.7:1 */
.input, .select, .textarea { border-color: var(--field-border); }
/* .seg clips the browser's focus ring (overflow: hidden): draw it inside the button */
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
/* Keeps visually hidden headers inside the scrolling table, not in the page width. */
.table-wrap { position: relative; }

/* Announcements for screen readers, e.g. "Math added to …" */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Live status light: green while connected, amber while Stroodle waits for something. */
.dot.live { position: relative; width: 10px; height: 10px; background: var(--ok); }
.dot.live.waiting { background: var(--amber); }
.dot.off { background: var(--muted); }
.dot.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: dot-pulse 1.8s ease-out infinite; }
@keyframes dot-pulse { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.8); opacity: 0; } }

/* Setup: the overview of what's connected, at the end of the setup */
.status-list { display: flex; flex-direction: column; }
.status-list > div { display: grid; grid-template-columns: 10px 110px minmax(0, 1fr); align-items: center; gap: 8px 14px; padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.status-list > div:first-child { border-top: 0; }
@media (max-width: 560px) {
    .status-list > div { grid-template-columns: 10px minmax(0, 1fr); }
    .status-list > div > :last-child { grid-column: 2; }
}

/* Setup stepper: the other steps are links, underlined so they don't read as plain labels */
.stepper a { display: block; padding-block: 6px; margin-block: -6px; color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--field-line); text-underline-offset: 4px; }
.stepper a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.stepper a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Recap page: switching between the week's modules (design: App-Recap) */
.module-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
.module-tabs a { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; color: var(--muted); font-size: 14px; text-decoration: none; }
.module-tabs a[aria-current="page"] { color: var(--text); font-weight: 500; border-bottom: 2px solid var(--accent); margin-bottom: -1px; }
.module-tabs a:hover { color: var(--text); }

/* Formulas (KaTeX, js/math.js) */
.math-display { overflow-x: auto; padding: 4px 0; }
.lead p, .next-p p { margin: 0 0 8px; }
.lead p:last-child, .next-p p:last-child { margin-bottom: 0; }

/* Archive: the week rows are headers for screen readers (th), styled like the design's td */
.group-row th { background: var(--bg); font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 16px; text-align: left; }

/* Dashboard (design: App-Dashboard) — "Up next": one task, coloured by what it is about */
.next { display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; border: 1px solid var(--line); border-left: 4px solid var(--c, var(--text)); border-radius: var(--radius); background: var(--surface); }
.next.is-warn { background: var(--warn-paper); border-color: var(--warn-line); border-left-color: var(--b-todo); }
.next-h { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.next-p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--text-2); max-width: 680px; }
.next .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 12px var(--mono); color: var(--muted); }
.next .prompt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-3); }
.next .prompt-text { flex: 1; min-width: 220px; font-size: 17px; font-weight: 500; }
.next .chips { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--field-line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) {
    .next { padding: 18px 16px; }
    .next-h { font-size: 22px; }
}

/* Semester grid: modules × weeks */
.grid-wrap { position: relative; overflow-x: auto; }
.sgrid { --name-w: 200px; display: grid; grid-template-columns: var(--name-w) repeat(var(--weeks), minmax(40px, 1fr)); min-width: calc(var(--name-w) + var(--weeks) * 44px); }
/* The module names stay put while the weeks scroll sideways */
.sgrid .name, .sgrid .corner { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.sgrid .h.corner { align-items: flex-start; padding-left: 16px; cursor: default; }
@media (max-width: 640px) {
    .sgrid { --name-w: 128px; }
    .sgrid .name { padding: 0 8px 0 12px; font-size: 13px; }
}
.sgrid > * { display: flex; align-items: center; justify-content: center; min-height: 44px; border-top: 1px solid var(--line-soft); }
.sgrid .h { min-height: 56px; border: 0; flex-direction: column; gap: 1px; font: 500 12px var(--mono); color: var(--muted); background: none; padding: 0; cursor: pointer; }
.sgrid span.h { cursor: default; }
.sgrid .h small { font-size: 10px; font-weight: 400; color: var(--muted-2); }
.sgrid .h.is-break { color: var(--faint); }
.sgrid .h.is-now { color: var(--text); }
.sgrid .h.is-sel { background: var(--text); color: var(--on-strong); border-radius: 4px 4px 0 0; }
.sgrid .h.is-sel small { color: var(--on-strong-muted); }
.sgrid .name { justify-content: flex-start; padding: 0 12px 0 16px; font-size: 14px; min-width: 0; }
.sgrid .name .mod { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.sgrid .name .swatch { display: inline-block; margin-right: 8px; vertical-align: 0; }
.sgrid .c { background: none; border-left: 0; border-right: 0; border-bottom: 0; padding: 0; cursor: pointer; text-decoration: none; }
.sgrid .c.is-sel { background: var(--accent-paper); }
.sgrid .c.is-break { background: var(--stripes); cursor: default; }
.sgrid .c.is-future { cursor: default; }
.sgrid .h:focus-visible, .sgrid .c:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mk { width: 16px; height: 16px; border-radius: 3px; }
.mk.read { background: var(--m); }
.mk.unread { border: 2px solid var(--m); background: var(--surface); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 8px var(--m); }
.mk.wait { border: 2px dashed var(--amber); background: var(--warn-paper); }
/* Calendar only: a faint calendar, the same size as the other markers */
.mk.cal { width: 14px; height: 14px; border: 1.5px solid var(--faint-line); border-top-width: 4px; border-radius: 3px; background: none; opacity: 0.75; }
.mk.future { width: 4px; height: 4px; border-radius: 50%; background: var(--field-line); }
/* A deadline of this module in this week: a red badge on the cell's marker, like a notification */
.mk-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 16px; min-height: 16px; }
.due-badge { position: absolute; top: -5px; right: -6px; width: 9px; height: 9px; border-radius: 50%; background: #D92D20; box-shadow: 0 0 0 2px var(--surface); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .legend-hint { margin-left: auto; }

/* Deadline calendar: one week, Mon–Sun */
.cal-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line-soft); }
/* One day with its deadlines (DeadlineDay): big cells in the calendar, small ones in the week rows of "Deadlines" */
.day { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.day-n { font: 500 12px var(--mono); color: var(--muted); }
.day.is-past .day-n { color: var(--faint); }
.day.is-today { background: var(--accent-soft); box-shadow: inset 0 3px 0 var(--accent); }
.day.is-today .day-n { color: var(--accent-ink); font-weight: 600; }
.days .day:not(.is-today) { background: var(--surface); }
.days .day { min-height: 110px; padding: 10px; }
.wk .day { min-height: 44px; padding: 6px 8px; gap: 4px; border-left: 1px solid var(--bg); }
.wk .day-n { font-size: 11px; }
.ev { display: flex; flex-direction: column; gap: 1px; padding: 5px 7px; border-left: 3px solid var(--m); border-radius: 2px; background: var(--surface-3); font-size: 12px; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.ev small { color: var(--muted); font-size: 11px; }
.none { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 14px; }
/* On a phone the week is a list: one row per day */
@media (max-width: 640px) {
    .days { grid-template-columns: minmax(0, 1fr); }
    .days .day, .wk .day { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
    .day-n { width: 72px; flex-shrink: 0; }
    .legend .legend-hint { margin-left: 0; }
}

/* Deadlines page (design: App-Deadlines) — the next four with a countdown */
.soon { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.cd { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: center; padding: 12px 16px; border-left: 1px solid var(--line-soft); }
.cd:first-child { border-left: 0; }
.cd-n { grid-row: 1 / 3; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 54px; padding: 6px 8px; border-radius: 4px; background: var(--bg); line-height: 1; }
.cd-n b { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cd-n span { font: 10px var(--mono); color: var(--muted); text-transform: uppercase; margin-top: 2px; }
.cd.is-first .cd-n { background: var(--warn-tint); }
.cd.is-first .cd-n b { color: var(--warn); }
.cd-what { font-size: 14px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
/* Week by week: Mon–Fri wide, the weekend narrow */
.days-h, .wk { display: grid; grid-template-columns: 110px repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, 0.55fr)); }
.days-h { border-bottom: 1px solid var(--line); font: 500 11px var(--mono); color: var(--muted); text-transform: uppercase; }
.days-h span { padding: 8px 10px; }
.wk { border-top: 1px solid var(--line-soft); }
.days-h + .wk { border-top: 0; }
.wk-l { display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 6px 12px; }
.wk-l b { font: 500 13px var(--mono); }
.wk-l span { font: 11px var(--mono); color: var(--muted); }
/* This week: a light tint over the whole row; today stands out within it */
.wk.is-now { background: var(--accent-faint); }
.wk.is-now .wk-l { box-shadow: inset 3px 0 0 var(--accent); }
.wk.is-now .wk-l b { color: var(--accent-deep); }
.gap { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted-2); background: var(--surface-2); }
.gap b { font: 500 12px var(--mono); min-width: 86px; }
.gap.is-break { background: var(--stripes); }
.ical { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; flex-direction: row; }
.ical-help { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line-soft); }
@media (max-width: 860px) {
    .soon { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cd:nth-child(3) { border-left: 0; }
    .cd:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
}
/* On a phone each week is a short list: only days with a deadline, and today */
@media (max-width: 640px) {
    .days-h { display: none; }
    .wk { grid-template-columns: minmax(0, 1fr); }
    .wk-l { flex-direction: row; justify-content: flex-start; align-items: baseline; gap: 10px; padding: 8px 12px; background: var(--surface-2); }
    .wk .day { border-left: 0; border-top: 1px solid var(--bg); }
    .wk .day.is-empty:not(.is-today) { display: none; }
    .soon { grid-template-columns: minmax(0, 1fr); }
    .cd { border-left: 0; }
    .cd + .cd { border-top: 1px solid var(--line-soft); }
}

/* Filter chips (Deadlines): one row, scrolls sideways on a phone. Not .chip: that's the mixer's add-ons. */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.filter-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 18px; background: var(--surface); color: var(--text); font: 500 13px var(--sans); white-space: nowrap; cursor: pointer; flex-shrink: 0; }
.filter-chip:hover { border-color: var(--text); }
.filter-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--on-strong); }
.filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Archive search: where a recap matched, below its topic */
.hit { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.hit mark { background: var(--highlight); color: var(--text); padding: 0 1px; border-radius: 2px; }
.hit-where { font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }

/* Paragraph-like text without the browser's default margins */
p.hint, p.small, h2.eyebrow { margin: 0; }

/* Sign-in page: what Stroodle does, as label and text rows */
.facts { display: flex; flex-direction: column; margin: 8px 0 0; }
.facts > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 1px solid var(--line); }
.facts dt { padding-top: 2px; }
.facts dd { margin: 0; font-size: 14px; }
@media (max-width: 560px) {
    .facts > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* Last, so it wins over the animations above */
@media (prefers-reduced-motion: reduce) {
    .knob, .track-fill { transition: none; }
    .dot.live::after { animation: none; }
    .spin { animation: none; }
}

/* Admin page (design: App-Admin) */
.admin-tag { font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-left: 1px solid var(--line-soft); }
.stat:first-child { border-left: 0; }
.stat-num { font-size: 28px; line-height: 1; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }
.code-cell { font-family: var(--mono); font-size: 13px; }
@media (max-width: 860px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat { border-left: 0; border-top: 1px solid var(--line-soft); }
}

/* Calendar entries (design: App-Deadlines, App-Dashboard): Moodle assignments are clickable cards, dates the AI found stay flat */
.ev-ex { display: flex; flex-direction: column; gap: 3px; padding: 6px 8px; border: 1px solid var(--card-line); border-left: 3px solid var(--m); border-radius: 3px; background: var(--surface); text-decoration: none; color: var(--text) !important; font-size: 12px; line-height: 1.3; box-shadow: 0 1px 2px rgba(21, 24, 29, .10); }
.ev-ex:hover { border-color: var(--accent); border-left-color: var(--m); }
.ev-ex:hover .ev-title { text-decoration: underline; }
.ev-ex.is-overdue { background: var(--danger-faint); border-color: var(--danger-line); border-left-color: var(--m); }
.ev-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 4px; }
.ev-time { font: 500 11px var(--mono); }
.ev-ex .badge, .cd-sub .badge { font-size: 9px; padding: 1px 4px; }
.ev-title { font-weight: 500; overflow-wrap: anywhere; }
/* Narrow day columns: long module names wrap, the badge and "Open ›" move to the next line instead of sticking out */
.ev-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 6px; font-size: 11px; color: var(--muted); }
.ev-foot > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.ev-foot > span + span { margin-left: auto; white-space: nowrap; }
.ev-found { display: flex; flex-direction: column; gap: 2px; padding: 4px 7px; border-left: 3px solid var(--m); background: var(--bg); border-radius: 2px; font-size: 12px; line-height: 1.3; color: var(--text-2); overflow-wrap: anywhere; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
/* "Next up": an assignment's title is a link that covers the whole card */
.cd { position: relative; }
.cd-link { color: var(--text) !important; text-decoration: none; }
.cd-link::after { content: ""; position: absolute; inset: 0; }
.cd:hover .cd-link { text-decoration: underline; }
.cd:has(.cd-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.cd-link:focus-visible { outline: none; }

/* Documents page (design: App-Documents) */
.filters { gap: 12px; align-items: flex-end; }
.table tr.is-overdue td { background: var(--danger-faint); }
.table tr.is-overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table tr.is-soon td { background: var(--warn-paper); }
.table tr.is-soon td:first-child { box-shadow: inset 3px 0 0 var(--b-todo); }
.due b { display: block; font-weight: 500; white-space: nowrap; }
.due small { font-size: 12px; color: var(--muted); }
tr.is-overdue .due small { color: var(--danger); font-weight: 500; }
tr.is-soon .due small { color: var(--warn); font-weight: 500; }
.guide-no { font-size: 13px; color: var(--muted); font-style: italic; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 28px; }
.prompt { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-3); font-weight: 500; }

/* Assignment and document page (design: App-Assignment): content left, details in a sticky sidebar (on a phone on top) */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.sidecard { position: sticky; top: 16px; }
.facts { margin: 0; display: flex; flex-direction: column; }
.facts > div { display: flex; flex-direction: column; gap: 3px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.facts > div:first-child { border-top: 0; }
.facts dt { font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-size: 15px; font-weight: 500; }
.facts small { font-size: 12px; color: var(--muted); }
.desc-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; }
.desc-fade { max-height: 96px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 40%, transparent); mask-image: linear-gradient(#000 40%, transparent); }
.ai-mark { display: inline-flex; align-items: center; gap: 6px; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 900px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
    .sidecard { position: static; order: -1; }
}

/* Recap page: read marker, questions and changes per line, bookmarks (design: App-Recap-Actions, issues #2 and #4) */
.stickyhead { position: sticky; top: 0; z-index: 8; margin: 0 -24px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 96%, transparent); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.stickyhead .h1 { font-size: 26px; }
.progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.pbar { flex: 1 1 200px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.pbar span { display: block; height: 100%; background: var(--ok); transition: width 0.2s ease; }
.continue { font-size: 14px; font-weight: 500; }
.side-col { position: sticky; top: 126px; max-height: calc(100vh - 142px); overflow: auto; }

.art { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 14px; padding-left: 20px; }
.art .intro { display: flex; flex-direction: column; gap: 10px; padding: 0 14px; }
.art .intro .u-text { font-size: 17px; color: var(--text-2); }
.art .block { gap: 4px; }
.art .lines { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
.line { position: relative; margin: 0 -6px; padding: 2px 6px; border-radius: 3px; }
.line:hover { background: var(--accent-faint); }
.u-text { margin: 0; font-size: 15px; line-height: 1.6; }
.line.is-read .u-text { color: var(--muted-2); }
.line.is-bookmark { background: var(--bookmark-bg); box-shadow: inset 3px 0 0 var(--bookmark); }
.line.is-bookmark .u-text { color: var(--text); }
.has-note > .u-text::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--b-todo); vertical-align: middle; }

/* The dot in the gutter left of every line, close to it; list items sit 26px further in */
.line-dot { position: absolute; left: -34px; top: 4px; width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
li.line > .line-dot { left: -60px; }
.line-dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--field-line); background: var(--surface); transition: transform 0.1s; }
.line:hover > .line-dot::before, .line-dot:focus-visible::before, .line.is-menu > .line-dot::before { border-color: var(--accent); transform: scale(1.25); }
.line.is-read > .line-dot::before { background: var(--ok); border-color: var(--ok); }
/* "read to here" left of the dot; on a phone below it, as there is no room on the left */
.line.is-mark > .line-dot::after { content: "read to here"; position: absolute; top: 50%; right: 24px; transform: translateY(-50%); white-space: nowrap; font: 500 10px var(--mono); color: var(--ok); }
@media (max-width: 900px) {
    .line.is-mark > .line-dot::after { top: 22px; right: auto; left: 0; width: 22px; transform: none; white-space: normal; text-align: center; font-size: 8px; line-height: 1.15; }
}

/* Room for that label on narrower desktop windows: the recap moves right only as far as the label needs (dot and text
   keep their small gap); wide windows have the room in the margin already */
@media (min-width: 901px) {
    .art { padding-left: max(20px, calc(84px - max(0px, (100vw - 1248px) / 2))); }
}

.menu { position: absolute; z-index: 6; left: -8px; top: 30px; display: flex; flex-direction: column; min-width: 220px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); box-shadow: 0 6px 18px var(--shadow); }
li.line > .menu { left: -34px; }
.menu button { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 3px; background: none; font: 14px var(--sans); color: var(--text); text-align: left; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--accent-paper); }
.menu b { width: 18px; text-align: center; font-weight: 600; color: var(--muted); }
/* The same colours as what each action leaves on the line: green read dot, blue question, orange change, purple bookmark */
.menu b.mark-read { color: var(--ok); }
.menu b.mark-question { color: var(--accent); }
.menu b.mark-rewrite { color: var(--b-todo); }
.menu b.mark-bookmark { color: var(--bookmark); }

.u-note { display: inline-flex; margin-top: 4px; padding: 1px 6px; border-radius: 9px; background: var(--warn-tint); color: var(--warn); font: 500 11px var(--mono); }
.u-answer { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; padding: 8px 10px; border-left: 3px solid var(--b-q); border-radius: 2px; background: var(--surface-3); font-size: 14px; line-height: 1.55; }
.u-answer p { margin: 0; }
.u-answer-q { font-size: 12px; color: var(--muted); }
.composer { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 6px; padding: 12px; border: 1px solid var(--accent-line); border-radius: 4px; background: var(--accent-faint); }
.composer.is-rewrite { border-color: var(--warn-line); background: var(--warn-paper); }
.c-kind { font: 500 12px var(--mono); color: var(--accent-deep); }
.composer.is-rewrite .c-kind { color: var(--warn); }
.composer .textarea { min-height: 72px; background: var(--surface); }

/* The bar below selected text */
.selpop { position: absolute; z-index: 5; display: flex; gap: 2px; padding: 4px; border-radius: 4px; background: var(--text); box-shadow: 0 4px 14px var(--shadow); transform: translateX(-50%); white-space: nowrap; }
.selpop button { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 10px; border: 0; border-radius: 3px; background: none; color: var(--on-strong); font: 500 13px var(--sans); cursor: pointer; }
.selpop button:hover, .selpop button:focus-visible { background: var(--text-2); }
.selpop b { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 3px; background: var(--text-2); font-weight: 600; }

.done { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px; border: 1px dashed var(--field-line); border-radius: 4px; background: var(--surface); }

/* Side panel "For your AI" and the bookmarks */
.item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.panel-head + .item { border-top: 0; }
.it-q { font-size: 12px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.it-t { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.it-x { grid-row: 1 / 4; grid-column: 2; align-self: start; width: 28px; height: 28px; border: 0; background: none; color: var(--muted); border-radius: 3px; cursor: pointer; }
.it-x:hover { background: var(--chip); color: var(--text); }
.bookmark-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 16px; border: 0; border-top: 1px solid var(--line-soft); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.panel-head + .bookmark-row { border-top: 0; }
.bookmark-row:hover { background: var(--surface-2); }
.bookmark-text { padding-left: 8px; border-left: 3px solid var(--bookmark); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }

/* Modules page: the arrow before a module opens its recaps below the row, each with its bookmarks */
.table td.expand-cell { width: 1%; padding-right: 0; }
.expand { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); font: 600 18px/1 var(--sans); cursor: pointer; transition: transform 0.15s; }
.expand:hover { background: var(--surface-2); color: var(--text); }
.expand[aria-expanded="true"] { transform: rotate(90deg); }
.bm-count { color: var(--bookmark); font-weight: 500; }
.table tr.bookmarks-row > td { border-top: 0; padding: 0 16px 16px 60px; }
.bookmarks-row p { margin: 0; }
.bm-recap { display: flex; flex-direction: column; gap: 4px; }
.bm-recap + .bm-recap { margin-top: 8px; }
.bm-recap:has(.bm-line) + .bm-recap { margin-top: 12px; }
.app .bm-recap-head { font-family: var(--mono); font-size: 11px; color: var(--muted); text-decoration: none; }
.app .bm-recap-head:hover { color: var(--text); text-decoration: underline; }
.app .bm-line { display: block; padding: 4px 8px; border-left: 3px solid var(--bookmark); border-radius: 0 var(--radius) var(--radius) 0; color: var(--text); font-size: 13px; line-height: 1.45; text-decoration: none; overflow-wrap: anywhere; }
.app .bm-line:hover { background: var(--bookmark-bg); color: var(--text); }
.bm-where { margin-right: 6px; color: var(--muted); font-size: 12px; }
/* Phones: the table scrolls sideways, the bookmarks stay in view and wrap at the screen's width. */
@media (max-width: 640px) {
  .table tr.bookmarks-row > td { padding-left: 16px; }
  .bm-cell { position: sticky; left: 16px; max-width: calc(100vw - 82px); }
}

@media (max-width: 900px) {
    .side-col { position: static; max-height: none; }
    .stickyhead .h1 { font-size: 20px; }
}


/* Banner below the top bar until the email address is confirmed */
.confirm-banner { background: var(--warn-faint); border-bottom: 1px solid var(--warn-line); font-size: 14px; }
.confirm-banner-in { max-width: 1200px; margin: 0 auto; padding: 10px 24px; display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }

/* Footer on every page (SiteFooter): at the bottom also on short pages. div.app only: the views in the AI's chat put
   class "app" on <html>. */
div.app { display: flex; flex-direction: column; }
.site-foot { margin-top: auto; border-top: 1px solid var(--line); background: var(--surface); font-size: 13px; color: var(--muted); }
.site-foot-in { max-width: 1200px; width: 100%; margin: 0 auto; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 8px 20px; flex-wrap: wrap; box-sizing: border-box; }
.site-foot-in + .site-foot-in { padding-top: 0; font-size: 12px; }
.site-foot-brand { display: flex; align-items: center; gap: 10px; }
.site-foot-brand .brand { font-size: 13px; }
.site-foot-links { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.app .site-foot a { color: var(--muted); }
.app .site-foot a:hover { color: var(--text); }

/* Text pages (privacy): one readable column */
.prose-page { width: 100%; max-width: 720px; margin: 0 auto; padding: 48px 24px 72px; display: flex; flex-direction: column; gap: 22px; box-sizing: border-box; }
.prose-page section { display: flex; flex-direction: column; gap: 8px; }
.prose-page .p { margin: 0; line-height: 1.6; }
.prose-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.6; }

/* Module settings: the module's Git repositories (GitRepositories) */
.git-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.panel-head + .git-row { border-top: 0; }
.git-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; overflow-wrap: anywhere; }
.git-problem { color: var(--danger); }
