/* ==========================================================================
   Page-specific styles: dashboard, courses, lessons, analytics, settings.
   ========================================================================== */

/* ---------- Dashboard ---------- */
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; background: linear-gradient(120deg, var(--primary-soft), transparent 70%), var(--bg-secondary); }
.welcome h1 { font-size: 1.35rem; margin-bottom: .15rem; }
.welcome p { margin: 0; color: var(--text-secondary); }
/* Dashboard welcome (partials/welcome.php): avatar and who they are, quick actions, then the headline numbers. */
.welcome-hero { position: relative; overflow: hidden; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem 1.25rem; padding: 1.4rem 1.5rem; }
.welcome-hero > :not(.welcome-art) { position: relative; }
.welcome-hero svg.welcome-art { position: absolute; right: 2%; top: -18px; width: 170px; height: 170px; stroke-width: 1; color: var(--primary-text); opacity: .07; transform: rotate(-12deg); pointer-events: none; }
.welcome-id { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.welcome-avatar { width: 64px; height: 64px; font-size: 1.3rem; flex-shrink: 0; box-shadow: 0 0 0 3px var(--bg-secondary), 0 0 0 5px var(--primary); }
.welcome-avatar img { width: 100%; height: 100%; object-fit: cover; }
.welcome-text { min-width: 0; }
.welcome-hero h1 { font-size: 1.45rem; margin-bottom: .4rem; }
.welcome-chips { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 1.6rem; }
.welcome-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 99px; background: var(--bg-secondary); border: 1px solid var(--border-color); font-size: .78rem; font-weight: 600; color: var(--text-secondary); }
.welcome-chip svg.icon { width: 13px; height: 13px; color: var(--primary-text); }
.welcome-hero p.welcome-note { margin-top: .5rem; font-size: .88rem; }
.welcome-hero p.welcome-note.is-warning { color: var(--warning); }
.welcome-hero p.welcome-note.is-success { color: var(--success); }
.welcome-hero p.welcome-note.is-danger { color: var(--danger); }
/* The quick actions are panes of the numbers' frosted glass, each icon in a tinted square as the numbers'
   are, centered beside the name; the main one is tinted, its icon solid (2026-11-06: the solid green
   button beside a near-black one, small and pinned to the corner, read as "pangit"). */
