/* The Esadecimale look, shared with code, learn and cyber.esadecimale.it:
   tokens, navbar, platform switcher and footer follow theirs, so moving
   between the platforms feels like moving between rooms of one house.

   Galène's Content-Security-Policy allows styles from 'self' only: no
   <style> blocks and no style="" attributes, everything lives here. */

:root {
    --bg: #0a0a0b;
    --surface: #18181b;
    --surface2: #232327;
    --border: #27272a;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --primary: #ee72f1;
    --primary2: #ec4899;
    --primary-glow: rgba(238, 114, 241, 0.18);
    --wip: #eab308;
    --wip-soft: rgba(234, 179, 8, 0.12);
    --danger: #f85149;
    --danger2: #da3633;
    --ok: #3fb950;

    /* The navbar's height, so a page can fill exactly what is left. */
    --nav-h: clamp(70px, 6vw, 92px);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: clamp(18px, 1.25vw, 24px);
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* One rule for every link on the site: the accent colour, never underlined.
   A link sits inside prose that already leans on the accent for emphasis, so
   the colour is the affordance and the hover deepens it. */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.1s;
}

a:hover {
    color: var(--primary2);
}

/* ── Navbar ─────────────────────────────────────────────────────────── */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Everything in the bar grows with the viewport, so a wide screen gets a
       bar in proportion instead of the same small one. */
    height: var(--nav-h);
    padding: 0 clamp(24px, 4vw, 64px);
    gap: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 24px var(--primary-glow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1vw, 16px);
}

.brand-home {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    flex-shrink: 0;
}

.brand-home:hover {
    color: var(--primary);
}

.nav-logo {
    width: clamp(40px, 3.2vw, 54px);
    height: clamp(40px, 3.2vw, 54px);
    object-fit: contain;
    flex-shrink: 0;
}

.brand-name {
    font-size: clamp(20px, 1.7vw, 30px);
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

/* Brand and account links take equal shares of the bar, which leaves the
   sections sitting in the true middle of it. */
.navbar-brand {
    flex: 1 1 0;
}

.navbar-links {
    flex: 1 1 0;
    min-width: 0;
}

/* ── Platform switcher ──────────────────────────────────────────────── */

/* The brand keeps going home; the platform is a chip next to it. The pill
   outline and the caret are what say this is a control and not more text. */
.platform-switcher {
    position: relative;
    flex-shrink: 0;
}

.platform-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px 7px 17px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font: inherit;
    font-size: clamp(17px, 1.35vw, 25px);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.platform-chip:hover,
.platform-switcher.is-open .platform-chip {
    border-color: var(--primary);
    color: var(--primary);
}

.platform-chip:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.platform-chip-caret {
    width: 0.85em;
    height: 0.85em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s;
}

.platform-switcher.is-open .platform-chip-caret {
    transform: rotate(180deg);
}

.platform-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    /* Wide enough for the longest row and no wider, so short
       descriptions do not leave a field of empty panel. */
    width: max-content;
    min-width: 300px;
    max-width: min(440px, calc(100vw - 32px));
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), 0 0 24px var(--primary-glow);
    z-index: 60;
}

.platform-menu[hidden] {
    display: none;
}

.platform-menu-title {
    padding: 8px 14px 10px;
    font-size: clamp(13px, 0.85vw, 16px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.platform-option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
    border-radius: 11px;
    color: var(--text);
    text-decoration: none;
}

a.platform-option:hover,
a.platform-option:focus-visible {
    background: var(--surface2);
    outline: none;
}

a.platform-option:focus-visible {
    box-shadow: inset 0 0 0 1px var(--primary);
}

a.platform-option:hover .platform-option-icon,
a.platform-option:focus-visible .platform-option-icon {
    color: var(--primary);
}

/* Where you already are is shown, not offered: it answers "which one is
   this?" as well as the menu answers "where else can I go?". */
.platform-option.is-current {
    color: var(--muted);
}

.platform-option-icon {
    width: 1.35em;
    height: 1.35em;
    flex-shrink: 0;
    margin-top: 0.1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.platform-option-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.platform-option-name {
    font-size: clamp(18px, 1.3vw, 24px);
    font-weight: 600;
    line-height: 1.25;
}

.platform-option-desc {
    font-size: clamp(15px, 1.05vw, 19px);
    line-height: 1.4;
    color: var(--muted);
}

.platform-option-badge {
    margin-left: 8px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: clamp(12px, 0.75vw, 14px);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    vertical-align: 2px;
    white-space: nowrap;
}

/* The dim belongs to the phone sheet only; the desktop menu is anchored and
   needs nothing behind it. */
.platform-backdrop {
    display: none;
}

.navbar-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(18px, 2vw, 40px);
}

.navbar-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: clamp(17px, 1.4vw, 25px);
    line-height: 1;
    transition: color 0.1s;
}

.navbar-links a:hover {
    color: var(--primary);
}

/* ── Navbar sections ────────────────────────────────────────────────── */

/* What the site is: bigger than the rest of the bar, in the centre of it,
   each with an icon. */
.navbar-sections {
    display: flex;
    align-items: center;
    gap: clamp(20px, 2.4vw, 52px);
    flex-shrink: 0;
}

.nav-section {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: clamp(19px, 1.7vw, 30px);
    font-weight: 600;
    line-height: 1;
    transition: color 0.15s;
}

.nav-section-icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.18s ease;
}

/* One rule that grows from the middle: the whole of the hover effect. */
.nav-section::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary2));
    translate: -50% 0;
    transition: width 0.2s ease;
}

