:root {
    /* ClassFlow Calm Professional. TenantTheme overrides only the brand tokens. */
    --cf-color-primary: #315FBE;
    --cf-color-on-primary: #FFFFFF;
    --cf-color-secondary: #6A5ACD;
    --cf-color-on-secondary: #FFFFFF;

    --cf-color-primary-soft: color-mix(in srgb, var(--cf-color-primary) 9%, #FFFFFF);
    --cf-color-primary-subtle: color-mix(in srgb, var(--cf-color-primary) 5%, #FFFFFF);
    --cf-color-primary-hover: color-mix(in srgb, var(--cf-color-primary) 88%, #000000);
    --cf-color-primary-active: color-mix(in srgb, var(--cf-color-primary) 78%, #000000);
    --cf-color-secondary-soft: color-mix(in srgb, var(--cf-color-secondary) 9%, #FFFFFF);

    --cf-color-background: #F6F8FB;
    --cf-color-surface: #FFFFFF;
    --cf-color-surface-muted: #F8FAFC;
    --cf-color-surface-strong: #F1F5F9;
    --cf-color-text: #17263A;
    --cf-color-text-muted: #5F6F82;
    --cf-color-text-subtle: #7B8998;
    --cf-color-border: #E2E8F0;
    --cf-color-border-strong: #CBD5E1;

    /* Semantic colors are ClassFlow-owned and are not tenant branding tokens. */
    --cf-color-success: #0F7A4D;
    --cf-color-warning: #A15C00;
    --cf-color-danger: #B42318;
    --cf-color-info: #0B63CE;
    --cf-color-focus: #0B63CE;

    --cf-radius-sm: 8px;
    --cf-radius-md: 12px;
    --cf-radius-lg: 16px;
    --cf-radius-xl: 20px;
    --cf-radius-round: 999px;

    --cf-space-1: 4px;
    --cf-space-2: 8px;
    --cf-space-3: 12px;
    --cf-space-4: 16px;
    --cf-space-5: 20px;
    --cf-space-6: 24px;
    --cf-space-8: 32px;
    --cf-space-10: 40px;
    --cf-space-12: 48px;
    --cf-space-16: 64px;

    --cf-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --cf-shadow-1: 0 1px 2px rgba(23, 38, 58, .06), 0 4px 12px rgba(23, 38, 58, .04);
    --cf-shadow-2: 0 12px 32px rgba(23, 38, 58, .12);
    --cf-motion-fast: 120ms;
    --cf-motion-base: 180ms;
    --cf-motion-panel: 230ms;
    --cf-ease-standard: cubic-bezier(.2, 0, 0, 1);

    --cf-content-reading: 760px;
    --cf-content-standard: 1120px;
    --cf-content-wide: 1280px;

    color: var(--cf-color-text);
    background: var(--cf-color-background);
    font-family: var(--cf-font-family);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    min-width: 320px;
    background: var(--cf-color-background);
    color: var(--cf-color-text);
    font-size: 16px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--cf-color-focus) 72%, #FFFFFF);
    outline-offset: 3px;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
    font-size: clamp(1.875rem, 2.4vw, 2rem);
    font-weight: 750;
    letter-spacing: -.028em;
    line-height: 1.15;
    margin-bottom: var(--cf-space-2);
}
h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1.25;
}
.material-symbols-rounded { vertical-align: middle; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.cf-tenant-theme,
.cf-shell { min-height: 100dvh; }

.cf-tenant-theme { font-family: var(--cf-font-family); }

/* Future style-template hook. Active Studio is the initial ClassFlow default. */
.cf-tenant-theme[data-cf-template="active-studio"],
.cf-branding-preview-card[data-cf-template="active-studio"] {
    --cf-template-card-radius: var(--cf-radius-lg);
    --cf-template-nav-radius: 10px;
    --cf-template-icon-radius: 12px;
}

.cf-tenant-theme[data-cf-template="calm-flow"],
.cf-branding-preview-card[data-cf-template="calm-flow"] {
    --cf-template-card-radius: 20px;
    --cf-template-nav-radius: 16px;
    --cf-template-icon-radius: 999px;
}

.cf-public-page,
.cf-entry-main {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(48px, 12vh, 120px) var(--cf-space-6);
}

.cf-eyebrow,
.cf-menu-label,
.cf-admin-nav p {
    color: var(--cf-color-text-subtle);
    font-size: .75rem;
    font-weight: 750;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.cf-lead { color: var(--cf-color-text-muted); font-size: 1.0625rem; line-height: 1.65; }

/* Reusable page-intro pattern. */
.cf-page-intro {
    max-width: 720px;
    margin-bottom: var(--cf-space-6);
}
.cf-page-intro .cf-eyebrow { margin-bottom: var(--cf-space-2); }
.cf-page-title { margin-bottom: var(--cf-space-2); }
.cf-page-subtitle,
.cf-page-date {
    color: var(--cf-color-text-muted);
    font-size: .975rem;
    line-height: 1.55;
    margin: 0;
    max-width: 620px;
}
.cf-page-date {
    font-weight: 500;
    text-transform: capitalize;
}

/* Calm Professional landing canvas: wider than reading content, centered in the application viewport. */
.cf-home-stage {
    margin: 0 auto;
    max-width: 920px;
    width: 100%;
}
.cf-home-stage .cf-page-intro {
    margin-bottom: 22px;
    max-width: 720px;
}

.cf-button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    gap: var(--cf-space-2);
    justify-content: center;
    min-height: 44px;
    padding: 9px 16px;
    text-decoration: none;
    font-weight: 700;
    transition: background-color var(--cf-motion-fast) var(--cf-ease-standard), border-color var(--cf-motion-fast) var(--cf-ease-standard), color var(--cf-motion-fast) var(--cf-ease-standard), box-shadow var(--cf-motion-fast) var(--cf-ease-standard), transform var(--cf-motion-fast) var(--cf-ease-standard);
}
.cf-button .material-symbols-rounded { font-size: 19px; }
.cf-button:active { transform: translateY(1px); }
.cf-button-primary {
    background: var(--cf-color-primary);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--cf-color-primary) 20%, transparent);
    color: var(--cf-color-on-primary);
}
.cf-button-primary:hover { background: var(--cf-color-primary-hover); box-shadow: 0 3px 8px color-mix(in srgb, var(--cf-color-primary) 18%, transparent); }
.cf-button-primary:active { background: var(--cf-color-primary-active); }
.cf-button-secondary { background: var(--cf-color-secondary); color: var(--cf-color-on-secondary); }
.cf-button-ghost { background: transparent; border-color: var(--cf-color-border); }
.cf-button-ghost:hover { background: var(--cf-color-surface-muted); border-color: var(--cf-color-border-strong); }
.cf-button-danger { background: var(--cf-color-danger); color: #FFFFFF; }

/* App shell */
.cf-header {
    align-items: center;
    backdrop-filter: blur(14px);
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid color-mix(in srgb, var(--cf-color-border) 90%, transparent);
    display: grid;
    gap: var(--cf-space-4);
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
    min-height: 68px;
    padding: 0 clamp(var(--cf-space-4), 2.5vw, var(--cf-space-8));
    position: sticky;
    top: 0;
    z-index: 40;
}

.cf-wordmark {
    color: var(--cf-color-primary);
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1;
    text-decoration: none;
}

.cf-header-divider {
    align-self: stretch;
    background: var(--cf-color-border);
    height: 22px;
    margin: auto 4px;
    width: 1px;
}

.cf-header-actions { align-items: center; display: flex; gap: var(--cf-space-1); justify-self: end; }
.cf-switcher,
.cf-account-menu { position: relative; }

.cf-switcher summary,
.cf-account-menu summary,
.cf-admin-drawer summary {
    align-items: center;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    gap: var(--cf-space-1);
    list-style: none;
    min-height: 44px;
    padding: 0 var(--cf-space-2);
    transition: background-color var(--cf-motion-fast) var(--cf-ease-standard), border-color var(--cf-motion-fast) var(--cf-ease-standard), color var(--cf-motion-fast) var(--cf-ease-standard);
}
.cf-switcher summary:hover,
.cf-account-menu summary:hover { background: var(--cf-color-surface-strong); }
summary::-webkit-details-marker { display: none; }

.cf-switcher-menu {
    background: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-lg);
    box-shadow: var(--cf-shadow-2);
    min-width: 280px;
    padding: var(--cf-space-2);
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 50;
}

.cf-switcher-menu a,
.cf-switcher-menu button {
    align-items: center;
    background: none;
    border: 0;
    border-radius: 10px;
    color: inherit;
    display: flex;
    gap: var(--cf-space-3);
    min-height: 44px;
    padding: 10px;
    text-align: left;
    text-decoration: none;
    width: 100%;
}
.cf-switcher-menu a:hover,
.cf-switcher-menu button:hover { background: var(--cf-color-surface-muted); }
.cf-switcher-menu small { color: var(--cf-color-text-muted); display: block; margin-top: 2px; }
.cf-org-mark {
    align-items: center;
    background: var(--cf-color-primary-soft);
    border-radius: 10px;
    color: var(--cf-color-primary);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: .82rem;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}
.cf-switcher-menu .is-current { background: var(--cf-color-primary-subtle); }

.cf-primary-nav,
.cf-desktop-nav {
    align-items: center;
    display: flex;
    gap: 2px;
    justify-content: center;
    min-width: 0;
}

.cf-primary-nav a,
.cf-desktop-nav a {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--cf-template-nav-radius, 10px);
    color: var(--cf-color-text-muted);
    display: inline-flex;
    gap: 7px;
    min-height: 42px;
    padding: 0 12px;
    text-decoration: none;
    transition: background-color var(--cf-motion-fast) var(--cf-ease-standard), border-color var(--cf-motion-fast) var(--cf-ease-standard), color var(--cf-motion-fast) var(--cf-ease-standard);
    white-space: nowrap;
}
.cf-primary-nav a .material-symbols-rounded,
.cf-desktop-nav a .material-symbols-rounded { font-size: 19px; }
.cf-primary-nav a:hover,
.cf-desktop-nav a:hover { background: var(--cf-color-surface-muted); color: var(--cf-color-text); }
.cf-primary-nav a.active,
.cf-desktop-nav a.active {
    background: var(--cf-color-primary-subtle);
    border-color: color-mix(in srgb, var(--cf-color-primary) 10%, var(--cf-color-border));
    color: var(--cf-color-primary);
    font-weight: 700;
}

.cf-main { padding: var(--cf-space-10) clamp(var(--cf-space-4), 3vw, var(--cf-space-8)); }
.cf-participant-main { margin: 0 auto; max-width: var(--cf-content-standard); }
.cf-instructor-main { margin: 0 auto; max-width: var(--cf-content-standard); }
.cf-admin-main { margin-left: 256px; max-width: 1200px; }

/* Compact, reusable empty state. */
.cf-empty-state {
    background: var(--cf-color-surface);
    border: 1px solid color-mix(in srgb, var(--cf-color-border) 88%, transparent);
    border-radius: var(--cf-template-card-radius, var(--cf-radius-lg));
    box-shadow: 0 1px 2px rgba(23, 38, 58, .035);
    margin-inline: auto;
    max-width: 840px;
    padding: 30px var(--cf-space-8) 32px;
    text-align: center;
    width: 100%;
}
.cf-home-stage > .cf-empty-state { max-width: none; }
.cf-empty-state h2 {
    font-size: 1.0625rem;
    line-height: 1.35;
    margin-bottom: 10px;
}
.cf-empty-state p {
    color: var(--cf-color-text-muted);
    font-size: .9375rem;
    line-height: 1.55;
    margin: 0 auto;
    max-width: 500px;
}
.cf-empty-icon-wrap {
    align-items: center;
    background: var(--cf-color-primary-subtle);
    border: 1px solid color-mix(in srgb, var(--cf-color-primary) 8%, var(--cf-color-border));
    border-radius: 11px;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    margin-bottom: 18px;
    width: 38px;
}
.cf-empty-icon { color: var(--cf-color-primary); font-size: 21px; }
.cf-empty-action { margin-top: 18px; }
.cf-home-primary-action { min-height: 42px; padding: 8px 14px; font-size: .9375rem; }
.cf-alert { border-radius: var(--cf-radius-sm); padding: var(--cf-space-3); }
.cf-alert-info { background: #E7F0FB; }
.cf-skeleton { animation: cf-pulse 1.5s ease-in-out infinite; background: linear-gradient(90deg,#edf1f5,#f7f9fb,#edf1f5); border-radius: var(--cf-radius-sm); }
.cf-toast { background: var(--cf-color-text); border-radius: var(--cf-radius-sm); bottom: auto; color: #FFFFFF; max-width: min(360px, calc(100vw - 48px)); padding: var(--cf-space-3); position: fixed; right: 24px; top: calc(68px + var(--cf-space-4)); z-index: 60; }
.cf-toast-error { background: var(--cf-color-danger); }

.cf-role-grid { display: grid; gap: var(--cf-space-4); grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); margin-top: var(--cf-space-8); }
.cf-role-card { background: var(--cf-color-surface); border: 1px solid var(--cf-color-border); border-radius: var(--cf-radius-lg); display: grid; gap: var(--cf-space-2); min-height: 190px; padding: var(--cf-space-6); text-decoration: none; }
.cf-role-card:hover { border-color: var(--cf-color-primary); box-shadow: var(--cf-shadow-1); }
.cf-role-card .material-symbols-rounded:first-child { color: var(--cf-color-primary); font-size: 32px; }
.cf-role-card .material-symbols-rounded:last-child { justify-self: end; }

.cf-admin-sidebar { background: #102A43; color: #EAF2F8; bottom: 0; left: 0; overflow-y: auto; padding: var(--cf-space-6) var(--cf-space-3); position: fixed; top: 68px; width: 256px; }
.cf-admin-sidebar .cf-wordmark { color: #FFFFFF; }
.cf-sidebar-tenant { color: #B7C7D6; font-size: .9rem; margin: var(--cf-space-2) 0 var(--cf-space-6); overflow: hidden; text-overflow: ellipsis; }
.cf-admin-nav { display: grid; gap: 2px; }
.cf-admin-nav a { align-items: center; border-radius: var(--cf-radius-sm); display: flex; gap: var(--cf-space-2); min-height: 42px; padding: 0 var(--cf-space-2); text-decoration: none; }
.cf-admin-nav a.active,
.cf-admin-nav a:hover { background: rgba(255,255,255,.14); }
.cf-admin-nav p { color: #AFC3D5; margin: var(--cf-space-4) var(--cf-space-2) var(--cf-space-1); }
.cf-admin-drawer { display: none; }

.cf-bottom-nav {
    backdrop-filter: blur(14px);
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--cf-color-border);
    bottom: 0;
    box-shadow: 0 -4px 16px rgba(23,38,58,.04);
    display: none;
    justify-content: space-around;
    left: 0;
    padding: var(--cf-space-1) var(--cf-space-2) calc(var(--cf-space-1) + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 40;
}
.cf-bottom-nav a {
    align-items: center;
    color: var(--cf-color-text-muted);
    display: flex;
    flex: 1;
    flex-direction: column;
    font-size: .72rem;
    gap: 2px;
    justify-content: center;
    min-height: 56px;
    text-decoration: none;
}
.cf-bottom-nav a .material-symbols-rounded {
    align-items: center;
    border-radius: 10px;
    display: inline-flex;
    font-size: 21px;
    height: 28px;
    justify-content: center;
    transition: background-color var(--cf-motion-fast) var(--cf-ease-standard), color var(--cf-motion-fast) var(--cf-ease-standard);
    width: 36px;
}
.cf-bottom-nav a.active { color: var(--cf-color-primary); font-weight: 700; }
.cf-bottom-nav a.active .material-symbols-rounded { background: var(--cf-color-primary-subtle); }

#blazor-error-ui { background: #FFF4E5; bottom: 0; display: none; left: 0; padding: 12px 16px; position: fixed; right: 0; z-index: 100; }

@keyframes cf-pulse { 50% { opacity: .55; } }

@media (prefers-reduced-motion: reduce) {
    *, *:before, *:after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Tablet: identity/actions on the first row, primary navigation on the second row. */
@media (min-width: 640px) and (max-width: 959.98px) {
    .cf-header {
        gap: 0 var(--cf-space-4);
        grid-template-columns: minmax(0,1fr) auto;
        min-height: 104px;
        padding: 0 var(--cf-space-6);
    }
    .cf-header-identity,
    .cf-header-actions { min-height: 56px; }
    .cf-primary-nav,
    .cf-desktop-nav {
        border-top: 1px solid var(--cf-color-border);
        grid-column: 1 / -1;
        justify-content: flex-start;
        margin: 0 calc(var(--cf-space-6) * -1);
        min-height: 48px;
        overflow-x: auto;
        padding: 0 var(--cf-space-6);
        scrollbar-width: none;
    }
    .cf-primary-nav::-webkit-scrollbar,
    .cf-desktop-nav::-webkit-scrollbar { display: none; }
    .cf-primary-nav a,
    .cf-desktop-nav a { min-height: 40px; }
    .cf-admin-sidebar { top: 104px; }
    .cf-toast { top: calc(104px + var(--cf-space-4)); }
    .cf-main { padding: var(--cf-space-8) var(--cf-space-6); }
}

/* Mobile: compact top bar + fixed bottom navigation. */
@media (max-width: 639.98px) {
    .cf-header {
        display: flex;
        gap: var(--cf-space-2);
        justify-content: space-between;
        min-height: 58px;
        padding: 0 var(--cf-space-4);
    }
    .cf-header-divider { height: 20px; margin-left: 0; margin-right: 0; }
    .cf-primary-nav,
    .cf-desktop-nav { display: none; }
    .cf-bottom-nav { display: flex; }
    .cf-main { padding: var(--cf-space-6) var(--cf-space-4) calc(88px + env(safe-area-inset-bottom)); }
    .cf-page-intro { margin-bottom: var(--cf-space-5); }
    .cf-page-subtitle,
    .cf-page-date { font-size: .925rem; }
    .cf-home-stage .cf-page-intro { margin-bottom: var(--cf-space-5); }
    .cf-empty-state { padding: var(--cf-space-6) var(--cf-space-4); }
    .cf-admin-sidebar { display: none; }
    .cf-admin-drawer { background: var(--cf-color-surface); border-bottom: 1px solid var(--cf-color-border); display: block; }
    .cf-admin-drawer summary { padding: 0 var(--cf-space-4); }
    .cf-admin-drawer .cf-admin-nav { background: var(--cf-color-surface); padding: var(--cf-space-2) var(--cf-space-4) var(--cf-space-4); }
    .cf-admin-drawer .cf-admin-nav p { color: var(--cf-color-text-muted); }
    .cf-admin-main { margin-left: 0; }
    .cf-toast { bottom: auto; left: auto; max-width: calc(100vw - var(--cf-space-8)); right: var(--cf-space-4); top: calc(58px + var(--cf-space-3) + env(safe-area-inset-top)); }
}