.welcome-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; align-self: center; }
.welcome-actions .btn {
    gap: .6rem; padding: .35rem .95rem .35rem .35rem; border-radius: var(--radius); font-size: .86rem; font-weight: 600;
    background: var(--glass-pane); border: 1px solid var(--glass-rim); box-shadow: var(--glass-shadow); color: var(--text-primary);
    -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
    transition: border-color var(--transition), transform var(--transition), background var(--transition);
}
.welcome-actions .btn svg.icon { width: 30px; height: 30px; padding: 7px; border-radius: 8px; flex-shrink: 0; background: var(--primary-soft); color: var(--primary-text); }
.welcome-actions .btn:hover { background: var(--glass-pane); border-color: var(--primary); transform: translateY(-1px); text-decoration: none; }
.welcome-actions .btn-primary { background: color-mix(in srgb, var(--primary) 18%, transparent); border-color: color-mix(in srgb, var(--primary) 55%, transparent); color: var(--primary-text); }
.welcome-actions .btn-primary svg.icon { background: var(--primary); color: var(--on-primary); }
.welcome-actions .btn-primary:hover { background: color-mix(in srgb, var(--primary) 26%, transparent); }
/* Beside the buttons, the cap drawn behind the card ran through them: it shows only where they sit under the name. */
@media (min-width: 721px) { .welcome-hero:has(.welcome-actions) svg.welcome-art { display: none; } }
/* The numbers are panes of frosted glass, as the app's welcome: soft lights behind the row show through them. */
.welcome-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(var(--welcome-stats, 3), minmax(0, 1fr)); gap: .75rem; position: relative; isolation: isolate; }
.welcome-stats::before {
    content: ''; position: absolute; inset: -30% -3%; z-index: -1; pointer-events: none;
    background:
        radial-gradient(24% 55% at 12% 58%, var(--glass-light), transparent 72%),
        radial-gradient(22% 52% at 50% 42%, var(--glass-light-2), transparent 72%),
        radial-gradient(24% 55% at 88% 58%, var(--glass-light), transparent 72%);
}
.welcome-stats:empty { display: none; }
.welcome-stat {
    display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem; border-radius: var(--radius);
    background: var(--glass-pane); border: 1px solid var(--glass-rim); box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
    color: inherit; text-decoration: none; transition: border-color var(--transition), transform var(--transition);
}
.welcome-stat:hover { border-color: var(--primary); transform: translateY(-1px); text-decoration: none; }
.welcome-stat strong { display: block; font-size: 1.15rem; line-height: 1.1; color: var(--text-primary); }
.welcome-stat small { color: var(--text-secondary); font-size: .76rem; }
.welcome-stat-skeleton { height: 58px; border-radius: var(--radius); }
.welcome-hero .term-pill { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 720px) {
    .welcome-hero { grid-template-columns: 1fr; }
    .welcome-actions { justify-content: flex-start; }
    .welcome-avatar { width: 52px; height: 52px; font-size: 1.05rem; }
}
@media (max-width: 1100px) { .welcome-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
/* Phones: the avatar sits beside the name, and the chips and the note take the card's full width
   below (.welcome-text drops out of the box so its children join the .welcome-id grid). The
   buttons share their row, and the numbers are a 2 × 2 grid instead of a tall single column. */
@media (max-width: 560px) {
    .welcome-hero { padding: 1.1rem 1rem; gap: .9rem; }
    .welcome-hero svg.welcome-art { width: 110px; height: 110px; top: -14px; right: -12px; }
    .welcome-id { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .7rem .8rem; }
    .welcome-text { display: contents; }
    .welcome-avatar { width: 46px; height: 46px; font-size: .95rem; }
    .welcome-hero h1 { font-size: 1.2rem; margin: 0; }
    .welcome-chips, .welcome-hero p.welcome-note { grid-column: 1 / -1; }
    .welcome-hero p.welcome-note { margin-top: 0; }
    .welcome-actions > * { flex: 1 1 auto; justify-content: center; }
    .welcome-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .welcome-stat { padding: .6rem .65rem; gap: .55rem; }
    .welcome-stat .stat-icon.sm { width: 30px; height: 30px; border-radius: 8px; }
    .welcome-stat small { display: block; line-height: 1.3; }
    .welcome-stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .welcome-stat, .welcome-actions .btn { transition: none; } .welcome-stat:hover, .welcome-actions .btn:hover { transform: none; } }
/* A viewer who asks for less transparency gets solid tiles. */
@media (prefers-reduced-transparency: reduce) {
    .welcome-stat, .welcome-actions .btn:not(.btn-primary) { background: var(--bg-secondary); border-color: var(--border-color); -webkit-backdrop-filter: none; backdrop-filter: none; }
    .welcome-actions .btn-primary { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Frosted glass cards over soft lights spread behind the whole grid: the dashboards' cards under the
   welcome and the Courses page's course cards (the user's picks; other pages keep solid cards).
   A card inside a card stays clear, so nothing is blurred twice. */
.glass-cards { position: relative; isolation: isolate; }
.glass-cards::before {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    /* Inside the grid, so a phone never scrolls sideways to it, and each light has faded out before
       the edge, so no straight line shows where the layer ends. */
    background:
        radial-gradient(20% 16% at 20% 18%, var(--glass-light), transparent),
        radial-gradient(20% 16% at 80% 34%, var(--glass-light-2), transparent),
        radial-gradient(22% 16% at 32% 70%, var(--glass-light-2), transparent),
        radial-gradient(20% 14% at 76% 84%, var(--glass-light), transparent);
}
.glass-cards .card {
    background: var(--glass-pane); border-color: var(--glass-rim); box-shadow: var(--glass-shadow);
    -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
}
.glass-cards .card .card { background: transparent; border-color: var(--border-color); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
/* The Courses page: a light behind each course card instead of across the grid, so a short list
   leaves no lights floating in the empty part of the grid. */
.grid-cards.glass-cards::before { content: none; }
.grid-cards.glass-cards > .course-card-wrap { isolation: isolate; }
.grid-cards.glass-cards > .course-card-wrap::before {
    content: ''; position: absolute; inset: 20% -5% -8%; z-index: -1; pointer-events: none;
    background: radial-gradient(50% 50% at 50% 50%, var(--glass-light), transparent);
}
.grid-cards.glass-cards > .course-card-wrap:nth-child(even)::before { background: radial-gradient(50% 50% at 50% 50%, var(--glass-light-2), transparent); }
@media (max-width: 560px) { .glass-cards .card { -webkit-backdrop-filter: blur(10px) saturate(140%); backdrop-filter: blur(10px) saturate(140%); } }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .glass-cards .card { background: var(--bg-secondary); } }
@media (prefers-reduced-transparency: reduce) { .glass-cards .card { background: var(--bg-secondary); border-color: var(--border-color); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.term-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border-radius: 99px; background: var(--bg-secondary); border: 1px solid var(--border-color); font-size: .8rem; color: var(--text-secondary); }

.integration-row { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--border-color); }
.integration-row:last-child { border-bottom: 0; }

/* ---------- Integrations page ---------- */
.integration-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
/* Per-system tint: the head wash and the icon tile share one accent. */
.integration-card { --accent: var(--primary-text); --accent-soft: var(--primary-soft); display: flex; flex-direction: column; overflow: hidden; transition: border-color var(--transition), box-shadow var(--transition); }
.integration-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.integration-card.is-off { opacity: .75; }
.accent-info { --accent: var(--info); --accent-soft: var(--info-soft); }
.accent-violet { --accent: var(--chart-4); --accent-soft: color-mix(in srgb, var(--chart-4) 14%, transparent); }
/* The detail page's heading tile carries the same accent as the system's card. */
.page-icon.accent-info, .page-icon.accent-violet {
    color: var(--accent);
    background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 45%, transparent));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.integration-head { display: flex; align-items: flex-start; gap: .9rem; padding: 1.15rem 1.25rem; background: linear-gradient(120deg, var(--accent-soft), transparent 70%); border-bottom: 1px solid var(--border-color); }
.integration-mark { background: var(--accent-soft); color: var(--accent); }
.integration-title { flex: 1; min-width: 0; }
.integration-title h2 { margin: 0 0 .2rem; font-size: 1.05rem; }
.integration-title p { margin: 0; font-size: .84rem; color: var(--text-secondary); }

.integration-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin: 0; padding: 1.15rem 1.25rem; }
.integration-fact { min-width: 0; padding: .6rem .75rem; border-radius: var(--radius); background: var(--bg-inset); border: 1px solid var(--border-color); }
.integration-fact dt { margin-bottom: .35rem; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.integration-fact dd { margin: 0; font-size: .85rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.integration-note { display: flex; gap: .55rem; align-items: flex-start; margin: 0 1.25rem 1.15rem; padding: .65rem .8rem; border-radius: var(--radius); font-size: .82rem; background: var(--danger-soft); color: var(--danger); }
.integration-note span { color: var(--text-primary); word-break: break-word; }
.integration-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: auto; background: var(--bg-inset); }
@media (max-width: 560px) { .integration-actions .btn { flex: 1; } }

.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.metric { padding: .7rem .8rem; border-radius: var(--radius); background: var(--bg-inset); border: 1px solid var(--border-color); }
.metric .metric-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.metric .metric-value { font-size: 1.2rem; font-weight: 700; }
@media (max-width: 760px) { .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Course cards ---------- */
.course-card { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.course-card-wrap { position: relative; height: 100%; }
/* Sits over the card link (a button can't be nested inside <a>); shown on hover/focus, always on touch screens. */
.course-card-delete {
    position: absolute; top: .6rem; right: .6rem;
    display: grid; place-items: center; width: 32px; height: 32px;
    border: 0; border-radius: 8px; cursor: pointer;
    background: rgba(0, 0, 0, 0.28); color: #fff;
    opacity: 0; transition: opacity var(--transition), background var(--transition);
}
.course-card-wrap:hover .course-card-delete, .course-card-delete:focus-visible { opacity: 1; }
.course-card-delete:hover { background: var(--danger); }
.course-card-delete:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.course-card-delete .icon { width: 16px; height: 16px; }
@media (hover: none) { .course-card-delete { opacity: 1; } }
/* Student dashboard: a class's Join Meet, over the card link like Delete, in room kept under the progress bar. */
.course-card-wrap.has-meet .course-card-body { padding-bottom: 3.5rem; }
.course-card-meet { position: absolute; left: 1.1rem; bottom: 1rem; z-index: 1; }
.course-card-banner { position: relative; overflow: hidden; height: 76px; padding: .9rem 1.1rem; display: flex; align-items: flex-end; justify-content: space-between; color: #fff; background: linear-gradient(135deg, var(--banner-a, #047857), var(--banner-b, #10b981)); }
.course-card-banner > * { position: relative; }
/* Large faded subject icon behind the banner; decorative. */
.course-card-banner svg.course-card-art { position: absolute; right: 22%; top: 50%; width: 92px; height: 92px; stroke-width: 1.3; opacity: .16; transform: translateY(-50%) rotate(-12deg); transition: transform 300ms ease, opacity 300ms ease; }
.course-card-wrap:hover .course-card-art { opacity: .24; transform: translateY(-50%) rotate(-4deg) scale(1.06); }
@media (prefers-reduced-motion: reduce) { .course-card-banner svg.course-card-art { transition: none; } }
.course-card-banner .code { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.1rem; letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0,0,0,.2); }
.course-card-glyph { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.course-card-glyph svg.icon { width: 16px; height: 16px; }
/* The banner is a fixed colored gradient in both themes, so its badge is a solid light chip with dark text. */
.course-card-banner .badge { background: rgba(255, 255, 255, 0.94); color: #065f46; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.course-card-banner .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.course-card-banner .badge-warning { color: #92400e; }
.course-card-banner .badge:not([class*="badge-"]) { color: #374151; }
.course-card-body { padding: 1rem 1.1rem; flex: 1; display: grid; gap: .5rem; align-content: start; }
.course-card-body h3 { margin: 0; }
.course-card-body p { margin: 0; color: var(--text-secondary); font-size: .84rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-card-body p.is-empty { color: var(--text-muted); font-style: italic; }
.course-card-footer { padding: .75rem 1.1rem; border-top: 1px solid var(--border-color); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; font-size: .8rem; color: var(--text-muted); }
.course-card-footer > span, .course-card-stats > span { display: inline-flex; align-items: center; gap: .35rem; }
.course-card-footer > .course-card-stats { gap: .85rem; }
.course-card-footer svg.icon { width: 14px; height: 14px; color: var(--text-secondary); }

/* ---------- Course outline ---------- */
/* Hero: the course's banner colors (courseTheme) with the actions on it, then title and counts. */
.course-hero { margin-bottom: 1.25rem; overflow: hidden; padding: 0; }
.course-hero-banner {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
    min-height: 92px; padding: 1.1rem 1.4rem; color: #fff;
    background: linear-gradient(135deg, var(--banner-a, #047857), var(--banner-b, #10b981));
}
.course-hero-banner > :not(.course-hero-art) { position: relative; }
.course-hero-banner svg.course-hero-art { position: absolute; right: 28%; top: 50%; width: 150px; height: 150px; stroke-width: 1.1; opacity: .14; transform: translateY(-50%) rotate(-10deg); pointer-events: none; }
.course-hero-id { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.course-hero-id .code { font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.course-hero-id .course-card-glyph { width: 38px; height: 38px; border-radius: 10px; }
.course-hero-id .course-card-glyph svg.icon { width: 19px; height: 19px; }
.course-hero-id .badge { background: rgba(255, 255, 255, 0.94); color: #065f46; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.course-hero-id .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.course-hero-id .badge-warning { color: #92400e; }
.course-hero-id .badge:not([class*="badge-"]) { color: #374151; }
.course-hero-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
/* Buttons on the fixed colored banner: same look in both themes. */
.btn-on-color { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255, 255, 255, 0.3); backdrop-filter: blur(4px); }
.btn-on-color:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }
.btn-light { background: #fff; color: #065f46; border-color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); }
.btn-light:hover:not(:disabled) { background: #ecfdf5; }
/* An uploaded cover replaces the generated gradient. The scrim keeps the course code,
   the status badge and the buttons readable whatever picture somebody chose. */
.course-card-banner.has-cover, .course-hero-banner.has-cover {
    background-image: linear-gradient(180deg, rgba(0, 0, 0, .12) 0%, rgba(0, 0, 0, .58) 100%), var(--cover);
    background-size: cover; background-position: center;
}
.course-hero-banner.has-cover { min-height: 168px; align-items: flex-end; }
.course-hero-label-short { display: none; }
/* Phones: the picture keeps only the course code and status, and the buttons move to a bar under
   it, so they no longer cover (and wrap over) the cover image. The banner colours and the cover
   move from the banner to .course-hero-id, the part above the bar. */
@media (max-width: 640px) {
    .course-hero > .course-hero-banner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0; min-height: 0; background: var(--bg-secondary); }
    .course-hero-id { min-height: 96px; align-content: flex-end; padding: 1rem; background: linear-gradient(135deg, var(--banner-a, #047857), var(--banner-b, #10b981)); }
    .course-hero-banner.has-cover .course-hero-id {
        min-height: 150px;
        background-image: linear-gradient(180deg, rgba(0, 0, 0, .05) 0%, rgba(0, 0, 0, .55) 100%), var(--cover);
        background-size: cover; background-position: center;
    }
    .course-hero-banner svg.course-hero-art { top: 48px; }
    .course-hero-actions { padding: .65rem 1rem; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
    .course-hero-actions:not(:has(.btn)) { display: none; }
    .course-hero-actions .btn { flex: 1 1 auto; justify-content: center; }
    .course-hero-actions .btn-on-color { background: var(--bg-inset); color: var(--text-primary); border-color: var(--border-color); backdrop-filter: none; }
    .course-hero-actions .btn-on-color:hover:not(:disabled) { background: var(--bg-hover); }
    .course-hero-actions .btn-light { background: var(--primary); color: var(--on-primary); border-color: var(--primary); box-shadow: none; }
    .course-hero-label-long { display: none; }
    .course-hero-label-short { display: inline; }
}
.course-card-banner.has-cover { height: 104px; align-items: flex-end; }

/* Who added a module or a material: shown beside it, because only they (and an
   administrator) may change or remove it. */
.author-chip { color: var(--text-muted); }
.m-author { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; color: var(--text-muted); }
.m-author svg.icon { width: 13px; height: 13px; }

.course-teachers { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-top: .35rem; }
.course-teachers-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); padding-top: .55rem; }
.course-teacher-list { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.course-teacher { display: flex; align-items: center; gap: .65rem; padding: .5rem .85rem .5rem .55rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); }
.course-teacher .avatar { width: 38px; height: 38px; font-size: .78rem; flex-shrink: 0; }
.course-teacher-text { display: grid; gap: .1rem; min-width: 0; }
.course-teacher-text strong { font-size: .88rem; }
.course-teacher-text small { font-size: .74rem; color: var(--text-muted); }
.course-teacher-sections { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; margin-top: .15rem; }
.course-teacher-sections .chip { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-teachers.is-empty { align-items: center; gap: .5rem; padding: .6rem .8rem; border: 1px dashed var(--border-color); border-radius: var(--radius); color: var(--text-muted); font-size: .82rem; }
.course-teachers.is-empty svg.icon { width: 17px; height: 17px; }
@media (max-width: 600px) { .course-teacher-sections .chip { max-width: 11rem; } }

.course-hero-body { padding: 1.2rem 1.4rem 1.3rem; display: grid; gap: .6rem; }
.course-hero-body h1 { margin: 0; }
.course-hero-description { margin: 0; color: var(--text-secondary); max-width: 70ch; }
.course-hero-description.is-empty { color: var(--text-muted); font-style: italic; }
.course-stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .35rem; }
.course-stat { display: flex; align-items: center; gap: .6rem; padding: .5rem .85rem .5rem .55rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); }
.course-stat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.course-stat-icon svg.icon { width: 16px; height: 16px; }
.course-stat strong { display: block; font-size: 1rem; line-height: 1.1; color: var(--text-primary); }
.course-stat small { display: block; font-size: .72rem; color: var(--text-muted); }
/* Phones: the five counts as one even row (icon over number over label) instead of chips that
   wrap 2 + 2 + 1. */
@media (max-width: 640px) {
    .course-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
    .course-stat { flex-direction: column; justify-content: flex-start; gap: .3rem; padding: .55rem .2rem .5rem; text-align: center; min-width: 0; }
    .course-stat-icon { width: 28px; height: 28px; border-radius: 8px; }
    .course-stat-icon svg.icon { width: 14px; height: 14px; }
    .course-stat small { font-size: .66rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.course-progress { display: grid; gap: .4rem; margin-top: .35rem; font-size: .84rem; }
.course-progress svg.icon { width: 16px; height: 16px; color: var(--success); }

/* Modules */
.module-list { display: grid; gap: 1.1rem; }
.module { overflow: hidden; position: relative; }
/* A thin stripe in the course's banner colors ties each module to the hero. */
.module::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(180deg, var(--banner-a, var(--primary)), var(--banner-b, var(--primary))); }
.module-header { position: relative; display: flex; align-items: center; gap: .6rem .75rem; padding: .75rem 1rem .75rem .85rem; flex-wrap: wrap; background: linear-gradient(100deg, color-mix(in srgb, var(--banner-b, var(--primary)) 9%, transparent), transparent 55%); }
/* At least about half the row for the title: when the chips and buttons need more, they go to
   the next line instead of squeezing a long title into a narrow column. */
.module-toggle-button { flex: 1 1 45%; min-width: 0; display: flex; align-items: center; gap: .85rem; padding: .3rem .5rem .3rem .3rem; border: 0; border-radius: var(--radius); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.module-toggle-button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.module-toggle {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    color: var(--text-primary); background: var(--bg-tertiary); border: 1px solid var(--border-strong);
    transition: transform var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}
.module-toggle svg.icon { width: 18px; height: 18px; stroke-width: 2.4; }
.module-toggle-button:hover .module-toggle { color: var(--primary-text); background: var(--primary-soft); border-color: var(--primary); }
.module[data-collapsed="true"] .module-toggle { transform: rotate(-90deg); }
.module[data-collapsed="true"] .module-body { display: none; }
.module-number {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
    font-weight: 800; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    background: linear-gradient(135deg, var(--banner-a, var(--primary)), var(--banner-b, var(--primary)));
    box-shadow: 0 3px 10px color-mix(in srgb, var(--banner-a, var(--primary)) 35%, transparent);
}
.module-titles { display: grid; gap: .12rem; min-width: 0; margin-right: auto; }
.module-title { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); }
.module-description { font-size: .8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-left: auto; }
.module-tools { display: inline-flex; gap: .1rem; padding-left: .35rem; margin-left: .15rem; border-left: 1px solid var(--border-color); }

/* Reordering arrows. Inside a lesson row they have to be lifted above the stretched
   link that makes the whole row clickable, or every tap would open the lesson. */
.move-tools { display: inline-flex; gap: .1rem; }
.lesson-row .move-tools { position: relative; z-index: 1; }
.move-tools .btn:disabled { cursor: default; }

/* On a pointer device the arrows fade in with the row, to keep the list calm. They
   stay put where there is no hover to reveal them - on a phone they are the control. */
@media (hover: hover) {
    .lesson-row .move-tools { opacity: 0; transition: opacity var(--transition); }
    .lesson-row:hover .move-tools,
    .lesson-row:focus-within .move-tools { opacity: 1; }
}
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600; color: var(--text-secondary); background: var(--bg-tertiary); white-space: nowrap; }
.chip svg.icon { width: 13px; height: 13px; }
.btn-danger-ghost:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.module-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--bg-tertiary); }
.module-progress span { display: block; height: 100%; background: var(--success); border-radius: 0 3px 3px 0; }

.module-body { border-top: 1px solid var(--border-color); }
.module-section { padding: .85rem 1.25rem 1rem; }
.module-section + .module-section { border-top: 1px solid var(--border-color); }
.module-section-materials { background: var(--bg-inset); }
.module-section-label { display: flex; align-items: center; gap: .4rem; margin-bottom: .55rem; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); }
.module-section-label svg.icon { width: 13px; height: 13px; }
.module-section-label span { min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; text-align: center; letter-spacing: 0; color: var(--text-secondary); background: var(--bg-tertiary); }
.module-empty { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-muted); font-size: .86rem; }
.module-empty svg.icon { color: var(--text-muted); }

/* Folders group modules ("Prelim", "Midterm"…): one row each, which opens the folder on its
   own (as in a file manager), with the way back above it (.folder-path). */
.module-folder { display: grid; gap: .75rem; }
.module-folder-header { display: flex; align-items: center; gap: .6rem .75rem; flex-wrap: wrap; padding: .5rem .85rem .5rem .6rem; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-secondary); }
.module-folder-toggle { flex: 1 1 240px; min-width: 0; display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem .25rem .25rem; border: 0; border-radius: var(--radius); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.module-folder-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.module-folder-toggle:hover .module-toggle { color: var(--primary-text); background: var(--primary-soft); border-color: var(--primary); }
.module-folder-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; color: var(--primary-text); background: var(--primary-soft); }
.module-folder-icon svg.icon { width: 20px; height: 20px; }
.module-folder-title { min-width: 0; margin-right: auto; font-weight: 700; font-size: 1rem; color: var(--text-primary); overflow-wrap: anywhere; }
.module-folder-toggle:hover .module-folder-title { color: var(--primary-text); }

/* The open folder's place: All modules ▸ 1st Semester ▸ Midterm, each but the last a way back. */
.folder-path { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .35rem; padding: .45rem .6rem; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-secondary); }
.folder-crumb { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; padding: .3rem .55rem; border: 0; border-radius: var(--radius); background: none; color: var(--text-secondary); font: inherit; font-size: .9rem; cursor: pointer; overflow-wrap: anywhere; }
button.folder-crumb:hover { color: var(--primary-text); background: var(--primary-soft); }
.folder-crumb:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.folder-crumb.is-current { color: var(--text-primary); font-weight: 700; cursor: default; }
.folder-crumb svg.icon { width: 16px; height: 16px; flex-shrink: 0; }
.folder-sep { display: inline-grid; color: var(--text-muted); }
.folder-sep svg.icon { width: 14px; height: 14px; }
.folder-path-tools { display: inline-flex; align-items: center; gap: .25rem; margin-left: auto; }

/* Dragging a module or folder onto a folder. Only a mouse gets the grip: a touch screen
   has no drag, and moves with the Move to button instead. */
.drag-grip { display: none; }
@media (hover: hover) and (pointer: fine) {
    .drag-grip { display: grid; place-items: center; align-self: stretch; width: 18px; margin: -.2rem -.45rem -.2rem -.35rem; border-radius: var(--radius-sm); color: var(--text-muted); cursor: grab; }
    .drag-grip:hover { color: var(--text-primary); background: var(--bg-hover); }
    .drag-grip svg.icon { width: 16px; height: 16px; }
}
.module.is-dragging, .module-folder.is-dragging { opacity: .45; }
.module-folder.is-drop-target > .module-folder-header { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.drop-top { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .85rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-muted); font-size: .86rem; }
.drop-top[hidden] { display: none; }
.drop-top.is-drop-target { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }

/* Lessons: numbered steps joined by a line. */
.lesson-path { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.lesson-row { position: relative; display: flex; align-items: center; gap: .85rem; padding: .55rem .7rem .55rem .45rem; border-radius: var(--radius); transition: background var(--transition); }
.lesson-row:hover { background: var(--bg-hover); }
.lesson-row:not(:last-child)::before { content: ""; position: absolute; left: calc(.45rem + 14px); top: calc(50% + 16px); height: calc(100% - 28px); width: 2px; background: var(--border-color); }
.lesson-row.is-done:not(:last-child)::before { background: color-mix(in srgb, var(--success) 55%, var(--border-color)); }
.lesson-marker { position: relative; z-index: 1; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.lesson-number { font-size: .78rem; font-weight: 700; color: var(--primary-text); background: var(--bg-secondary); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 45%, var(--border-color)); }
.lesson-row:hover .lesson-number { color: #fff; background: var(--primary); box-shadow: none; }
.lesson-status { border: 2px solid var(--border-strong); color: transparent; background: var(--bg-secondary); }
.lesson-status.done { background: var(--success); border-color: var(--success); color: #fff; }
.lesson-status svg { width: 14px; height: 14px; stroke-width: 3; }
.lesson-main { flex: 1; min-width: 0; display: grid; gap: .05rem; }
/* The title link covers the whole row. */
.lesson-row a.lesson-title { font-weight: 600; color: var(--text-primary); }
.lesson-row a.lesson-title::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.lesson-row a.lesson-title:hover { text-decoration: none; }
.lesson-row:hover a.lesson-title { color: var(--primary-text); }
.lesson-summary { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-time { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .5rem; border-radius: 999px; font-size: .74rem; color: var(--text-secondary); background: var(--bg-tertiary); white-space: nowrap; }
.lesson-time svg.icon { width: 13px; height: 13px; }
.lesson-go { display: grid; color: var(--text-muted); transition: transform var(--transition), color var(--transition); }
.lesson-row:hover .lesson-go { color: var(--primary-text); transform: translateX(3px); }

/* Materials: a grid of file cards. */
.material-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .7rem; }
.material-card { display: flex; flex-direction: column; gap: .6rem; min-width: 0; padding: .8rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-secondary); transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); }
.material-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.material-card-top { display: flex; align-items: center; gap: .5rem; }
.material-card .m-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.material-card .m-icon svg.icon { width: 19px; height: 19px; }
.material-card-delete { margin-left: auto; }
.material-card-text { display: grid; gap: .15rem; min-width: 0; }
.material-card .m-title { font-size: .9rem; font-weight: 700; color: var(--text-primary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-file { font-size: .76rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-description { font-size: .78rem; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.material-card-actions { display: flex; align-items: center; gap: .35rem; margin-top: auto; }
.material-card-note { font-size: .76rem; color: var(--text-muted); }
.m-ext { padding: .1rem .4rem; border-radius: 5px; font-size: .66rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.m-icon.tone-info, .m-ext.tone-info { background: var(--info-soft); color: var(--info); }
.m-icon.tone-warning, .m-ext.tone-warning { background: var(--warning-soft); color: var(--warning); }
.m-icon.tone-danger, .m-ext.tone-danger { background: var(--danger-soft); color: var(--danger); }
.m-icon.tone-success, .m-ext.tone-success { background: var(--success-soft); color: var(--success); }
.m-icon.tone-primary, .m-ext.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.m-icon.tone-muted, .m-ext.tone-muted { background: var(--bg-tertiary); color: var(--text-secondary); }
.m-icon.tone-violet, .m-ext.tone-violet { background: color-mix(in srgb, var(--chart-4) 14%, transparent); color: var(--chart-4); }

/* Add lesson / material */
.module-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; padding: .85rem 1.25rem 1rem; border-top: 1px solid var(--border-color); }
.add-tile { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: none; color: var(--text-secondary); font: inherit; text-align: left; cursor: pointer; transition: border-color var(--transition), background var(--transition), color var(--transition); }
.add-tile:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 55%, transparent); color: var(--text-primary); }
.add-tile-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary-text); transition: background var(--transition), color var(--transition); }
.add-tile:hover .add-tile-icon { background: var(--primary); color: #fff; }
.add-tile-icon svg.icon { width: 16px; height: 16px; }
.add-tile strong { display: block; font-size: .86rem; color: var(--text-primary); }
.add-tile small { display: block; font-size: .74rem; color: var(--text-muted); }

/* Activities: rows that read like the lesson path — icon, title, chips, due countdown. */
.activity-list { list-style: none; margin: 0; padding: .5rem; display: grid; gap: .3rem; }
.activity-row { position: relative; display: flex; align-items: center; gap: .8rem; padding: .7rem .75rem; border: 1px solid transparent; border-radius: var(--radius); transition: background var(--transition), border-color var(--transition); }
.activity-row:hover { background: var(--bg-secondary); border-color: var(--border-color); }
.activity-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--bg-tertiary); color: var(--text-secondary); }
.activity-icon svg.icon { width: 18px; height: 18px; }
.activity-icon.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.activity-icon.tone-info { background: var(--info-soft); color: var(--info); }
.activity-icon.tone-success { background: var(--success-soft); color: var(--success); }
.activity-icon.tone-warning { background: var(--warning-soft); color: var(--warning); }
.activity-icon.tone-violet { background: color-mix(in srgb, var(--chart-4) 14%, transparent); color: var(--chart-4); }
.activity-main { flex: 1; min-width: 0; display: grid; gap: .3rem; }
.activity-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; min-width: 0; }
/* The title link covers the whole row, like a lesson row. */
.activity-row a.activity-title { font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row a.activity-title::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.activity-row a.activity-title:hover { text-decoration: none; }
.activity-row:hover a.activity-title { color: var(--primary-text); }
.activity-chips { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.activity-chips .chip { font-weight: 500; }
.activity-chips .chip.tone-primary { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.activity-chips .chip.tone-info { background: var(--info-soft); color: var(--info); font-weight: 600; }
.activity-chips .chip.tone-success { background: var(--success-soft); color: var(--success); font-weight: 600; }
.activity-chips .chip.tone-warning { background: var(--warning-soft); color: var(--warning); font-weight: 600; }
.activity-chips .chip.tone-violet { background: color-mix(in srgb, var(--chart-4) 14%, transparent); color: var(--chart-4); font-weight: 600; }
/* Above the stretched title link, so the due date keeps its own tooltip. */
.activity-end { position: relative; z-index: 1; display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.activity-due { display: grid; gap: .1rem; justify-items: end; text-align: right; white-space: nowrap; }
.activity-due > span { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--text-secondary); }
.activity-due svg.icon { width: 13px; height: 13px; }
.activity-due small { font-size: .72rem; color: var(--text-muted); }
.activity-due.is-soon > span, .activity-due.is-soon small { color: var(--warning); }
.activity-due.is-past > span, .activity-due.is-past small { color: var(--danger); }
.activity-due.is-none { font-size: .78rem; color: var(--text-muted); }
.activity-go { display: grid; color: var(--text-muted); transition: transform var(--transition), color var(--transition); }
.activity-row:hover .activity-go { color: var(--primary-text); transform: translateX(3px); }

@media (max-width: 640px) {
    .activity-row { flex-wrap: wrap; }
    .activity-main { flex-basis: calc(100% - 3.8rem); }
    .activity-end { width: 100%; justify-content: space-between; padding-left: calc(38px + .8rem); }
    .activity-due { justify-items: start; text-align: left; }
    .activity-go { display: none; }
}

@media (max-width: 640px) {
    .course-hero-banner, .course-hero-body { padding-inline: 1rem; }
    .course-hero-banner svg.course-hero-art { right: -1.5rem; }
    .module-meta { margin-left: 0; width: 100%; }
    .module-tools { margin-left: auto; }
    /* The name gets the width (a smaller tile and chevron, tighter spacing, the grip on its line) and a long one starts at the top. */
    .module-header { padding: .6rem .75rem .6rem .8rem; }
    .module-toggle-button, .module-folder-toggle { flex-basis: 0; }
    .module-toggle-button { align-items: flex-start; gap: .65rem; padding: .2rem; }
    .module-number { width: 36px; height: 36px; border-radius: 10px; font-size: .95rem; }
    .module-titles { align-self: center; }
    .module-title { font-size: .96rem; line-height: 1.35; }
    .module-toggle { width: 28px; height: 28px; }
    .module-section, .module-actions { padding-inline: .85rem; }
    .folder-path-tools { margin-left: 0; }
    .lesson-time, .lesson-summary { display: none; }
}

/* ---------- Activity ---------- */
.activity-detail-head { display: flex; align-items: flex-start; gap: .9rem; padding: 1.1rem 1.25rem; }
.activity-detail-head .activity-icon { width: 46px; height: 46px; border-radius: 13px; }
.activity-detail-head .activity-icon svg.icon { width: 22px; height: 22px; }
.activity-detail-titles { flex: 1; min-width: 0; display: grid; gap: .35rem; }
.activity-detail-titles h1 { margin: 0; font-size: 1.3rem; line-height: 1.25; }
.activity-detail-sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .82rem; }
.activity-detail-sub a { color: var(--text-secondary); }
.activity-detail-sub a:hover { color: var(--primary-text); }
.activity-detail-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

/* Due, points, module and visibility as tiles rather than a label/value list. */
.activity-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; padding: 0 1.25rem 1.1rem; }
.activity-fact { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); min-width: 0; }
.activity-fact-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--bg-tertiary); color: var(--text-secondary); }
.activity-fact-icon svg.icon { width: 16px; height: 16px; }
.activity-fact-text { display: grid; gap: .05rem; min-width: 0; }
.activity-fact-text small { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.activity-fact-text strong { font-size: .88rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-fact-text em { font-size: .74rem; font-style: normal; color: var(--text-muted); }
.activity-fact.tone-danger { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.activity-fact.tone-danger .activity-fact-icon { background: var(--danger-soft); color: var(--danger); }
.activity-fact.tone-danger .activity-fact-text em { color: var(--danger); }
.activity-fact.tone-warning { border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.activity-fact.tone-warning .activity-fact-icon { background: var(--warning-soft); color: var(--warning); }
.activity-fact.tone-warning .activity-fact-text em { color: var(--warning); }
.activity-fact.tone-success { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.activity-fact.tone-success .activity-fact-icon { background: var(--success-soft); color: var(--success); }

.activity-instructions { border-top: 1px solid var(--border-color); }
.activity-instructions h2 { display: flex; align-items: center; gap: .4rem; margin-bottom: .55rem; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); }
.activity-instructions h2 svg.icon { width: 13px; height: 13px; }
.activity-instructions .pre-line { line-height: 1.7; color: var(--text-primary); }
.activity-instructions .is-empty { margin: 0; color: var(--text-muted); font-style: italic; }

/* How much of the class has handed in, in the Submissions header. */
.submission-progress { display: grid; gap: .3rem; min-width: 190px; }
.submission-progress-text { font-size: .78rem; color: var(--text-muted); text-align: right; }
.submission-progress-text strong { color: var(--text-primary); }

/* Same grade for many (activities/show.js): the score, then who gets it in two groups,
   New and Already graded, one student a row, in a list that scrolls under its group's heading. */
.grade-many-top { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 1rem; margin-bottom: 1rem; }
.grade-many-score { display: flex; align-items: center; gap: .5rem; }
.grade-many-score .input { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.grade-many-outof { color: var(--text-muted); white-space: nowrap; font-weight: 600; }
.grade-many input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex-shrink: 0; accent-color: var(--primary); cursor: pointer; }
.grade-many-list { border: 1px solid var(--border-color); border-radius: var(--radius); max-height: min(50vh, 440px); overflow: auto; }
.grade-many-group + .grade-many-group { border-top: 1px solid var(--border-color); }
.grade-many-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: .7rem; padding: .6rem .9rem; background: var(--bg-tertiary); border-bottom: 1px solid var(--border-color); cursor: pointer; }
.grade-many-head-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.grade-many-head-text small { color: var(--text-muted); font-size: .76rem; }
.grade-many-count { min-width: 1.6rem; padding: .05rem .45rem; border-radius: 999px; background: var(--bg-inset); color: var(--text-secondary); font-size: .76rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.grade-many-group ul { list-style: none; margin: 0; padding: 0; }
.grade-many-row { display: flex; align-items: center; gap: .7rem; padding: .5rem .9rem; cursor: pointer; }
.grade-many-row:hover { background: var(--bg-hover); }
.grade-many-group li + li .grade-many-row { border-top: 1px solid var(--border-color); }
.grade-many-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.grade-many-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.grade-many-who small { color: var(--text-muted); font-size: .74rem; }
.grade-many-meta { color: var(--text-muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grade-many-meta strong { color: var(--text-primary); }
/* Draft each with AI: a student's own feedback under their name, out of sight while they are not ticked. */
.grade-many-own { padding: 0 .9rem .65rem calc(.9rem + 16px + .7rem); }
.grade-many-own .textarea { width: 100%; font-size: .88rem; }
.grade-many-group li:has(> .grade-many-row input:not(:checked)) > .grade-many-own { display: none; }
@media (max-width: 560px) { .grade-many-top { grid-template-columns: 1fr; } }

/* A student's Response box (writingBox() in activities/show.js): Full screen beside the label, the
   word count under the box, and the full-screen view that lends the box the whole window. */
.response-head, .response-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.response-head .btn { margin-right: -.4rem; }
.response-words { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.write-full { position: fixed; inset: 0; z-index: 100; background: var(--bg-primary); padding: max(.75rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom)); }
.write-full-inner { display: flex; flex-direction: column; gap: .75rem; height: 100%; max-width: 860px; margin: 0 auto; }
.write-full-bar { display: flex; align-items: center; gap: .75rem; }
.write-full-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.write-full-bar .field-help { white-space: nowrap; font-variant-numeric: tabular-nums; }
.write-full .textarea { flex: 1; min-height: 0; resize: none; font-size: 1rem; line-height: 1.65; padding: 1rem 1.1rem; }
body.write-full-open { overflow: hidden; }

@media (max-width: 640px) {
    .activity-detail-head { flex-wrap: wrap; padding-inline: 1rem; }
    .activity-detail-actions { width: 100%; justify-content: flex-start; }
    .activity-facts { padding-inline: 1rem; }
    .submission-progress { min-width: 140px; }
    /* The "taken in FormFlow" box: its words take the width beside the icon, Open in FormFlow goes under them. */
    .activity-formflow { align-items: flex-start; }
    .activity-formflow > .grow { flex-basis: calc(100% - 44px - 1rem); }
    .activity-formflow > .btn { width: 100%; }
}

/* ---------- Lesson ---------- */
/* Plain text shown as typed, in the text-material modal. */
.lesson-content { font-size: .98rem; line-height: 1.75; white-space: pre-line; color: var(--text-primary); }

.lesson-head { display: flex; align-items: flex-start; gap: .9rem; padding: 1.1rem 1.25rem; }
.lesson-head-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary-text); }
.lesson-head-icon svg.icon { width: 22px; height: 22px; }
.lesson-head-text { flex: 1; min-width: 0; display: grid; gap: .4rem; }
.lesson-head-text h1 { margin: 0; font-size: 1.3rem; line-height: 1.25; }
.lesson-head-sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; font-size: .82rem; }
.lesson-head-sub a { color: var(--text-secondary); }
.lesson-head-sub a:hover { color: var(--primary-text); }
/* A long module name is cut short with "…" (the breadcrumb above has it in full) instead of widening the page. */
.lesson-head-sub .chip { max-width: 100%; }
.lesson-head-sub .chip > span { overflow: hidden; text-overflow: ellipsis; }
.lesson-head-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

/* How far into the course this lesson sits. */
.lesson-place { display: flex; align-items: center; gap: .8rem; padding: 0 1.25rem 1rem; font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.lesson-place strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.lesson-place .progress { flex: 1; height: 5px; }

.lesson-body { border-top: 1px solid var(--border-color); padding-block: 1.4rem 1.6rem; }
.lesson-lead { margin: 0 0 1.4rem; padding-left: .95rem; border-left: 3px solid var(--primary); font-size: .97rem; line-height: 1.6; color: var(--text-secondary); max-width: 70ch; }

/* Lesson text, given a reading measure and a structure by lessons/show.js. */
.lesson-prose { max-width: 72ch; font-size: 1rem; line-height: 1.75; color: var(--text-primary); overflow-wrap: break-word; /* a long link breaks instead of running off a phone */ }
.lesson-prose > * { margin: 0; }
.lesson-prose > * + * { margin-top: 1rem; }
.lesson-prose h2 { margin-top: 1.9rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border-color); font-size: 1.02rem; line-height: 1.35; scroll-margin-top: calc(var(--topbar-height) + 1rem); }
.lesson-prose > h2:first-child { margin-top: 0; }
.lesson-prose ul, .lesson-prose ol { display: grid; gap: .4rem; padding-left: 1.35rem; }
.lesson-prose li::marker { color: var(--text-muted); }
.lesson-prose pre { padding: .85rem 1rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); overflow-x: auto; }
.lesson-prose code { font-family: var(--font-mono); font-size: .86rem; line-height: 1.65; }
.lesson-prose.is-empty { color: var(--text-muted); font-style: italic; }

/* Students: mark the lesson complete. */
.lesson-done { display: flex; align-items: center; gap: .85rem; padding: .9rem 1.1rem; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-secondary); box-shadow: var(--shadow-sm); }
.lesson-done-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--bg-tertiary); color: var(--text-secondary); }
.lesson-done-icon svg.icon { width: 19px; height: 19px; }
.lesson-done-text { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.lesson-done-text strong { font-size: .92rem; }
.lesson-done-text small { font-size: .78rem; color: var(--text-muted); }
.lesson-done.is-done { border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--success-soft); }
.lesson-done.is-done .lesson-done-icon { background: var(--success); color: var(--text-inverse); }
.lesson-done.is-done .lesson-done-text strong { color: var(--success); }

/* Previous / next, as cards that can hold a full lesson title. */
.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.lesson-step { display: flex; align-items: center; gap: .6rem; min-width: 0; padding: .7rem .9rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-secondary); color: var(--text-primary); transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); }
.lesson-step:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.lesson-step.is-empty { border: 0; background: none; box-shadow: none; }
.lesson-step.is-next { justify-content: flex-end; text-align: right; }
.lesson-step svg.icon { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-muted); }
.lesson-step:hover svg.icon { color: var(--primary-text); }
.lesson-step-text { display: grid; gap: .1rem; min-width: 0; }
.lesson-step-text small { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.lesson-step-text strong { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The right column follows the reader down a long lesson. */
.lesson-aside { position: sticky; top: calc(var(--topbar-height) + 1rem); }
/* The headings keep the numbering their author typed, so the list adds none. */
.lesson-toc-list { margin: 0; padding: .5rem 0 .7rem; list-style: none; }
.lesson-toc-list a { display: block; padding: .35rem 1.25rem; font-size: .84rem; line-height: 1.45; color: var(--text-secondary); border-left: 2px solid transparent; }
.lesson-toc-list a:hover { color: var(--primary-text); border-left-color: var(--primary); background: var(--bg-hover); }

.material-list { margin: 0; padding: .4rem; list-style: none; display: grid; gap: .2rem; }
.material-row { display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: var(--radius); transition: background var(--transition); }
.material-row:hover { background: var(--bg-hover); }
.material-row .m-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.material-row .m-icon svg.icon { width: 16px; height: 16px; }
.material-row-text { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.material-row-text strong { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-row-text > span { font-size: .74rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-row-note { margin: .25rem 0 0; font-size: .8rem; line-height: 1.55; color: var(--text-secondary); }
.material-row-actions { display: flex; align-items: center; gap: .25rem; flex-shrink: 0; }

/* The AI Lesson Assistant, only while an administrator has it on (AI Settings). */
.ai-assist { display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1rem; border-radius: var(--radius-lg); border: 1px solid var(--border-color); background: var(--bg-inset); }
.ai-assist .ai-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex-shrink: 0; }
.ai-assist .ai-icon svg.icon { width: 16px; height: 16px; }
.ai-assist strong { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .86rem; }
.ai-assist p { margin-top: .2rem; font-size: .8rem; line-height: 1.5; }
.ai-assist .btn { margin-top: .65rem; }
.ai-notes-note { display: flex; align-items: flex-start; gap: .45rem; margin: 1.4rem 0 0; padding-top: .9rem; border-top: 1px solid var(--border-color); font-size: .8rem; color: var(--text-muted); }
.ai-notes-note svg.icon { width: 15px; height: 15px; margin-top: .1rem; }

@media (max-width: 1100px) {
    .lesson-aside { position: static; }
}

@media (max-width: 640px) {
    .lesson-head { flex-wrap: wrap; padding-inline: 1rem; }
    .lesson-head-actions { width: 100%; justify-content: flex-start; }
    .lesson-place { padding-inline: 1rem; }
    .lesson-nav { grid-template-columns: 1fr; }
    .lesson-step.is-empty { display: none; }
    .lesson-done { flex-wrap: wrap; }
    .lesson-done .btn { width: 100%; justify-content: center; }
}

/* ---------- Analytics ---------- */
/* What a chart counts, beside its title. */
.chart-note { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.risk-level { display: inline-flex; align-items: center; gap: .35rem; }
.flag-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.threshold-list { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Quiz results: the proctoring record under a FormFlow score ---------- */
/* Its own row, joined to the result above it: amber when something was flagged, red once points came off. */
.table tbody tr.has-proctor-record td { border-bottom: 0; }
.table tbody tr.proctor-row:hover { background: transparent; }
.table tbody tr.proctor-row td { padding-top: 0; }
.proctor-record { display: grid; gap: .55rem; padding: .7rem .9rem; border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); border-left: 3px solid var(--warning); border-radius: var(--radius); background: var(--warning-soft); }
.proctor-record.is-deducted { border-color: color-mix(in srgb, var(--danger) 35%, transparent); border-left-color: var(--danger); background: var(--danger-soft); }
.proctor-line { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.proctor-label { display: inline-flex; align-items: center; gap: .35rem; min-width: 7.5rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warning); }
.proctor-label svg.icon { width: 14px; height: 14px; }
.is-deducted .proctor-label.is-deduction { color: var(--danger); }
.proctor-label.is-deduction { color: var(--text-secondary); }
.proctor-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.proctor-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent); border-radius: 999px; background: var(--bg-secondary); font-size: .8rem; color: var(--text-primary); }
.proctor-chip strong { font-weight: 800; }
.proctor-chip em { font-style: normal; font-size: .72rem; font-weight: 600; color: var(--text-muted); }
.proctor-chip em.is-cost { color: var(--danger); }
.proctor-deduction { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; font-size: .82rem; color: var(--text-secondary); }
.proctor-deduction strong { font-size: .9rem; color: var(--success); }
.is-deducted .proctor-deduction strong { font-size: 1rem; color: var(--danger); }
.proctor-note { font-size: .76rem; color: var(--text-secondary); }
.table .cell-sub.proctor-clean { display: flex; align-items: center; gap: .3rem; color: var(--success); }
.table .cell-sub.proctor-clean svg.icon { width: 13px; height: 13px; }

/* ---------- Audit logs ---------- */
/* What happened in words, with a tone dot; the raw slug sits under it. */
.audit-action { display: inline-flex; align-items: center; gap: .45rem; }
.audit-action .dot { width: 7px; height: 7px; flex-shrink: 0; }
/* The details window keeps the raw user agent folded away under the device's name. */
.audit-agent summary { cursor: pointer; color: var(--text-muted); font-size: .8rem; }
.audit-agent p { margin: .4rem 0 0; font-size: .75rem; color: var(--text-secondary); word-break: break-all; }

/* ---------- Announcements ---------- */
.announcement { padding: 1.1rem 1.25rem; }
.announcement + .announcement { border-top: 1px solid var(--border-color); }
.announcement h3 { margin-bottom: .2rem; }
.announcement .meta { font-size: .78rem; color: var(--text-muted); margin-bottom: .5rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.announcement .body { white-space: pre-line; color: var(--text-primary); }
.announcement.important { border-left: 3px solid var(--warning); }

/* The wall's dashboard card: a line per post, not the post itself. */
.wall-peek { display: flex; align-items: flex-start; gap: .6rem; padding: .85rem 1.25rem; color: inherit; transition: background var(--transition); }
.wall-peek + .wall-peek { border-top: 1px solid var(--border-color); }
.wall-peek:hover { background: var(--bg-tertiary); }
.wall-peek-body { min-width: 0; flex: 1; }
.wall-peek-head { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: .74rem; color: var(--text-muted); }
.wall-peek-head strong { font-size: .82rem; font-weight: 650; color: var(--text-primary); }
.wall-peek-head span { color: var(--primary-text); font-weight: 600; }
.wall-peek p { margin: .2rem 0 0; font-size: .85rem; line-height: 1.5; color: var(--text-secondary); overflow-wrap: anywhere; }
.wall-peek-meta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .35rem; font-size: .74rem; color: var(--text-muted); }
.wall-peek-meta:empty { display: none; }
.wall-peek-meta span { display: inline-flex; align-items: center; gap: .25rem; }
.wall-peek-meta svg.icon { width: 13px; height: 13px; }

/* ---------- Announcements timeline ---------- */
.timeline-filters .toolbar { border-bottom: 0; }
.timeline-feed { display: grid; gap: 1.6rem; margin-top: 1.4rem; }
.timeline-date { display: flex; align-items: center; gap: .75rem; margin: 0 0 .85rem; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.timeline-date::after { content: ""; flex: 1; height: 1px; background: var(--border-color); }
.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 1.1rem; bottom: 1.1rem; width: 2px; border-radius: 2px; background: linear-gradient(var(--border-strong), var(--border-color)); }
.timeline-item { --dot: var(--primary); --dot-soft: var(--primary-soft); position: relative; padding-left: 54px; animation: timeline-in .3s ease both; }
.timeline-item + .timeline-item { margin-top: .9rem; }
.timeline-item.scope-course { --dot: var(--info); --dot-soft: var(--info-soft); }
.timeline-item.scope-section { --dot: var(--chart-4); --dot-soft: color-mix(in srgb, var(--chart-4) 15%, var(--bg-secondary)); }
.timeline-item.important { --dot: var(--warning); --dot-soft: var(--warning-soft); }
.timeline-dot { position: absolute; left: 0; top: .95rem; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--dot-soft); color: var(--dot); box-shadow: 0 0 0 4px var(--bg-primary), inset 0 0 0 1px color-mix(in srgb, var(--dot) 25%, transparent); }
.timeline-dot svg.icon { width: 17px; height: 17px; }
.timeline-card { padding: 1rem 1.2rem 1.05rem; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition); }
.timeline-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }
.timeline-item.important .timeline-card { border-color: color-mix(in srgb, var(--warning) 35%, var(--border-color)); background: linear-gradient(115deg, var(--warning-soft), transparent 50%), var(--bg-secondary); }
.timeline-head { display: flex; align-items: center; gap: .65rem; margin-bottom: .65rem; }
.timeline-head .avatar { flex-shrink: 0; width: 30px; height: 30px; font-size: .72rem; }
.timeline-head .avatar svg.icon { width: 15px; height: 15px; }
.timeline-byline { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.timeline-byline strong { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-author { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.timeline-author .badge { flex-shrink: 0; font-size: .66rem; padding: .05rem .4rem; }
.timeline-byline time { font-size: .75rem; color: var(--text-muted); }
.timeline-actions { display: flex; flex-shrink: 0; margin: -.25rem -.4rem 0 0; }
.timeline-card h3 { margin: 0 0 .4rem; font-size: 1.02rem; line-height: 1.35; overflow-wrap: anywhere; }
.timeline-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .65rem; }
.timeline-body { white-space: pre-line; overflow-wrap: anywhere; color: var(--text-primary); line-height: 1.6; }
.timeline-body.is-clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.timeline-more { margin-top: .45rem; padding: 0; border: 0; background: none; font: inherit; font-size: .84rem; font-weight: 600; color: var(--primary-text); cursor: pointer; }
.timeline-more:hover { text-decoration: underline; }
.timeline-pager { display: flex; justify-content: center; margin-top: 1.4rem; }
.timeline-end { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: 1.6rem 0 .5rem; font-size: .82rem; color: var(--text-muted); }
.timeline-end svg.icon { width: 15px; height: 15px; }
@keyframes timeline-in { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 520px) {
    .timeline::before { left: 13px; }
    .timeline-item { padding-left: 40px; }
    .timeline-dot { width: 28px; height: 28px; top: 1rem; }
    .timeline-dot svg.icon { width: 14px; height: 14px; }
    .timeline-card { padding: .9rem 1rem; }
}
@media print {
    .timeline-filters, .timeline-pager, .timeline-actions, .timeline-more { display: none !important; }
    .timeline-body.is-clamped { display: block; -webkit-line-clamp: unset; }
    .timeline-item { break-inside: avoid; animation: none; }
}

/* ---------- Class wall ---------- */
/* The wall fills the content column like every other page - no reading-column cap. */
.wall-feed { --wall-pad: 1.15rem; display: grid; gap: 1.1rem; margin-top: 1.4rem; }
.wall-post { padding: var(--wall-pad); background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); animation: timeline-in .3s ease both; }
.wall-post.is-pinned { border-color: color-mix(in srgb, var(--warning) 45%, var(--border-color)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 20%, transparent), var(--shadow-sm); }

.wall-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.wall-head .avatar { flex-shrink: 0; width: 42px; height: 42px; font-size: .8rem; }
.wall-byline { display: grid; gap: .12rem; min-width: 0; flex: 1; }
.wall-byline strong { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; font-size: .94rem; font-weight: 650; }
.wall-to { display: inline-flex; color: var(--text-muted); }
.wall-to svg.icon { width: 13px; height: 13px; }
.wall-dest { font-weight: 600; color: var(--primary-text); }
.wall-meta-line { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; font-size: .76rem; color: var(--text-muted); }
.wall-meta-line svg.icon { width: 13px; height: 13px; }
.wall-closed { display: inline-flex; align-items: center; gap: .25rem; }
.wall-closed::before { content: "·"; margin-right: .1rem; }
.wall-actions { display: flex; gap: .1rem; opacity: 0; transition: opacity var(--transition); }
.wall-post:hover .wall-actions, .wall-actions:focus-within { opacity: 1; }

.wall-body { font-size: .95rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

/* The photo keeps its own size up to a cap, so a wide card does not turn every
   picture into a banner and nothing is cropped off the sides. */
.wall-photo { margin: .9rem 0 0; }
.wall-photo img { display: block; width: auto; height: auto; max-width: min(100%, 42rem); max-height: 30rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-tertiary); }

.wall-stats { display: flex; align-items: center; gap: .6rem; min-height: 1.6rem; margin-top: .85rem; font-size: .8rem; color: var(--text-muted); }
.wall-reactors, .wall-count { display: inline-flex; align-items: center; gap: .4rem; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.wall-count { margin-left: auto; }
.wall-reactors:hover, .wall-count:hover { color: var(--text-primary); text-decoration: underline; }
.wall-face { font-size: 1rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.wall-faces { display: inline-flex; }
.wall-faces .wall-face { display: grid; place-items: center; width: 20px; height: 20px; font-size: .78rem; border-radius: 50%; background: var(--bg-secondary); box-shadow: 0 0 0 1.5px var(--bg-secondary); }
.wall-faces .wall-face + .wall-face { margin-left: -6px; }
.wall-stat-empty { font-size: .78rem; }

.wall-bar { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border-color); }
.wall-action { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; width: 100%; padding: .5rem; border: 0; border-radius: var(--radius); background: none; font: inherit; font-size: .85rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; transition: background var(--transition), color var(--transition); }
.wall-action:hover:not(:disabled) { background: var(--bg-tertiary); color: var(--text-primary); }
.wall-action:disabled { opacity: .45; cursor: not-allowed; }
.wall-action svg.icon { width: 17px; height: 17px; }
.wall-action.is-reacted { color: var(--primary-text); }
.wall-action.is-reacted .wall-face { animation: wall-pop .3s ease; }
.wall-action.is-love, .wall-action.is-angry { color: var(--danger); }
.wall-action.is-haha, .wall-action.is-wow { color: var(--warning-text, var(--warning)); }
.wall-action.is-sad { color: var(--text-secondary); }
@keyframes wall-pop { 40% { transform: scale(1.35); } }

/* The picker: hover on a pointer, hold on a touch screen, focus for the keyboard. */
.wall-react { position: relative; }
.wall-picker { position: absolute; bottom: calc(100% + .4rem); left: 50%; transform: translate(-50%, 6px) scale(.94); display: flex; gap: .1rem; padding: .3rem; border: 1px solid var(--border-color); border-radius: 999px; background: var(--bg-secondary); box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transition: opacity var(--transition), transform var(--transition), visibility var(--transition); z-index: 5; }
.wall-react:hover .wall-picker, .wall-react:focus-within .wall-picker, .wall-react.is-open .wall-picker { opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1); }
.wall-pick { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; font-size: 1.25rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; cursor: pointer; transition: transform var(--transition), background var(--transition); }
.wall-pick:hover, .wall-pick:focus-visible { transform: scale(1.25) translateY(-2px); background: var(--bg-tertiary); }
.wall-pick.is-chosen { background: var(--primary-soft); }

.wall-reactors-list { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.wall-reactors-list li { display: flex; align-items: center; gap: .55rem; font-size: .9rem; }

/* A comment, the Reply line under it and its replies, indented past the avatar. */
.wall-comments { --wall-indent: calc(30px + .5rem); display: grid; gap: .8rem; margin: .95rem 0 0; padding: 0; list-style: none; }
.wall-comments:empty { display: none; }
.wall-comment-item { display: grid; gap: .3rem; }
.wall-comment { display: flex; align-items: flex-start; gap: .5rem; }
/* The bubble hugs what was written - a two-word comment should not be a full-width bar. */
.wall-comment-bubble { flex: 0 1 auto; width: fit-content; min-width: 0; max-width: min(100%, 44rem); padding: .5rem .9rem .6rem; border-radius: 1rem; background: var(--bg-tertiary); }
.wall-comment-head { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: .74rem; color: var(--text-muted); }
.wall-comment-head strong { font-size: .82rem; font-weight: 650; color: var(--text-primary); }
.wall-comment-bubble p { margin: .1rem 0 0; font-size: .88rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.wall-comment-delete { flex-shrink: 0; opacity: 0; transition: opacity var(--transition); }
.wall-comment:hover .wall-comment-delete, .wall-comment-delete:focus { opacity: 1; }
.wall-comment-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding-left: calc(var(--wall-indent) + .3rem); }
.wall-comment-tools:empty { display: none; }
.wall-comment-tools .wall-more { font-size: .76rem; color: var(--text-muted); }
.wall-comment-tools .wall-more:hover, .wall-comment-tools .wall-more:focus-visible { color: var(--primary-text); }
.wall-comment-tools .wall-more svg.icon { width: 13px; height: 13px; }

/* Like on a comment: the same picker as a post, sized for a line of small type. */
.wall-react-sm { display: inline-flex; }
.wall-react-sm .wall-picker { bottom: calc(100% + .3rem); padding: .2rem; }
.wall-react-sm .wall-pick { width: 30px; height: 30px; font-size: 1.05rem; }
.wall-comment-like .wall-face { font-size: .82rem; }
.wall-comment-like.is-reacted { font-weight: 700; color: var(--primary-text); }
.wall-comment-like.is-love, .wall-comment-like.is-angry { color: var(--danger); }
.wall-comment-like.is-haha, .wall-comment-like.is-wow { color: var(--warning-text, var(--warning)); }
.wall-comment-like.is-sad { color: var(--text-secondary); }
.wall-comment-like.is-reacted .wall-face { animation: wall-pop .3s ease; }
.wall-comment-tally { display: inline-flex; align-items: center; gap: .25rem; padding: 0; border: 0; background: none; font: inherit; font-size: .74rem; color: var(--text-muted); cursor: pointer; }
.wall-comment-tally:hover { color: var(--text-primary); text-decoration: underline; }
.wall-comment-tally .wall-face { width: 16px; height: 16px; font-size: .62rem; }
.wall-comment-tally .wall-face + .wall-face { margin-left: -5px; }
/* One step in, with a hairline rail instead of a second bubble outline. */
.wall-replies { display: grid; gap: .7rem; margin: .45rem 0 .1rem calc(15px - 1px); padding: 0 0 0 calc(var(--wall-indent) - 14px); list-style: none; border-left: 1px solid var(--border-color); }
.wall-reply-composer { margin: .5rem 0 .2rem var(--wall-indent); }
.wall-more { padding: 0; border: 0; background: none; font: inherit; font-size: .82rem; font-weight: 600; color: var(--primary-text); cursor: pointer; display: inline-flex; align-items: center; gap: .25rem; }
.wall-more:hover { text-decoration: underline; }
.wall-more svg.icon { width: 14px; height: 14px; }

.wall-composer { display: flex; align-items: center; gap: .5rem; margin-top: .7rem; }
.wall-composer-field { position: relative; flex: 1; min-width: 0; }
.wall-composer-field .input { width: 100%; padding-right: 2.7rem; border-radius: 999px; background: var(--bg-tertiary); }
.wall-composer-field .btn { position: absolute; top: 50%; right: .3rem; transform: translateY(-50%); border-radius: 50%; }

.avatar-sm { width: 30px; height: 30px; font-size: .68rem; }
.avatar-sm svg.icon { width: 15px; height: 15px; }

@media (max-width: 520px) {
    .wall-feed { --wall-pad: .95rem; }
    .wall-actions, .wall-comment-delete { opacity: 1; }
    .wall-comments { --wall-indent: 1rem; }
    .wall-head .avatar { width: 38px; height: 38px; }
}
@media print {
    .timeline-filters, .wall-actions, .wall-bar, .wall-composer, .wall-more, .wall-comment-delete, .wall-comment-tools, .wall-picker { display: none !important; }
    .wall-post { break-inside: avoid; animation: none; box-shadow: none; }
}

/* ---------- Error page ---------- */
.error-card { max-width: 480px; text-align: center; padding: 2.5rem 2rem; }
.error-code { font-size: 4rem; font-weight: 800; line-height: 1; background: linear-gradient(135deg, var(--primary), var(--success)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.debug-trace { text-align: left; margin-top: 1rem; max-height: 280px; overflow: auto; padding: .75rem; background: var(--bg-inset); border: 1px solid var(--border-color); border-radius: var(--radius); font-size: .75rem; color: var(--text-secondary); }

/* The Open in Chrome page (errors/in-app-browser.php), seen inside Messenger and other apps. */
.in-app-card { width: 100%; max-width: 420px; display: grid; justify-items: center; gap: 1rem; padding: 2rem 1.5rem; text-align: center; }
.in-app-card .brand-mark { width: 52px; height: 52px; border-radius: 14px; font-size: 1.2rem; }
.in-app-card h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.in-app-card p { margin: 0; line-height: 1.55; }
.in-app-help { font-size: .86rem; color: var(--text-secondary); }
.in-app-help strong { color: var(--text-primary); white-space: nowrap; }
.in-app-link { display: flex; gap: .5rem; width: 100%; }
.in-app-link .input { flex: 1; min-width: 0; font-size: .78rem; }

/* ---------- Settings: branding ---------- */
.branding-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; }
@media (max-width: 1100px) { .branding-layout { grid-template-columns: 1fr; } }

.brand-assets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-top: 1rem; }
@media (max-width: 640px) { .brand-assets { grid-template-columns: 1fr; } }
.brand-asset { display: flex; gap: .85rem; padding: .85rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); }
.brand-asset-thumb {
    width: 56px; height: 56px; flex-shrink: 0; border-radius: 12px; overflow: hidden;
    display: grid; place-items: center;
    background: #fff; border: 1px solid var(--border-color);
}
.brand-asset-thumb img { width: 100%; height: 100%; object-fit: contain; }
.brand-asset-thumb.is-empty { background: var(--bg-tertiary); color: var(--text-muted); border-style: dashed; }
/* The letterhead is a banner, not an icon: it gets the whole row and a wide thumb,
   so what is shown is the shape that will actually print. */
.brand-asset[data-asset="letterhead"] { grid-column: 1 / -1; }
.brand-asset-thumb.is-wide { width: 132px; border-radius: 8px; }
.brand-asset-body { display: grid; gap: .2rem; min-width: 0; align-content: start; }
.brand-asset-body small { color: var(--text-muted); font-size: .76rem; line-height: 1.4; }
.brand-asset-actions { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .35rem; }

.brand-preview { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: .45rem; padding: 1rem; border-radius: var(--radius-lg); background: var(--bg-inset); border: 1px solid var(--border-color); position: sticky; top: calc(var(--topbar-height) + 1rem); }
.brand-preview-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-top: .35rem; }
.brand-preview-label:first-child { margin-top: 0; }
.brand-preview-sidebar {
    display: flex; align-items: center; gap: .8rem; min-height: 64px; padding: 0 1rem; border-radius: 12px; overflow: hidden;
    color: var(--sidebar-text-active);
    background: radial-gradient(120% 120% at 0% 0%, var(--sidebar-glow), transparent 65%), var(--sidebar-bg);
}
.brand-preview-sidebar .brand-text small { color: var(--sidebar-muted); }
.brand-preview-tab {
    display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; max-width: 100%;
    border-radius: 10px 10px 0 0; background: var(--bg-secondary); border: 1px solid var(--border-color); border-bottom: 0;
    font-size: .8rem; color: var(--text-primary); overflow: hidden; white-space: nowrap;
}
.brand-preview-tab > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.brand-preview-favicon { width: 16px; height: 16px; flex-shrink: 0; border-radius: 4px; overflow: hidden; display: grid; place-items: center; }
.brand-preview-favicon img { width: 100%; height: 100%; object-fit: contain; }
.brand-preview-favicon.is-tile { background: linear-gradient(135deg, #6ee7b7, #10b981 45%, #047857); color: #022c22; font-size: 7px; font-weight: 800; letter-spacing: -.04em; }
.brand-preview-favicon.is-tile[data-length="3"], .brand-preview-favicon.is-tile[data-length="4"] { font-size: 5px; }
.brand-preview-login { padding: .6rem .8rem; border-radius: 10px; background: var(--bg-secondary); border: 1px solid var(--border-color); font-size: .8rem; color: var(--text-secondary); }

/* ---------- Profile ---------- */
.profile-hero { overflow: hidden; margin-bottom: 1rem; }
.profile-cover {
    height: 110px;
    background:
        radial-gradient(60% 120% at 10% 0%, rgba(52, 211, 153, 0.45), transparent 70%),
        radial-gradient(50% 120% at 100% 100%, rgba(20, 184, 166, 0.35), transparent 70%),
        linear-gradient(135deg, #03352a, #01160f);
}
.profile-hero-body { display: flex; align-items: flex-end; gap: 1.1rem; flex-wrap: wrap; padding: 0 1.4rem 1.25rem; margin-top: -30px; }
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
    width: 96px; height: 96px; font-size: 1.9rem; letter-spacing: -.02em;
    border: 4px solid var(--bg-secondary);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, #6ee7b7, #10b981 50%, #047857); color: #022c22;
}
.profile-avatar-edit {
    position: absolute; right: 0; bottom: 2px;
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    border: 3px solid var(--bg-secondary); background: var(--primary); color: var(--on-primary);
    cursor: pointer; transition: transform var(--transition), background var(--transition);
}
.profile-avatar-edit:hover { background: var(--primary-hover); transform: scale(1.06); }
.profile-avatar-edit svg.icon { width: 14px; height: 14px; }
.profile-avatar-wrap.is-uploading .profile-avatar { opacity: .55; }
.profile-avatar-wrap.is-uploading::after {
    content: ""; position: absolute; inset: 34px; border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: spin .8s linear infinite;
}
.profile-identity { flex: 1; min-width: 220px; padding-bottom: .15rem; }
.profile-identity h2 { font-size: 1.45rem; letter-spacing: -.015em; margin-bottom: .35rem; }
.profile-meta { display: flex; align-items: center; gap: .45rem 1rem; flex-wrap: wrap; color: var(--text-secondary); font-size: .84rem; }
.profile-meta > span { display: inline-flex; align-items: center; gap: .35rem; }
.profile-meta svg.icon { width: 15px; height: 15px; color: var(--text-muted); }
.profile-hero-actions { display: flex; gap: .4rem; padding-bottom: .15rem; }

.profile-details { display: grid; gap: 0; margin: 0; padding-block: .35rem; }
.profile-detail { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--border-color); }
.profile-detail:last-child { border-bottom: 0; }
.profile-detail dt { color: var(--text-muted); font-size: .82rem; }
.profile-detail dd { margin: 0; font-weight: 600; text-align: right; }

.profile-security { display: grid; gap: .9rem; }
.profile-security-row { display: flex; align-items: center; gap: .75rem; }
.profile-security-row strong { display: block; font-size: .88rem; }
.profile-security-row small { color: var(--text-muted); font-size: .78rem; }

@media (max-width: 640px) {
    .profile-hero-body { align-items: flex-start; }
    .profile-hero-actions { width: 100%; }
}

/* Avatar photos (top bar, profile) */
.avatar.has-photo { padding: 0; overflow: hidden; background: var(--bg-tertiary); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* ---------- Section: its numbers ---------- */
/* The schedule is a meeting a line ("8:00-9:30, TUE (Magic Lab B, F2F)"), too long for a
   quarter of the row: it takes two of five columns, and a whole row once the cards go two
   across. Dense packing lets Room fill the place beside Enrolled then. */
.section-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-flow: row dense; }
.section-stats .stat-schedule { grid-column: span 2; }
.section-stats .stat-schedule .stat-value { font-size: 1rem; line-height: 1.35; }
@media (max-width: 1100px) { .section-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .section-stats { grid-template-columns: 1fr; } .section-stats .stat-schedule { grid-column: auto; } }

/* ---------- Section: instructors ---------- */
.instructor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: .9rem; }
.instructor-card {
    position: relative; display: flex; gap: 1rem; align-items: flex-start; min-width: 0; overflow: hidden;
    padding: 1rem 2.75rem 1rem 1rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.instructor-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
/* The primary instructor gets a brand accent along the top edge and around the photo. */
.instructor-card.is-primary {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border-color));
    background: linear-gradient(180deg, var(--primary-soft), transparent 70%), var(--bg-secondary);
}
.instructor-card.is-primary::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--primary);
}
.instructor-photo { flex-shrink: 0; display: grid; }
.instructor-photo .avatar { box-shadow: 0 0 0 3px var(--bg-secondary), 0 0 0 4.5px var(--border-strong); }
.is-primary .instructor-photo .avatar { box-shadow: 0 0 0 3px var(--bg-secondary), 0 0 0 5px var(--primary); }
.instructor-main { flex: 1; min-width: 0; }
.instructor-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; margin-bottom: .45rem; }
.instructor-head h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.instructor-head .badge svg.icon { width: 13px; height: 13px; }
.instructor-meta { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; font-size: .82rem; color: var(--text-secondary); }
.instructor-meta li { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.instructor-meta li > span, .instructor-meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.instructor-meta svg.icon, .instructor-since svg.icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-muted); }
.instructor-since { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; padding-top: .55rem; border-top: 1px dashed var(--border-color); font-size: .76rem; color: var(--text-muted); }
.instructor-remove { position: absolute; top: .55rem; right: .55rem; color: var(--text-muted); }
.instructor-remove:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }

/* ---------- Attendance ---------- */
/* Status picker: one radio pill per status; the checked pill takes the status color. */
.status-toggle { display: inline-flex; gap: .25rem; }
.status-toggle label { position: relative; display: inline-flex; }
.status-toggle input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.status-toggle span {
    padding: .28rem .6rem; border: 1px solid var(--border-strong); border-radius: 999px;
    background: var(--bg-secondary); color: var(--text-secondary);
    font-size: .76rem; font-weight: 600; white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.status-toggle label:hover span { background: var(--bg-hover); }
.status-toggle input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.status-toggle input:checked + .status-present { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.status-toggle input:checked + .status-late { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.status-toggle input:checked + .status-absent { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.status-toggle input:checked + .status-excused { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.attendance-row-unmarked td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.attendance-remarks { min-width: 140px; }
.attendance-savebar {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
    padding: .75rem 1.25rem; border-top: 1px solid var(--border-color); background: var(--bg-secondary);
}
.metric-row-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 760px) { .metric-row-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Enroll students modal: short how-to above the filters */
.enroll-steps {
    margin: 0 0 1rem; padding: .7rem .9rem .7rem 2rem; border-radius: var(--radius);
    background: var(--bg-inset); border: 1px solid var(--border-color);
    font-size: .84rem; color: var(--text-secondary); display: grid; gap: .2rem;
}
.enroll-steps strong { color: var(--text-primary); }

/* QR scanner */
.scanner-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 960px) { .scanner-layout { grid-template-columns: 1fr; } }
.scanner-view {
    position: relative; overflow: hidden; aspect-ratio: 4 / 3; max-width: 100%;
    width: min(100%, 520px, 70vh); margin-inline: auto;
    border-radius: var(--radius); background: var(--bg-inset); border: 1px solid var(--border-color);
}
/* Buttons and the student ID field line up under the preview. */
.scanner-controls { width: min(100%, 520px, 70vh); margin-inline: auto; justify-content: center; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-idle { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .4rem; color: var(--text-muted); }
.scanner-idle .icon { width: 2.2rem; height: 2.2rem; }
.scanner-idle p { margin: 0; font-size: .85rem; }
.scanner-frame {
    position: absolute; inset: 18% 24%; border-radius: 12px; pointer-events: none;
    border: 3px solid transparent; transition: border-color var(--transition), box-shadow var(--transition);
}
.scanner-view.is-live .scanner-frame { border-color: rgba(255, 255, 255, .85); box-shadow: 0 0 0 999px rgba(0, 0, 0, .28); }
.scanner-view.is-hit .scanner-frame { border-color: var(--success); }
/* Scan line: sweeps the frame while the camera looks for a code, hidden once one is found. */
.scanner-frame { overflow: hidden; }
.scanner-frame::after {
    content: ''; position: absolute; inset: 0 6%; opacity: 0;
    background: linear-gradient(to bottom, transparent 42%, color-mix(in srgb, var(--primary) 30%, transparent) 49%, var(--primary) 49.6%, var(--primary) 50.4%, color-mix(in srgb, var(--primary) 30%, transparent) 51%, transparent 58%);
    transition: opacity var(--transition);
}
.scanner-view.is-live .scanner-frame::after { opacity: 1; animation: scanner-sweep 1.8s ease-in-out infinite alternate; }
.scanner-view.is-live.has-code .scanner-frame::after { opacity: 0; }
@keyframes scanner-sweep { from { transform: translateY(-46%); } to { transform: translateY(46%); } }
@media (prefers-reduced-motion: reduce) { .scanner-view.is-live .scanner-frame::after { animation: none; } }
/* Outline around the detected code; its color follows the scan result. */
.scanner-outline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
.scanner-view.has-code .scanner-outline { display: block; }
.scanner-outline polygon {
    --outline: var(--primary);
    fill: color-mix(in srgb, var(--outline) 22%, transparent); stroke: var(--outline); stroke-width: 4; stroke-linejoin: round;
    transition: fill var(--transition), stroke var(--transition);
    animation: scanner-outline-in .25s ease-out;
}
.scanner-view[data-outcome="ok"] .scanner-outline polygon { --outline: var(--success); }
.scanner-view[data-outcome="repeat"] .scanner-outline polygon { --outline: var(--info); }
.scanner-view[data-outcome="error"] .scanner-outline polygon { --outline: var(--danger); }
@keyframes scanner-outline-in { from { stroke-width: 12; opacity: 0; } to { stroke-width: 4; opacity: 1; } }
.scanner-feed { max-height: 420px; overflow-y: auto; }
.scan-result { display: flex; gap: 1rem; align-items: flex-start; padding: .9rem; border-radius: var(--radius); border: 1px solid var(--border-color); background: var(--bg-inset); }
.scan-result-success { border-color: var(--success); background: var(--success-soft); }
.scan-result-warning { border-color: var(--warning); background: var(--warning-soft); }
.scan-result-info { border-color: var(--info); background: var(--info-soft); }
.scan-result-danger { border-color: var(--danger); background: var(--danger-soft); }
.scan-avatar { width: 72px; height: 72px; flex: none; border-radius: 50%; object-fit: cover; background: var(--bg-tertiary); }
.scan-avatar-initials { display: grid; place-items: center; font-weight: 700; font-size: 1.4rem; color: var(--text-secondary); }
.scan-avatar-initials .icon { width: 1.8rem; height: 1.8rem; color: var(--danger); }
.scan-name { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }

/* Student QR cards */
.qr-card-single { max-width: 360px; margin: 0 auto; overflow: hidden; }
.qr-card-single img { display: block; width: 100%; height: auto; }
.qr-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.qr-card-item { margin: 0; display: grid; justify-items: center; gap: .35rem; }
.qr-card-item img { width: 100%; height: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }

@media print {
    .sidebar, .sidebar-backdrop, .topbar, .no-print { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    .qr-card-grid { grid-template-columns: repeat(3, 1fr); gap: 8mm; }
    .qr-card-item { break-inside: avoid; }
    .qr-card-item img { border-color: #999; }
}

/* Attendance links */
.attendance-link-panel { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: .85rem 1rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); }
/* The text needs real width: with .grow's zero basis it stayed beside the buttons and shrank to
   one word per line on a wide phone; at this basis the buttons wrap below it instead. */
.attendance-link-panel > .grow { flex: 1 1 16rem; }
/* Phones (section page, Attendance tab): the buttons fill the width with the main one first, and
   each tally row (a session or a student) is its title over one line of five small counts instead
   of the six-line card .table-stack makes (the labels are still the column headers). */
@media (max-width: 640px) {
    .attendance-actions { width: 100%; }
    .attendance-actions > .btn { flex: 1 1 auto; justify-content: center; }
    .attendance-actions > .btn-primary { order: -1; flex-basis: 100%; }
    .table-stack.table-tally tr { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .15rem .35rem; }
    .table-stack.table-tally td.is-row-title { grid-column: 1 / -1; margin-bottom: .25rem; }
    .table-stack.table-tally td:not(.is-row-title) { flex-direction: column; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: .15rem; padding: .1rem 0; text-align: center; min-width: 0; }
    .table-stack.table-tally td:not(.is-row-title)::before { max-width: 100%; font-size: .64rem; letter-spacing: 0; text-transform: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.attend-card { max-width: 560px; margin: 0 auto; }
.attend-course { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.attend-code-input { font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: .15em; text-align: center; text-transform: uppercase; }
/* An attendance link opened without signing in (attendance/attend-guest.php): no sidebar, the student number instead. */
.attend-guest { padding: clamp(1.25rem, 5vh, 3rem) 1rem 2rem; }
/* The attendance code page: one centered column, the code card between what to do and the three steps. */
.attend-intro { max-width: 560px; margin: 0 auto 1.25rem; display: grid; justify-items: center; gap: .35rem; text-align: center; }
.attend-intro .stat-icon { width: 56px; height: 56px; border-radius: 16px; }
.attend-intro .stat-icon .icon { width: 26px; height: 26px; }
.attend-intro h1 { margin: .4rem 0 0; font-size: 1.6rem; }
.attend-intro p { margin: 0; color: var(--text-secondary); }
.attend-steps { list-style: none; max-width: 560px; margin: 1.25rem auto 0; padding: 0 .25rem; display: grid; gap: .7rem; }
.attend-steps li { display: flex; gap: .75rem; align-items: flex-start; font-size: .9rem; color: var(--text-secondary); }
.attend-steps strong { color: var(--text-primary); }
.attend-step-no { flex: 0 0 auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); font-size: .8rem; font-weight: 700; }
.attend-guest-brand { justify-content: center; max-width: 560px; margin: .25rem auto 1.25rem; color: var(--text-primary); }
.attend-number-input { font-family: var(--font-mono); font-size: 1.35rem; letter-spacing: .08em; text-align: center; }
.attend-late-note { display: block; font-size: .82rem; color: var(--text-muted); }
.attend-confirm { display: grid; justify-items: center; gap: .25rem; padding: 1rem; text-align: center; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); }
.attend-confirm-label { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.attend-confirm .avatar { margin: .35rem 0 .25rem; }
.attend-confirm-name { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); overflow-wrap: anywhere; }
.attend-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.attend-actions > .btn { flex: 1 1 auto; justify-content: center; }
.present-share-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.present-share-actions > .btn { flex: 1 1 0; justify-content: center; }
.present-late-input { flex: 1 1 7rem; min-width: 0; }
.present-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 960px) { .present-layout { grid-template-columns: 1fr; } }
.present-body { display: grid; justify-items: center; gap: .9rem; text-align: center; }
.present-qr canvas { display: block; width: min(420px, 70vw); height: auto; border-radius: var(--radius-sm); }
.present-qr.is-closed { opacity: .25; filter: grayscale(1); }
.present-code { font-size: clamp(2rem, 6vw, 3.6rem); font-weight: 700; letter-spacing: .12em; color: var(--text-primary); }
.present-status { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: center; color: var(--text-secondary); }
.present-count { font-size: 1.05rem; font-weight: 600; color: var(--text-secondary); }
.present-layout:fullscreen { background: var(--bg-primary); padding: 2rem; grid-template-columns: 1fr; place-content: center; }
.present-layout:fullscreen .present-controls { display: none; }
.present-layout:fullscreen .present-qr canvas { width: min(70vh, 80vw); }
.metric-button { font: inherit; text-align: left; cursor: pointer; color: inherit; }
.metric-button:hover { border-color: var(--border-strong); }
.metric-danger { border-color: var(--danger); background: var(--danger-soft); }
.metric-warning { border-color: var(--warning); background: var(--warning-soft); }

/* Attendance reports: shown in the page and printed (Print → Save as PDF) */
.report-filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 760px) { .report-filters { grid-template-columns: 1fr; } }
.report-options { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.report { padding: 1.5rem; }
.report-header { display: grid; gap: .35rem; margin-bottom: 1rem; }
.report-brand { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; color: var(--text-secondary); border-bottom: 2px solid var(--primary); padding-bottom: .35rem; }
/* The uploaded letterhead, in place of the typed institution line. Full width and its
   own aspect ratio, so a banner scanned from the school's paper prints as it looks. */
.report-letterhead { display: block; width: 100%; height: auto; margin-bottom: .35rem; }
.report-title { margin: .35rem 0 .15rem; font-size: 1.35rem; letter-spacing: -.01em; }
/* Label over value, in a bordered panel: the border survives printing, the fill does not need to. */
.report-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem 1.25rem; margin: 0; padding: .8rem 1rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); font-size: .85rem; }
.report-meta > div { min-width: 0; }
.report-meta dt { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .1rem; }
.report-meta dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.report-code { display: inline-block; margin-left: .2rem; padding: 0 .35rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: .74rem; color: var(--text-secondary); }
@media (max-width: 900px) { .report-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .report-meta { grid-template-columns: 1fr; } }

/* Figures above the table (statsFor() in reports.js, drawn again by pdf.js). */
.report-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; margin-top: .6rem; }
.report-stat { display: grid; gap: .1rem; align-content: start; padding: .6rem .75rem; border: 1px solid var(--border-color); border-radius: var(--radius); }
.report-stat-label { display: flex; align-items: center; gap: .35rem; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.report-stat-value { font-size: 1.45rem; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.report-stat-hint { font-size: .74rem; color: var(--text-secondary); }
.report-stat-good .report-stat-value { color: var(--success); }
.report-stat-bad .report-stat-value { color: var(--danger); }
.report-stat-warn .report-stat-value { color: var(--warning); }
@media (max-width: 900px) { .report-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.report-dot { display: inline-block; flex: none; width: .55rem; height: .55rem; border-radius: 50%; }
.report-dot-present, .report-mix-present { background: var(--att-present); }
.report-dot-late, .report-mix-late { background: var(--att-late); }
.report-dot-absent, .report-mix-absent { background: var(--att-absent); }
.report-dot-excused, .report-mix-excused { background: var(--att-excused); }
.report-mix { display: grid; gap: .4rem; margin-top: .6rem; }
.report-mix-bar { display: flex; gap: 2px; height: .5rem; border-radius: 999px; overflow: hidden; background: var(--chart-track); }
.report-mix-bar > span { flex-basis: 0; min-width: 3px; }
.report-mix-legend { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin: 0; padding: 0; list-style: none; font-size: .78rem; color: var(--text-secondary); }
.report-mix-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.report-mix-legend strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.report-mix-legend span { color: var(--text-muted); }
.report-note { font-size: .8rem; color: var(--text-secondary); margin: 0 0 .75rem; }
.report-empty { padding: 1.5rem 0; color: var(--text-muted); }
.report-table { font-size: .82rem; }
.report-table th, .report-table td { padding: .35rem .5rem; }
.report-table tfoot th { border-top: 2px solid var(--border-strong); }
.report-dates { font-size: .75rem; color: var(--text-secondary); max-width: 360px; }
.report-sheet th, .report-sheet td { text-align: center; padding: .25rem .3rem; }
.report-sheet td:nth-child(2), .report-sheet th:nth-child(2) { text-align: left; }
.report-day { font-size: .68rem; white-space: nowrap; }
.report-mark { font-weight: 700; font-size: .75rem; }
.report-mark-late { color: var(--warning); }
.report-mark-absent { color: var(--danger); }
.report-mark-excused { color: var(--info); }
.report-mark-none { background: var(--danger-soft); }
.report-signature { display: flex; gap: 3rem; margin-top: 2.5rem; font-size: .78rem; color: var(--text-secondary); flex-wrap: wrap; }
.report-signature > div { display: grid; gap: .3rem; min-width: 220px; }
.report-line { display: block; border-bottom: 1px solid var(--text-primary); height: 1.6rem; }
/* The printed name sits on the line that is signed over. The Date column keeps an
   empty one so both captions stay on the same baseline. */
.report-signer { display: block; min-height: 1.15em; font-size: .85rem; color: var(--text-primary); }

@page { size: A4 portrait; margin: 12mm; }
@page landscape { size: A4 landscape; margin: 10mm; }
@media print {
    .report { border: 0 !important; box-shadow: none !important; padding: 0; }
    /* On body, not the report: a named page on an inner element leaves a blank page after it. */
    body.print-landscape { page: landscape; }
    .report-table tfoot { display: table-row-group; }
    .report-table { font-size: 9pt; }
    .report-sheet { font-size: 7.5pt; }
    .report-table thead { display: table-header-group; }
    .report-table tr { break-inside: avoid; }
    .report .table-wrap { overflow: visible !important; }
    .report .badge { border: 1px solid currentColor; }
    /* Browsers drop background graphics when printing; a letterhead is content, so it
       is an <img> rather than a background, and it must not be split across pages. */
    .report-letterhead { break-inside: avoid; break-after: avoid; }
    .report-mark-none { background: #eee !important; }
    /* The split bar and its dots are colour or nothing, so they keep it on paper. */
    .report-dot, .report-mix-bar, .report-mix-bar > span { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    /* A4 is narrower than the screen breakpoints, so the paper layout is set outright. */
    .report-meta { background: none; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: .5rem .7rem; font-size: 9pt; }
    .report-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .report-stat { padding: .35rem .5rem; }
    .report-stat-value { font-size: 14pt; }
    .report-stats, .report-mix { break-inside: avoid; }
    body, .content, .main { background: #fff !important; }
}

/* Join a class with a code: the instructor's card on the section page, the student's page */
.join-code-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .85rem 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg-inset); }
.join-code-row.is-off { opacity: .6; }
.join-code-main { min-width: 0; }
.join-code { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; letter-spacing: .22em; line-height: 1.1; color: var(--primary-text); }
.join-link { font-size: .78rem; color: var(--text-muted); overflow-wrap: anywhere; }
.join-qr-body { display: grid; justify-items: center; gap: .6rem; text-align: center; }
.join-qr { width: min(100%, 320px); height: auto; border-radius: var(--radius-sm); }
.tab-count.tab-count-alert, .tab[aria-selected="true"] .tab-count.tab-count-alert { color: var(--on-primary); background: var(--warning); }
.join-requests { list-style: none; margin: 0; padding: 0; }
.join-requests-title { margin: .25rem 0 0; font-size: .9rem; }
.join-requests li { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-top: 1px solid var(--border-color); }
.join-requests li:first-child { border-top: 0; }
.join-requests .cell-sub { display: block; }

/* The class's Google Meet link in the section page's Google Meet modal. */
.meet-link { overflow-wrap: anywhere; }

/* Attendance history */
.history-class { border: 1px solid var(--border-color); border-radius: var(--radius); }
.history-class summary { display: flex; gap: .75rem; align-items: center; padding: .7rem .9rem; cursor: pointer; flex-wrap: wrap; }
.history-class summary .grow { display: grid; min-width: 180px; }
.history-counts { font-size: .78rem; color: var(--text-secondary); }
.history-days { list-style: none; margin: 0; padding: 0 .9rem .6rem; max-height: 320px; overflow-y: auto; }
.history-days li { display: grid; grid-template-columns: minmax(0, 1fr) auto 3.5rem; gap: .75rem; align-items: center; padding: .35rem 0; border-top: 1px solid var(--border-color); font-size: .84rem; }
.history-empty { padding: 0 .9rem .7rem; font-size: .84rem; }


/* Student photos */
.avatar-xl { width: 88px; height: 88px; font-size: 1.6rem; }
.avatar.no-photo { background: var(--bg-tertiary); color: var(--text-muted); }
.photo-zoom { border: 0; padding: 0; cursor: zoom-in; font: inherit; }
.photo-zoom:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.photo-viewer { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--radius); background: var(--bg-inset); }
.student-photo { display: grid; justify-items: center; gap: .4rem; }

/* User guide */
/* ---------- What's New (core/whats-new.js) ---------- */
.modal.whats-new-modal { position: relative; max-width: 640px; overflow: hidden; }
.whats-new-modal .modal-header { position: absolute; inset: 0 0 auto; z-index: 1; border: 0; padding: .8rem 1rem .8rem 1.5rem; color: var(--brand-on-ribbon); }
.whats-new-modal .modal-header h2 { color: inherit; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.whats-new-modal .modal-header .icon-button { color: var(--brand-on-ribbon); }
.whats-new-modal .modal-header .icon-button:hover { background: var(--brand-on-ribbon-soft); }
.whats-new-modal .modal-footer { justify-content: space-between; align-items: center; }
.whats-new-hero {
    position: relative; overflow: hidden;
    margin: -1.25rem -1.25rem 0; padding: 3.4rem 1.5rem 2.9rem;
    color: var(--brand-on-ribbon);
    /* The ribbon starts light (it is shared with the sidebar logo); a dark wash keeps the white text readable. */
    background:
        radial-gradient(var(--brand-on-ribbon-soft) 1px, transparent 1.5px) 0 0 / 16px 16px,
        linear-gradient(160deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.12) 60%, rgba(0, 0, 0, 0.05)),
        var(--brand-ribbon);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
    clip-path: polygon(0 0, 100% 0, 100% 80%, 50% 100%, 0 80%);
}
.whats-new-spark { position: absolute; right: -1.2rem; top: 1.4rem; opacity: .22; transform: rotate(-12deg); }
.whats-new-spark .icon { width: 150px; height: 150px; stroke-width: 1.2; }
.whats-new-eyebrow {
    display: inline-block; margin: 0 0 .55rem; padding: .18rem .6rem; border-radius: 999px;
    background: rgba(0, 0, 0, 0.26); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    font-size: .74rem; font-weight: 700; text-shadow: none;
}
.whats-new-hero h3 { position: relative; margin: 0; max-width: 30ch; font-size: 1.45rem; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; color: inherit; }
/* Timeline: one rail; each update has a date marker, each item an icon node on the rail. */
.wn-timeline { --rail: 19px; position: relative; list-style: none; margin: 1.1rem 0 0; padding: 0 0 0 calc(var(--rail) * 2 + .7rem); display: grid; gap: 1.4rem; }
.wn-timeline::before { content: ""; position: absolute; left: calc(var(--rail) - 1px); top: .5rem; bottom: .25rem; width: 2px; border-radius: 2px; background: linear-gradient(180deg, var(--primary) 0, color-mix(in srgb, var(--primary) 35%, var(--border-color)) 9rem, var(--border-color) 60%, transparent); }
.wn-release { position: relative; }
.wn-release-head { position: relative; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-height: 1.5rem; margin-bottom: .6rem; }
.wn-marker { position: absolute; left: calc(-1 * (var(--rail) + .7rem) - 6px); top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--bg-secondary); box-shadow: 0 0 0 2px var(--border-strong); }
.wn-release.is-latest .wn-marker { background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 25%, transparent); animation: wn-pulse 2.4s ease-out infinite; }
.wn-release-head time { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.wn-release.is-latest .wn-release-head time { color: var(--primary-text); }
.wn-tag { padding: .08rem .5rem; border-radius: 999px; font-size: .66rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--on-primary, #fff); background: var(--primary); }
.wn-release-title { font-size: .86rem; font-weight: 700; color: var(--text-primary); }
.wn-items { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.wn-item { position: relative; animation: whats-new-in .38s ease both; animation-delay: calc(min(var(--i), 10) * 60ms + 120ms); }
.wn-node {
    position: absolute; left: calc(-1 * (var(--rail) * 2 + .7rem)); top: .55rem;
    width: calc(var(--rail) * 2); height: calc(var(--rail) * 2); border-radius: 50%; display: grid; place-items: center;
    color: var(--primary-text); background: var(--primary-soft);
    box-shadow: 0 0 0 4px var(--bg-secondary), inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent);
}
.wn-node svg.icon { width: 18px; height: 18px; }
.wn-card { padding: .75rem .95rem; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-inset); transition: border-color var(--transition), transform var(--transition); }
.wn-item:hover .wn-card { border-color: var(--primary); transform: translateX(2px); }
.wn-card h4 { margin: 0 0 .2rem; font-size: .95rem; }
.wn-card p { margin: 0; font-size: .86rem; line-height: 1.5; color: var(--text-secondary); }
/* Earlier updates: smaller nodes, no card. */
.wn-item.is-compact .wn-node { top: .1rem; left: calc(-1 * (var(--rail) * 2 + .7rem) + 6px); width: calc(var(--rail) * 2 - 12px); height: calc(var(--rail) * 2 - 12px); color: var(--text-secondary); background: var(--bg-tertiary); box-shadow: 0 0 0 4px var(--bg-secondary); }
.wn-item.is-compact .wn-node svg.icon { width: 13px; height: 13px; }
.wn-item.is-compact .wn-card { padding: 0; border: 0; background: none; }
.wn-item.is-compact:hover .wn-card { transform: none; }
.wn-item.is-compact h4 { font-size: .86rem; }
.wn-item.is-compact p { font-size: .82rem; }
.wn-end { display: flex; align-items: center; gap: .4rem; margin: 1.1rem 0 0; padding-left: calc(var(--rail, 19px) * 2 + .7rem); font-size: .76rem; color: var(--text-muted); }
.wn-end svg.icon { width: 13px; height: 13px; }
.whats-new-link { display: inline-flex; align-items: center; gap: .2rem; margin-top: .45rem; font-size: .82rem; font-weight: 600; color: var(--primary-text); }
.whats-new-link .icon { width: 14px; height: 14px; transition: transform var(--transition); }
.whats-new-link:hover .icon { transform: translateX(2px); }
@keyframes wn-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
.whats-new-footnote { font-size: .78rem; color: var(--text-muted); }
.whats-new-footnote .icon { width: 14px; height: 14px; margin-right: .3rem; vertical-align: -2px; }
@keyframes whats-new-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 640px) {
    .whats-new-hero { padding: 3.2rem 1.1rem 2.4rem; }
    .whats-new-hero h3 { font-size: 1.2rem; }
    .whats-new-footnote { display: none; }
    .whats-new-modal .modal-footer { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
    .wn-item, .wn-release.is-latest .wn-marker { animation: none; }
    .wn-item:hover .wn-card, .whats-new-link:hover .icon { transform: none; }
}

.guide-welcome { display: flex; gap: 1rem; align-items: flex-start; }
.guide-welcome p { margin-bottom: .6rem; }
.guide-welcome ul { margin: 0 0 .8rem; padding-left: 1.2rem; display: grid; gap: .3rem; color: var(--text-secondary); }
@media (max-width: 480px) { .guide-welcome .stat-icon { display: none; } }
.guide-search { position: relative; min-width: min(280px, 100%); }
.guide-search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.guide-search .input { padding-left: 2.2rem; }
.guide-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.guide-toc { position: sticky; top: calc(var(--topbar-height) + 1rem); padding: .9rem; display: grid; gap: .9rem; max-height: calc(100vh - var(--topbar-height) - 2rem); overflow-y: auto; }
.guide-toc-group { display: grid; gap: .1rem; }
.guide-toc-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: .2rem; }
.guide-toc a { padding: .3rem .5rem; border-radius: var(--radius-sm); font-size: .85rem; color: var(--text-secondary); }
.guide-toc a:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.guide-group h2 { font-size: 1.05rem; }
.guide-topic { scroll-margin-top: calc(var(--topbar-height) + 1rem); }
.guide-topic summary { display: flex; gap: .9rem; align-items: center; padding: .9rem 1.1rem; cursor: pointer; list-style: none; }
.guide-topic summary::-webkit-details-marker { display: none; }
.guide-topic summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: var(--radius); }
.guide-topic summary .stat-icon { width: 38px; height: 38px; border-radius: 10px; }
.guide-topic-title { display: block; font-weight: 600; color: var(--text-primary); }
.guide-topic-summary { display: block; font-size: .84rem; color: var(--text-secondary); }
.guide-chevron { color: var(--text-muted); transition: transform var(--transition); }
.guide-topic[open] .guide-chevron { transform: rotate(180deg); }
.guide-topic-body { display: grid; gap: 1rem; padding: 1rem 1.1rem 1.1rem; border-top: 1px solid var(--border-color); }
.guide-steps { counter-reset: guide-step; list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.guide-steps li { counter-increment: guide-step; position: relative; padding-left: 2.2rem; line-height: 1.55; }
.guide-steps li::before { content: counter(guide-step); position: absolute; left: 0; top: 0; width: 1.55rem; height: 1.55rem; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: var(--primary-soft); color: var(--primary-text); }
.guide-steps strong, .guide-tips strong { color: var(--text-primary); }
.guide-tips { padding: .75rem .9rem; border-radius: var(--radius); background: var(--bg-inset); border: 1px solid var(--border-color); font-size: .86rem; }
.guide-tips > strong { display: flex; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.guide-tips ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .3rem; color: var(--text-secondary); }
@media (max-width: 900px) {
    .guide-layout { grid-template-columns: 1fr; }
    .guide-toc { display: none; }
}
@media (prefers-reduced-motion: reduce) { .guide-chevron { transition: none; } }

/* Student CSV import */
.import-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.import-columns > div { display: grid; gap: .2rem; padding: .7rem .8rem; border-radius: var(--radius); background: var(--bg-inset); border: 1px solid var(--border-color); font-size: .84rem; }
.import-columns span { color: var(--text-secondary); }
.import-drop { display: grid; justify-items: center; gap: .25rem; padding: 1.6rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); cursor: pointer; text-align: center; transition: border-color var(--transition), background var(--transition); }
.import-drop .icon { width: 28px; height: 28px; color: var(--primary-text); }
.import-drop:hover, .import-drop.is-over, .import-drop:focus-within { border-color: var(--primary); background: var(--primary-soft); }
.import-preview { max-height: 300px; overflow: auto; border: 1px solid var(--border-color); border-radius: var(--radius); }
.import-preview tr.is-invalid td { background: var(--danger-soft); }
.import-preview td { white-space: nowrap; }
@media (max-width: 640px) { .import-columns { grid-template-columns: 1fr; } }

/* Student import: progress while batches are sent */
.import-progress { display: grid; gap: 1rem; }
.import-progress-head { display: flex; align-items: center; gap: .85rem; }
.import-progress-icon { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary-text); }
.import-progress-icon .icon { width: 22px; height: 22px; animation: import-lift 1.4s ease-in-out infinite; }
.import-progress-title { font-weight: 700; font-size: 1rem; }
.import-progress-sub { color: var(--text-secondary); font-size: .84rem; }
.import-progress-pct { margin-left: auto; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.import-progress .metric-value { font-variant-numeric: tabular-nums; }
.import-progress-note { display: inline-flex; align-items: center; gap: .4rem; margin-right: auto; color: var(--text-muted); font-size: .82rem; }
.progress-lg { height: 12px; }
.progress.is-active > span {
    background-image: linear-gradient(45deg, color-mix(in srgb, var(--on-primary) 22%, transparent) 25%, transparent 25%, transparent 50%, color-mix(in srgb, var(--on-primary) 22%, transparent) 50%, color-mix(in srgb, var(--on-primary) 22%, transparent) 75%, transparent 75%);
    background-size: 1rem 1rem;
    animation: progress-stripes .8s linear infinite;
}
@keyframes progress-stripes { from { background-position: 1rem 0; } to { background-position: 0 0; } }
@keyframes import-lift { 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .progress.is-active > span, .import-progress-icon .icon { animation: none; } }
@media (max-width: 640px) {
    .import-progress-pct { font-size: 1.25rem; }
    .import-progress-note { display: none; }
}

/* ---------- Calendar ---------- */
.cal-kinds { display: flex; gap: .35rem; flex-wrap: wrap; }
/* A kind switched off keeps its place but reads as inactive. */
.cal-kind { font: inherit; font-size: .76rem; font-weight: 600; padding: .34rem .7rem; cursor: pointer; border: 1px solid transparent; color: var(--text-primary); transition: background var(--transition), border-color var(--transition), color var(--transition); }
.cal-kind[aria-pressed="false"] { background: transparent; border-color: var(--border-color); color: var(--text-muted); }
.cal-kind[aria-pressed="false"] svg.icon { opacity: .6; }
.cal-kind:hover { border-color: var(--border-strong); }

/* The grid runs edge to edge, so the card clips it to its own corners. */
.cal-card { overflow: hidden; }
.cal-card .card-header { padding-block: .85rem; }
.cal-month { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.cal-year { font-size: 1.15rem; font-weight: 400; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cal-nav { display: flex; align-items: center; gap: .25rem; }

/* Row 1 is the weekday strip and sizes to its text; the day rows below it get the height. */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto; grid-auto-rows: minmax(96px, auto); }
.cal-weekday { padding: .55rem .55rem; background: var(--bg-inset); border-bottom: 1px solid var(--border-color); text-align: left; font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.cal-weekday:first-child, .cal-weekday:last-child { color: color-mix(in srgb, var(--text-muted) 70%, transparent); }
.cal-error { grid-column: 1 / -1; background: var(--bg-secondary); }

/* Hairlines on the cells themselves, so the grid reads as one surface. */
.cal-day { position: relative; display: flex; flex-direction: column; gap: .3rem; align-items: stretch; padding: .4rem .4rem .5rem; border: 0; border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); background: var(--bg-secondary); text-align: left; font: inherit; color: inherit; cursor: pointer; transition: background var(--transition); }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--bg-hover); }
.cal-day:focus-visible { outline: none; box-shadow: var(--focus-ring) inset; z-index: 1; }
.cal-day.is-outside { background: color-mix(in srgb, var(--bg-inset) 60%, var(--bg-secondary)); }
.cal-day.is-outside .cal-daynum, .cal-day.is-outside .cal-chip { opacity: .5; }

.cal-daynum { display: grid; place-items: center; align-self: flex-start; width: 26px; height: 26px; border-radius: 999px; font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.cal-day.is-today .cal-daynum { background: var(--primary); color: var(--on-primary); font-weight: 700; box-shadow: 0 2px 6px color-mix(in srgb, var(--primary) 40%, transparent); }
/* Selected is a ring, not a fill: the day keeps its own colours underneath. */
.cal-day.is-selected { background: color-mix(in srgb, var(--primary) 7%, var(--bg-secondary)); }
.cal-day.is-selected::after { content: ""; position: absolute; inset: 0; border: 2px solid var(--primary); pointer-events: none; }
.cal-day.is-selected:not(.is-today) .cal-daynum { color: var(--primary-text); font-weight: 700; }

.cal-chips { display: grid; gap: .18rem; min-width: 0; }
.cal-chip { display: flex; align-items: center; gap: .32rem; min-width: 0; padding: .14rem .32rem; border-radius: var(--radius-sm); background: var(--bg-tertiary); font-size: .71rem; line-height: 1.45; }
.cal-chip-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.cal-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); font-weight: 500; }
.cal-more { padding-left: .34rem; font-size: .68rem; font-weight: 600; color: var(--text-muted); }

/* The day panel beside the grid. */
.cal-aside { position: sticky; top: calc(var(--topbar-height) + 1rem); }
.cal-aside .card-header h2 { font-size: .95rem; }
.cal-events { display: grid; padding: .4rem; gap: .1rem; }
.cal-event { display: flex; align-items: center; gap: .6rem; padding: .5rem .55rem; border-radius: var(--radius); color: var(--text-primary); transition: background var(--transition); }
a.cal-event:hover { background: var(--bg-hover); }
.cal-event-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-muted); }
.cal-event-text { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.cal-event-text strong { font-size: .85rem; font-weight: 600; }
.cal-event-text small { font-size: .74rem; color: var(--text-muted); }
.cal-event svg.icon { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
a.cal-event:hover svg.icon { color: var(--primary-text); }
/* Nothing on this day: a quiet line, not a boxed-off empty state. */
.cal-empty { display: flex; align-items: center; gap: .55rem; padding: 1.1rem 1.25rem; color: var(--text-muted); font-size: .84rem; }
.cal-empty svg.icon { width: 17px; height: 17px; flex-shrink: 0; }

/* Event colours: the dot carries the meaning, the pill only tints behind it. */
.tone-primary .cal-chip-dot, .tone-primary .cal-event-dot { background: var(--primary); }
.tone-success .cal-chip-dot, .tone-success .cal-event-dot { background: var(--success); }
.tone-danger .cal-chip-dot, .tone-danger .cal-event-dot { background: var(--danger); }
.tone-info .cal-chip-dot, .tone-info .cal-event-dot { background: var(--info); }
.tone-violet .cal-chip-dot, .tone-violet .cal-event-dot { background: var(--chart-4); }
.tone-muted .cal-chip-dot, .tone-muted .cal-event-dot { background: var(--text-muted); }
.cal-chip.tone-primary { background: color-mix(in srgb, var(--primary) 13%, transparent); }
.cal-chip.tone-primary .cal-chip-text { color: var(--primary-text); }
.cal-chip.tone-success { background: var(--success-soft); }
.cal-chip.tone-success .cal-chip-text { color: var(--success); }
.cal-chip.tone-danger { background: var(--danger-soft); }
.cal-chip.tone-danger .cal-chip-text { color: var(--danger); }
.cal-chip.tone-info { background: var(--info-soft); }
.cal-chip.tone-info .cal-chip-text { color: var(--info); }
.cal-chip.tone-violet { background: color-mix(in srgb, var(--chart-4) 14%, transparent); }
.cal-chip.tone-violet .cal-chip-text { color: var(--chart-4); }

/* An attendance mark keeps the colours of the records pages. */
.att-present .cal-chip-dot, .att-present .cal-event-dot { background: var(--att-present); }
.att-late .cal-chip-dot, .att-late .cal-event-dot { background: var(--att-late); }
.att-excused .cal-chip-dot, .att-excused .cal-event-dot { background: var(--att-excused); }
.att-absent .cal-chip-dot, .att-absent .cal-event-dot { background: var(--att-absent); }
.cal-chip.att-present { background: var(--success-soft); }
.cal-chip.att-present .cal-chip-text { color: var(--att-present); }
.cal-chip.att-late { background: var(--warning-soft); }
.cal-chip.att-late .cal-chip-text { color: var(--att-late); }
.cal-chip.att-absent { background: var(--danger-soft); }
.cal-chip.att-absent .cal-chip-text { color: var(--att-absent); }
.cal-chip.att-excused { background: var(--bg-tertiary); }
.cal-chip.att-excused .cal-chip-text { color: var(--text-muted); }

.cal-summary-box { padding: .4rem; }
.cal-summary { display: grid; gap: .1rem; margin: 0; padding: 0; list-style: none; font-size: .85rem; }
.cal-summary li { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; border-radius: var(--radius-sm); color: var(--text-secondary); }
.cal-summary li.is-empty { color: var(--text-muted); }
.cal-summary strong { margin-left: auto; font-size: .95rem; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cal-summary li.is-empty strong { color: var(--text-muted); font-weight: 600; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cal-dot.kind-deadline { background: var(--primary); }
.cal-dot.kind-attendance { background: var(--info); }
.cal-dot.kind-term { background: var(--chart-4); }

/* What is still ahead, so the column beside a quiet month is not blank. */
.cal-next { display: grid; padding: .4rem; gap: .1rem; }
.cal-next-item { display: flex; align-items: center; gap: .55rem; padding: .45rem .5rem; border-radius: var(--radius); color: var(--text-primary); transition: background var(--transition); }
.cal-next-item:hover { background: var(--bg-hover); }
.cal-next-date { display: grid; place-items: center; width: 40px; flex-shrink: 0; padding: .24rem 0; border-radius: var(--radius-sm); background: var(--bg-tertiary); line-height: 1.15; }
.cal-next-date small { font-size: .6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.cal-next-date strong { font-size: .92rem; font-variant-numeric: tabular-nums; }
.cal-next-text { min-width: 0; display: grid; gap: .05rem; }
.cal-next-text strong { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-next-text small { font-size: .72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
    .cal-aside { position: static; }
}

@media (max-width: 720px) {
    /* Too narrow for labels: the day keeps its dots and the panel carries the detail. */
    .cal-grid { grid-auto-rows: minmax(58px, auto); }
    .cal-day { padding: .3rem .25rem; gap: .2rem; }
    .cal-daynum { width: 22px; height: 22px; font-size: .74rem; }
    .cal-chips { display: flex; flex-wrap: wrap; gap: .2rem; padding-left: .15rem; }
    .cal-chip { padding: 0; background: none; }
    .cal-chip-text, .cal-more { display: none; }
    .cal-weekday { font-size: .58rem; padding: .4rem .25rem; text-align: center; }
    .cal-kinds .cal-kind { font-size: .7rem; padding: .3rem .55rem; }
}

/* ---------- Messages (messages/index.js) ---------- */
/* Conversations beside the open thread; on a phone one or the other (data-view). */
.messenger { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 1rem; height: calc(100dvh - 220px); min-height: 440px; }
.messenger-list, .messenger-thread { display: flex; flex-direction: column; overflow: hidden; padding: 0; min-width: 0; }
.messenger-list-head { padding: .75rem; border-bottom: 1px solid var(--border-color); }
.messenger-conversations { flex: 1; overflow-y: auto; }
.messenger-item { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .7rem .85rem; border: 0; border-bottom: 1px solid var(--border-color); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background var(--transition); }
.messenger-item:hover { background: var(--bg-hover); }
.messenger-item.active { background: var(--primary-soft); }
.messenger-item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.messenger-item .avatar, .contact-item .avatar { width: 40px; height: 40px; flex-shrink: 0; }
.messenger-item-text { flex: 1; min-width: 0; display: grid; gap: .15rem; }
.messenger-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.messenger-item-top strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messenger-item-top small { flex-shrink: 0; font-size: .72rem; color: var(--text-muted); }
.messenger-item-preview { font-size: .8rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messenger-item.unread .messenger-item-preview { color: var(--text-primary); font-weight: 600; }
.messenger-unread { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: var(--on-primary); font-size: .7rem; font-weight: 700; line-height: 20px; text-align: center; }
.messenger-empty, .msg-start { margin: auto; }
.messenger-thread-head { display: flex; align-items: center; gap: .7rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border-color); }
.messenger-thread-head .avatar { width: 40px; height: 40px; flex-shrink: 0; }
.messenger-thread-title { display: grid; min-width: 0; }
.messenger-thread-title small { font-size: .74rem; color: var(--text-muted); }
.messenger-back { display: none; }
.messenger-delete { margin-left: auto; flex-shrink: 0; color: var(--text-secondary); }
.messenger-delete:hover { color: var(--danger); }
.messenger-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .35rem; background: var(--bg-primary); }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 75%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-bubble { padding: .55rem .8rem; border-radius: 16px 16px 16px 4px; background: var(--bg-tertiary); color: var(--text-primary); font-size: .9rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .msg-bubble { background: var(--primary); color: var(--on-primary); border-radius: 16px 16px 4px 16px; }
.msg.removed .msg-bubble { background: transparent; border: 1px dashed var(--border-color); color: var(--text-muted); font-style: italic; }
.msg-bubble svg.icon { width: 13px; height: 13px; vertical-align: -2px; }
.msg-meta { display: flex; align-items: center; gap: .3rem; margin-top: .1rem; padding: 0 .3rem; font-size: .68rem; color: var(--text-muted); }
/* Sent, or Seen with the other person's photo, beside the time of one's last message (the app's chat says the same). */
.msg-status { display: inline-flex; align-items: center; gap: .2rem; }
.msg-status svg.icon { width: 12px; height: 12px; }
.msg-status .avatar { width: 14px; height: 14px; font-size: .42rem; }
.msg-remove { padding: 0 .15rem; border: 0; background: none; color: var(--text-muted); cursor: pointer; opacity: 0; transition: opacity var(--transition); }
.msg:hover .msg-remove, .msg-remove:focus-visible { opacity: 1; }
.msg-remove:hover { color: var(--danger); }
.msg-remove svg.icon { width: 12px; height: 12px; }
@media (hover: none) { .msg-remove { opacity: 1; } }
.msg-day { margin: .6rem 0 .3rem; text-align: center; font-size: .72rem; color: var(--text-muted); }
.msg-day span { padding: .15rem .65rem; border-radius: 99px; background: var(--bg-secondary); border: 1px solid var(--border-color); }
.msg-older { text-align: center; }
.messenger-composer { display: flex; align-items: flex-end; gap: .5rem; padding: .75rem 1rem 0; border-top: 1px solid var(--border-color); }
.messenger-composer .textarea { flex: 1; min-height: 42px; max-height: 160px; resize: none; }
.messenger-composer .btn { width: 42px; height: 42px; justify-content: center; flex-shrink: 0; }
.messenger-hint { margin: .3rem 1rem .6rem; font-size: .7rem; color: var(--text-muted); }
.messenger-closed { display: flex; align-items: center; gap: .5rem; padding: .85rem 1rem; border-top: 1px solid var(--border-color); background: var(--bg-inset); color: var(--text-muted); font-size: .84rem; }
.messenger-closed svg.icon { width: 16px; height: 16px; flex-shrink: 0; }
.contact-list { display: grid; gap: .2rem; max-height: 55vh; overflow-y: auto; }
.contact-item { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .6rem; border: 0; border-radius: var(--radius); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.contact-item:hover, .contact-item:focus-visible { background: var(--bg-hover); }
.contact-item > span:last-child { display: grid; min-width: 0; }
.contact-item small { font-size: .76rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 820px) {
    .messenger { grid-template-columns: 1fr; height: calc(100dvh - 190px); }
    .messenger[data-view="list"] .messenger-thread, .messenger[data-view="thread"] .messenger-list { display: none; }
    .messenger-back { display: inline-flex; }
    .msg { max-width: 85%; }
}
@media (prefers-reduced-motion: reduce) { .messenger-item, .msg-remove { transition: none; } }

/* Database Monitor: on a phone the verdict's text takes the width beside the icon, with the badge under it. */
@media (max-width: 640px) {
    .db-verdict { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; row-gap: .6rem; }
    .db-verdict > .badge { grid-column: 2; justify-self: start; }
}
/* Database Monitor: the pending migrations above the Apply updates button. */
.migration-list { margin: .4rem 0 .6rem; padding-left: 1.1rem; font-size: .76rem; display: grid; gap: .15rem; }

/* ---------- Class ranking (records/ranking.js) ----------
   eGradeBook's shared ranking page (share.php, share.css there) in a modal: one podium
   block per PLACE (2 · 1 · 3, ties together), then the tied and the rest by place, with
   the student's own row marked. Plays once on open: #3, #2, then #1 with confetti. */
.ranking { display: grid; gap: 1rem; }
.ranking-you { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-radius: var(--radius); background: color-mix(in srgb, var(--medal-gold) 12%, var(--bg-inset)); border: 1px solid color-mix(in srgb, var(--medal-gold) 35%, transparent); font-size: .88rem; }
.ranking-you svg.icon { width: 18px; height: 18px; color: var(--medal-gold); flex-shrink: 0; }
.ranking-you strong { color: var(--text-primary); }
.rank-pd { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: .5rem; margin: .4rem 0 0; padding: 0; }
.rank-pd.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 70%; margin-inline: auto; }
.rank-pd.cols-1 { grid-template-columns: minmax(0, 1fr); max-width: 45%; margin-inline: auto; }
.rank-slot { --tier: var(--medal-bronze); display: flex; flex-direction: column; min-width: 0; }
.rank-slot.t1 { --tier: var(--medal-gold); }
.rank-slot.t2 { --tier: var(--medal-silver); }
.rank-person { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 0 .15rem .6rem; min-width: 0; text-align: center; }
.rank-face { position: relative; display: flex; justify-content: center; }
.rank-av { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; font-weight: 700; font-size: 1rem; color: var(--text-primary); background: color-mix(in srgb, var(--tier) 16%, var(--bg-tertiary)); border: 3px solid var(--tier); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tier) 14%, transparent); }
.rank-av img { width: 100%; height: 100%; object-fit: cover; }
.rank-slot.t1 .rank-av { width: 68px; height: 68px; font-size: 1.15rem; }
.rank-slot .rank-av.sm { width: 38px; height: 38px; font-size: .72rem; border-width: 2px; box-shadow: 0 0 0 2px var(--bg-secondary); }
.rank-av.sm + .rank-av.sm { margin-left: -6px; }
.rank-av.more { color: var(--tier); font-weight: 800; }
.rank-slot .rank-av.is-me { border-color: var(--primary); }
.rank-medal { position: absolute; right: -8px; bottom: -6px; font-size: 1.25rem; line-height: 1; }
.rank-name { max-width: 100%; font-size: .84rem; font-weight: 700; line-height: 1.25; overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rank-names { list-style: none; display: flex; flex-direction: column; gap: .15rem; max-width: 100%; margin: .1rem 0 0; padding: 0; }
.rank-names li { font-size: .74rem; font-weight: 700; line-height: 1.2; overflow-wrap: break-word; }
.rank-names li + li { padding-top: .2rem; border-top: 1px dashed var(--border-color); }
.rank-names .more { font-size: .66rem; font-weight: 600; color: var(--tier); }
.rank-you-tag { display: inline-block; margin-left: .3rem; padding: 0 .4rem; border-radius: 99px; font-size: .62rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; background: var(--primary-soft); color: var(--primary-text); }
.rank-block { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; height: 54px; border-radius: 12px 12px 0 0; border-top: 3px solid var(--tier); background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 26%, transparent), color-mix(in srgb, var(--tier) 6%, transparent)); }
.rank-slot.t1 .rank-block { height: 92px; }
.rank-slot.t2 .rank-block { height: 70px; }
.rank-num { font-size: 1.7rem; font-weight: 800; color: var(--tier); font-variant-numeric: tabular-nums; line-height: 1; }
.rank-slot.t1 .rank-num { font-size: 2.2rem; }
.rank-tie { font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tier); border: 1px solid color-mix(in srgb, var(--tier) 50%, transparent); border-radius: 99px; padding: .05rem .5rem; white-space: nowrap; }
.rank-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding-top: 1rem; border-top: 1px solid var(--border-color); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.rank-head em { font-style: normal; margin-left: .25rem; padding: .05rem .45rem; border-radius: 99px; background: var(--bg-tertiary); color: var(--text-primary); }
.rank-head .input-group { flex: 0 1 220px; min-width: 0; text-transform: none; letter-spacing: 0; font-weight: 400; }
.rank-head .input { border-radius: 99px; padding-top: .35rem; padding-bottom: .35rem; font-size: .82rem; }
.rank-ls { list-style: none; margin: -.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.rank-row { display: flex; align-items: center; gap: .65rem; padding: .45rem .6rem; border-radius: 10px; background: var(--bg-tertiary); border: 1px solid transparent; min-width: 0; }
.rank-row.tied { border-color: color-mix(in srgb, var(--primary) 35%, transparent); border-left: 3px solid var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--bg-tertiary)); }
.rank-row[hidden], .rank-p[hidden] { display: none; }
.rank-rk { flex: 0 0 2rem; display: flex; flex-direction: column; align-items: center; font-weight: 800; font-size: .9rem; color: var(--text-muted); font-variant-numeric: tabular-nums; line-height: 1.1; }
.rank-row.tied .rank-rk { color: var(--primary-text); font-size: 1.05rem; }
.rank-rk small { font-size: .56rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.rank-people { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.rank-p { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.rank-row.tied .rank-p + .rank-p { padding-top: .35rem; border-top: 1px dashed var(--border-color); }
.rank-p .rank-av { width: 32px; height: 32px; border: 0; box-shadow: none; font-size: .7rem; background: color-mix(in srgb, var(--primary) 16%, var(--bg-secondary)); }
.rank-p.is-me .rank-av { box-shadow: 0 0 0 2px var(--primary); }
.rank-pname { flex: 1 1 auto; min-width: 0; font-size: .88rem; font-weight: 500; overflow-wrap: break-word; }
.rank-p.is-me .rank-pname { font-weight: 700; }
.rank-empty { margin: 0; color: var(--text-muted); font-size: .9rem; }
.rank-foot { display: flex; align-items: center; gap: .35rem; padding-top: .8rem; border-top: 1px solid var(--border-color); font-size: .75rem; color: var(--text-muted); }
.rank-foot svg.icon { width: 14px; height: 14px; }
.rank-note { margin: 0; font-size: .72rem; color: var(--text-muted); text-align: center; line-height: 1.5; }
/* A shared class rank on Grades is a button (trophy, place, chevron), so it reads as one on a phone too. */
.rank-open { gap: .35rem; font-weight: 500; }
.rank-open svg.icon { width: 14px; height: 14px; }
.rank-open svg.icon:first-child { color: var(--medal-gold); }
.rank-open svg.icon:last-child { color: var(--text-muted); margin-right: -.2rem; }
.rank-open strong { font-weight: 700; }
/* The intro: blocks rise from the floor (revealed, not stretched), then each place pops in. */
.rank-block { animation: rank-rise .65s cubic-bezier(.2, .8, .25, 1) both; animation-delay: var(--d-block); }
.rank-num, .rank-tie { animation: rank-fade-up .45s ease-out both; animation-delay: calc(var(--d-block) + .25s); }
.rank-person { animation: rank-pop .55s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d-person); }
.rank-medal { transform-origin: 50% 0; animation: rank-swing .9s ease-out both; animation-delay: calc(var(--d-person) + .35s); }
.rank-slot.t3 { --d-block: .15s; --d-person: .5s; }
.rank-slot.t2 { --d-block: .45s; --d-person: .8s; }
.rank-slot.t1 { --d-block: .75s; --d-person: 1.1s; }
.rank-slot.t1 .rank-block::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .28) 50%, transparent 65%); transform: translateX(-120%); animation: rank-shine 4.5s ease-in-out 2.2s infinite; pointer-events: none; }
.rank-slot.t1 .rank-face > .rank-av { animation: rank-glow 2.8s ease-in-out 2.2s infinite; }
.rank-confetti { position: absolute; left: 50%; top: 34px; width: 0; height: 0; pointer-events: none; z-index: 2; }
.rank-confetti i { position: absolute; width: 7px; height: 11px; border-radius: 2px; background: var(--medal-gold); opacity: 0; animation: rank-burst 1.2s cubic-bezier(.15, .7, .35, 1) both; animation-delay: calc(var(--d-person) + .2s); }
.rank-confetti i:nth-child(3n + 1) { background: var(--primary); }
.rank-confetti i:nth-child(3n + 2) { background: var(--medal-silver); width: 6px; height: 6px; border-radius: 50%; }
.rank-confetti i:nth-child(1) { --x: -78px; --y: -46px; --r: 220deg; }
.rank-confetti i:nth-child(2) { --x: -54px; --y: -74px; --r: -160deg; }
.rank-confetti i:nth-child(3) { --x: -22px; --y: -88px; --r: 300deg; }
.rank-confetti i:nth-child(4) { --x: 14px; --y: -92px; --r: -240deg; }
.rank-confetti i:nth-child(5) { --x: 46px; --y: -78px; --r: 180deg; }
.rank-confetti i:nth-child(6) { --x: 76px; --y: -52px; --r: -300deg; }
.rank-confetti i:nth-child(7) { --x: 88px; --y: -12px; --r: 260deg; }
.rank-confetti i:nth-child(8) { --x: -90px; --y: -8px; --r: -200deg; }
.rank-confetti i:nth-child(9) { --x: -64px; --y: 22px; --r: 140deg; }
.rank-confetti i:nth-child(10) { --x: 66px; --y: 26px; --r: -120deg; }
.rank-confetti i:nth-child(11) { --x: -34px; --y: -60px; --r: 90deg; }
.rank-confetti i:nth-child(12) { --x: 32px; --y: -58px; --r: -90deg; }
.rank-head, .rank-ls { animation: rank-fade-up .45s ease-out 1.5s both; }
/* After a search, rows that come back show at once instead of replaying their entrance. */
.ranking.searched .rank-head, .ranking.searched .rank-ls { animation: none; }
@keyframes rank-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rank-rise { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes rank-pop { from { opacity: 0; transform: translateY(-18px) scale(.85); } to { opacity: 1; transform: none; } }
@keyframes rank-swing { 0% { transform: rotate(0); } 25% { transform: rotate(-22deg); } 50% { transform: rotate(14deg); } 75% { transform: rotate(-6deg); } 100% { transform: rotate(0); } }
@keyframes rank-shine { 0% { transform: translateX(-120%); } 30%, 100% { transform: translateX(120%); } }
@keyframes rank-glow { 0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--tier) 14%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--tier) 22%, transparent), 0 0 22px color-mix(in srgb, var(--tier) 45%, transparent); } }
@keyframes rank-burst { 0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(.4); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1); } }
@media (prefers-reduced-motion: reduce) { .ranking *, .ranking *::after { animation: none !important; } .rank-confetti { display: none; } }
@media (max-width: 480px) {
    .rank-pd { gap: .35rem; }
    .rank-pd.cols-2 { max-width: none; }
    .rank-pd.cols-1 { max-width: 60%; }
    .rank-av { width: 46px; height: 46px; font-size: .85rem; }
    .rank-slot.t1 .rank-av { width: 56px; height: 56px; font-size: 1rem; }
    .rank-slot .rank-av.sm { width: 32px; height: 32px; font-size: .64rem; }
    .rank-av.sm + .rank-av.sm { margin-left: -5px; }
    .rank-names li { font-size: .68rem; }
    .rank-name { font-size: .76rem; }
    .rank-block { height: 44px; }
    .rank-slot.t1 .rank-block { height: 76px; }
    .rank-slot.t2 .rank-block { height: 58px; }
    .rank-num { font-size: 1.4rem; }
    .rank-slot.t1 .rank-num { font-size: 1.8rem; }
    .rank-head .input-group { flex-basis: 100%; }
}

