/* ==========================================================================
   ClassSync · 云课表
   Mobile-first design system. Native-feeling surfaces, container-driven layout,
   restrained motion. Tokens live in one place; components never invent values.
   ========================================================================== */

@layer reset, tokens, base, layout, components, shell, utilities;

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
@layer tokens {
    :root {
        color-scheme: light;

        --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC",
                   "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
        --font-num: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

        /* Surfaces */
        --bg: #f5f5f7;
        --surface: #ffffff;
        --surface-2: #f6f7f9;
        --surface-3: #eceef1;
        --surface-raised: #ffffff;

        /* Ink */
        --text: #1d1d1f;
        --text-2: #55555a;
        --text-3: #6e6e73;
        --text-inverse: #ffffff;

        /* Lines */
        --separator: rgba(0, 0, 0, .09);
        --separator-strong: rgba(0, 0, 0, .16);
        --divider: rgba(0, 0, 0, .07);

        /* Accent & semantics */
        --accent: #0066cc;
        --accent-fill: #0071e3;
        --accent-fill-hover: #0062c4;
        --accent-soft: rgba(0, 113, 227, .10);
        --accent-softer: rgba(0, 113, 227, .055);
        --success: #146c2e;
        --success-soft: rgba(20, 108, 46, .10);
        --warning: #8a5a00;
        --warning-soft: rgba(154, 103, 0, .10);
        --danger: #c9252d;
        --danger-fill: #c9252d;
        --danger-soft: rgba(201, 37, 45, .09);

        /* Elevation */
        --shadow-card: 0 1px 2px rgba(16, 24, 40, .035);
        --shadow-panel: 0 1px 2px rgba(16, 24, 40, .04), 0 20px 48px -24px rgba(16, 24, 40, .22);
        --shadow-float: 0 8px 24px -8px rgba(16, 24, 40, .24);
        --shadow-toast: 0 10px 32px -8px rgba(16, 24, 40, .35);

        /* Radii */
        --r-sm: 10px;
        --r-md: 12px;
        --r-lg: 16px;
        --r-xl: 20px;
        --r-2xl: 24px;
        --r-full: 999px;

        /* Space */
        --s-1: 4px;
        --s-2: 8px;
        --s-3: 12px;
        --s-4: 16px;
        --s-5: 24px;
        --s-6: 32px;
        --s-7: 48px;
        --s-8: 64px;

        /* Chrome */
        --header-h: 56px;
        --tabbar-h: 54px;
        --page-max: 1180px;
        --sidebar-w: 216px;

        /* Motion */
        --ease-out: cubic-bezier(.23, 1, .32, 1);
        --ease-in-out: cubic-bezier(.77, 0, .175, 1);
        --ease-drawer: cubic-bezier(.32, .72, 0, 1);
        --dur-press: 120ms;
        --dur-hover: 140ms;
        --dur-enter: 240ms;
        --dur-exit: 160ms;

        /* Toast is always a dark pill on light UI */
        --toast-bg: #1d1d1f;
        --toast-text: #ffffff;
    }

    :root[data-theme="dark"] {
        color-scheme: dark;

        --bg: #0e0f12;
        --surface: #16181d;
        --surface-2: #1b1e24;
        --surface-3: #23262d;
        --surface-raised: #1d2026;

        --text: #f5f6f7;
        --text-2: #b0b4bd;
        --text-3: #8f949e;
        --text-inverse: #0e0f12;

        --separator: rgba(255, 255, 255, .10);
        --separator-strong: rgba(255, 255, 255, .18);
        --divider: rgba(255, 255, 255, .07);

        --accent: #6cb2ff;
        --accent-fill: #0a6be0;
        --accent-fill-hover: #1b7bec;
        --accent-soft: rgba(76, 154, 255, .14);
        --accent-softer: rgba(76, 154, 255, .07);
        --success: #4ac26b;
        --success-soft: rgba(74, 194, 107, .12);
        --warning: #e3b341;
        --warning-soft: rgba(227, 179, 65, .12);
        --danger: #ff6b6b;
        --danger-fill: #b3261e;
        --danger-soft: rgba(255, 107, 107, .12);

        --shadow-card: 0 1px 2px rgba(0, 0, 0, .28);
        --shadow-panel: 0 1px 2px rgba(0, 0, 0, .4), 0 24px 56px -24px rgba(0, 0, 0, .7);
        --shadow-float: 0 10px 28px -10px rgba(0, 0, 0, .65);
        --shadow-toast: 0 12px 36px -10px rgba(0, 0, 0, .8);

        --toast-bg: #f2f3f5;
        --toast-text: #16181d;
    }
}

/* --------------------------------------------------------------------------
   2. RESET
   -------------------------------------------------------------------------- */
@layer reset {
    *, *::before, *::after { box-sizing: border-box; }
    * { margin: 0; }

    html {
        scrollbar-gutter: stable;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
        -webkit-tap-highlight-color: transparent;
        scroll-padding-top: calc(var(--header-h) + 16px);
        overscroll-behavior: none;
    }

    body {
        min-height: 100svh;
        background: var(--bg);
        color: var(--text);
        font-family: var(--font-ui);
        font-size: 15px;
        line-height: 1.6;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
        font-synthesis-weight: none;
    }

    img, svg, video { display: block; max-width: 100%; }
    img { height: auto; }

    button, input, select, textarea {
        font: inherit;
        color: inherit;
    }

    button {
        padding: 0;
        border: 0;
        background: none;
        cursor: pointer;
        text-align: inherit;
    }

    a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
    ul, ol { padding: 0; list-style: none; }
    table { border-collapse: collapse; width: 100%; }
    fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
    legend { padding: 0; }

    :focus { outline: none; }
    :focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    ::selection { background: var(--accent-soft); }

    /* Scrolling is instant by default; desktop nav opts into smooth motion in JS. */
}

/* --------------------------------------------------------------------------
   3. BASE
   -------------------------------------------------------------------------- */
@layer base {
    h1, h2, h3, h4, h5 {
        font-weight: 650;
        line-height: 1.25;
        letter-spacing: -.02em;
        text-wrap: balance;
    }

    p { text-wrap: pretty; }

    code {
        padding: 1px 5px;
        border-radius: 5px;
        background: var(--surface-3);
        font-family: var(--font-num);
        font-size: .9em;
    }

    .icon-sprite {
        position: absolute;
        width: 0;
        height: 0;
        overflow: hidden;
    }

    .icon {
        width: 20px;
        height: 20px;
        flex: none;
    }

    .skip-link {
        position: fixed;
        top: 8px;
        left: 8px;
        z-index: 300;
        padding: 10px 14px;
        border-radius: 10px;
        background: var(--text);
        color: var(--bg);
        font-size: 14px;
        font-weight: 600;
        transform: translateY(-160%);
        transition: transform 160ms var(--ease-out);
    }

    .skip-link:focus-visible { transform: none; }
}

/* --------------------------------------------------------------------------
   4. LAYOUT
   -------------------------------------------------------------------------- */
@layer layout {
    .app-header {
        position: sticky;
        top: 0;
        z-index: 50;
        padding-top: env(safe-area-inset-top, 0px);
        background: var(--bg);
        background: color-mix(in srgb, var(--bg) 80%, transparent);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-bottom: 1px solid var(--separator);
    }

    @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
        .app-header { background: var(--bg); }
    }

    .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        max-width: var(--page-max);
        min-height: var(--header-h);
        margin-inline: auto;
        padding-inline: 16px;
    }

    .app-main {
        width: 100%;
        max-width: var(--page-max);
        margin-inline: auto;
        padding: 20px 16px 56px;
    }

    /* Auth: on mobile the form sits right under the headline. */
    .auth { padding-block: 8px 16px; }

    .auth-grid {
        display: grid;
        grid-template-areas:
            "head"
            "panel"
            "body";
        gap: 24px;
    }

    .auth-copy { display: contents; }
    .auth-head { grid-area: head; }
    .auth-panel { grid-area: panel; }
    .auth-body { grid-area: body; }

    .dashboard-frame {
        display: grid;
        gap: 24px;
        align-items: start;
    }

    .sidebar { display: none; min-width: 0; }

    .dashboard-content {
        min-width: 0;
        container-type: inline-size;
        container-name: content;
    }

    /* Footer */
    .app-footer {
        margin-top: 40px;
        border-top: 1px solid var(--separator);
        padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    }

    .footer-inner {
        display: flex;
        flex-direction: column;
        gap: 16px;
        max-width: var(--page-max);
        margin-inline: auto;
        font-size: 12px;
        color: var(--text-3);
        flex-wrap: wrap;
    }
}

/* --------------------------------------------------------------------------
   5. COMPONENTS
   -------------------------------------------------------------------------- */