.nav-section:hover {
    color: var(--text);
}

.nav-section:hover::after {
    width: 100%;
}

/* The section you are in keeps its hover look: the rule says "here". */
.nav-section[aria-current="page"] {
    color: var(--text);
}

.nav-section[aria-current="page"]::after {
    width: 100%;
}

.nav-section[aria-current="page"] .nav-section-icon {
    color: var(--primary);
}

.nav-section:hover .nav-section-icon {
    color: var(--primary);
    transform: translateY(-2px);
}

/* Too narrow for labels next to the brand and the links: the icons carry
   the sections on their own. */
@media (max-width: 1000px) {
    .nav-section span {
        display: none;
    }

    .nav-section-icon {
        width: 1.5em;
        height: 1.5em;
    }
}

/* Phones: the brand mark alone, so the sections keep the middle. */
@media (max-width: 560px) {
    .navbar {
        padding: 0 16px;
        gap: 8px;
    }

    .brand-name {
        display: none;
    }

    .navbar-sections {
        gap: 22px;
    }

    /* The bar is tight here, so the chip gives back what it can. */
    .platform-chip {
        gap: 5px;
        padding: 5px 10px 5px 13px;
        font-size: 16px;
    }

    .platform-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 55;
    }

    .platform-menu {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        min-width: 0;
        max-width: none;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
        border-right: none;
        border-bottom: none;
        border-left: none;
        border-radius: 18px 18px 0 0;
    }
}

/* ── Layout ─────────────────────────────────────────────────────────── */

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 48px clamp(32px, 4vw, 80px);
    min-height: calc(100vh - 70px - 320px);
}

.muted {
    color: var(--muted);
}

.accent {
    color: var(--primary);
}

/* ── Buttons ────────────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
    transition: filter 0.1s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
}

.btn-primary:hover {
    color: #fff;
    filter: brightness(1.1);
}

/* ── Home backdrop ──────────────────────────────────────────────────── */

/* Slow-drifting glows behind the page: enough movement to feel alive, slow
   enough that nothing pulls the eye off the content. */
.home-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.home-blob {
    position: absolute;
    width: 46vw;
    height: 46vw;
    min-width: 320px;
    min-height: 320px;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.35;
    will-change: transform;
}

.home-blob-1 {
    top: -12vw;
    left: -8vw;
    background: radial-gradient(circle, var(--primary), transparent 68%);
    animation: home-drift 26s ease-in-out infinite;
}

.home-blob-2 {
    top: 20vh;
    right: -14vw;
    background: radial-gradient(circle, var(--primary2), transparent 68%);
    animation: home-drift 34s ease-in-out infinite reverse;
}

.home-blob-3 {
    bottom: -18vw;
    left: 30vw;
    opacity: 0.22;
    background: radial-gradient(circle, var(--primary), transparent 70%);
    animation: home-drift 42s ease-in-out infinite;
    animation-delay: -12s;
}

@keyframes home-drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(4vw, 3vh) scale(1.06); }
    66%      { transform: translate(-3vw, 5vh) scale(0.96); }
}

/* ── Home hero ──────────────────────────────────────────────────────── */

/* The idea on the left, what is coming up on the right. */
.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
    align-items: center;
    column-gap: clamp(32px, 5vw, 80px);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.home-title {
    font-size: clamp(38px, 5vw, 76px);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.home-subtitle {
    margin-top: clamp(8px, 1.2vh, 16px);
    font-size: clamp(20px, 1.8vw, 30px);
    color: var(--text);
}

.home-copy {
    margin-top: clamp(28px, 6vh, 84px);
}

.home-copy p {
    color: var(--muted);
    font-size: clamp(1.1em, 1.3vw, 1.35em);
    line-height: 1.65;
    margin-bottom: 14px;
}

.home-copy p:last-child {
    margin-bottom: 0;
}

.home-copy strong {
    color: var(--text);
}

/* Words that lead somewhere: underlined so they read as links among the
   plain accents. */
.home-link {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: color-mix(in srgb, var(--primary) 45%, transparent);
    transition: text-decoration-color 0.15s;
}

.home-link:hover {
    text-decoration-color: var(--primary);
}

/* The home page is meant to be seen whole: navbar, hero and footer share one
   screen with nothing below the fold. Only on a screen tall and wide enough to
   hold it (the events panel needs more height than code's logo wall) —
   anywhere else the page scrolls normally rather than clipping. */
@media (min-height: 900px) and (min-width: 1001px) {
    body.home-page {
        height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.home-page .container {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: center;
        padding-block: clamp(20px, 3vh, 48px);
    }

    body.home-page .footer {
        margin-top: 0;
        padding-block: clamp(24px, 3.5vh, 48px);
    }
}

/* ── Upcoming events ────────────────────────────────────────────────── */

/* A panel of its own beside the text: the one thing on the page that
   changes from week to week. */
.events {
    align-self: center;
    padding: clamp(18px, 1.6vw, 28px);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 0 40px var(--primary-glow);
    backdrop-filter: blur(6px);
}

.events-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: clamp(12px, 1.2vw, 18px);
}

.events-title {
    font-size: clamp(13px, 0.85vw, 16px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.events-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 0.8vw, 12px);
}

.event {
    display: flex;
    align-items: center;
    gap: clamp(14px, 1.2vw, 20px);
    padding: clamp(12px, 1vw, 16px);
    background: linear-gradient(135deg, var(--surface2), var(--surface));
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    transition: transform 0.2s ease, border-color 0.15s, box-shadow 0.2s;
}

/* Only an event with a room behind it is a link, and only a link moves. */
a.event:hover,
a.event:focus-visible {
    color: var(--text);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 0 28px var(--primary-glow);
    outline: none;
}

/* The date as a torn-off calendar leaf: the day leads, the month labels it. */
.event-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: clamp(58px, 4.4vw, 72px);
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    line-height: 1;
}