/* ---------- Download page (download/index.js) ----------
   The apps on two CSS 3D phones over the sign-in page's dark emerald hero. A phone is its
   front (bezel and screen in a metal rim), its back, thin slices between them (--d) for its
   edge and side buttons turned to face out, all turned by --rx/--ry from the script, which
   also slides a light across the glass (--glare); it floats by itself through `translate`,
   so the turn stays the script's. No `filter` on a phone: it would flatten the 3D. Sizes
   inside a phone are in em of its width (--w). */
.download { min-height: 100vh; background: var(--bg-primary); color: var(--text-primary); }
.download-top {
    position: absolute; top: 0; left: 0; right: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem clamp(1rem, 4vw, 3rem); color: var(--hero-text);
}
.download-brand { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; color: inherit; }
.download-brand:hover { text-decoration: none; }
.download-brand .brand-mark { width: 40px; height: 40px; }
.download-brand > span { display: grid; line-height: 1.25; min-width: 0; }
.download-brand small { font-size: .74rem; color: var(--hero-muted); }
.download-top-actions { display: flex; align-items: center; gap: .5rem; }
.download-top .theme-switch-toggle { color: var(--hero-muted); }
.download-top .theme-switch-toggle:hover, .download-top .theme-switch-toggle[aria-expanded="true"] { background: var(--hero-glass); color: var(--hero-text); }
.download-signin { background: var(--hero-glass); color: var(--hero-text); border: 1px solid var(--hero-line); }
.download-signin:hover { background: var(--hero-line); color: var(--hero-text); text-decoration: none; }

