/*
 * App layer on top of vendored Pico CSS (static/pico.min.css).
 *
 * Pico styles the semantic elements (typography, forms, buttons, tables, links)
 * and provides light/dark via `data-theme` + `--pico-*` variables. This file
 * (1) retunes Pico's design tokens into a distinct identity for the lesson
 * planner — indigo primary, warm-amber accent, editorial heading serif — so we
 * are not shipping Pico's defaults as-is, and (2) adds the app-specific chrome
 * (top bar, nav), card/panel layout, form helpers, and the journal / grade /
 * seating grids — all keyed off Pico variables so they follow the active theme.
 */

/* ---------- Self-hosted fonts (SIL OFL; files in /static/fonts) ---------- */
/*
 * Inter for body/UI, Fraunces for headings. `font-display: swap` shows the
 * system fallback immediately and swaps in the web font once loaded, so first
 * paint is never blocked. Only the latin subset is shipped.
 */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/static/fonts/inter-400.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/static/fonts/inter-500.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/static/fonts/inter-600.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/static/fonts/inter-700.woff2") format("woff2");
}
@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/static/fonts/fraunces-500.woff2") format("woff2");
}
@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/static/fonts/fraunces-600.woff2") format("woff2");
}
@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/static/fonts/fraunces-700.woff2") format("woff2");
}

/* ---------- Design tokens: retune Pico for a distinct identity ---------- */
:root {
    /* Typography: crisp UI sans for body, editorial serif for headings. */
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --font-head: "Fraunces", Georgia, "Times New Roman", serif;
    --pico-font-family-sans-serif: var(--font-body);
    --pico-font-family: var(--font-body);

    /* App accent. `--accent` is a bright amber for decorative fills (brand mark,
     * card edges); `--accent-text` is a darker shade that clears WCAG AA contrast
     * (>=4.5:1 on the card background) for accent-coloured *text*. */
    --accent: #e08a1e;
    --accent-text: #b45309;

    /* Slightly softer, more modern rounding and a calmer type scale. */
    --pico-border-radius: 0.6rem;
    --pico-line-height: 1.6;

    /* Indigo primary (light). Overriding Pico's blue with the app's own hue. */
    --pico-primary: #4338ca;
    --pico-primary-background: #4f46e5;
    --pico-primary-hover: #3730a3;
    --pico-primary-hover-background: #4338ca;
    --pico-primary-focus: rgba(79, 70, 229, 0.28);
    --pico-primary-inverse: #ffffff;
    --pico-primary-underline: rgba(67, 56, 202, 0.4);

    /* Cool off-white app canvas so white cards/panels lift off the page. */
    --pico-background-color: #f5f6fb;
    --pico-card-background-color: #ffffff;
    --pico-card-border-color: #e7e8f0;
    --pico-card-sectioning-background-color: #fbfbfe;
    --pico-muted-border-color: #e7e8f0;
    --pico-card-box-shadow: 0 1px 2px rgba(20, 22, 40, 0.04), 0 6px 20px rgba(20, 22, 40, 0.05);
}

[data-theme="dark"] {
    --accent: #f4b458;
    /* On the dark canvas the bright amber already clears AA, so text reuses it. */
    --accent-text: #f4b458;

    /* Indigo primary (dark) — brighter so it reads on the deep canvas. */
    --pico-primary: #a5b4fc;
    --pico-primary-background: #6366f1;
    --pico-primary-hover: #c7d2fe;
    --pico-primary-hover-background: #4f46e5;
    --pico-primary-focus: rgba(129, 140, 248, 0.3);
    --pico-primary-inverse: #0b0d14;
    --pico-primary-underline: rgba(165, 180, 252, 0.4);

    /* Deep, slightly cool slate canvas with lifted card surfaces. */
    --pico-background-color: #0f111a;
    --pico-card-background-color: #191c28;
    --pico-card-border-color: #2a2e3f;
    --pico-card-sectioning-background-color: #1f2331;
    --pico-muted-border-color: #2a2e3f;
    --pico-card-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* ---------- Design tokens: spacing & type scale ---------- */
/*
 * A single spacing scale (4px base) and a modular type scale (1.2 ratio off a
 * 1rem body) so layout values come from one vocabulary instead of ad-hoc rems.
 * Prefer these vars for new padding/margin/gap and font sizes.
 */
:root {
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 2rem;

    --text-sm: 0.833rem;   /* labels, table cells, dense UI */
    --text-base: 1rem;     /* body / prose */
    --text-lg: 1.2rem;     /* section leads */
    --text-xl: 1.44rem;    /* h2 */
    --text-2xl: 1.728rem;  /* h1 */
}

/* Editorial serif headings with tightened tracking; keep dense UI on the sans. */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    font-weight: 600;
    letter-spacing: -0.01em;
}
h1 { letter-spacing: -0.02em; }
.content > h1:first-child { margin-bottom: var(--space-5); }