.event-day {
    font-size: clamp(22px, 1.8vw, 30px);
    font-weight: 700;
    color: var(--primary);
}

.event-month {
    margin-top: 4px;
    font-size: clamp(11px, 0.75vw, 13px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.event-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.event-title {
    font-size: clamp(17px, 1.2vw, 22px);
    font-weight: 600;
    line-height: 1.25;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: clamp(14px, 0.95vw, 17px);
    line-height: 1.3;
    color: var(--muted);
}

.event-tag {
    padding: 1px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: clamp(12px, 0.75vw, 14px);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Today and live: the two moments worth shouting about. */
.event-tag.is-soon {
    border-color: color-mix(in srgb, var(--primary) 55%, transparent);
    color: var(--primary);
}

.event-tag.is-live {
    border-color: color-mix(in srgb, var(--ok) 55%, transparent);
    color: var(--ok);
}

.events-empty {
    padding: 18px 4px 6px;
    color: var(--muted);
    font-size: clamp(15px, 1vw, 18px);
}

/* One column: the text, then the events under it. */
@media (max-width: 1000px) {
    .home-hero {
        grid-template-columns: 1fr;
        row-gap: clamp(32px, 5vh, 56px);
        margin-bottom: 56px;
    }

    .home-copy {
        margin-top: clamp(22px, 4vh, 44px);
    }

    .home-title {
        font-size: clamp(30px, 6.4vw, 48px);
    }

    .home-subtitle {
        font-size: clamp(18px, 3.2vw, 24px);
    }

    .home-copy p {
        font-size: 1.1em;
    }
}

@media (max-width: 560px) {
    .home-blob {
        filter: blur(60px);
        width: 70vw;
        height: 70vw;
    }

    .events {
        padding: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-bg * {
        animation: none;
    }
}

.events-more {
    font-size: clamp(14px, 0.95vw, 17px);
    font-weight: 600;
    white-space: nowrap;
}

.event-room {
    font-size: clamp(13px, 0.85vw, 15px);
}

/* ── Event kinds ────────────────────────────────────────────────────── */

/* One colour per kind of event, taken from the palette the other platforms
   use for syntax highlighting, so the calendar reads at a glance. */
[class*="kind-"] {
    --kind: var(--primary);
}

.kind-live-coding { --kind: #7dd3fc; }
.kind-q-a         { --kind: #fbbf24; }
.kind-workshop    { --kind: #7ee787; }
.kind-community   { --kind: #c4b5fd; }

.event-tag[class*="kind-"] {
    border-color: color-mix(in srgb, var(--kind) 45%, transparent);
    color: var(--kind);
}

/* ── Utilities ──────────────────────────────────────────────────────── */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ── Calendar ───────────────────────────────────────────────────────── */

.cal {
    max-width: 1400px;
    margin: 0 auto;
}

.cal-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: clamp(20px, 3vh, 36px);
}

/* Month and year are the page title, and each is also the control that
   changes it. */
.cal-title {
    display: flex;
    align-items: baseline;
    gap: 0.25em;
    font-size: clamp(40px, 5vw, 76px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.cal-picker {
    position: relative;
}

.cal-title-btn {
    display: flex;
    align-items: center;
    gap: 0.12em;
    padding: 0 0.08em;
    background: none;
    border: none;
    border-radius: 12px;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: color 0.15s;
}

.cal-title-year {
    color: var(--primary);
}

.cal-title-btn:hover,
.cal-picker.is-open .cal-title-btn {
    color: var(--primary2);
}

.cal-title-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
}

/* The month's picker is as wide as "Settembre" and its caret, so the year
   beside it never moves while the caret still follows the word. */
.cal-title > .cal-picker:first-child {
    min-width: 6em;
}

.cal-title-caret {
    width: 0.4em;
    height: 0.4em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.6;
    transition: transform 0.15s, opacity 0.15s;
}

.cal-title-btn:hover .cal-title-caret,
.cal-picker.is-open .cal-title-caret {
    opacity: 1;
}

.cal-picker.is-open .cal-title-caret {
    transform: rotate(180deg);
}

.cal-popover {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 40;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), 0 0 24px var(--primary-glow);
    font-size: clamp(16px, 1.05vw, 19px);
    font-weight: 500;
    letter-spacing: normal;
    line-height: 1.3;
}

.cal-popover[hidden] {
    display: none;
}

.cal-popover-months {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    width: max-content;
    min-width: 360px;
}

.cal-popover-years {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 140px;
    max-height: 300px;
    overflow-y: auto;
}

.cal-option {
    position: relative;
    padding: 10px 14px;
    background: none;
    border: none;
    border-radius: 9px;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.cal-option:hover,
.cal-option:focus-visible {
    background: var(--surface2);
    outline: none;
}

.cal-option:focus-visible {
    box-shadow: inset 0 0 0 1px var(--primary);
}

.cal-option.is-current {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    font-weight: 600;
}

/* A year with something planned in it. */
.cal-option.has-events::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    translate: 0 -50%;
}

.cal-option.is-current.has-events::after {
    background: #fff;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cal-nav-btn,
.cal-today-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    font-size: clamp(16px, 1vw, 18px);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.cal-nav-btn {
    width: 46px;
    border-radius: 50%;
}

.cal-nav-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cal-today-btn {
    padding: 0 20px;
    border-radius: 999px;
}

.cal-nav-btn:hover,
.cal-today-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cal-nav-btn:focus-visible,
.cal-today-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* The board: weekday names, then the fixed 6×7 grid. Hairlines between the
   cells are the board's own background showing through a 1px gap. */
.cal-board {
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 0 40px var(--primary-glow);
}

.cal-weekdays,
.cal-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-weekdays li {
    padding: 12px 12px 10px;
    font-size: clamp(12px, 0.8vw, 15px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.cal-grid {
    /* Fixed rows: every month takes the same space, whatever its shape. */
    grid-template-rows: repeat(6, clamp(96px, 12vh, 140px));
    gap: 1px;
    background: var(--border);
}

.cal-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 8px;
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s;
}

.cal-cell:hover {
    background: var(--surface2);
}

/* Not a day of this month: hatched and inert. */
.cal-cell.is-outside {
    background:
        repeating-linear-gradient(135deg,
            transparent 0 7px,
            color-mix(in srgb, var(--border) 45%, transparent) 7px 8px),
        var(--bg);
    cursor: default;
}

.cal-cell.has-events {
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.cal-cell.has-events:hover {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface2));
}

.cal-cell.is-selected {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.cal-day-btn {
    align-self: flex-start;
    background: none;
    border: none;
    border-radius: 999px;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.cal-day-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.cal-day-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2em;
    height: 2em;
    padding: 0 0.4em;
    border-radius: 999px;
    font-size: clamp(14px, 0.95vw, 17px);
    font-weight: 600;
    line-height: 1;
}

.cal-cell.is-past .cal-day-num {
    color: var(--muted);
}

.cal-cell.is-today .cal-day-num {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
}

.cal-events {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cal-event {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    padding: 3px 8px;
    border-left: 3px solid var(--kind);
    border-radius: 6px;
    background: color-mix(in srgb, var(--kind) 14%, transparent);
    color: var(--text);
    font-size: clamp(12px, 0.8vw, 15px);
    line-height: 1.35;
    white-space: nowrap;
    transition: background 0.15s;
}

a.cal-event:hover,
a.cal-event:focus-visible {
    background: color-mix(in srgb, var(--kind) 30%, transparent);
    color: var(--text);
    outline: none;
}

a.cal-event:focus-visible {
    box-shadow: 0 0 0 1px var(--kind);
}

/* No room yet: shown, but visibly not a way in. */
.cal-event.is-unlinked {
    border-left-style: dashed;
    color: var(--muted);
}

.cal-cell.is-past .cal-event {
    opacity: 0.55;
}

.cal-event-time {
    flex-shrink: 0;
    font-weight: 700;
    color: var(--kind);
    font-variant-numeric: tabular-nums;
}

.cal-event-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-more {
    align-self: flex-start;
    padding: 0 8px;
    background: none;
    border: none;
    color: var(--muted);
    font: inherit;
    font-size: clamp(12px, 0.8vw, 14px);
    font-weight: 600;
    cursor: pointer;
}

.cal-more:hover {
    color: var(--primary);
}

.cal-dots {
    display: none;
}

/* The chosen day, in full, under the board. */
.cal-day {
    max-width: 900px;
    margin-top: clamp(28px, 4vh, 48px);
    scroll-margin-top: 110px;
}

.cal-day-title {
    margin-bottom: 16px;
    font-size: clamp(22px, 1.9vw, 32px);
    line-height: 1.25;
}

.cal-day-empty {
    color: var(--muted);
}

/* On the day list the leaf shows the time instead of the date. */
.event-time {
    width: clamp(72px, 5.4vw, 88px);
}

.event-time .event-day {
    font-size: clamp(17px, 1.3vw, 22px);
    font-variant-numeric: tabular-nums;
}

.event-time .event-month {
    text-transform: none;
    letter-spacing: 0.02em;
}

/* Phones: a compact board of numbers and dots; the selected day's events
   are listed under it. */
@media (max-width: 700px) {
    .cal-header {
        align-items: flex-end;
    }

    .cal-title {
        font-size: clamp(30px, 9vw, 44px);
    }

    .cal-popover-months {
        min-width: min(320px, calc(100vw - 32px));
    }

    .cal-nav-btn,
    .cal-today-btn {
        height: 40px;
    }

    .cal-nav-btn {
        width: 40px;
    }

    .cal-board {
        border-radius: 14px;
    }

    .cal-weekdays li {
        padding: 8px 0;
        text-align: center;
        font-size: 11px;
        letter-spacing: 0.04em;
    }

    .cal-grid {
        grid-template-rows: repeat(6, 58px);
    }

    .cal-cell {
        align-items: center;
        gap: 4px;
        padding: 6px 2px;
    }

    .cal-day-btn {
        align-self: center;
    }

    .cal-day-num {
        font-size: 15px;
    }

    .cal-events {
        display: none;
    }

    .cal-dots {
        display: flex;
        gap: 3px;
    }

    .cal-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--kind);
    }
}

/* ── Page intro ─────────────────────────────────────────────────────── */

.intro {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 0 16px;
}

.intro h1 {
    font-size: clamp(32px, 3.5vw, 52px);
    line-height: 1.2;
    margin-bottom: 20px;
}

.intro p {
    max-width: 60ch;
    color: var(--muted);
    margin-bottom: 16px;
}

.intro strong {
    color: var(--text);
}

/* ── Rooms ──────────────────────────────────────────────────────────── */

.rooms {
    max-width: 1400px;
    margin: clamp(24px, 4vh, 48px) auto 0;
}

.rooms-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: clamp(14px, 1.4vw, 22px);
}

.rooms-title {
    font-size: clamp(13px, 0.85vw, 16px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.rooms-summary {
    font-size: clamp(14px, 0.95vw, 17px);
    color: var(--muted);
}

/* As many columns as fit, every card the same height in its row. */
.rooms-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: clamp(12px, 1.2vw, 20px);
}

.room {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    padding: clamp(16px, 1.4vw, 24px);
    background: linear-gradient(135deg, var(--surface2), var(--surface));
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    transition: transform 0.2s ease, border-color 0.15s, box-shadow 0.2s;
}

.room:hover,
.room:focus-visible {
    color: var(--text);
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 0 28px var(--primary-glow);
    outline: none;
}

.room-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.room-icon {
    width: 1.4em;
    height: 1.4em;
    flex-shrink: 0;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.room-name {
    flex: 1;
    min-width: 0;
    font-size: clamp(19px, 1.35vw, 25px);
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.room-tag {
    flex-shrink: 0;
    padding: 1px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: clamp(12px, 0.75vw, 14px);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.room-tag.is-locked {
    border-color: color-mix(in srgb, var(--wip) 55%, transparent);
    color: var(--wip);
}

.room-desc {
    color: var(--muted);
    font-size: clamp(15px, 1vw, 18px);
    line-height: 1.5;
}

/* Who is in and the way in, pinned to the bottom so a row of cards lines up
   whatever the length of their descriptions. */
.room-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: clamp(14px, 0.95vw, 17px);
}

.room-people {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.room-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--muted) 45%, transparent);
}

/* Someone is in: the dot turns green and breathes. */
.room-people.is-active {
    color: var(--text);
}

.room-people.is-active .room-dot {
    background: var(--ok);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent);
    animation: room-pulse 2s ease-out infinite;
}

@keyframes room-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
    70%  { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.room-join {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--primary);
}

.room-join-icon {
    width: 1em;
    height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.18s ease;
}

.room:hover .room-join-icon,
.room:focus-visible .room-join-icon {
    transform: translateX(3px);
}

.rooms-empty,
.rooms-error {
    padding: 24px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 16px;
    color: var(--muted);
}

.rooms-error {
    border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

@media (prefers-reduced-motion: reduce) {
    .room-people.is-active .room-dot {
        animation: none;
    }
}

/* ── Forms ──────────────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field[hidden] {
    display: none;
}

.field-label {
    font-size: clamp(14px, 0.9vw, 16px);
    font-weight: 600;
    color: var(--text);
}

.field-hint {
    font-weight: 400;
    color: var(--muted);
}

.field-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    font-size: clamp(16px, 1vw, 18px);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.field-input:disabled {
    color: var(--muted);
}

select.field-input {
    appearance: none;
    padding-right: 40px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    text-overflow: ellipsis;
}

.form-error {
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--text);
    font-size: clamp(14px, 0.95vw, 17px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.btn-ghost {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ── Avatars ────────────────────────────────────────────────────────── */

/* Initials in a gradient disc: what stands in for a camera that is off. */
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    user-select: none;
}

.avatar-lg {
    width: clamp(84px, 8vw, 120px);
    height: clamp(84px, 8vw, 120px);
    font-size: clamp(30px, 2.8vw, 44px);
}

/* ── Call controls ──────────────────────────────────────────────────── */

/* Round buttons: on is quiet, off is loud (red), since being muted when
   you think you are not is the mistake worth catching. */
.ctl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ctl[hidden] {
    display: none;
}

.ctl svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ctl:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ctl:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.ctl .ctl-off,
.ctl[aria-pressed="false"] .ctl-on {
    display: none;
}

.ctl[aria-pressed="false"] .ctl-off {
    display: block;
}

.ctl[aria-pressed="false"] {
    background: var(--danger2);
    border-color: var(--danger2);
    color: #fff;
}

.ctl[aria-pressed="false"]:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.ctl-leave {
    width: auto;
    padding: 0 22px;
    border-radius: 999px;
    background: var(--danger2);
    border-color: var(--danger2);
    color: #fff;
}

.ctl-leave svg {
    fill: currentColor;
    stroke: none;
}

.ctl-leave:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* ── Lobby ──────────────────────────────────────────────────────────── */

.room-main {
    max-width: 1400px;
}

/* Yourself on the left, the room and the way in on the right. */
.lobby {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(28px, 4vw, 72px);
    margin: clamp(8px, 3vh, 40px) auto 0;
}

.lobby[hidden],
.call[hidden],
.room-message[hidden] {
    display: none;
}

.preview-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 0 40px var(--primary-glow);
}

.preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* A preview is a mirror: moving left should move left. */
    transform: scaleX(-1);
}

.preview-off {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: radial-gradient(circle at 50% 40%, var(--surface2), var(--surface) 70%);
}

.preview-frame.is-off .preview-off {
    display: flex;
}

.preview-frame.is-off .preview-video {
    visibility: hidden;
}

.preview-off-text {
    color: var(--muted);
    font-size: clamp(15px, 1vw, 18px);
}

/* The mic level: a bar along the bottom edge that moves when you speak. */
.preview-meter {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.35);
}

.preview-meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--ok), #a3e635);
    transform-origin: left;
    transform: scaleX(var(--level, 0));
    transition: transform 0.08s linear;
}

.preview-controls {
    position: absolute;
    left: 50%;
    bottom: 18px;
    display: flex;
    gap: 12px;
    translate: -50% 0;
}

.preview-controls .ctl {
    background: rgba(24, 24, 27, 0.75);
    backdrop-filter: blur(6px);
}

.preview-controls .ctl[aria-pressed="false"] {
    background: var(--danger2);
}

.device-pickers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.lobby-device-error {
    margin-top: 12px;
    color: var(--wip);
    font-size: clamp(14px, 0.95vw, 17px);
}

.lobby-kicker {
    font-size: clamp(13px, 0.85vw, 16px);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.lobby-title {
    margin-top: 4px;
    font-size: clamp(32px, 3.4vw, 54px);
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.lobby-desc {
    margin-top: 10px;
    color: var(--muted);
}

.lobby-people {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-size: clamp(15px, 1vw, 18px);
}

.lobby-people::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--muted) 45%, transparent);
}

.lobby-people.is-active {
    color: var(--text);
}

.lobby-people.is-active::before {
    background: var(--ok);
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: clamp(20px, 3vh, 32px);
}

.join-mode {
    color: var(--muted);
    font-size: clamp(14px, 0.95vw, 17px);
}

.btn-join {
    align-self: flex-start;
    font-size: clamp(17px, 1.1vw, 20px);
    padding: 14px 32px;
}

@media (max-width: 1000px) {
    .lobby {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .device-pickers {
        grid-template-columns: 1fr;
    }

    .btn-join {
        align-self: stretch;
    }
}

/* ── Call ───────────────────────────────────────────────────────────── */

/* In a call the page is the call: no footer, nothing to scroll, the stage
   takes every pixel the navbar leaves. */
body.in-call {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body.in-call .footer {
    display: none;
}

body.in-call .room-main {
    max-width: none;
    height: calc(100dvh - var(--nav-h));
    min-height: 0;
    padding: clamp(12px, 1.4vw, 20px) clamp(12px, 1.6vw, 24px);
}

/* Panel on the left, the call on the right. Closing the panel gives its
   column back to the videos. */
.call {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(12px, 1.4vw, 20px);
    height: 100%;
}

.call.is-panel-open {
    grid-template-columns: clamp(300px, 24vw, 400px) minmax(0, 1fr);
}

.call-main {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.2vw, 16px);
    min-width: 0;
    min-height: 0;
}

.call-header {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.call-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(20px, 1.5vw, 26px);
}

.call-people {
    flex-shrink: 0;
    color: var(--muted);
    font-size: clamp(14px, 0.95vw, 17px);
}

.call-badge {
    flex-shrink: 0;
    padding: 2px 10px;
    border: 1px solid color-mix(in srgb, var(--wip) 55%, transparent);
    border-radius: 999px;
    color: var(--wip);
    font-size: clamp(12px, 0.75vw, 14px);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.call-badge[hidden] {
    display: none;
}

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
}

/* Tiles are sized by room.js (--tile-w) to the largest 16:9 that fits
   them all; the box just centres them. */
.tiles {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
}

.tile {
    position: relative;
    width: var(--tile-w, 320px);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.tile-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

/* A shared screen is read, not looked at: show all of it, and first. */
.tile.is-screen {
    order: -1;
}

.tile.is-screen .tile-video {
    object-fit: contain;
}

.tile.mirror .tile-video {
    transform: scaleX(-1);
}

.avatar-tile {
    position: absolute;
    top: 50%;
    left: 50%;
    display: none;
    width: clamp(56px, 28%, 120px);
    aspect-ratio: 1;
    font-size: clamp(20px, 2.4vw, 42px);
    translate: -50% -50%;
}

.tile.no-video {
    background: radial-gradient(circle at 50% 45%, var(--surface2), var(--surface) 70%);
}

.tile.no-video .tile-video {
    visibility: hidden;
}

.tile.no-video .avatar-tile {
    display: flex;
}

.tile-label {
    position: absolute;
    left: 10px;
    bottom: 10px;
    max-width: calc(100% - 20px);
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(10, 10, 11, 0.7);
    backdrop-filter: blur(4px);
    font-size: clamp(13px, 0.9vw, 16px);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-state {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(10, 10, 11, 0.7);
    color: var(--wip);
    font-size: 13px;
    font-weight: 600;
}

.tile.is-connecting .tile-state {
    display: block;
}

.stage-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
}

.stage-empty[hidden] {
    display: none;
}

.call-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.call-toast {
    position: absolute;
    left: 50%;
    bottom: 76px;
    max-width: min(560px, calc(100% - 32px));
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    font-size: clamp(14px, 0.95vw, 17px);
    translate: -50% 0;
}

.call-toast[hidden] {
    display: none;
}

@media (max-width: 560px) {
    .ctl {
        width: 48px;
        height: 48px;
    }

    .ctl-leave {
        width: auto;
        padding: 0 18px;
    }

    .call-people {
        display: none;
    }
}

/* ── Side panel ─────────────────────────────────────────────────────── */

.side-panel {
    position: relative;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.call.is-panel-open .side-panel {
    display: flex;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

/* Two tabs as one segmented control. */
.panel-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--bg);
}

.panel-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    border-radius: 9px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: clamp(15px, 0.95vw, 17px);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.panel-tab:hover {
    color: var(--text);
}

.panel-tab[aria-selected="true"] {
    background: var(--surface2);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border);
}

.panel-tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.tab-count {
    color: var(--muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.tab-badge {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.tab-badge[hidden] {
    display: none;
}

/* Only phones need a way to close the overlay from inside it. */
.panel-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
}

.panel-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.panel-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.panel-body[hidden] {
    display: none;
}

/* ── Chat ───────────────────────────────────────────────────────────── */

.chat-scroll {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 14px;
    overscroll-behavior: contain;
}

.chat-empty {
    padding: 24px 8px;
    color: var(--muted);
    font-size: clamp(14px, 0.9vw, 16px);
    text-align: center;
}

.chat-empty[hidden] {
    display: none;
}

.chat-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.avatar-sm {
    width: 26px;
    height: 26px;
    font-size: 11px;
}

.chat-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(14px, 0.9vw, 16px);
    font-weight: 700;
}

.chat-msg.is-own .chat-name {
    color: var(--primary);
}

.chat-tag {
    flex-shrink: 0;
    padding: 0 7px;
    border: 1px solid color-mix(in srgb, var(--wip) 55%, transparent);
    border-radius: 999px;
    color: var(--wip);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-time {
    flex-shrink: 0;
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.chat-bodies {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 34px;
}

.chat-body {
    font-size: clamp(14px, 0.92vw, 16px);
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-body.is-action {
    color: var(--muted);
    font-style: italic;
}

.chat-link {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border);
}

.chat-form[hidden] {
    display: none;
}

.chat-input {
    flex: 1;
    min-width: 0;
    max-height: 160px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: clamp(15px, 0.95vw, 16px);
    line-height: 1.4;
    resize: none;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    cursor: pointer;
    transition: filter 0.1s;
}

.chat-send:hover {
    filter: brightness(1.1);
}

.chat-send:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.chat-send svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-disabled {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: clamp(13px, 0.85vw, 15px);
}

.chat-disabled[hidden] {
    display: none;
}

/* ── People ─────────────────────────────────────────────────────────── */

.people-list {
    list-style: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
}

.person {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
}

.person:hover {
    background: var(--surface2);
}

.person .avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.person-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.person-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(14px, 0.95vw, 16px);
    font-weight: 600;
}

.person-role {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.person-role.is-op {
    color: var(--primary);
}

.person-role.is-observer {
    color: var(--wip);
}

.person-medias {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    color: var(--muted);
}

.person-media-icon {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Panel toggle ───────────────────────────────────────────────────── */

/* Showing the panel or sharing the screen is not a mute: never red,
   accent when on. */
.ctl.ctl-panel {
    position: relative;
}

.ctl.ctl-panel[aria-pressed="false"],
.ctl.ctl-share[aria-pressed="false"] {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}

.ctl.ctl-panel[aria-pressed="false"]:hover,
.ctl.ctl-share[aria-pressed="false"]:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ctl.ctl-panel[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--primary) 60%, transparent);
    color: var(--primary);
}

.ctl.ctl-hand[aria-pressed="false"] {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}

.ctl.ctl-hand[aria-pressed="false"]:hover {
    border-color: var(--wip);
    color: var(--wip);
}

/* A raised hand is waiting for an answer: yellow, the "pending" colour. */
.ctl.ctl-hand[aria-pressed="true"],
.ctl.ctl-hand[aria-pressed="true"]:hover {
    background: var(--wip);
    border-color: var(--wip);
    color: #18181b;
}

/* Sharing is something others see: say it loudly. */
.ctl.ctl-share[aria-pressed="true"] {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    border-color: transparent;
    color: #fff;
}

.ctl-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--surface2);
    border-radius: 50%;
    background: var(--primary);
}

.ctl-dot[hidden] {
    display: none;
}

/* Phones: the panel is a sheet over the videos, closed by default. */
@media (max-width: 800px) {
    .call.is-panel-open {
        grid-template-columns: minmax(0, 1fr);
    }

    .side-panel {
        position: absolute;
        inset: 0;
        z-index: 30;
        box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
    }

    .panel-close {
        display: flex;
    }
}

/* ── Moderator tools ────────────────────────────────────────────────── */

/* Room-wide controls above the tabs, for moderators only. */
/* The lock button takes the room the label needs; recording stays
   compact ("Registra" / "Ferma"). */
.mod-tools {
    display: flex;
    gap: 8px;
    padding: 10px 10px 0;
}

.mod-tool-lock {
    flex: 1 1 auto;
}

.mod-tool-record {
    flex: 0 0 auto;
}

.mod-tools[hidden] {
    display: none;
}

.mod-tool {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font: inherit;
    font-size: clamp(14px, 0.9vw, 15px);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.mod-tool[hidden] {
    display: none;
}

.mod-tool span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.mod-tool:hover {
    border-color: var(--primary);
}

.mod-tool:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.mod-tool svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Locked: the "pending" yellow, like a raised hand. */
.mod-tool-lock[aria-pressed="true"] {
    border-color: var(--wip);
    background: var(--wip-soft);
    color: var(--wip);
}

/* Recording: red, unmistakable. */
.mod-tool-record[aria-pressed="true"] {
    border-color: var(--danger2);
    background: var(--danger2);
    color: #fff;
}

.rec-dot {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--danger);
}

.mod-tool-record[aria-pressed="true"] .rec-dot,
.call-badge.is-rec .rec-dot {
    background: #fff;
    animation: rec-pulse 1.4s ease-in-out infinite;
}

@keyframes rec-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.call-badge.is-locked {
    border-color: color-mix(in srgb, var(--wip) 55%, transparent);
    color: var(--wip);
}

.call-badge.is-rec {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-color: var(--danger2);
    background: var(--danger2);
    color: #fff;
}

.call-badge.is-rec[hidden] {
    display: none;
}

.call-badge.is-rec .rec-dot {
    width: 8px;
    height: 8px;
}

@media (prefers-reduced-motion: reduce) {
    .rec-dot {
        animation: none !important;
    }
}

/* ── Speaking, hands and tile controls ──────────────────────────────── */

/* Whoever is talking gets a green ring: drawn inside, so the layout does
   not move when it comes and goes. */
.tile::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 3px var(--ok);
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.tile.is-speaking::after {
    opacity: 1;
}

.tile-hand {
    position: absolute;
    top: 10px;
    left: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--wip);
    color: #18181b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.tile.has-hand .tile-hand {
    display: flex;
    animation: hand-wave 1.2s ease-in-out 2;
}

.tile-hand-icon,
.person-hand-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes hand-wave {
    0%, 100% { transform: rotate(0); }
    25%      { transform: rotate(-14deg); }
    75%      { transform: rotate(14deg); }
}

/* Controls float over the top right corner, shown on hover or focus;
   touch screens have no hover, so there they stay visible. */
.tile-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.tile:hover .tile-controls,
.tile:focus-within .tile-controls {
    opacity: 1;
}

@media (hover: none) {
    .tile-controls {
        opacity: 1;
    }
}

/* Connection state sits where the controls are; move it below them. */
.tile:not(.is-local) .tile-state {
    top: 52px;
}

.tile-ctl {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    background: rgba(10, 10, 11, 0.7);
    backdrop-filter: blur(4px);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.tile-ctl:hover {
    background: rgba(10, 10, 11, 0.9);
    color: var(--primary);
}

.tile-ctl:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.tile-ctl-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tile-volume {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 10px;
    border-radius: 10px;
    background: rgba(10, 10, 11, 0.7);
    backdrop-filter: blur(4px);
}

.tile-volume .tile-ctl {
    background: none;
    backdrop-filter: none;
}

.tile-slider {
    width: 80px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Someone we turned down shows it, so silence is not mistaken for theirs. */
.tile.is-muted .tile-controls {
    opacity: 1;
}

.tile.is-muted .tile-volume .tile-ctl {
    color: var(--danger);
}

/* A tile in fullscreen fills the screen, picture uncropped. */
.tile:fullscreen {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    background: #000;
}

.tile:fullscreen .tile-video {
    object-fit: contain;
}

.tile:fullscreen::after {
    display: none;
}

/* ── People: speaking, hands and moderator menu ─────────────────────── */

.person .avatar-sm {
    transition: box-shadow 0.15s;
}

.person.is-speaking .avatar-sm {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ok);
}

.person.has-hand {
    background: var(--wip-soft);
}

.person-hand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--wip);
    color: #18181b;
}