.download-hero {
    position: relative; isolation: isolate; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 2rem;
    min-height: min(100vh, 880px);
    padding: 7rem clamp(1rem, 5vw, 4.5rem) 6rem;
    color: var(--hero-text); background: var(--hero-bg);
}
.download-network { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
.download-hero-text { max-width: 34rem; animation: guest-rise 700ms cubic-bezier(.2, .8, .2, 1) both; }
.download-eyebrow {
    display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .85rem; border-radius: 99px;
    background: var(--hero-glass); border: 1px solid var(--hero-line);
    font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-letter);
}
.download-eyebrow svg.icon { width: 15px; height: 15px; }
.download-hero h1 { margin: 1.1rem 0 .9rem; color: var(--hero-text); font-size: clamp(2.1rem, 4.4vw, 3.5rem); line-height: 1.07; letter-spacing: -.025em; }
.download-hero h1 em {
    font-style: normal; color: transparent;
    background: linear-gradient(90deg, var(--sidebar-accent), var(--brand-letter), var(--formflow-cyan));
    -webkit-background-clip: text; background-clip: text;
}
.download-hero p { margin: 0; color: var(--hero-muted); font-size: 1.02rem; line-height: 1.65; }
.download-hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.6rem; }
.download-hero-actions .btn { gap: .5rem; }
.download-hero-second { background: var(--hero-glass); color: var(--hero-text); border: 1px solid var(--hero-line); }
.download-hero-second:hover { background: var(--hero-line); color: var(--hero-text); text-decoration: none; }
.download-hero p.download-hero-note { display: flex; align-items: center; gap: .45rem; margin-top: 1rem; font-size: .86rem; }
.download-hero-note svg.icon { width: 16px; height: 16px; color: var(--sidebar-accent); }