/* Page title with an inline control (e.g. the school-year picker) on the right,
 * so a one-select filter doesn't cost a whole panel row above the content. */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin-bottom: var(--space-5);
}
.page-head h1 { margin-bottom: 0; }
.page-head form {
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
}
.page-head label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-size: 0.9rem;
    color: var(--pico-muted-color);
}
.page-head select { width: auto; margin: 0; }
/* Groups the right-hand controls (a filter/picker form + a "New…" button) into
 * one cluster, so the page-head stays a clean title-left / controls-right split
 * instead of stranding a middle item when there are three. */
.page-head-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
}

/* ---------- Layout: fixed left sidebar + scrolling content ---------- */
.layout { display: flex; align-items: stretch; min-height: 100vh; }
.content { flex: 1 1 auto; min-width: 0; padding: 1.75rem 2rem 4rem; }

.sidebar {
    flex: 0 0 15rem;
    width: 15rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 0.9rem 1.2rem;
    background: var(--pico-card-background-color);
    border-right: 1px solid var(--pico-muted-border-color);
    /* Stays put while the content column scrolls; its own list scrolls if tall. */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
/* Brand + collapse button share one row; the divider lives on the wrapper. */
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--pico-color);
    text-decoration: none;
    white-space: nowrap;
    padding: 0.2rem 0.55rem;
}
.brand:hover { text-decoration: none; }
/* Warm accent mark before the wordmark for a small piece of identity. */
.brand::before {
    content: "";
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 0.2rem;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.mainnav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    margin: 0.3rem 0;
}
.mainnav a {
    display: block;
    color: var(--pico-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.45rem 0.7rem;
    border-radius: 0.45rem;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.mainnav a:hover {
    color: var(--pico-primary);
    background: color-mix(in srgb, var(--pico-primary) 12%, transparent);
    text-decoration: none;
}
/* Current section (set by nav.js). Filled pill so the location is obvious. */
.mainnav a[aria-current="page"] {
    color: var(--pico-primary-inverse);
    background: var(--pico-primary-background);
    font-weight: 600;
}
/* User + logout pinned to the bottom of the sidebar. */
.sidebar-foot {
    margin-top: auto;
    padding-top: 0.8rem;
    border-top: 1px solid var(--pico-muted-border-color);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.user { color: var(--pico-muted-color); font-size: 0.8rem; word-break: break-all; }
.sidebar-foot .inline { margin: 0; }
.sidebar-foot button { width: 100%; margin: 0; }
.spacer { flex: 1; }

/* Theme toggle lives in the sidebar footer; full-width like the logout button
 * (the .sidebar-foot button rule sizes it), just a touch smaller. */
.theme-toggle { font-size: 0.85rem; padding-block: 0.4rem; }

/* ---------- Collapsible sidebar ---------- */
/* A ghost square button whose glyph is a CSS-drawn hamburger (three bars via a
 * bar + box-shadow), so it inherits the current text color in both themes. */
.nav-toggle {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    color: var(--pico-secondary);
    background: transparent;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 0.45rem;
    cursor: pointer;
}
.nav-toggle:hover {
    color: var(--pico-primary);
    border-color: var(--pico-primary);
    background: color-mix(in srgb, var(--pico-primary) 12%, transparent);
}
.nav-toggle::before {
    content: "";
    width: 1rem;
    height: 2px;
    background: currentColor;
    box-shadow: 0 -0.32rem 0 currentColor, 0 0.32rem 0 currentColor;
}

/* Reopen tab: hidden until the sidebar is collapsed, then floats top-left. */
.nav-open {
    display: none;
    position: fixed;
    top: 0.7rem;
    left: 0.7rem;
    z-index: 50;
    background: var(--pico-card-background-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.nav-collapsed .sidebar { display: none; }
.nav-collapsed .nav-open { display: inline-flex; }
/* Keep page content clear of the floating reopen button while collapsed. */
.nav-collapsed .content { padding-top: 3.5rem; }

/* Narrow screens: drop the sidebar to a stacked top bar (no JS drawer needed). */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar {
        flex: none;
        width: auto;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--pico-muted-border-color);
    }
    .sidebar-head { border-bottom: none; padding-bottom: 0.3rem; }
    .mainnav { flex-direction: row; flex-wrap: wrap; gap: 0.2rem 0.3rem; }
    /* The stacked top bar is already compact; the collapse feature doesn't apply. */
    .nav-toggle { display: none; }
    .nav-collapsed .sidebar { display: flex; }
    .nav-collapsed .content { padding-top: 1.25rem; }
    .sidebar-foot {
        flex-direction: row;
        align-items: center;
        margin-top: 0.4rem;
        padding-top: var(--space-2);
    }
    .sidebar-foot button { width: auto; }
    .content { padding: 1.25rem 1.1rem 3rem; }
}

/* ---------- Panels / cards ---------- */
.panel {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color, var(--pico-muted-border-color));
    border-radius: var(--pico-border-radius);
    padding: 1rem 1.25rem;
    margin-bottom: var(--space-5);
    box-shadow: var(--pico-card-box-shadow);
}
.panel > :last-child { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.auth-card {
    max-width: 24rem;
    margin: 3.5rem auto;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color, var(--pico-muted-border-color));
    border-radius: var(--pico-border-radius);
    padding: 2rem 2rem 1.75rem;
    box-shadow: var(--pico-card-box-shadow);
    /* Warm accent hairline along the top edge for a branded touch. */
    border-top: 3px solid var(--accent);
}
.auth-card h1 { margin-bottom: 0.25rem; }
.auth-card .auth-sub { color: var(--pico-muted-color); margin-bottom: 1.5rem; font-size: 0.95rem; }
.auth-card button[type="submit"] { margin-top: 0.5rem; }
.auth-card > p:last-child { margin-bottom: 0; text-align: center; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.card {
    display: flex; flex-direction: column; gap: 0.2rem;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-card-border-color, var(--pico-muted-border-color));
    border-radius: var(--pico-border-radius);
    padding: 1.25rem; color: var(--pico-color); text-decoration: none;
    box-shadow: var(--pico-card-box-shadow);
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
a.card:hover {
    border-color: color-mix(in srgb, var(--pico-primary) 55%, var(--pico-card-border-color));
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(20, 22, 40, 0.1);
    text-decoration: none;
}
.card .stat {
    font-family: var(--font-head);
    font-size: 2.4rem; font-weight: 600; line-height: 1.05;
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
}
.card .label { color: var(--pico-muted-color); font-weight: 500; }
.card ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }

/* ---------- Form layouts ---------- */
/* An inline row of controls (Pico makes inputs full-width + spaced; undo that). */
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem; margin-bottom: 0.5rem; }
.row :is(input, select, textarea) { width: auto; flex: 1; min-width: 11ch; margin-bottom: 0; }
.row button, .row .secondary { width: auto; margin-bottom: 0; }
.row .grow { flex: 4; }
.row .code { flex: 0 0 auto; font-family: var(--pico-font-family-monospace); white-space: nowrap; }
.narrow { flex: 0 0 7ch !important; min-width: 0 !important; }

/* A responsive label grid for the bigger forms. */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; align-items: end; }
.grid-form > label { margin-bottom: 0.6rem; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form > button, .grid-form .form-actions { grid-column: 1 / -1; justify-self: start; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.25rem; }
.form-actions .secondary, .form-actions button { margin-bottom: 0; }

/* Inline single-button forms (delete/save actions in tables). */
.inline { display: inline; margin: 0; }
/* Pico makes `button[type=submit]` full-width; keep action buttons shrink-wrapped. */
.inline button, .actions button { width: auto; margin: 0; }
td.actions, .actions { display: flex; gap: 0.6rem; align-items: center; justify-content: flex-end; }
.actions a { white-space: nowrap; }

/* Compact, uniform sizing for form controls and every button / button-styled
 * link, so inputs and buttons line up at the same height in a row. (Pico's
 * default 1rem / 1.5-line-height control is a touch tall for dense action rows.)
 * Single-line controls get line-height:1 to match the buttons exactly;
 * textarea keeps a readable multi-line height. */
button, [type="submit"], [type="button"], [type="reset"], [role="button"],
a.secondary,
input:not([type="checkbox"]):not([type="radio"]), select {
    font-size: 0.85rem;
    line-height: 1;
    /* Pin every control to the exact same height (box-sizing is border-box):
     * text box (0.85rem) + Pico's shared vertical padding + border, top and
     * bottom. An explicit value avoids the sub-pixel rounding that content-based
     * `height: auto` produces differently for inputs vs buttons. */
    height: calc(0.85rem + var(--pico-form-element-spacing-vertical) * 2
                 + var(--pico-border-width) * 2);
}
textarea { font-size: 0.85rem; }

/* Links styled as secondary buttons (Pico only styles `button.secondary`). */
a.secondary {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
    border: var(--pico-border-width, 1px) solid var(--pico-secondary-border, var(--pico-secondary));
    border-radius: var(--pico-border-radius);
    color: var(--pico-secondary-inverse, #fff);
    background: var(--pico-secondary-background, var(--pico-secondary));
    text-decoration: none;
}
a.secondary:hover { text-decoration: none; filter: brightness(1.05); }

/* Destructive actions (Pico has no red variant). */
button.danger, .danger {
    --pico-background-color: #c0392b;
    --pico-border-color: #c0392b;
    --pico-color: #fff;
}
[data-theme="dark"] button.danger, [data-theme="dark"] .danger {
    --pico-background-color: #e06c5a;
    --pico-border-color: #e06c5a;
    --pico-color: #17110f;
}
button.linkish { width: auto; margin: 0; padding: 0 0.3rem; background: transparent; border: none; color: #c0392b; font-weight: 700; }

/* ---------- Chips & misc ---------- */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0.5rem 0; }
.chips li { background: var(--pico-secondary-background, var(--pico-muted-border-color)); color: var(--pico-secondary-inverse, var(--pico-color)); border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.85rem; }
.muted { color: var(--pico-muted-color); }
.error { color: #c0392b; font-weight: 500; }

/* Read-only banner shown to users without a valid subscription. */
.view-only-banner {
    margin-bottom: 1rem;
    padding: 0.6rem 1rem;
    border-radius: var(--pico-border-radius);
    background: #fff3cd;
    border: 1px solid #ffe08a;
}
.view-only-banner a { color: #7a5b00; font-weight: 600; text-decoration: none; }

/* Subscription status + admin active/expired markers. */
.status-ok { color: #2e7d32; font-weight: 500; }
.status-warn { color: #c0392b; font-weight: 500; }
.badge { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.5rem;
    border-radius: 999px; font-size: 0.8em; }
.badge.ok { background: #e6f4ea; color: #2e7d32; }
.badge.warn { background: #fdecea; color: #c0392b; }
label.checkbox { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }
label.checkbox input { width: auto; margin: 0; }

/* ---------- Journal & seating grids ---------- */
table.journal, table.seatgrid { table-layout: fixed; }
table.journal th, table.journal td,
table.seatgrid td {
    border: 1px solid var(--pico-muted-border-color);
    vertical-align: top;
    padding: 0.4rem;
}
table.journal thead th, table.journal tbody th {
    background: var(--pico-card-sectioning-background-color);
}
table.journal td { height: 3.4rem; }
table.journal small { color: var(--pico-muted-color); }
/* Occupied slots (cells containing a lesson link) read as filled tiles with a
 * primary accent edge; empty slots stay quiet until hovered. Needs :has(). */
table.journal td:has(a) {
    background: color-mix(in srgb, var(--pico-primary) 9%, transparent);
    border-left: 3px solid var(--pico-primary-background);
}
table.journal td:has(a) a { font-weight: 500; }
/* When the lesson's subject has a colour, it replaces the generic primary
 * accent (tint + left edge) so the journal is scannable at a glance. Placed
 * after the rule above to win at equal specificity. --subject-color is set
 * inline from a server-validated #RRGGBB value. */
table.journal td.has-subject {
    background: color-mix(in srgb, var(--subject-color) 15%, transparent);
    border-left: 3px solid var(--subject-color);
}
table.journal td:has(.cell-place):hover {
    background: color-mix(in srgb, var(--pico-primary) 5%, transparent);
}
table.seatgrid td { height: 3rem; text-align: center; vertical-align: middle; border-style: dashed; }
/* Empty seats: faint dashed placeholder; occupied seats: solid filled chip. */
table.seatgrid td:empty::before { content: "·"; color: var(--pico-muted-color); }
table.seatgrid td:not(:empty) {
    border-style: solid;
    font-weight: 500;
    background: color-mix(in srgb, var(--pico-primary) 8%, transparent);
}
/* A lesson whose own from/to was edited off its period slot: flag it below
 * the title in the accent colour so the deviation stands out. */
small.alt-time {
    display: block;
    margin-top: 0.1rem;
    color: var(--accent-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: help;
}
.cell-place select { width: 100%; margin: 0; border: none; background: transparent; }
/* The "+" placeholder in empty slots: a subtle, centered add affordance. */
.cell-place select:invalid { color: var(--pico-muted-color); text-align: center; }

/* Day information rows above the lessons (holidays, day notes, absences,
 * birthdays): compact, auto height, and never styled as lesson tiles even
 * when a cell holds links (the absence list links to each student). */
table.journal tr.day-info td {
    height: auto;
    background: none;
    border-left: 1px solid var(--pico-muted-border-color);
    font-size: var(--text-sm);
}
table.journal tr.day-info td a { font-weight: 400; }
/* A heavier rule separates the day rows from the lesson grid below. */
table.journal tr.day-info-last td,
table.journal tr.day-info-last th { border-bottom-width: 3px; }
table.journal tr.day-info td.is-holiday {
    background: color-mix(in srgb, var(--accent-text) 12%, transparent);
}
.day-tag { display: block; font-weight: 600; color: var(--accent-text); }
.day-list { list-style: none; margin: 0 0 0.25rem; padding: 0; }
.day-list li { margin: 0; padding: 0; list-style: none; }
.day-note { margin: 0; }
.day-note textarea {
    margin: 0 0 0.25rem;
    padding: 0.25rem 0.4rem;
    min-height: 2.6rem;
    font-size: var(--text-sm);
    resize: vertical;
}
.day-note button { width: 100%; margin: 0; padding: 0.15rem 0.4rem; font-size: var(--text-sm); }

.phase { border-left: 3px solid var(--pico-muted-border-color); padding-left: 0.75rem; }

/* ---------- Table polish (Pico owns the base; add scannability) ---------- */
/* Uppercase, muted headers read as column labels rather than heavy text. */
:where(.panel, .content) table th {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pico-muted-color);
    font-weight: 600;
}
/* Row hover aids left-to-right tracking in long student/grade lists. */
:where(.panel, .content) tbody tr {
    transition: background-color 0.1s ease;
}
:where(.panel, .content) tbody tr:hover {
    background: color-mix(in srgb, var(--pico-primary) 6%, transparent);
}

/* ---------- Course folders (lesson list, grouped by course) ---------- */
.course-folder {
    border: 1px solid var(--pico-card-border-color, var(--pico-muted-border-color));
    border-radius: var(--pico-border-radius);
    background: var(--pico-card-background-color);
    box-shadow: var(--pico-card-box-shadow);
    margin-bottom: 0.7rem;
    overflow: hidden;
}
.course-folder > summary {
    cursor: pointer;
    padding: 0.65rem 0.95rem;
    font-family: var(--font-head);
    font-weight: 600;
}
.course-folder > summary:hover {
    background: color-mix(in srgb, var(--pico-primary) 6%, transparent);
}
.course-folder[open] > summary {
    border-bottom: 1px solid var(--pico-muted-border-color);
}
/* Lesson count badge, pushed to the right edge of the folder header. */
.folder-count {
    float: right;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--pico-muted-color);
    background: color-mix(in srgb, var(--pico-primary) 12%, transparent);
    border-radius: 999px;
    padding: 0.05rem 0.55rem;
}
.course-folder table { margin: 0; }
/* Lesson rows are a flex list (not a table) so every course folder lays out
 * identically: title fills the left, then the date, a small gap, and the
 * edit/delete actions pinned to the right — with the date right-aligned in a
 * fixed slot so dates line up vertically across folders. */
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.95rem;
    border-top: 1px solid var(--pico-muted-border-color);
}
.lesson-row:first-child { border-top: none; }
.lesson-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-date {
    flex: 0 0 auto;
    min-width: 6rem;
    text-align: right;
    white-space: nowrap;
    color: var(--pico-muted-color);
    font-variant-numeric: tabular-nums;
}
/* The little gap before the buttons, then the actions cluster on the right. */
.lesson-row-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 0.5rem;
}
.lesson-row-actions a { white-space: nowrap; }
/* Numeric cells align on the decimal for tidy grade columns. */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Small helpers used on the setup page. */
.small { font-size: 0.8rem; }
.empty {
    color: var(--pico-muted-color);
    text-align: center;
    padding: var(--space-5);
    border: 1px dashed var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
}

/* ---------- Flash toast (transient success feedback; see flash.js) ---------- */
.toast {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    background: var(--pico-primary-background);
    color: var(--pico-primary-inverse);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--pico-border-radius);
    box-shadow: 0 6px 24px rgba(20, 22, 40, 0.18);
    font-size: var(--text-sm);
    font-weight: 600;
    opacity: 1;
    transition: opacity 0.4s ease;
}
.toast-hide { opacity: 0; }

/* ---------- Student photos ---------- */
/* Preview on the edit page. */
.student-photo {
    display: block;
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--pico-border-radius);
    margin-bottom: var(--space-4);
}
/* Name column with a leading round avatar in the student list. */
.name-cell { display: flex; align-items: center; gap: var(--space-3); }
.avatar {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
}
/* Placeholder keeps names aligned when a student has no photo. */
.avatar-empty { background: color-mix(in srgb, var(--pico-primary) 12%, transparent); }

/* ---------- Seating plan drag-and-drop ---------- */
.seat-chip { cursor: grab; }
.seat-chip:active { cursor: grabbing; }
/* The unseated students tray: a dashed drop zone of draggable name pills. */
.seat-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    min-height: 2.4rem;
    padding: 0.45rem;
    margin-bottom: 0.7rem;
    border: 1px dashed var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius);
}
.seat-tray .seat-chip {
    padding: 0.15rem 0.6rem;
    background: color-mix(in srgb, var(--pico-primary) 12%, transparent);
    border-radius: 999px;
    font-size: 0.85rem;
}
/* Highlight whatever a chip is hovering over during a drag. */
.drop-target { outline: 2px dashed var(--pico-primary); outline-offset: -2px; }
table.seatgrid td.drop-target {
    background: color-mix(in srgb, var(--pico-primary) 20%, transparent);
}
/* Blocked seats: hatched, not a drop target. */
table.seatgrid td.blocked {
    background: repeating-linear-gradient(
        45deg,
        var(--pico-muted-border-color) 0 4px,
        transparent 4px 8px
    );
    cursor: not-allowed;
}

/* Blocked-seat editor on the classroom form: a grid of toggle buttons. */
.blocked-editor {
    display: grid;
    grid-template-columns: repeat(var(--cols, 6), 1.6rem);
    gap: 3px;
    margin: 0.35rem 0 0.2rem;
}
.blk-cell {
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    margin: 0;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 3px;
    background: var(--pico-card-background-color);
    cursor: pointer;
}
.blk-cell.blocked {
    background: var(--pico-muted-color);
    border-color: var(--pico-muted-color);
}

/* Rich-text editor (Quill): theming lives in quill-theme.css, loaded after
 * quill.snow.css so it wins the cascade. Only the wrapper spacing stays here. */
.rich-editor { margin-bottom: 0.25rem; }