@layer components {

    /* ── Brand & header ─────────────────────────────────────────────── */
    .brand {
        display: inline-flex;
        align-items: center;
        gap: 11px;
        min-height: 44px;
        margin-left: -8px;
        padding: 4px 8px;
        border-radius: 12px;
        color: var(--text);
        transition: background-color var(--dur-hover) ease;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 11px;
        flex: none;
        box-shadow: 0 0 0 1px rgba(16, 24, 40, .06), 0 4px 12px -2px rgba(16, 24, 40, .16);
        transition: transform var(--dur-hover) var(--ease-out);
    }

    :root[data-theme="dark"] .brand-mark {
        box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 6px 16px -4px rgba(0, 0, 0, .55);
    }

    .brand-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        line-height: 1.05;
    }

    .brand-name {
        font-size: 18px;
        font-weight: 680;
        letter-spacing: -.035em;
    }

    .brand-sub {
        margin-top: 3px;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: .12em;
        text-transform: uppercase;
        color: var(--text-3);
    }

    .brand-divider {
        width: 1px;
        height: 22px;
        margin-inline: 6px;
        background: var(--separator);
    }

    .brand-tagline {
        font-size: 12px;
        letter-spacing: .01em;
        color: var(--text-3);
        white-space: nowrap;
    }

    .header-actions { display: flex; align-items: center; gap: 8px; }
    .logout-short { display: none; }

    /* ── Buttons ────────────────────────────────────────────────────── */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        min-height: 44px;
        padding: 0 16px;
        border: 1px solid transparent;
        border-radius: var(--r-md);
        font-size: 15px;
        font-weight: 600;
        line-height: 1;
        white-space: nowrap;
        text-decoration: none;
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        transition: transform var(--dur-press) var(--ease-out),
                    background-color var(--dur-hover) ease,
                    border-color var(--dur-hover) ease,
                    color var(--dur-hover) ease,
                    opacity var(--dur-hover) ease;
    }

    .btn:active:not(:disabled) { transform: scale(.97); }

    .btn:disabled { opacity: .5; cursor: default; }

    .btn .icon { width: 18px; height: 18px; }

    .btn-primary {
        background: var(--accent-fill);
        color: #fff;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16);
    }

    .btn-secondary {
        background: var(--surface-3);
        color: var(--text);
    }

    .btn-quiet {
        background: transparent;
        color: var(--text-2);
    }

    .btn-ghost {
        background: transparent;
        color: var(--text-2);
    }

    .btn-danger {
        background: var(--danger-fill);
        color: #fff;
    }

    .btn-danger-quiet {
        background: transparent;
        color: var(--danger);
        border-color: color-mix(in srgb, var(--danger) 30%, transparent);
    }

    .btn-block { width: 100%; }

    .btn-sm {
        min-height: 36px;
        padding: 0 12px;
        border-radius: var(--r-sm);
        font-size: 13px;
    }

    .btn-sm .icon { width: 16px; height: 16px; }

    .btn-loader {
        width: 15px;
        height: 15px;
        border: 2px solid currentColor;
        border-right-color: transparent;
        border-radius: 50%;
        animation: spin .65s linear infinite;
    }

    .spinner {
        width: 18px;
        height: 18px;
        border: 2px solid var(--separator-strong);
        border-top-color: var(--accent);
        border-radius: 50%;
        animation: spin .7s linear infinite;
    }

    @keyframes spin { to { transform: rotate(1turn); } }

    .icon-btn {
        display: inline-grid;
        place-items: center;
        width: 40px;
        height: 40px;
        border-radius: var(--r-sm);
        color: var(--text-2);
        touch-action: manipulation;
        transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease,
                    transform var(--dur-press) var(--ease-out);
    }

    .icon-btn:active { transform: scale(.94); }
    .icon-btn .icon { width: 18px; height: 18px; }

    @media (hover: hover) and (pointer: fine) {
        .btn-primary:hover { background: var(--accent-fill-hover); }
        .btn-secondary:hover { background: color-mix(in srgb, var(--surface-3) 70%, var(--text) 6%); }
        .btn-quiet:hover, .btn-ghost:hover { background: var(--surface-3); color: var(--text); }
        .btn-danger:hover { background: color-mix(in srgb, var(--danger-fill) 86%, black); }
        .btn-danger-quiet:hover { background: var(--danger-soft); }
        .icon-btn:hover { background: var(--surface-3); color: var(--text); }
        .brand:hover { background: var(--surface-3); }
        .brand:hover .brand-name { color: var(--accent); }
        .brand:hover .brand-mark { transform: scale(1.03); }
    }

    /* ── Auth ───────────────────────────────────────────────────────── */
    .eyebrow {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        font-size: 12px;
        font-weight: 600;
        letter-spacing: .04em;
        color: var(--text-3);
    }

    .group-head .eyebrow { color: var(--accent); }

    .live-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--success);
        box-shadow: 0 0 0 3px var(--success-soft);
    }

    .auth-title {
        margin-top: 14px;
        font-size: clamp(2.05rem, 7.2vw, 3.5rem);
        font-weight: 700;
        line-height: 1.06;
        letter-spacing: -.035em;
    }

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

    .auth-lede {
        max-width: 34em;
        margin-top: 16px;
        font-size: 15.5px;
        line-height: 1.7;
        color: var(--text-2);
    }

    .feature-list {
        display: grid;
        gap: 16px;
        margin-top: 28px;
    }

    .feature {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }

    .feature-icon {
        display: grid;
        place-items: center;
        width: 36px;
        height: 36px;
        flex: none;
        border-radius: var(--r-sm);
        background: var(--accent-soft);
        color: var(--accent);
    }

    .feature-icon .icon { width: 18px; height: 18px; }

    .feature-copy {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding-top: 1px;
        min-width: 0;
    }

    .feature-copy strong { font-size: 14.5px; font-weight: 600; }
    .feature-copy small { font-size: 13px; color: var(--text-3); line-height: 1.5; }

    .pill-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 26px;
    }

    .pill {
        padding: 5px 11px;
        border: 1px solid var(--separator);
        border-radius: var(--r-full);
        background: var(--surface);
        font-size: 12px;
        font-weight: 500;
        color: var(--text-2);
    }

    .auth-panel {
        background: var(--surface);
        border: 1px solid var(--separator);
        border-radius: var(--r-2xl);
        box-shadow: var(--shadow-panel);
        overflow: hidden;
        container-type: inline-size;
        container-name: auth;
    }

    .auth-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        margin: 14px 14px 0;
        padding: 4px;
        border-radius: var(--r-lg);
        background: var(--surface-2);
    }

    .auth-tab {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        height: 44px;
        text-align: center;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        color: var(--text-2);
        touch-action: manipulation;
        transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease,
                    box-shadow var(--dur-hover) ease;
    }

    .auth-tab.is-active {
        background: var(--surface);
        color: var(--text);
        box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
    }

    .auth-panel-inner { padding: 20px 20px 24px; }

    .auth-panel-head h2 {
        font-size: 21px;
        font-weight: 700;
        letter-spacing: -.025em;
    }

    .auth-panel-head p {
        margin-top: 5px;
        font-size: 13px;
        color: var(--text-3);
    }

    .auth-form {
        display: grid;
        gap: 12px;
        margin-top: 18px;
    }

    .auth-links {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding-top: 2px;
        font-size: 13px;
    }

    .dot-sep { color: var(--text-3); }

    .text-link {
        color: var(--accent);
        font-weight: 500;
        text-decoration: none;
        touch-action: manipulation;
    }

    @media (hover: hover) and (pointer: fine) {
        .text-link:hover { text-decoration: underline; }
        .auth-tab:hover:not(.is-active) { color: var(--text); }
    }

    /* ── Forms ──────────────────────────────────────────────────────── */
    .field { display: grid; gap: 6px; min-width: 0; }

    .form-label {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-2);
    }

    .label-optional {
        font-weight: 400;
        color: var(--text-3);
    }

    .form-tip {
        font-size: 12px;
        line-height: 1.5;
        color: var(--text-3);
    }

    .success-tip { color: var(--success); }

    .error-tip { color: var(--danger); }

    .form-input {
        width: 100%;
        min-height: 46px;
        padding: 10px 13px;
        border: 1px solid var(--separator-strong);
        border-radius: var(--r-md);
        background: var(--surface-2);
        color: var(--text);
        font-size: 16px;
        line-height: 1.4;
        transition: border-color var(--dur-hover) ease, background-color var(--dur-hover) ease,
                    box-shadow var(--dur-hover) ease;
    }

    .form-input::placeholder { color: var(--text-3); opacity: .85; }

    .form-input:focus {
        border-color: var(--accent);
        background: var(--surface);
        box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .form-input.is-valid { border-color: color-mix(in srgb, var(--success) 55%, transparent); }
    .form-input.is-invalid { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }

    .form-input.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

    select.form-input {
        padding-right: 36px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        appearance: none;
        -webkit-appearance: none;
    }

    :root[data-theme="dark"] select.form-input {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238f949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    }

    textarea.form-input {
        min-height: 120px;
        resize: vertical;
    }

    .input-affix { position: relative; }
    .input-affix .form-input { padding-right: 52px; }

    .btn-toggle-password {
        position: absolute;
        top: 50%;
        right: 3px;
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
        transform: translateY(-50%);
        border-radius: var(--r-sm);
        color: var(--text-3);
        touch-action: manipulation;
    }

    .btn-toggle-password .icon { width: 18px; height: 18px; }
    .btn-toggle-password .eye-hide { display: none; }
    .btn-toggle-password[aria-pressed="true"] .eye-show { display: none; }
    .btn-toggle-password[aria-pressed="true"] .eye-hide { display: block; }
    .btn-toggle-password[aria-pressed="true"] { color: var(--text); }

    @media (hover: hover) and (pointer: fine) {
        .btn-toggle-password:hover { color: var(--text); }
    }

    .input-with-action {
        display: flex;
        align-items: stretch;
        gap: 8px;
    }

    .input-with-action .form-input { flex: 1 1 auto; min-width: 0; }
    .input-with-action .btn { flex: none; padding-inline: 14px; font-size: 13px; }

    .checkline {
        display: flex;
        align-items: flex-start;
        gap: 9px;
        font-size: 13px;
        line-height: 1.55;
        color: var(--text-2);
        cursor: pointer;
    }

    .checkline input[type="checkbox"] {
        width: 18px;
        height: 18px;
        margin-top: 1px;
        flex: none;
        accent-color: var(--accent-fill);
    }

    .checkline a { color: var(--accent); }

    .check-stack { display: grid; gap: 10px; margin-top: 12px; }

    .form-grid { display: grid; gap: 14px; }

    /* ── Dashboard shell ────────────────────────────────────────────── */
    .dashboard-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-label {
        padding: 6px 12px 8px;
        font-size: 11.5px;
        font-weight: 600;
        letter-spacing: .06em;
        color: var(--text-3);
    }

    .nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 42px;
        padding: 0 12px;
        border-radius: var(--r-sm);
        color: var(--text-2);
        font-size: 14px;
        font-weight: 500;
        text-align: left;
        touch-action: manipulation;
        transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease;
    }

    .nav-item .icon { width: 18px; height: 18px; color: var(--text-3); }

    .nav-item.active {
        background: var(--accent-soft);
        color: var(--accent);
        font-weight: 600;
    }

    .nav-item.active .icon { color: var(--accent); }

    @media (hover: hover) and (pointer: fine) {
        .nav-item:hover:not(.active) { background: var(--surface-3); color: var(--text); }
    }

    .sidebar-foot {
        margin-top: 20px;
        padding: 14px 12px 0;
        border-top: 1px solid var(--divider);
        font-size: 12px;
        line-height: 1.55;
        color: var(--text-3);
    }

    .sidebar-foot span { color: var(--text-3); opacity: .8; }

    .group-head { padding-inline: 4px; }
    .group-head .eyebrow { margin-bottom: 4px; }

    .group-head h2 {
        font-size: clamp(21px, 1.2vw + 17px, 26px);
        font-weight: 700;
        letter-spacing: -.025em;
    }

    .dashboard-group {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* ── Cards ──────────────────────────────────────────────────────── */
    .card {
        position: relative;
        background: var(--surface);
        border: 1px solid var(--separator);
        border-radius: var(--r-xl);
        box-shadow: var(--shadow-card);
    }

    .card-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 16px;
        padding: 18px 18px 0;
    }

    .card-body { padding: 14px 18px 18px; }

    .card-title {
        font-size: 18px;
        font-weight: 650;
        letter-spacing: -.02em;
        line-height: 1.3;
    }

    .card-caption {
        margin-top: 3px;
        font-size: 13px;
        color: var(--text-3);
        letter-spacing: 0;
    }

    .meta-text {
        font-size: 12px;
        color: var(--text-3);
        font-variant-numeric: tabular-nums;
    }

    .body-text {
        font-size: 14px;
        line-height: 1.65;
        color: var(--text-2);
    }

    .invite-hint { transition: color .15s ease; }
    .invite-hint.is-valid { color: var(--success); }
    .invite-hint.is-invalid { color: var(--danger); }

    .fine-print {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        margin-top: 12px;
        font-size: 12px;
        line-height: 1.6;
        color: var(--text-3);
    }

    .fine-print .icon { width: 14px; height: 14px; margin-top: 2px; flex: none; }

    .section-divider {
        height: 1px;
        margin: 16px 0;
        background: var(--divider);
    }

    .section-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 10px;
    }

    .section-title-sm { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }

    .warning-text { font-size: 12px; line-height: 1.55; color: var(--warning); }

    /* ── Badges, chips, notices ─────────────────────────────────────── */
    .badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        flex: none;
        padding: 4px 10px;
        border-radius: var(--r-full);
        background: var(--surface-3);
        color: var(--text-2);
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
    }

    .badge::before {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
        opacity: .7;
    }

    .badge-active { background: var(--success-soft); color: var(--success); }
    .badge-expired { background: var(--danger-soft); color: var(--danger); }

    .chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

    .chip {
        padding: 4px 10px;
        border: 1px solid var(--separator);
        border-radius: 8px;
        background: var(--surface-2);
        font-size: 12px;
        font-weight: 600;
        color: var(--text-2);
    }

    .notice {
        padding: 12px 14px;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface-2);
        font-size: 13px;
        line-height: 1.6;
        color: var(--text-2);
    }

    .notice-info { border-color: color-mix(in srgb, var(--accent) 28%, transparent); background: var(--accent-softer); }
    .notice-warning { border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-soft); color: var(--text-2); }
    .notice-warning strong { color: var(--warning); }

    .notice .btn { margin-top: 8px; }

    /* ── Status / stats ─────────────────────────────────────────────── */
    .status-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    @container content (min-width: 560px) {
        .status-grid {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }
    }

    .status-cell {
        display: flex;
        flex-direction: column;
        gap: 3px;
        min-width: 0;
        padding: 12px;
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .status-label { font-size: 12px; color: var(--text-3); }

    .status-value {
        font-size: 16px;
        font-weight: 600;
        letter-spacing: -.01em;
        font-variant-numeric: tabular-nums;
    }

    .status-email {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14px;
    }

    .status-link { font-size: 12px; font-weight: 500; }

    .stat-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .stat-cell {
        display: flex;
        flex-direction: column;
        gap: 3px;
        min-width: 0;
        padding: 12px;
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .stat-label { font-size: 12px; color: var(--text-3); line-height: 1.4; }

    .stat-number {
        font-size: clamp(19px, 4.6vw, 24px);
        font-weight: 700;
        letter-spacing: -.03em;
        font-variant-numeric: tabular-nums;
    }

    /* ── Layout helpers inside cards ────────────────────────────────── */
    .two-col-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        align-items: start;
    }

    .action-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 4px;
    }

    .action-row > .btn { flex: 1 1 150px; }

    .action-row-end { justify-content: flex-end; margin-top: 12px; }
    .action-row-end > .btn { flex: 0 1 auto; }

    .inline-between {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 14px;
    }

    .copy-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-top: 12px;
    }

    .copy-row .readonly-input { grid-column: 1 / -1; }

    .copy-row .btn {
        min-width: 0;
        padding-inline: 6px;
        gap: 6px;
        font-size: 12.5px;
    }

    .copy-row .btn .icon { width: 16px; height: 16px; }

    @container content (min-width: 620px) {
        .copy-row { grid-template-columns: minmax(0, 1fr) auto auto; }

        .copy-row .readonly-input { grid-column: auto; }

        .copy-row .btn {
            padding-inline: 14px;
            font-size: 14px;
        }
    }

    .readonly-input { color: var(--text-2); font-size: 14px; }

    .inline-form {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        margin-top: 10px;
    }

    .inline-form .form-input { flex: 1 1 150px; min-width: 0; }
    .inline-form .btn { flex: none; }

    .stack-form { display: grid; gap: 8px; margin-top: 10px; }

    .convert-preview { font-size: 13px; color: var(--text-3); white-space: nowrap; }
    .convert-preview strong { color: var(--accent); font-variant-numeric: tabular-nums; }

    .subpanel {
        margin-top: 12px;
        padding: 14px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface-2);
    }

    .settings-group {
        margin-top: 18px;
        padding: 16px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface-2);
    }

    .settings-group .section-title-sm { margin-bottom: 10px; }

    .invite-code-section { margin-top: 16px; }

    .vip-redeem-section { margin-top: 4px; }

    .redeem-form {
        display: flex;
        gap: 8px;
        align-items: stretch;
    }

    .redeem-form .form-input { flex: 1 1 auto; min-width: 0; }
    .redeem-form .btn { flex: none; }

    /* ── Tables ─────────────────────────────────────────────────────── */
    .table-scroll {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .table-scroll-tall { max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }

    .data-table { font-size: 13px; }

    .data-table th {
        padding: 8px 10px;
        border-bottom: 1px solid var(--separator);
        color: var(--text-3);
        font-size: 12px;
        font-weight: 600;
        text-align: left;
        white-space: nowrap;
    }

    .data-table td {
        padding: 10px;
        border-bottom: 1px solid var(--divider);
        color: var(--text-2);
        vertical-align: top;
    }

    .data-table tbody tr:last-child td { border-bottom: 0; }

    .data-table .align-end,
    .data-table th.align-end { text-align: right; }

    .table-empty { padding: 20px 0 !important; text-align: center; color: var(--text-3) !important; }

    /* ── Schedule ───────────────────────────────────────────────────── */
    .schedule-card {
        container-type: inline-size;
        container-name: schedule;
        overflow: clip;
    }

    .card-toolbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 16px 18px;
    }

    .schedule-heading {
        display: flex;
        flex-direction: column;
        gap: 1px;
        min-width: 0;
        flex: 1 1 auto;
    }

    .schedule-heading .meta-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .schedule-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .schedule-body { padding: 0 10px 10px; min-height: 120px; }

    .week-nav,
    .zoom-controls {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        padding: 3px;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .week-label {
        min-width: 58px;
        padding-inline: 4px;
        font-size: 13px;
        font-weight: 600;
        text-align: center;
        font-variant-numeric: tabular-nums;
    }

    .week-nav .btn { border-radius: 8px; }
    .week-nav .icon-btn { width: 36px; height: 36px; }

    .zoom-controls output {
        min-width: 46px;
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        color: var(--text-2);
        font-variant-numeric: tabular-nums;
    }

    .zoom-btn {
        display: grid;
        place-items: center;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        font-size: 17px;
        font-weight: 500;
        color: var(--text-2);
        touch-action: manipulation;
    }

    .zoom-btn:disabled { opacity: .4; }
    .zoom-btn:active:not(:disabled) { transform: scale(.94); }

    @media (hover: hover) and (pointer: fine) {
        .zoom-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
    }

    /* Week grid (desktop / wide containers) */
    .schedule-grid-scroll {
        overflow: auto;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
        overscroll-behavior-x: contain;
    }

    .schedule-grid-container {
        display: grid;
        grid-template-columns: 62px repeat(7, minmax(0, 1fr));
        background: var(--surface);
    }

    .grid-header-cell,
    .grid-section-cell,
    .grid-slot-cell {
        min-width: 0;
        border-right: 1px solid var(--divider);
        border-bottom: 1px solid var(--divider);
    }

    .grid-header-cell {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        padding: 6px 2px;
        background: var(--surface-2);
        color: var(--text-2);
        font-size: 12px;
        font-weight: 600;
    }

    .time-header-cell {
        position: sticky;
        left: 0;
        z-index: 3;
        background: var(--surface-2);
        color: var(--text-3);
        font-size: 10.5px;
        line-height: 1.25;
    }

    .header-text-line { font-size: 10.5px; }

    .weekday-name { white-space: nowrap; }

    .weekday-date {
        font-size: 10.5px;
        font-weight: 500;
        color: var(--text-3);
        font-variant-numeric: tabular-nums;
    }

    .grid-header-cell.is-today {
        background: var(--accent-soft);
        color: var(--accent);
    }

    .grid-header-cell.is-today .weekday-date { color: var(--accent); }

    .grid-section-cell {
        position: sticky;
        left: 0;
        z-index: 2;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        padding: 4px 2px;
        background: var(--surface-2);
        text-align: center;
    }

    .grid-section-cell::before {
        content: "";
        position: absolute;
        left: 0;
        top: 8px;
        bottom: 8px;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background: var(--period-color, var(--separator-strong));
    }

    .sec-coral { --period-color: #ff7a59; }
    .sec-blue { --period-color: #4c9aff; }
    .sec-purple { --period-color: #a78bfa; }

    .section-number {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-2);
        white-space: nowrap;
    }

    .section-time {
        font-size: 10px;
        color: var(--text-3);
        font-variant-numeric: tabular-nums;
        line-height: 1.3;
    }

    .grid-slot-cell { background: var(--surface); }

    .grid-course-card {
        z-index: 1;
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        margin: 3px;
        padding: 6px 7px;
        border-left: 3px solid;
        border-radius: 8px;
        overflow: hidden;
        color: var(--text);
    }

    .course-name {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.3;
        word-break: break-word;
    }

    .course-meta {
        display: flex;
        flex-direction: column;
        gap: 1px;
        font-size: 10.5px;
        line-height: 1.35;
        color: var(--text-2);
    }

    .course-room,
    .course-teacher {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Day agenda (phones / narrow containers) */
    .schedule-agenda { display: block; }

    .agenda-days {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(44px, 1fr);
        gap: 4px;
        padding: 2px 2px 12px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .agenda-days::-webkit-scrollbar { display: none; }

    .day-chip {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 58px;
        padding: 6px 0;
        border: 1px solid transparent;
        border-radius: var(--r-md);
        background: var(--surface-3);
        color: var(--text-2);
        scroll-snap-align: start;
        touch-action: manipulation;
        transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease,
                    border-color var(--dur-hover) ease;
    }

    .day-chip-name { font-size: 12px; font-weight: 600; }

    .day-chip-date {
        font-size: 10.5px;
        color: var(--text-2);
        font-variant-numeric: tabular-nums;
    }

    .day-chip.is-active {
        background: var(--accent-fill);
        border-color: var(--accent-fill);
        color: #fff;
    }

    .day-chip.is-active .day-chip-date { color: #fff; }

    .day-chip.has-classes .day-chip-date::after {
        content: "";
        display: inline-block;
        width: 4px;
        height: 4px;
        margin-left: 3px;
        vertical-align: middle;
        border-radius: 50%;
        background: var(--accent);
    }

    .day-chip.is-active.has-classes .day-chip-date::after { background: #fff; }

    .agenda-head {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 10px;
        margin: 2px 2px 10px;
    }

    .agenda-head h4 { font-size: 15px; font-weight: 650; }

    .agenda-list { display: grid; gap: 8px; }

    .agenda-item {
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 10px;
        align-items: stretch;
    }

    .agenda-time {
        display: flex;
        flex-direction: column;
        gap: 1px;
        padding-top: 12px;
        font-size: 12px;
        font-weight: 600;
        color: var(--text-2);
        font-variant-numeric: tabular-nums;
    }

    .agenda-time span:last-child { font-size: 10.5px; font-weight: 500; color: var(--text-3); }

    .agenda-card {
        position: relative;
        padding: 12px 14px;
        border: 1px solid var(--separator);
        border-left: 3px solid var(--course-accent, var(--accent));
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .agenda-card h5 {
        font-size: 14.5px;
        font-weight: 650;
        line-height: 1.35;
        word-break: break-word;
    }

    .agenda-meta {
        margin-top: 3px;
        font-size: 12.5px;
        line-height: 1.5;
        color: var(--text-2);
    }

    .agenda-sections { margin-top: 6px; font-size: 11.5px; color: var(--text-3); }

    .agenda-empty {
        padding: 40px 16px;
        text-align: center;
    }

    .agenda-empty .empty-title { font-size: 14px; }
    .agenda-empty .empty-copy { font-size: 12.5px; }

    /* Container switch: card width decides, not the device */
    @container schedule (max-width: 560px) {
        .card-toolbar { padding: 13px 13px 10px; gap: 8px; }
        .schedule-heading { flex: 1 1 100%; }
        .schedule-actions { width: 100%; justify-content: flex-start; gap: 10px; }
        .week-nav { flex: 1 1 auto; justify-content: space-between; padding: 1px; gap: 0; min-width: 0; }
        .week-nav .icon-btn { width: 44px; height: 44px; }
        .week-label { min-width: 44px; padding-inline: 0; font-size: 12px; }
        .week-nav .btn-sm { min-height: 44px; min-width: 44px; padding: 0 8px; font-size: 11px; }
        #btn-refresh-schedule { flex: none; min-height: 44px; padding: 0 6px; font-size: 12px; }
        .schedule-heading .meta-text { font-size: 11.5px; }
    }

    @container schedule (min-width: 690px) {
        .schedule-agenda { display: none; }
    }

    @container schedule (max-width: 689px) {
        .schedule-grid-scroll { display: none; }
        .zoom-controls { display: none; }
        .schedule-body { padding: 0 12px 12px; }
    }

    /* ── Tutorial / segmented ───────────────────────────────────────── */
    .segmented {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        gap: 3px;
        padding: 3px;
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .segmented-item {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 38px;
        padding: 0 10px;
        border-radius: 9px;
        color: var(--text-2);
        font-size: 13.5px;
        font-weight: 600;
        white-space: nowrap;
        touch-action: manipulation;
        transition: background-color var(--dur-hover) ease, color var(--dur-hover) ease,
                    box-shadow var(--dur-hover) ease;
    }

    .segmented-item .icon { width: 16px; height: 16px; }

    .segmented-item.active {
        background: var(--surface);
        color: var(--text);
        box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
    }

    @media (hover: hover) and (pointer: fine) {
        .segmented-item:hover:not(.active) { color: var(--text); }
    }

    .tutorial-tabs { margin-top: 16px; }
    .tab-contents { margin-top: 12px; }
    .tab-pane { display: none; }
    .tab-pane.active { display: block; }

    .steps {
        display: grid;
        gap: 6px;
        margin-top: 8px;
        padding-left: 18px;
        list-style: decimal;
        font-size: 13px;
        line-height: 1.65;
        color: var(--text-2);
    }

    .steps strong { color: var(--text); font-weight: 600; }

    /* ── AI import ──────────────────────────────────────────────────── */
    .ai-pane { margin-top: 12px; min-height: 200px; }
    #pane-ai-image { display: none; }

    .ai-textarea {
        display: block;
        height: 200px;
        min-height: 200px;
        max-height: 420px;
        resize: none;
        overflow-y: auto;
        font-family: var(--font-num);
        font-size: 13.5px;
        line-height: 1.65;
    }

    .dropzone {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 200px;
        min-height: 200px;
        padding: 18px;
        border: 1.5px dashed var(--separator-strong);
        border-radius: var(--r-lg);
        background: var(--surface-2);
        cursor: pointer;
        text-align: center;
        transition: border-color var(--dur-hover) ease, background-color var(--dur-hover) ease;
    }

    .dropzone.is-dragover {
        border-color: var(--accent);
        background: var(--accent-softer);
    }

    .dropzone-preview {
        display: none;
        max-height: 220px;
        border-radius: var(--r-sm);
        cursor: zoom-in;
    }

    .dropzone-placeholder {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        color: var(--text-3);
    }

    .dropzone-placeholder .icon { width: 26px; height: 26px; color: var(--text-3); }
    .dropzone-placeholder strong { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
    .dropzone-placeholder span { font-size: 12px; }

    .dropzone-clear {
        position: absolute;
        top: 8px;
        right: 8px;
        display: none;
        place-items: center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(0, 0, 0, .62);
        color: #fff;
        font-size: 13px;
        line-height: 1;
    }

    .cost-chip {
        padding: 2px 7px;
        border-radius: var(--r-full);
        background: rgba(0, 0, 0, .24);
        font-size: 11.5px;
        font-weight: 600;
    }

    .ai-preview {
        margin-top: 16px;
        padding: 14px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface-2);
    }

    .ai-table { font-size: 12.5px; min-width: 560px; }

    .ai-table th {
        padding: 7px 8px;
        border-bottom: 1px solid var(--separator);
        background: var(--surface-3);
        color: var(--text-3);
        font-size: 11.5px;
        font-weight: 600;
        text-align: left;
        white-space: nowrap;
    }

    .ai-table td {
        padding: 5px 8px;
        border-bottom: 1px solid var(--divider);
        vertical-align: middle;
    }

    .ai-cell-input {
        width: 100%;
        min-width: 80px;
        height: 32px;
        padding: 0 6px;
        border: 1px solid var(--separator-strong);
        border-radius: 7px;
        background: var(--surface);
        color: var(--text);
        font-size: 12.5px;
    }

    .ai-cell-input:focus { border-color: var(--accent); }

    /* ── School config ──────────────────────────────────────────────── */
    .mode-switch {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        margin-top: 16px;
        padding: 12px 14px;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .mode-switch-copy { display: flex; flex-direction: column; gap: 2px; }
    .mode-switch-copy strong { font-size: 13.5px; font-weight: 600; }
    .mode-switch-copy span { font-size: 12px; color: var(--text-3); }

    .switch { position: relative; display: inline-flex; align-items: center; flex: none; min-height: 44px; }
    .switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

    .switch-slider {
        position: relative;
        display: block;
        flex: none;
        width: 46px;
        height: 28px;
        border-radius: var(--r-full);
        background: var(--surface-3);
        transition: background-color 180ms ease;
    }

    .switch-slider::after {
        content: "";
        position: absolute;
        top: 3px;
        left: 3px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
        transition: transform 180ms var(--ease-out);
    }

    .switch input:checked + .switch-slider { background: var(--success); }
    .switch input:checked + .switch-slider::after { transform: translateX(18px); }
    .switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent); outline-offset: 2px; }

    .block-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
        gap: 10px;
        margin-top: 14px;
    }

    .block-card {
        padding: 12px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface-2);
    }

    .block-title {
        margin-bottom: 8px;
        padding-inline: 4px;
        font-size: 13px;
        font-weight: 650;
        color: var(--text);
    }

    .compact-field {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        padding-block: 5px;
    }

    .compact-field > label { font-size: 12.5px; color: var(--text-2); }

    .compact-input {
        width: 100%;
        min-height: 36px;
        padding: 4px 9px;
        font-size: 13px;
        border-radius: var(--r-sm);
        background: var(--surface);
    }

    .compact-row { display: flex; gap: 6px; }
    .compact-row .compact-input { min-height: 36px; }
    .compact-suffix { width: 92px; flex: none; }

    .input-suffix { position: relative; }
    .input-suffix .form-input { padding-right: 46px; }
    .input-suffix > span {
        position: absolute;
        top: 50%;
        right: 9px;
        transform: translateY(-50%);
        font-size: 11px;
        color: var(--text-3);
        pointer-events: none;
    }

    .stepper {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        padding: 2px;
        border: 1px solid var(--separator-strong);
        border-radius: var(--r-sm);
        background: var(--surface);
    }

    .stepper button {
        display: grid;
        place-items: center;
        width: 30px;
        height: 30px;
        border-radius: 7px;
        font-size: 16px;
        color: var(--text-2);
        touch-action: manipulation;
    }

    .stepper button:active { transform: scale(.92); }

    .stepper-input {
        width: 34px;
        height: 30px;
        border: 0;
        background: transparent;
        color: var(--text);
        font-size: 13px;
        font-weight: 600;
        text-align: center;
        -moz-appearance: textfield;
        appearance: textfield;
    }

    .stepper-input::-webkit-outer-spin-button,
    .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

    .manual-box { margin-top: 16px; }

    .manual-time-table td { padding-block: 5px; }
    .manual-time-table .form-input { min-height: 36px; padding: 4px 9px; font-size: 13px; }

    .timeline-block { margin-top: 20px; }

    .timeline-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
        gap: 8px;
    }

    .timeline-period {
        padding: 11px;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .timeline-period-heading {
        margin-bottom: 7px;
        font-size: 11.5px;
        font-weight: 650;
        letter-spacing: .02em;
        color: var(--text-3);
    }

    .timeline-period-nodes { display: grid; gap: 4px; }

    .timeline-node {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 8px;
        padding: 5px 8px;
        border-radius: 7px;
        background: var(--surface);
        font-size: 12px;
        line-height: 1.5;
    }

    .timeline-node-title { font-weight: 500; color: var(--text); }
    .timeline-node-time { flex: none; color: var(--text-3); font-variant-numeric: tabular-nums; }

    .timeline-node.break-node {
        background: transparent;
        color: var(--text-3);
        padding-block: 2px;
    }

    .timeline-node.break-node .timeline-node-title { color: var(--text-3); font-weight: 400; }

    .timeline-node.big-break-node .timeline-node-title,
    .timeline-node.big-break-node .timeline-node-time { color: var(--warning); }

    .timeline-period-empty { font-size: 12px; color: var(--text-3); }

    /* ── Bound credentials ──────────────────────────────────────────── */
    .bound-box {
        margin-top: 14px;
        padding: 14px;
        border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
        border-radius: var(--r-lg);
        background: var(--success-soft);
    }

    .bound-head { display: flex; align-items: flex-start; gap: 10px; }

    :root[data-theme="dark"] .bound-icon { color: #0e0f12; }

    .bound-icon {
        display: grid;
        place-items: center;
        width: 30px;
        height: 30px;
        flex: none;
        border-radius: 50%;
        background: var(--success);
        color: #fff;
        font-size: 14px;
        font-weight: 700;
    }

    .bound-title { font-size: 14px; font-weight: 650; }
    .bound-meta { margin-top: 2px; font-size: 12.5px; color: var(--text-2); word-break: break-all; }

    .bound-box .btn-block { margin-top: 12px; }

    #form-edu-bind #btn-bind-edu { margin-top: 18px; }
    .bound-box .notice .btn { width: auto; }

    /* ── Announcement ───────────────────────────────────────────────── */
    .announcement-card { padding: 0; overflow: hidden; }

    .announcement-stage {
        position: relative;
        display: grid;
        min-height: 200px;
        touch-action: pan-y;
        overscroll-behavior-x: contain;
    }

    .announcement-slide {
        grid-area: 1 / 1;
        display: flex;
        align-items: center;
        gap: 20px;
        padding: 22px 22px 38px;
        opacity: 0;
        visibility: hidden;
        transition: opacity 320ms ease, visibility 0s linear 320ms;
    }

    .announcement-slide.active {
        opacity: 1;
        visibility: visible;
        transition: opacity 320ms ease;
    }

    .announcement-slide--banner { padding: 0; }
    .announcement-slide--banner img { width: 100%; height: auto; object-fit: cover; }
    .announcement-slide--clickable { cursor: pointer; }

    .announcement-qr { flex: none; }

    .announcement-qr img {
        width: 132px;
        height: 132px;
        border-radius: var(--r-md);
        object-fit: contain;
        background: var(--surface-2);
    }

    .announcement-text { min-width: 0; }

    .announcement-text h4 {
        font-size: 16.5px;
        font-weight: 650;
        line-height: 1.4;
    }

    .announcement-text p {
        margin-top: 6px;
        font-size: 13px;
        line-height: 1.65;
        color: var(--text-2);
        overflow-wrap: anywhere;
        /* Admin edits announcements with real line breaks; keep them. */
        white-space: pre-line;
    }

    .announcement-text--solo { max-width: 46em; }

    .announcement-title-link { color: inherit; }
    .announcement-inline-link { color: var(--accent); }

    .announcement-link-list,
    .announcement-banner-links {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 12px;
    }

    .announcement-link-btn,
    .announcement-banner-links a {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        padding: 0 12px;
        border-radius: var(--r-sm);
        background: var(--accent-soft);
        color: var(--accent);
        font-size: 12.5px;
        font-weight: 600;
    }

    .announcement-banner-links {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        padding: 24px 14px 12px;
        background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent);
    }

    .announcement-banner-links a {
        background: rgba(255, 255, 255, .92);
        color: #1d1d1f;
    }

    .announcement-dots {
        position: absolute;
        left: 50%;
        bottom: 10px;
        z-index: 2;
        display: flex;
        gap: 6px;
        padding: 5px 8px;
        border-radius: var(--r-full);
        background: var(--surface);
        background: color-mix(in srgb, var(--surface) 80%, transparent);
        transform: translateX(-50%);
        backdrop-filter: blur(8px);
    }

    .announcement-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--separator-strong);
        cursor: pointer;
    }

    .announcement-dot.active { background: var(--accent); }

    /* ── Resources ──────────────────────────────────────────────────── */
    .resource-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
        gap: 8px;
    }

    .resource-card {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface-2);
        color: var(--text);
        transition: border-color var(--dur-hover) ease, background-color var(--dur-hover) ease,
                    transform var(--dur-press) var(--ease-out);
    }

    .resource-card:active { transform: scale(.985); }

    .resource-avatar {
        display: grid;
        place-items: center;
        width: 38px;
        height: 38px;
        flex: none;
        overflow: hidden;
        border-radius: 10px;
        background: var(--surface-3);
        font-size: 17px;
    }

    .resource-avatar img { width: 100%; height: 100%; object-fit: cover; }

    .resource-copy { min-width: 0; }

    .resource-title {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 13.5px;
        font-weight: 600;
    }

    .resource-desc {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-top: 2px;
        font-size: 12px;
        line-height: 1.5;
        color: var(--text-3);
    }

    @media (hover: hover) and (pointer: fine) {
        .resource-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-softer); }
    }

    .resources-note { margin-top: 14px; }
    .resources-note a { color: var(--text-3); text-decoration: underline; }

    /* ── Empty & loading states ─────────────────────────────────────── */
    .empty-state { padding: 36px 16px; text-align: center; }
    .empty-title { font-size: 14.5px; font-weight: 600; color: var(--text-2); }
    .empty-copy { margin-top: 4px; font-size: 13px; color: var(--text-3); }

    .loading-state {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        min-height: 140px;
        padding: 24px;
        color: var(--text-3);
        font-size: 13px;
    }

    /* ── Footer ─────────────────────────────────────────────────────── */
    .footer-brand { display: flex; align-items: center; gap: 10px; }

    .footer-mark { border-radius: 8px; flex: none; }

    .footer-name { font-size: 13px; font-weight: 600; color: var(--text-2); }
    .footer-tagline { margin-top: 2px; font-size: 12px; }

    .footer-links { display: flex; flex-wrap: wrap; gap: 16px; }
    .footer-links a { color: var(--text-2); }
    .footer-links a:active { opacity: .6; }

    .footer-legal {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px 14px;
        color: var(--text-3);
        font-size: 11.5px;
    }

    .footer-legal a {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        color: var(--text-3);
    }

    /* ── Mobile tab bar ─────────────────────────────────────────────── */
    .tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 70;
        display: none;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--surface);
        background: color-mix(in srgb, var(--surface) 86%, transparent);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid var(--separator);
    }

    .tabbar-item {
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: var(--tabbar-h);
        padding: 6px 2px;
        color: var(--text-3);
        font-size: 10.5px;
        font-weight: 500;
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        transition: color var(--dur-hover) ease;
    }

    .tabbar-item .icon { width: 22px; height: 22px; }
    .tabbar-item.active { color: var(--accent); font-weight: 600; }

    .tabbar-item:active { opacity: .65; }

    /* ── More sheet ─────────────────────────────────────────────────── */
    .sheet {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: none;
        align-items: flex-end;
        background: rgba(0, 0, 0, .38);
        opacity: 0;
        visibility: hidden;
        transition: opacity 220ms ease, visibility 0s linear 220ms;
    }

    .sheet.is-open {
        opacity: 1;
        visibility: visible;
        transition: opacity 220ms ease;
    }

    .sheet-panel {
        width: 100%;
        max-height: 84dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 6px 14px calc(16px + env(safe-area-inset-bottom, 0px));
        border-radius: 22px 22px 0 0;
        background: var(--surface);
        box-shadow: var(--shadow-panel);
        transform: translateY(100%);
        transition: transform 320ms var(--ease-drawer);
    }

    .sheet.is-open .sheet-panel { transform: none; }

    .sheet-grabber {
        width: 36px;
        height: 5px;
        margin: 6px auto 10px;
        border-radius: 3px;
        background: var(--separator-strong);
    }

    .sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 2px 8px;
    }

    .sheet-head h2 { font-size: 18px; font-weight: 700; }

    .sheet-list { display: grid; gap: 2px; }

    .sheet-item {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 56px;
        padding: 8px 10px;
        border-radius: var(--r-md);
        color: var(--text);
        touch-action: manipulation;
        transition: background-color var(--dur-hover) ease;
    }

    .sheet-item .icon { width: 20px; height: 20px; color: var(--text-3); }
    .sheet-item .chevron { width: 16px; height: 16px; margin-left: auto; color: var(--text-3); }

    .sheet-item-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
    .sheet-item-copy strong { font-size: 14.5px; font-weight: 600; }
    .sheet-item-copy small { font-size: 12px; color: var(--text-3); }

    .sheet-item:active { background: var(--surface-2); }

    /* ── Modals ─────────────────────────────────────────────────────── */
    .modal-overlay {
        position: fixed;
        inset: 0;
        z-index: 100;
        display: grid;
        place-items: center;
        padding: 20px;
        background: rgba(0, 0, 0, .42);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 200ms ease, visibility 0s linear 200ms;
    }

    .modal-overlay.active {
        opacity: 1;
        visibility: visible;
        transition: opacity 200ms ease;
    }

    .modal-panel {
        width: min(560px, 100%);
        max-height: min(86dvh, 760px);
        overflow-y: auto;
        overscroll-behavior: contain;
        border: 1px solid var(--separator);
        border-radius: var(--r-2xl);
        background: var(--surface);
        box-shadow: var(--shadow-panel);
        transform: scale(.96);
        transition: transform var(--dur-enter) var(--ease-out);
    }

    .modal-overlay.active .modal-panel { transform: none; }

    .modal-head {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 16px 18px;
        border-bottom: 1px solid var(--divider);
        background: var(--surface);
    }

    .modal-head h2 { font-size: 17px; font-weight: 650; }

    .modal-body { padding: 16px 18px 20px; }

    .prose p { font-size: 13.5px; line-height: 1.75; color: var(--text-2); }
    .prose p + p { margin-top: 12px; }

    .poster-modal {
        /* 预览高度与面板宽度联动：图片按 3:4 完整显示，左右不再出现留白 */
        --poster-preview-height: min(calc(86dvh - 200px), 560px);
        width: min(540px, calc(0.75 * var(--poster-preview-height) + 38px), calc(100vw - 24px));
    }

    .poster-body { display: grid; gap: 12px; }

    #poster-image {
        display: block;
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: var(--poster-preview-height);
        margin-inline: auto;
        border: 1px solid var(--separator);
        border-radius: 14px;
        background: var(--surface-2);
    }

    .poster-hint {
        font-size: 12.5px;
        line-height: 1.6;
        color: var(--text-3);
        text-align: center;
    }

    .modal-lightbox {
        background: rgba(0, 0, 0, .88);
        cursor: zoom-out;
        place-items: center;
        padding: 16px;
    }

    .modal-lightbox img {
        max-width: 94vw;
        max-height: 90dvh;
        border-radius: var(--r-md);
        box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
    }

    /* ── Toast ──────────────────────────────────────────────────────── */
    .toast {
        position: fixed;
        left: 50%;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        z-index: 200;
        display: flex;
        align-items: center;
        gap: 8px;
        max-width: min(440px, calc(100vw - 32px));
        padding: 11px 16px;
        border-radius: var(--r-md);
        background: var(--toast-bg);
        color: var(--toast-text);
        box-shadow: var(--shadow-toast);
        font-size: 13px;
        font-weight: 500;
        line-height: 1.5;
        opacity: 0;
        visibility: hidden;
        transform: translate(-50%, 10px);
        transition: opacity 200ms ease, transform 200ms var(--ease-out),
                    visibility 0s linear 200ms;
    }

    .toast.is-visible {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, 0);
        transition: opacity 200ms ease, transform 200ms var(--ease-out);
    }

    .toast.toast-error::before,
    .toast.toast-success::before {
        content: "";
        width: 7px;
        height: 7px;
        flex: none;
        border-radius: 50%;
        background: var(--success);
    }

    .toast.toast-error::before { background: #ff6b6b; }

    /* ── Small-screen component adjustments ─────────────────────────── */
    @container content (min-width: 620px) {
        .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

    @container content (min-width: 720px) {
        .two-col-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }



    @media (max-width: 359px) {
        .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .stat-cell:last-child { grid-column: 1 / -1; }
    }

    @media (max-width: 599px) {
        .card-header { padding: 16px 16px 0; }
        .card-body { padding: 12px 16px 16px; }
        .card-toolbar { padding: 14px 16px; }
        .schedule-body { padding: 0 8px 8px; }
        .auth-panel-inner { padding: 18px 18px 22px; }
        .auth-tabs { margin: 12px 12px 0; }
        .announcement-slide { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
        .announcement-qr img { width: 100%; max-height: 180px; }
        .logout-full { display: none; }
        .logout-short { display: inline; }
        .brand-divider,
        .brand-tagline { display: none; }
    }
}

/* --------------------------------------------------------------------------
   6. UTILITIES
   -------------------------------------------------------------------------- */
@layer utilities {
    .hidden { display: none !important; }
    .visually-hidden {
        position: absolute !important;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .text-center { text-align: center; }
    .align-end { text-align: right; }
}

/* --------------------------------------------------------------------------
   7. RESPONSIVE SHELL
   -------------------------------------------------------------------------- */
@layer shell {
    @media (min-width: 600px) {
        .header-inner { padding-inline: 24px; }
        .app-main { padding: 28px 24px 64px; }
        .app-footer { padding-inline: 24px; }
        .footer-inner { flex-direction: row; align-items: center; justify-content: space-between; gap: 24px; }
        .footer-legal { justify-content: flex-end; }
    }

    @media (min-width: 900px) {
        :root { --header-h: 64px; }

        .header-inner { padding-inline: 32px; }
        .app-main { padding: 36px 32px 72px; }
        .app-footer { padding-inline: 32px; }

        .auth { padding-block: 24px 40px; }
        .auth-grid {
            grid-template-columns: minmax(0, 1fr) 420px;
            grid-template-areas: "copy panel";
            column-gap: clamp(40px, 6vw, 88px);
            align-items: start;
        }

        .auth-copy {
            grid-area: copy;
            display: flex;
            flex-direction: column;
            gap: 34px;
            min-width: 0;
        }

        .auth-panel {
            grid-area: panel;
            align-self: start;
            margin-top: 0;
        }
        .auth-panel-inner { padding: 20px 24px 24px; }
        .auth-tabs { margin: 16px 16px 0; }

        .dashboard-frame {
            grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
            gap: 28px;
        }

        .sidebar {
            display: block;
            position: sticky;
            top: calc(var(--header-h) + 20px);
            align-self: start;
            max-height: calc(100dvh - var(--header-h) - 40px);
            overflow-y: auto;
            overscroll-behavior: contain;
            padding: 4px;
        }

        .tabbar, .sheet { display: none; }

        /* All groups visible once the sidebar exists. */
        .dashboard-group { display: flex; margin-bottom: 36px; }
        .dashboard-group:last-child { margin-bottom: 0; }
        .dashboard-frame[data-mode="mobile"] .dashboard-group { display: flex; }

        .group-head { margin-bottom: 2px; }
    }

    @media (min-width: 1200px) {
        :root { --sidebar-w: 232px; }
        .app-main { padding-inline: 40px; }
        .header-inner { padding-inline: 40px; }
        .app-footer { padding-inline: 40px; }
    }

    @media (min-width: 900px) {
        .app-main { padding-bottom: 80px; }
    }

    /* ── Phone / tablet shell ──────────────────────────────────────── */
    @media (max-width: 899px) {
        .sheet { display: flex; }
        body.is-authed { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
        body.is-authed .tabbar { display: flex; }
        body.is-authed .app-footer { padding-bottom: 16px; }

        .dashboard-frame[data-mode="mobile"] .dashboard-group { display: none; }
        .dashboard-frame[data-mode="mobile"] .dashboard-group.is-current { display: flex; }

        /* On a phone the announcement reads as the tail of the timetable. */
        .dashboard-frame[data-mode="mobile"]:has(#grp-schedule.is-current) #grp-announcement {
            display: flex;
            margin-top: 28px;
        }
        .dashboard-frame[data-mode="mobile"]:has(#grp-schedule.is-current) #grp-announcement .eyebrow { display: none; }
        .dashboard-frame[data-mode="mobile"]:has(#grp-schedule.is-current) #grp-announcement .group-head h2 {
            font-size: 18px;
            font-weight: 650;
        }

        .dashboard-frame[data-mode="mobile"] .group-head {
            margin-bottom: 2px;
            padding-inline: 2px;
        }

        .dashboard-content { padding-bottom: 8px; }

        body.sheet-open { overflow: hidden; }
    }

    /* Mobile sheet for regular modals */
    @media (max-width: 599px) {
        .modal-overlay {
            align-items: end;
            padding: 0;
            backdrop-filter: blur(4px);
        }

        .modal-overlay .modal-panel {
            width: 100%;
            max-height: 88dvh;
            border-radius: 22px 22px 0 0;
            border-bottom: 0;
            padding-bottom: env(safe-area-inset-bottom, 0px);
            transform: translateY(100%);
            transition: transform 320ms var(--ease-drawer);
        }

        .modal-overlay.active .modal-panel { transform: none; }

        .toast { bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0px)); }

        .poster-modal { --poster-preview-height: 52dvh; }
    }
}

/* --------------------------------------------------------------------------
   8. ACCESSIBILITY PREFERENCES
   -------------------------------------------------------------------------- */
@layer utilities {
    @media (prefers-reduced-motion: reduce) {
        .btn, .icon-btn, .nav-item, .tabbar-item, .sheet-item, .day-chip,
        .segmented-item, .resource-card, .auth-tab, .zoom-btn {
            transition-duration: 60ms;
        }

        .btn:active:not(:disabled),
        .icon-btn:active,
        .resource-card:active,
        .day-chip:active { transform: none; }

        .btn:active:not(:disabled),
        .icon-btn:active { filter: brightness(.94); }

        .modal-panel,
        .sheet-panel,
        .modal-overlay .modal-panel,
        .toast,
        .announcement-slide { transform: none !important; }

        .skip-link { transition-duration: 0ms; }

        .modal-overlay,
        .sheet { transition-duration: 120ms; }

        .btn-loader,
        .spinner { animation-duration: 1.4s; }
    }

    @media (prefers-reduced-transparency: reduce) {
        .app-header,
        .tabbar,
        .sheet-panel,
        .announcement-dots {
            background: var(--surface);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }

        .modal-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(0, 0, 0, .55); }
    }

    @media (prefers-contrast: more) {
        :root {
            --separator: rgba(0, 0, 0, .35);
            --separator-strong: rgba(0, 0, 0, .55);
        }

        :root[data-theme="dark"] {
            --separator: rgba(255, 255, 255, .38);
            --separator-strong: rgba(255, 255, 255, .6);
        }

        .card, .form-input, .badge { border-width: 1.5px; }
    }

    @media (pointer: coarse), (any-pointer: coarse) {
        .btn-sm, .icon-btn, .week-nav .icon-btn, .zoom-btn, .segmented-item {
            min-height: 44px;
        }

        .icon-btn { width: 44px; height: 44px; }
        .zoom-btn { min-width: 44px; min-height: 44px; }

        .compact-input, .stepper button, .stepper-input, .manual-time-table .form-input {
            min-height: 44px;
        }

        .stepper button { width: 44px; height: 44px; }
        .stepper-input { width: 44px; }

        input, select, textarea { font-size: 16px; }
        .compact-input, .manual-time-table .form-input, .stepper-input { font-size: 16px; }

        .checkline { min-height: 44px; align-items: center; }
        .checkline input[type="checkbox"] { margin-top: 0; width: 20px; height: 20px; }
    }
}

/* --------------------------------------------------------------------------
   9. RENDERED-LIST DETAILS
   -------------------------------------------------------------------------- */
@layer components {
    .resource-grid > .empty-state,
    .resource-grid > .loading-state { grid-column: 1 / -1; }

    .agenda-panel { min-height: 120px; }

    .cell-sub { font-size: 11.5px; color: var(--text-3); }
    .cell-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
    .cell-status { font-weight: 500; }
    .status-pending { color: var(--warning); }
    .status-approved { color: var(--success); }
    .status-rejected { color: var(--danger); }
}

@layer components {
    .card:has(#body-school-config.hidden) #icon-collapse-school-config { transform: rotate(-90deg); }
    #icon-collapse-school-config { transition: transform 180ms var(--ease-out); }

    .badge-sm { padding: 2px 7px; font-size: 11px; }
    .badge-completed { background: var(--success-soft); color: var(--success); }
    .badge-pending { background: var(--surface-3); color: var(--text-2); }
    .cell-gold { font-weight: 600; color: var(--warning); white-space: nowrap; }

    .form-input:focus-visible { outline: none; }
}

@layer components {
    .card-danger {
        border-color: color-mix(in srgb, var(--danger) 26%, var(--separator));
    }

    .card-danger .btn { margin-top: 18px; }

    body:has(.modal-overlay.active) { overflow-y: hidden; }
}

@layer base {
    a, button, [role="button"] { touch-action: manipulation; }
    button, [role="button"], .tabbar-item, .day-chip { user-select: none; -webkit-user-select: none; }
}

/* --------------------------------------------------------------------------
   10. LEGAL PAGES
   -------------------------------------------------------------------------- */
@layer components {
    .legal-main { max-width: 880px; }
    .legal-card { padding: clamp(20px, 4vw, 44px); }
    .legal-card h1 {
        margin-top: 8px;
        font-size: clamp(28px, 4.4vw, 38px);
        font-weight: 700;
        letter-spacing: -.03em;
        line-height: 1.15;
    }
    .legal-card .updated { margin-top: 6px; font-size: 13px; color: var(--text-3); }
    .legal-body { margin-top: 28px; }
    .legal-body h2 {
        margin: 30px 0 10px;
        font-size: 19px;
        font-weight: 650;
        letter-spacing: -.015em;
    }
    .legal-body h3 { margin: 20px 0 6px; font-size: 15.5px; font-weight: 650; }
    .legal-body p, .legal-body li { font-size: 14px; line-height: 1.8; color: var(--text-2); }
    .legal-body p + p { margin-top: 8px; }
    .legal-body ul { margin: 8px 0 14px; padding-left: 20px; list-style: disc; }
    .legal-body li + li { margin-top: 4px; }
    .legal-body strong { color: var(--text); font-weight: 600; }
    .legal-body .highlight { color: var(--success); font-weight: 600; }
    .legal-body a { color: var(--accent); }
    .legal-body .quote {
        margin: 14px 0;
        padding: 13px 16px;
        border-left: 3px solid var(--accent);
        border-radius: 0 10px 10px 0;
        background: var(--accent-softer);
        font-size: 13.5px;
        line-height: 1.75;
        color: var(--text-2);
    }
    .legal-footer {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 18px;
        margin-top: 20px;
        padding: 0 4px;
        font-size: 12px;
    }
    .legal-footer a { color: var(--text-3); }
}

@layer components {
    .sheet-item.is-current { background: var(--accent-soft); color: var(--accent); }
    .sheet-item.is-current .icon { color: var(--accent); }
}

@layer components {
    .dashboard-nav-menu { display: flex; flex-direction: column; gap: 2px; }
    .withdrawal-logs { margin-top: 20px; }
    .segmented-neutral { background: var(--surface-3); }
}

@layer utilities {
    @media (pointer: coarse), (any-pointer: coarse) {
        .footer-links a,
        .footer-legal a,
        .legal-footer a,
        .resources-note a,
        .announcement-link-btn,
        .announcement-banner-links a {
            display: inline-flex;
            align-items: center;
            min-height: 44px;
        }
    }
}

@layer utilities {
    @media (pointer: coarse), (any-pointer: coarse) {
        .resources-note a { padding-inline: 4px; }
    }
}

@layer components {
    .import-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        align-items: start;
    }

    .tutorial-tabs .segmented { max-width: 520px; }
}

@layer components {
    @container content (min-width: 760px) {
        .import-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
            align-items: stretch;
        }

        .import-grid > .card {
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .import-grid > .card > .card-body { flex: 1; }

        #form-edu-bind #btn-bind-edu { margin-top: 24px; }
    }
}


@layer components {
    .onboarding-modal { width: min(520px, 100%); }

    .onboarding-body { padding-bottom: 8px; }

    .onboarding-lede {
        font-size: 14px;
        line-height: 1.7;
        color: var(--text-2);
    }

    .onboarding-steps {
        display: grid;
        gap: 10px;
        margin-top: 16px;
    }

    .onboarding-steps li {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 12px;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .onboarding-num {
        display: grid;
        place-items: center;
        width: 28px;
        height: 28px;
        flex: none;
        border-radius: 50%;
        background: var(--accent-soft);
        color: var(--accent);
        font-size: 13px;
        font-weight: 650;
    }

    .onboarding-steps strong {
        display: block;
        font-size: 14px;
        font-weight: 600;
        line-height: 1.4;
    }

    .onboarding-steps small {
        display: block;
        margin-top: 2px;
        font-size: 12.5px;
        line-height: 1.5;
        color: var(--text-3);
    }

    .modal-foot {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding: 0 18px 18px;
    }

    @media (max-width: 599px) {
        .modal-foot .btn { flex: 1; }
    }
}

@layer components {
    .clear-modal { width: min(480px, 100%); }

    .clear-list {
        display: grid;
        gap: 6px;
        margin: 12px 0 4px;
        padding: 12px 14px;
        border-radius: var(--r-md);
        background: var(--surface-2);
        list-style: disc;
        padding-left: 32px;
    }

    .clear-list li {
        font-size: 13px;
        line-height: 1.6;
        color: var(--text-2);
    }
}

@layer components {
    .invite-reward-modal { width: min(420px, 100%); }

    .invite-reward-body {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 28px 24px 24px;
    }

    .invite-reward-emoji {
        display: grid;
        place-items: center;
        width: 64px;
        height: 64px;
        margin-bottom: 14px;
        border-radius: 50%;
        background: var(--accent-soft);
        font-size: 32px;
    }

    .invite-reward-body h2 {
        font-size: 22px;
        font-weight: 700;
        letter-spacing: -.03em;
    }

    .invite-reward-body .body-text {
        margin-top: 8px;
        font-size: 14px;
        line-height: 1.65;
    }

    .invite-reward-pills {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin: 16px 0 20px;
    }

    .invite-reward-pills span {
        padding: 6px 12px;
        border-radius: var(--r-full);
        background: var(--accent-soft);
        color: var(--accent);
        font-size: 13px;
        font-weight: 600;
    }
}

@layer components {
    .badge-progress { background: var(--accent-soft); color: var(--accent); }
    .badge-inactive { background: var(--warning-soft); color: var(--warning); }
}

@layer components {
    .profile-form {
        display: flex;
        align-items: flex-end;
        gap: 12px;
    }

    .profile-form .field { flex: 1; }

    .couple-shell {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        min-width: 0;
    }

    .couple-hero {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        padding: 24px;
        border-radius: var(--r-lg);
        background:
            radial-gradient(120% 160% at 0% 0%, var(--accent-soft), transparent 60%),
            var(--surface);
        border: 1px solid var(--separator);
    }

    .couple-hero h3 {
        font-size: 20px;
        font-weight: 700;
        letter-spacing: -.03em;
    }

    .couple-hero p {
        margin-top: 6px;
        font-size: 13px;
        line-height: 1.6;
        color: var(--text-2);
        max-width: 48em;
    }

    .couple-hero-icon {
        display: grid;
        place-items: center;
        width: 56px;
        height: 56px;
        flex: none;
        border-radius: 50%;
        background: var(--accent-soft);
        color: var(--accent);
    }

    .couple-empty-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .couple-card {
        padding: 20px;
        border-radius: var(--r-lg);
        border: 1px solid var(--separator);
        background: var(--surface);
    }

    .couple-card h3 { font-size: 16px; font-weight: 650; }

    .couple-card p {
        margin-top: 6px;
        font-size: 13px;
        line-height: 1.65;
        color: var(--text-2);
    }

    .couple-card .btn { margin-top: 16px; }

    .couple-form-row {
        display: flex;
        gap: 8px;
        margin-top: 14px;
    }

    .couple-form-row .form-input { flex: 1; min-width: 0; }

    .couple-room-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 16px;
        padding: 20px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
    }

    .couple-room-code {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin-top: 10px;
        font-size: 12px;
        color: var(--text-2);
    }

    .couple-room-code code {
        padding: 4px 10px;
        border-radius: var(--r-full);
        background: var(--surface-2);
        color: var(--text);
        font-size: 14px;
        font-weight: 700;
        letter-spacing: .12em;
    }

    .couple-copy {
        padding: 2px 8px;
        border: 1px solid var(--separator);
        border-radius: var(--r-full);
        background: var(--surface);
        color: var(--text-2);
        font-size: 11px;
    }

    .couple-members {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 14px;
    }

    .couple-member {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px 6px 6px;
        border: 1px solid var(--separator);
        border-radius: var(--r-full);
        background: var(--surface);
        font-size: 12px;
    }

    .couple-avatar {
        display: grid;
        place-items: center;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--accent-soft);
        color: var(--accent);
        font-size: 12px;
        font-weight: 700;
    }

    .couple-weekbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 16px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
    }

    .couple-weekbar-main {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .couple-week-title {
        font-size: 14px;
        font-weight: 650;
        white-space: nowrap;
    }

    .couple-summary {
        font-size: 12px;
        color: var(--text-3);
        white-space: nowrap;
    }

    .couple-days { display: grid; gap: 12px; }

    .couple-day {
        padding: 16px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
    }

    .couple-day-head {
        display: flex;
        align-items: baseline;
        gap: 8px;
        margin-bottom: 12px;
    }

    .couple-day-head strong { font-size: 15px; font-weight: 650; }

    .couple-day-head span { font-size: 12px; color: var(--text-3); }

    .couple-columns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .couple-column {
        min-width: 0;
        padding: 12px;
        border-radius: var(--r-md);
        background: var(--surface-2);
    }

    .couple-person-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 8px;
        font-size: 12px;
        font-weight: 650;
    }

    .couple-person-head small { font-weight: 500; color: var(--text-3); }

    .couple-course-list, .couple-free-list { display: grid; gap: 6px; }

    .couple-course {
        padding: 8px 10px;
        border-left: 3px solid var(--accent);
        border-radius: 0 var(--r-sm) var(--r-sm) 0;
        background: var(--surface);
        font-size: 12px;
        line-height: 1.45;
    }

    .couple-course strong { display: block; font-weight: 600; }
    .couple-course small { color: var(--text-3); }

    .couple-empty-line {
        font-size: 12px;
        color: var(--text-3);
    }

    .couple-common {
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--separator);
    }

    .couple-common-head {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 12px;
        font-weight: 600;
        color: var(--success);
    }

    .couple-free-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 8px;
    }

    .couple-chip {
        display: inline-flex;
        align-items: center;
        padding: 4px 8px;
        border-radius: var(--r-full);
        background: var(--success-soft);
        color: var(--success);
        font-size: 11.5px;
        font-weight: 600;
        white-space: nowrap;
    }

    .couple-chip--muted {
        background: var(--surface);
        color: var(--text-2);
        font-weight: 500;
    }

    .couple-hint {
        padding: 18px;
        border: 1px dashed var(--separator-strong);
        border-radius: var(--r-lg);
        background: var(--surface-2);
        text-align: center;
        font-size: 13px;
        line-height: 1.65;
        color: var(--text-2);
    }

    .couple-hint .btn { margin-top: 12px; }

    @media (max-width: 760px) {
        .couple-empty-grid { grid-template-columns: 1fr; }
        .couple-columns { grid-template-columns: 1fr; }
        .couple-hero { padding: 18px; }
        .couple-room-head { flex-direction: column; }
        .couple-weekbar { flex-wrap: wrap; }
        .couple-summary { white-space: normal; }
        .profile-form { flex-direction: column; align-items: stretch; }
    }
}