.download-stage {
    --phone-w: clamp(150px, 18vw, 230px);
    position: relative; display: flex; justify-content: center; align-items: center;
    min-height: calc(var(--phone-w) * 2.35);
    perspective: 1400px; touch-action: pan-y; user-select: none; -webkit-user-select: none; text-align: left;
}
.phone3d {
    --w: var(--phone-w); --depth: calc(var(--phone-w) * .055); --radius: calc(var(--phone-w) * .16);
    position: relative; flex-shrink: 0; width: var(--w); height: calc(var(--w) * 2.05);
    font-size: calc(var(--w) / 21); transform-style: preserve-3d; cursor: grab;
    animation: phone3d-enter 1.1s cubic-bezier(.2, .8, .2, 1) both;
}
.phone3d.is-dragging { cursor: grabbing; }
/* The light of each app's screen, around the phone and on the floor. */
.phone3d-lms { --phone-glow: color-mix(in srgb, var(--sidebar-accent) 40%, transparent); z-index: 2; margin-right: calc(var(--w) * -.03); }
.phone3d-formflow {
    --phone-glow: color-mix(in srgb, var(--formflow-violet) 50%, transparent);
    margin-left: calc(var(--w) * -.03); margin-top: calc(var(--w) * .3); scale: .92; animation-delay: .12s;
}
.phone3d-model {
    position: absolute; inset: 0; transform-style: preserve-3d;
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    animation: phone3d-float 6s ease-in-out infinite;
}
.phone3d-front, .phone3d-back, .phone3d-edge { position: absolute; inset: 0; border-radius: var(--radius); }
.phone3d-front, .phone3d-back { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.phone3d-front {
    transform: translateZ(calc(var(--depth) / 2));
    padding: calc(var(--w) * .026);
    border: calc(var(--w) * .012) solid transparent;
    background: linear-gradient(var(--device-bezel), var(--device-bezel)) padding-box, var(--device-metal) border-box;
    box-shadow: 0 0 3.5em -.6em var(--phone-glow, var(--device-shadow));
}
.phone3d-back {
    transform: rotateY(180deg) translateZ(calc(var(--depth) / 2));
    display: grid; place-items: center;
    border: calc(var(--w) * .012) solid transparent;
    background: var(--device-frame) padding-box, var(--device-metal) border-box;
}
.phone3d-edge {
    transform: translateZ(calc(var(--depth) / 2 - var(--d) * var(--depth) / 10));
    background: var(--device-metal);
}
/* Power on the right, volume on the left: slabs as deep as the phone, turned to face out. */
.phone3d-button { position: absolute; width: var(--depth); border-radius: calc(var(--depth) / 3); background: var(--device-metal); }
.phone3d-button-power {
    right: 0; top: 25%; height: 11%; transform-origin: 100% 50%;
    transform: translateX(calc(var(--depth) * .2)) translateZ(calc(var(--depth) / -2)) rotateY(90deg);
}
.phone3d-button-volume {
    left: 0; top: 20%; height: 7%; transform-origin: 0 50%;
    transform: translateX(calc(var(--depth) * -.2)) translateZ(calc(var(--depth) / -2)) rotateY(-90deg);
}
.phone3d-button-volume.is-lower { top: 29%; }
.phone3d-camera {
    position: absolute; top: 1.4em; left: 1.4em; width: 4.2em; height: 4.2em; border-radius: 1.3em;
    background: var(--device-bezel); box-shadow: inset 0 0 0 .25em var(--device-edge-dark), 0 0 0 .12em var(--device-edge-light);
}
.phone3d-back-mark.brand-mark, .phone3d-back-icon { width: 5em; height: 5em; border-radius: 1.4em; font-size: 1.6em; opacity: .9; }
.phone3d-screen {
    position: relative; height: 100%; overflow: hidden;
    display: flex; flex-direction: column; gap: .65em; padding: 3em 1em 1em;
    border-radius: calc(var(--radius) - var(--w) * .038);
}
/* The light on the glass: a band that crosses the screen as the phone turns (--glare, -1 to 1). */
.phone3d-screen::after {
    content: ""; position: absolute; inset: 0 -70%; pointer-events: none;
    background: linear-gradient(110deg, transparent 38%, var(--device-glare) 50%, transparent 62%);
    translate: calc(var(--glare, 0) * -28%) 0;
}
.phone3d-island { position: absolute; top: .75em; left: 50%; translate: -50% 0; width: 30%; height: 1.45em; border-radius: 99px; background: var(--device-bezel); }
.app-status { position: absolute; top: .9em; left: 1.7em; right: 1.7em; display: flex; justify-content: space-between; font-size: .78em; font-weight: 700; }
.app-status-dots { display: inline-flex; align-items: center; gap: .22em; }
.app-status-dots i { width: .5em; height: .5em; border-radius: 50%; background: currentColor; opacity: .85; }
.phone3d-shadow {
    position: absolute; left: 4%; right: 4%; bottom: calc(var(--w) * -.22); height: calc(var(--w) * .16);
    border-radius: 50%; pointer-events: none;
    background:
        radial-gradient(closest-side, var(--device-shadow), transparent 70%),
        radial-gradient(closest-side, var(--phone-glow, transparent), transparent);
    animation: phone3d-shadow 6s ease-in-out infinite;
}
.phone3d-formflow .phone3d-model, .phone3d-formflow .phone3d-shadow { animation-delay: -3s; }
@keyframes phone3d-enter { from { opacity: 0; translate: 0 18%; } }
@keyframes phone3d-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 calc(var(--w) * -.06); } }
@keyframes phone3d-shadow { 0%, 100% { scale: 1; opacity: 1; } 50% { scale: .8; opacity: .55; } }