.person-hand-icon {
    width: 17px;
    height: 17px;
}

.person-more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

.person-more:hover,
.person-more[aria-expanded="true"] {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.person-more:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.person-more-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
}

.person-menu {
    position: absolute;
    z-index: 20;
    min-width: 240px;
    max-width: calc(100% - 16px);
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface2);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.person-menu[hidden] {
    display: none;
}

.person-menu-title {
    padding: 6px 10px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.person-menu-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: clamp(14px, 0.9vw, 15px);
    text-align: left;
    cursor: pointer;
}

.person-menu-item:hover,
.person-menu-item:focus-visible {
    background: var(--surface);
    outline: none;
}

.person-menu-item.is-danger {
    color: var(--danger);
}

.person-menu-sep {
    margin: 6px 4px;
    border: none;
    border-top: 1px solid var(--border);
}

/* ── Room messages ──────────────────────────────────────────────────── */

.room-message {
    max-width: 640px;
    margin: clamp(32px, 10vh, 120px) auto;
    text-align: center;
}

.room-message-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 0 32px var(--primary-glow);
}

.room-message-icon svg {
    width: 36px;
    height: 36px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.room-message h1 {
    margin-top: 20px;
    font-size: clamp(26px, 2.4vw, 40px);
}

.room-message p {
    margin: 10px 0 28px;
    color: var(--muted);
}

.room-message-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.room-message-actions [hidden] {
    display: none;
}

/* ── Error pages ────────────────────────────────────────────────────── */

.error-page {
    max-width: 720px;
    margin: clamp(32px, 10vh, 120px) auto;
    text-align: center;
}

.error-code {
    font-size: clamp(64px, 9vw, 140px);
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.error-page h1 {
    margin-top: 12px;
    font-size: clamp(26px, 2.4vw, 40px);
}

.error-page p {
    margin: 12px 0 32px;
    color: var(--muted);
}

/* ── Footer ─────────────────────────────────────────────────────────── */

.footer {
    border-top: 1px solid var(--border);
    padding: 48px clamp(32px, 4vw, 80px);
    margin-top: 80px;
    background: var(--surface);
    /* Above the landing-page glows, which sit at z-index -1. */
    position: relative;
    z-index: 1;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    max-width: 100%;
    margin: 0 auto;
    justify-items: center;
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-col h4 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.footer-col p,
.footer-col a {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.6;
}

.footer-col a:hover {
    color: var(--primary);
}

/* More platforms than fit one column: three to a column, filled top to
   bottom, so the footer grows sideways instead of down. */
.footer-links {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(3, auto);
    justify-content: start;
    gap: 8px clamp(24px, 2.5vw, 40px);
}

.footer-col .footer-email {
    color: var(--primary);
}

.footer-credit {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin-top: 40px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 600px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
        justify-items: start;
    }
}