@layer components {
    .couple-subhead {
        margin: 10px 0 2px;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .04em;
        color: var(--text-3);
        text-transform: uppercase;
    }
}

@layer components {
    .couple-timetable-card {
        min-width: 0;
        max-width: 100%;
        padding: 12px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
    }

    .couple-timetable-scroll {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        border: 1px solid var(--separator);
        border-radius: var(--r-md);
        background: var(--surface);
    }

    .couple-timetable { width: 100%; min-width: 0; }

    .couple-timetable-head {
        display: grid;
        grid-template-columns: 56px repeat(7, minmax(0, 1fr));
        border-bottom: 1px solid var(--separator-strong);
        background: var(--surface-2);
    }

    .couple-time-head,
    .couple-day-head-cell {
        padding: 9px 4px;
        text-align: center;
        font-size: 11px;
        color: var(--text-2);
        border-left: 1px solid var(--separator);
    }

    .couple-time-head {
        border-left: 0;
        font-size: 10px;
        color: var(--text-3);
        background: var(--surface-2);
    }

    .couple-day-head-cell strong { display: block; font-size: 11.5px; font-weight: 650; color: var(--text); }
    .couple-day-head-cell span { display: block; margin-top: 2px; font-size: 9.5px; color: var(--text-3); }
    .couple-day-head-cell.is-today { background: var(--accent-softer); }
    .couple-day-head-cell.is-today strong { color: var(--accent); }

    .couple-timetable-body {
        display: grid;
        grid-template-columns: 56px repeat(7, minmax(0, 1fr));
        height: 870px;
        background: var(--surface);
    }

    .couple-time-axis {
        position: relative;
        border-right: 1px solid var(--separator);
        background: var(--surface-2);
    }

    .couple-time-label {
        position: absolute;
        right: 5px;
        transform: translateY(-50%);
        font-size: 9px;
        color: var(--text-3);
        white-space: nowrap;
    }

    .couple-time-label:first-child { transform: none; }
    .couple-time-label:last-child { transform: translateY(-100%); }

    .couple-day-column {
        position: relative;
        overflow: hidden;
        border-left: 1px solid var(--separator);
        background: var(--surface);
    }

    .couple-day-column.is-today { background: var(--accent-softer); }

    .couple-hour-line {
        position: absolute;
        left: 0;
        right: 0;
        border-top: 1px solid var(--separator);
        pointer-events: none;
        z-index: 0;
    }

    .couple-hour-line.is-half { opacity: .35; }

    .couple-lane-divider {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        border-left: 1px dashed var(--separator);
        pointer-events: none;
        z-index: 0;
    }

    .couple-common-band {
        position: absolute;
        left: 0;
        right: 0;
        background: var(--success-soft);
        border-top: 1px solid rgba(20, 108, 46, .10);
        border-bottom: 1px solid rgba(20, 108, 46, .10);
        pointer-events: none;
        z-index: 0;
    }

    .couple-course-block {
        position: absolute;
        left: 1px;
        right: 1px;
        width: auto;
        z-index: 1;
        padding: 2px 3px;
        overflow: hidden;
        border-left: 2px solid var(--accent);
        border-radius: 3px;
        background: var(--accent-soft);
        color: var(--text);
        box-sizing: border-box;
    }

    .couple-course-block.ta {
        border-left: 0;
        border-right: 2px solid var(--danger);
        background: var(--danger-soft);
    }

    /* Same time slot on both sides: use half-width color lanes, hide text. */
    .couple-course-block.is-overlap {
        right: auto;
        width: calc(50% - 2px);
    }

    .couple-course-block.is-overlap.ta {
        left: auto;
        right: 1px;
    }

    .couple-course-block.is-overlap strong {
        font-size: 7.5px;
        line-height: 1.12;
    }

    .couple-course-block.is-overlap small {
        font-size: 6.5px;
        line-height: 1.12;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .couple-course-block strong {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 9px;
        font-weight: 650;
        line-height: 1.2;
    }

    .couple-course-block small {
        display: block;
        margin-top: 1px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 8px;
        line-height: 1.2;
        color: var(--text-2);
    }

    .couple-grid-legend {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        padding: 10px 2px 2px;
        font-size: 11px;
        color: var(--text-2);
    }

    .couple-grid-legend > span { display: inline-flex; align-items: center; gap: 5px; }

    .couple-dot {
        display: inline-block;
        width: 9px;
        height: 9px;
        border-radius: 2px;
    }

    .couple-dot--me { background: var(--accent); }
    .couple-dot--ta { background: var(--danger); }
    .couple-dot--free { background: var(--success); opacity: .35; }

    .couple-legend-note { color: var(--text-3); }
}

@layer components {
    .couple-course-block {
        cursor: pointer;
        transition: transform 120ms ease, box-shadow 120ms ease;
    }

    .couple-course-block:hover {
        box-shadow: 0 0 0 1px var(--separator-strong);
    }

    .couple-course-block:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
    }

    .couple-course-block strong {
        white-space: normal;
        overflow-wrap: anywhere;
        text-overflow: clip;
        line-height: 1.18;
    }

    .couple-course-modal { width: min(420px, 100%); }

    .couple-course-detail {
        display: grid;
        gap: 12px;
    }

    .couple-course-detail > div {
        display: grid;
        grid-template-columns: 48px 1fr;
        gap: 12px;
        align-items: baseline;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--separator);
    }

    .couple-course-detail > div:last-child { border-bottom: 0; padding-bottom: 0; }

    .couple-course-detail dt {
        font-size: 12px;
        color: var(--text-3);
    }

    .couple-course-detail dd {
        margin: 0;
        font-size: 14px;
        line-height: 1.55;
        color: var(--text);
        overflow-wrap: anywhere;
    }

    .couple-course-block small {
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.15;
    }
}