/* The LMS app's dashboard, in its dark emerald. */
.app-screen-lms { background: var(--hero-bg); color: var(--hero-text); }
.app-hero { display: grid; justify-items: start; gap: .2em; padding: .9em; border-radius: 1.2em; background: var(--hero-glass); border: 1px solid var(--hero-line); }
.app-hero-mark.brand-mark { width: 2.6em; height: 2.6em; border-radius: .8em; font-size: 1em; margin-bottom: .3em; }
.app-hero strong { font-size: 1.12em; }
.app-hero small { font-size: .76em; color: var(--hero-muted); }
.app-hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4em; width: 100%; margin-top: .55em; }
.app-hero-stats span { display: grid; gap: .1em; padding: .45em .2em; border-radius: .7em; background: var(--hero-glass); text-align: center; }
.app-hero-stats b { font-size: .98em; color: var(--brand-letter); }
.app-hero-stats small { font-size: .6em; }
.app-row { display: flex; align-items: center; gap: .65em; padding: .65em .75em; border-radius: 1em; background: var(--hero-glass); border: 1px solid var(--hero-line); }
.app-row svg.icon { width: 1.35em; height: 1.35em; color: var(--sidebar-accent); flex-shrink: 0; }
.app-row > span { display: grid; min-width: 0; }
.app-row b { font-size: .88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-row small { font-size: .7em; color: var(--hero-muted); }
.app-menu-button {
    margin: auto auto 0; padding: .55em 1.5em; border-radius: 99px;
    background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: .82em;
    box-shadow: 0 0 0 .3em var(--sidebar-active);
}

/* The FormFlow app's exam, in its night violet. */
.app-screen-formflow {
    color: var(--formflow-text);
    background:
        radial-gradient(90% 45% at 50% 0%, color-mix(in srgb, var(--formflow-violet) 42%, transparent), transparent 75%),
        var(--formflow-night);
}
.ff-head { display: flex; align-items: center; gap: .55em; }
.ff-head img { width: 2.3em; height: 2.3em; border-radius: .7em; }
.ff-head strong {
    font-size: 1.25em; color: transparent;
    background: linear-gradient(90deg, var(--formflow-lilac), var(--formflow-cyan));
    -webkit-background-clip: text; background-clip: text;
}
.ff-card {
    display: grid; gap: .3em; padding: .85em; border-radius: 1em;
    background: color-mix(in srgb, var(--formflow-violet) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--formflow-violet) 45%, transparent);
}
.ff-card small { font-size: .7em; opacity: .75; }
.ff-card b { font-size: .9em; }
.ff-progress { height: .45em; border-radius: 99px; background: var(--hero-glass); overflow: hidden; }
.ff-progress span { display: block; width: 60%; height: 100%; background: linear-gradient(90deg, var(--formflow-violet), var(--formflow-cyan)); }
.ff-question { display: grid; gap: .42em; }
.ff-question b { font-size: .88em; }
.ff-choice { padding: .5em .8em; border-radius: .8em; border: 1px solid var(--hero-line); font-size: .8em; }
.ff-choice.is-picked { border-color: var(--formflow-violet); background: color-mix(in srgb, var(--formflow-violet) 32%, transparent); }
.ff-submit {
    margin-top: auto; padding: .65em; border-radius: .9em; text-align: center; font-weight: 700; font-size: .86em;
    background: linear-gradient(90deg, var(--formflow-violet), var(--formflow-violet-end));
}

/* The apps' cards, half over the hero. */
.download-apps {
    position: relative; z-index: 2;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem;
    max-width: 1120px; margin: -3.5rem auto 0; padding: 0 clamp(1rem, 4vw, 2rem);
}
/* One app left on the page (Settings → App downloads hid the other). */
.download-apps-one { grid-template-columns: minmax(0, 1fr); max-width: 640px; }
/* Both apps hidden: the hero only says why. */
.download-hero.download-hero-closed { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; min-height: 100vh; }
.download-closed { max-width: 520px; display: grid; justify-items: center; gap: .9rem; }
.download-closed-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--hero-glass); border: 1px solid var(--hero-line); color: var(--warning); }
.download-closed-icon svg.icon { width: 26px; height: 26px; }
.download-closed h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.02em; color: var(--hero-text); }
.download-closed p { margin: 0; color: var(--hero-muted); line-height: 1.6; }
.download-app {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1.1rem; align-items: start;
    padding: 1.4rem; border-radius: var(--radius-lg); scroll-margin-top: 1.5rem;
    background: color-mix(in srgb, var(--bg-secondary) 90%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--border-color); box-shadow: var(--shadow-lg);
}
.download-app-icon.brand-mark, .download-app-icon { width: 64px; height: 64px; border-radius: 18px; font-size: 1.15rem; }
.download-app-icon-formflow { overflow: hidden; box-shadow: var(--shadow-md); }
.download-app-icon-formflow img { width: 100%; height: 100%; object-fit: cover; }
.download-app h2 { margin: 0 0 .35rem; font-size: 1.3rem; }
.download-app p { margin: 0; color: var(--text-secondary); font-size: .92rem; line-height: 1.55; }
.download-app-features { list-style: none; display: grid; gap: .4rem; margin: .85rem 0 1.1rem; padding: 0; font-size: .86rem; }
.download-app-features li { display: flex; align-items: center; gap: .5rem; }
.download-app-features svg.icon { width: 16px; height: 16px; color: var(--primary-text); flex-shrink: 0; }
.download-app-get .btn { gap: .5rem; }
.download-app p.download-app-meta { margin-top: .6rem; font-size: .78rem; color: var(--text-muted); }
.download-app-qr { display: grid; justify-items: center; gap: .35rem; }
.download-app-qr:empty { display: none; }
.download-app-qr canvas { width: 124px; height: 124px; border-radius: var(--radius); border: 1px solid var(--border-color); image-rendering: pixelated; }
.download-app-qr small { font-size: .72rem; color: var(--text-muted); }

.download-steps { max-width: 1120px; margin: 3.25rem auto 0; padding: 0 clamp(1rem, 4vw, 2rem); }
.download-steps h2 { margin: 0 0 1rem; font-size: 1.35rem; }
.download-steps ol { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0; padding: 0; counter-reset: download-step; }
.download-steps li {
    display: grid; gap: .45rem; align-content: start; padding: 1.25rem; counter-increment: download-step;
    border-radius: var(--radius-lg); background: var(--bg-secondary); border: 1px solid var(--border-color);
}
.download-step-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.download-step-icon svg.icon { width: 20px; height: 20px; }
.download-steps li strong::before { content: counter(download-step) ". "; color: var(--primary-text); }
.download-steps li > span:last-child { color: var(--text-secondary); font-size: .9rem; line-height: 1.55; }
.download-steps-note { display: flex; align-items: flex-start; gap: .5rem; margin: 1rem 0 0; font-size: .86rem; color: var(--text-secondary); }
.download-steps-note svg.icon { width: 16px; height: 16px; margin-top: 2px; color: var(--info); flex-shrink: 0; }
.download-foot { padding: 2.75rem 1rem; text-align: center; font-size: .8rem; color: var(--text-muted); }

@media (max-width: 960px) {
    .download-hero { grid-template-columns: 1fr; gap: 1rem; min-height: 0; padding-top: 6rem; padding-bottom: 5rem; text-align: center; }
    .download-hero-text { margin: 0 auto; }
    .download-hero-actions, .download-hero p.download-hero-note { justify-content: center; }
    .download-stage { --phone-w: clamp(128px, 33vw, 200px); }
    .download-apps { grid-template-columns: 1fr; margin-top: -2.5rem; }
    .download-steps ol { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .download-app { grid-template-columns: auto minmax(0, 1fr); padding: 1.15rem; }
    /* On the phone itself the button is the way: no code to scan. */
    .download-app-qr { display: none; }
    .download-brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .phone3d, .phone3d-model, .phone3d-shadow, .download-hero-text { animation: none; }
}

/* The Privacy Policy (privacy/index.php): a public page, one readable column on the page's
   own colours, with the theme switch and Sign in on top as on the Download page. */
.legal { min-height: 100vh; background: var(--bg-primary); color: var(--text-primary); }
.legal-top {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    max-width: 820px; margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 2rem);
}
.legal-brand { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; color: var(--text-primary); }
.legal-brand:hover { text-decoration: none; color: var(--primary-text); }
.legal-top-actions { display: flex; align-items: center; gap: .5rem; }
.legal-doc {
    max-width: 820px; margin: 0 auto; padding: 2rem clamp(1.25rem, 4vw, 2.75rem) 2.25rem;
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    line-height: 1.65;
}
.legal-doc h1 { margin: 0 0 .25rem; font-size: clamp(1.7rem, 3vw, 2.2rem); letter-spacing: -.02em; }
.legal-doc h2 { margin: 1.9rem 0 .5rem; font-size: 1.15rem; }
.legal-doc p, .legal-doc li { color: var(--text-secondary); }
.legal-doc p { margin: 0 0 .75rem; }
.legal-doc ul { margin: .25rem 0 .9rem; padding-left: 1.25rem; }
.legal-doc li + li { margin-top: .4rem; }
.legal-doc strong { color: var(--text-primary); }
.legal-doc p.legal-updated { margin-bottom: 1.4rem; font-size: .9rem; color: var(--text-muted); }
.legal-foot { padding: 1.75rem 1rem 2.5rem; text-align: center; font-size: .8rem; color: var(--text-muted); }
@media (max-width: 640px) {
    .legal-doc { border-radius: 0; border-left: 0; border-right: 0; }
}