@media (max-width: 360px) {
    .tabbar-item { font-size: 9.5px; padding-left: 1px; padding-right: 1px; }
    .tabbar-item .icon { width: 20px; height: 20px; }
}



@layer components {
    /* Compact couple-space chrome: keep the week switcher and room card from
       dominating the timetable, especially on phones. */
    .couple-shell { gap: 12px; }

    .couple-weekbar {
        min-height: 0;
        padding: 7px 10px;
        gap: 8px;
    }

    .couple-weekbar-main { gap: 4px; }

    .couple-weekbar .icon-btn {
        width: 28px;
        height: 28px;
    }

    .couple-week-title { font-size: 12.5px; }

    .couple-weekbar .btn-sm {
        padding: 3px 8px;
        font-size: 11px;
    }

    .couple-timetable-card { padding: 8px; }

    .couple-day-head-cell,
    .couple-time-head { padding: 7px 3px; }

    .couple-grid-legend {
        gap: 10px;
        padding: 6px 2px 0;
        font-size: 10.5px;
    }

    .couple-room-head {
        flex-direction: row;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px;
    }

    .couple-room-head > div {
        flex: 1;
        min-width: 0;
    }

    .couple-room-head .card-title { font-size: 16px; }

    .couple-room-head .btn-sm {
        flex: none;
        padding: 4px 8px;
        font-size: 11px;
    }

    .couple-room-code {
        margin-top: 6px;
        font-size: 11px;
    }

    .couple-room-code code {
        padding: 2px 8px;
        font-size: 12.5px;
    }

    .couple-members {
        margin-top: 8px;
        gap: 6px;
    }

    .couple-member {
        gap: 6px;
        padding: 4px 8px 4px 4px;
        font-size: 11.5px;
    }

    .couple-avatar {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
}

@layer components {
    .couple-weekbar .icon-btn {
        min-height: 28px;
        height: 28px;
    }

    .couple-weekbar .btn-sm {
        min-height: 28px;
    }

    .couple-room-head {
        padding: 12px;
        gap: 6px;
    }

    .couple-room-head .btn-sm {
        min-height: 28px;
    }

    .couple-room-code {
        margin-top: 4px;
    }

    .couple-members {
        margin-top: 6px;
    }

    .couple-member {
        padding: 3px 7px 3px 3px;
        font-size: 11px;
    }

    .couple-avatar {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .couple-room-head .eyebrow {
        font-size: 10px;
        letter-spacing: .04em;
    }
}

@layer components {
    .couple-week-arrow {
        display: grid;
        place-items: center;
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        flex: none;
        border-radius: var(--r-sm);
        color: var(--text-2);
    }

    .couple-week-arrow .icon { width: 17px; height: 17px; }
    .couple-week-arrow:active { opacity: .6; }

    .couple-week-now {
        min-height: 28px;
        padding: 3px 8px;
        border-radius: var(--r-full);
        color: var(--text-2);
        font-size: 11px;
        font-weight: 600;
        line-height: 1;
        background: var(--surface-2);
    }
}

@layer components {
    .couple-focus-row {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin: 0 0 10px;
    }

    .couple-focus-chip {
        padding: 5px 10px;
        border: 1px solid var(--separator);
        border-radius: var(--r-full);
        background: var(--surface);
        color: var(--text-2);
        font-size: 11.5px;
        font-weight: 600;
        line-height: 1.2;
    }

    .couple-focus-chip.is-active {
        border-color: var(--accent);
        background: var(--accent-soft);
        color: var(--accent);
    }

    .couple-group-days {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .couple-group-day {
        padding: 14px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
    }

    .couple-group-free-label {
        margin: 10px 0 6px;
        font-size: 10px;
        font-weight: 650;
        letter-spacing: .05em;
        color: var(--accent);
        text-transform: uppercase;
    }

    .couple-share-options {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 14px;
    }

    .couple-checkline {
        min-height: 0;
        font-size: 12px;
    }

    .couple-share-select {
        width: auto;
        min-width: 92px;
        padding-top: 6px;
        padding-bottom: 6px;
        font-size: 12px;
    }

    .couple-share-result {
        display: flex;
        gap: 8px;
        margin-top: 12px;
    }

    .couple-share-result .form-input { flex: 1; min-width: 0; }

    .couple-share-list {
        display: grid;
        gap: 8px;
        margin-top: 12px;
    }

    .couple-share-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 0;
        border-top: 1px solid var(--separator);
    }

    .couple-share-item-main { flex: 1; min-width: 0; }
    .couple-share-item-main strong { display: block; font-size: 12px; font-weight: 600; }
    .couple-share-item-main small { display: block; margin-top: 2px; font-size: 10.5px; color: var(--text-3); }

    @media (max-width: 760px) {
        .couple-group-days { grid-template-columns: 1fr; }
        .couple-share-result { flex-direction: column; }
        .couple-share-item { flex-wrap: wrap; }
    }
}

@layer components {
    .couple-password-input {
        width: 100%;
        margin-top: 10px;
    }

    .couple-join-form {
        display: grid;
        gap: 8px;
        margin-top: 12px;
    }

    .couple-join-form .couple-form-row { margin-top: 0; }

    .couple-consent {
        min-height: 0;
        align-items: flex-start;
        font-size: 11.5px;
        line-height: 1.5;
        color: var(--text-2);
    }

    .couple-consent input { margin-top: 2px; }
}

@layer components {
    .couple-common-band--accent {
        background: var(--accent-soft);
        border-top: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
        border-bottom: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
    }
}

@layer components {
    .couple-room-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-bottom: 2px;
    }

    .couple-room-tab {
        padding: 6px 10px;
        border: 1px solid var(--separator);
        border-radius: var(--r-full);
        background: var(--surface);
        color: var(--text-2);
        font-size: 11px;
        font-weight: 600;
    }

    .couple-room-tab.is-active {
        border-color: var(--accent);
        background: var(--accent-soft);
        color: var(--accent);
    }

    .couple-room-tab--add {
        border-style: dashed;
        color: var(--text-3);
    }

    .couple-add-room-panel {
        padding: 14px;
        border: 1px dashed var(--separator-strong);
        border-radius: var(--r-lg);
        background: var(--surface-2);
    }

    .couple-add-room-panel .couple-empty-grid { margin-top: 10px; }
}

@layer components {
    .couple-room-toolbar {
        padding: 8px 10px;
        border: 1px solid var(--separator);
        border-radius: var(--r-lg);
        background: var(--surface);
    }

    .couple-toolbar-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .couple-toolbar-code {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

    .couple-room-label {
        font-size: 10px;
        color: var(--text-3);
    }

    .couple-toolbar-code code {
        font-size: 13px;
        font-weight: 700;
        letter-spacing: .08em;
    }

    .couple-toolbar-code .couple-copy {
        padding: 2px 7px;
        font-size: 10.5px;
    }

    .couple-toolbar-top .btn-sm {
        min-height: 28px;
        padding: 3px 8px;
        font-size: 11px;
    }

    .couple-room-toolbar .couple-weekbar {
        margin-top: 7px;
        padding: 6px 0 0;
        border: 0;
        border-top: 1px solid var(--separator);
        border-radius: 0;
        background: transparent;
    }

    .couple-focus-inline {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 5px;
        margin-left: auto;
    }

    .couple-focus-inline .couple-focus-chip {
        padding: 4px 8px;
        font-size: 10.5px;
    }

    .couple-focus-chip.is-me {
        border-color: transparent;
        background: var(--surface-2);
        color: var(--text-3);
        cursor: default;
    }

    @media (max-width: 760px) {
        .couple-toolbar-top { align-items: flex-start; }
        .couple-room-toolbar .couple-weekbar { align-items: flex-start; }
        .couple-focus-inline { width: 100%; margin-left: 0; }
    }
}

@layer components {
    .couple-member-checks {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 5px;
        margin-left: auto;
    }

    .couple-member-check {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 8px;
        border: 1px solid var(--separator);
        border-radius: var(--r-full);
        background: var(--surface);
        color: var(--text-2);
        font-size: 10.5px;
        line-height: 1.2;
        cursor: pointer;
        user-select: none;
    }

    .couple-member-check:has(input:checked) {
        border-color: var(--accent);
        background: var(--accent-soft);
        color: var(--accent);
    }

    .couple-member-check input {
        width: 12px;
        height: 12px;
        margin: 0;
        accent-color: var(--accent);
    }

    .couple-member-self {
        padding: 4px 8px;
        border-radius: var(--r-full);
        background: var(--surface-2);
        color: var(--text-3);
        font-size: 10.5px;
        line-height: 1.2;
    }

    .couple-overview-body.is-updating {
        opacity: .55;
        transition: opacity .15s ease;
    }

    .couple-lane-course {
        padding: 2px 3px;
        text-align: left;
    }

    .couple-lane-course.is-tiny strong,
    .couple-lane-course.is-tiny small {
        display: none;
    }

    .couple-lane-course:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
    }

    @media (max-width: 760px) {
        .couple-member-checks { width: 100%; margin-left: 0; }
        .couple-room-toolbar .couple-weekbar { align-items: flex-start; }
    }
}


@layer components {
    .couple-common-band--accent {
        background: var(--success-soft);
        border-top: 1px solid color-mix(in srgb, var(--success) 18%, transparent);
        border-bottom: 1px solid color-mix(in srgb, var(--success) 18%, transparent);
    }
}




/* Course detail must not use the mobile bottom-sheet slide: the shell layer
   defines that animation, so this override lives in the last layer. */
@layer utilities {
    #modal-couple-course {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        transition: none !important;
    }
    #modal-couple-course .modal-panel {
        transform: none !important;
        transition: none !important;
        animation: none !important;
    }
}
