:root {
    color-scheme: dark;
    --page-bg: #07111f;
    --panel: rgba(15, 23, 42, 0.94);
    --panel-soft: rgba(30, 41, 59, 0.74);
    --border: rgba(148, 163, 184, 0.22);
    --text: #f8fafc;
    --muted: #b4c1d5;
    --portal-accent: #38bdf8;
    --portal-accent-2: #6366f1;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--portal-accent) 25%, transparent), transparent 33rem),
        radial-gradient(circle at 90% 5%, color-mix(in srgb, var(--portal-accent-2) 22%, transparent), transparent 32rem),
        linear-gradient(145deg, #050b14, var(--page-bg));
}
a { color: inherit; }
button, input, select { font: inherit; }

.access-layout { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; }
.access-card {
    width: min(640px, 100%);
    padding: clamp(24px, 5vw, 46px);
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(18px);
}
.back-link, .admin-link, .signout-link, .topbar-action {
    display: inline-flex;
    color: #bae6fd;
    font-weight: 750;
    text-decoration: none;
}
.back-link:hover, .admin-link:hover, .signout-link:hover, .topbar-action:hover { text-decoration: underline; }
.portal-mark {
    display: grid;
    place-items: center;
    width: 74px;
    height: 74px;
    margin-top: 26px;
    border-radius: 22px;
    font-size: 38px;
    background: linear-gradient(135deg, var(--portal-accent), var(--portal-accent-2));
    box-shadow: 0 16px 40px color-mix(in srgb, var(--portal-accent) 25%, transparent);
}
.eyebrow {
    margin: 20px 0 5px;
    color: var(--portal-accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.06; }
.portal-subtitle { margin: 9px 0; color: #e2e8f0; font-size: 1.12rem; font-weight: 750; }
.access-description, .portal-hero p, .resource-card p, .portal-empty-state p, .directory-hero p, .token-admin-hero p, .token-output-card p {
    color: var(--muted);
    line-height: 1.7;
}
.alert, .notice {
    margin: 22px 0 0;
    padding: 13px 15px;
    border-radius: 13px;
    font-weight: 650;
}
.alert { border: 1px solid rgba(248, 113, 113, 0.5); background: rgba(127, 29, 29, 0.35); color: #fecaca; }
.notice { border: 1px solid rgba(74, 222, 128, 0.45); background: rgba(20, 83, 45, 0.42); color: #bbf7d0; }
.verification-form { display: grid; gap: 16px; margin-top: 24px; }
.verification-form label, .token-form-card label { display: grid; gap: 7px; color: #e2e8f0; font-weight: 750; }
.verification-form input, .token-form-card input, .token-form-card select {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.38);
    border-radius: 13px;
    padding: 14px 15px;
    background: rgba(2, 6, 23, 0.76);
    color: #fff;
    outline: none;
}
.verification-form input:focus, .token-form-card input:focus, .token-form-card select:focus {
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--portal-accent) 18%, transparent);
}
.verification-form button, .token-form-card button, .token-output-heading button {
    border: 0;
    border-radius: 14px;
    padding: 14px 18px;
    color: #04111f;
    background: linear-gradient(135deg, var(--portal-accent), var(--portal-accent-2));
    font-weight: 850;
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease;
}
.verification-form button:hover, .token-form-card button:hover, .token-output-heading button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.access-notes {
    margin: 22px 0;
    padding: 15px;
    border-radius: 15px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 0.9rem;
}
.access-notes p { margin: 7px 0; line-height: 1.55; }
.access-admin-actions { display: flex; flex-wrap: wrap; gap: 10px 20px; }

.portal-topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px clamp(16px, 4vw, 48px);
    border-bottom: 1px solid var(--border);
    background: rgba(5, 11, 20, 0.9);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { margin-right: auto; font-size: 1.25rem; font-weight: 900; text-decoration: none; }
.brand span { color: var(--portal-accent); }
.viewer-chip, .admin-badge, .count-chip {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 0.82rem;
}
.viewer-chip strong { color: #fff; }
.viewer-chip small { color: #94a3b8; }
.portal-container { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 42px 0 70px; }
.portal-hero {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    align-items: center;
    padding: clamp(24px, 5vw, 46px);
    border: 1px solid var(--border);
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(15,23,42,.96), rgba(15,23,42,.72));
    box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.portal-hero .portal-mark { margin: 0; width: 90px; height: 90px; font-size: 46px; }
.portal-hero h1 { font-size: clamp(2.2rem, 5vw, 4rem); }
.resource-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 28px; }
.resource-card, .portal-empty-state {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--panel);
}
.resource-icon { font-size: 32px; }
.resource-card h2, .portal-empty-state h2 { margin: 12px 0 4px; }
.status-pill {
    display: inline-flex;
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--portal-accent) 18%, transparent);
    color: #dff8ff;
    font-size: 0.78rem;
    font-weight: 850;
}
.status-next { background: rgba(245, 158, 11, 0.16); color: #fde68a; }
.portal-empty-state { margin-top: 20px; text-align: center; }
.portal-footer { padding: 24px; text-align: center; color: #7f8ea3; }

.directory-container, .token-admin-container { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 46px 0 74px; }
.directory-hero, .token-admin-hero {
    padding: clamp(24px, 5vw, 44px);
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--panel);
}
.directory-hero h1, .token-admin-hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); }
.portal-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
.portal-link-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: center;
    min-height: 128px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--portal-accent) 12%, #0f172a), #0f172a);
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease;
}
.portal-link-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--portal-accent) 65%, white); }
.portal-card-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 17px; font-size: 30px; background: linear-gradient(135deg, var(--portal-accent), var(--portal-accent-2)); }
.portal-link-card strong { display: block; font-size: 1.18rem; }
.portal-link-card small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.4; }
.portal-card-arrow { font-size: 26px; color: var(--portal-accent); }

.token-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
.token-form-grid-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.token-form-card, .token-output-card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--panel);
}
.token-form-card { display: grid; align-content: start; gap: 15px; }
.token-form-card h2 { margin: 0 0 4px; }
.token-form-featured { border-color: color-mix(in srgb, var(--portal-accent) 58%, var(--border)); box-shadow: 0 18px 45px color-mix(in srgb, var(--portal-accent) 10%, transparent); }
.token-form-card button:disabled, .token-form-card select:disabled { cursor: not-allowed; opacity: .55; transform: none; filter: none; }
.token-form-danger button { background: linear-gradient(135deg, #fb7185, #f97316); }
.form-help { color: var(--muted); line-height: 1.55; font-size: .9rem; }
.schema-notice { margin: 22px 0 0; padding: 15px 17px; border: 1px solid rgba(250, 204, 21, .45); border-radius: 15px; color: #fef3c7; background: rgba(113, 63, 18, .38); line-height: 1.6; }
.schema-notice code { margin: 0 3px; }
.token-output-card { margin-top: 22px; }
.token-output-priority { border-color: color-mix(in srgb, var(--portal-accent) 58%, var(--border)); }
.token-inline-form { margin: 0; }
.token-inline-form button { border: 1px solid rgba(248, 113, 113, .5); border-radius: 10px; padding: 8px 10px; color: #fecaca; background: rgba(127, 29, 29, .38); font-weight: 800; cursor: pointer; }
.token-inline-form button:hover { background: rgba(153, 27, 27, .58); }
.token-output-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.token-output-heading h2 { margin: 0; }
.token-output-heading .eyebrow { margin-top: 0; }
.token-output-heading button { padding: 10px 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 15px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: #cbd5e1; background: rgba(30, 41, 59, .85); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
td { color: #e2e8f0; }
tr:last-child td { border-bottom: 0; }
code { display: inline-block; padding: 5px 8px; border-radius: 8px; color: #fff; background: #020617; font-weight: 850; letter-spacing: .08em; }
.empty-table { padding: 20px; text-align: center; background: var(--panel-soft); border-radius: 14px; }

@media (max-width: 900px) {
    .token-form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .portal-topbar { align-items: flex-start; flex-wrap: wrap; }
    .brand { width: 100%; }
    .portal-hero { grid-template-columns: 1fr; }
    .resource-grid, .portal-card-grid { grid-template-columns: 1fr; }
    .viewer-chip { border-radius: 14px; }
}
@media print {
    body { background: #fff; color: #000; }
    .portal-topbar, .token-admin-hero, .token-form-grid, .notice, .alert, .schema-notice, .token-status-card, .token-output-heading button { display: none !important; }
    .token-admin-container { width: 100%; padding: 0; }
    .token-output-card { border: 0; background: #fff; color: #000; }
    .token-output-card p, td, th { color: #000; }
    code { color: #000; background: #eee; }
}

/* Phase 5: student-published Workspace resources */
.cr-published-resources {
    margin-top: 28px;
    padding: clamp(20px, 4vw, 34px);
    border: 1px solid var(--border);
    border-radius: 28px;
    background: rgba(15, 23, 42, .94);
    color: var(--text);
    box-shadow: 0 22px 65px rgba(0,0,0,.24);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.cr-published-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.cr-published-eyebrow { margin: 0 0 5px; color: var(--portal-accent); font-size: .72rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.cr-published-heading h2 { margin: 0; color: var(--text); font-size: clamp(1.65rem, 4vw, 2.45rem); }
.cr-published-heading p { max-width: 760px; margin: 8px 0 0; color: var(--muted); line-height: 1.65; }
.cr-published-count { padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; color: #dbeafe; background: var(--panel-soft); font-size: .82rem; font-weight: 850; }
.cr-published-sections { display: grid; gap: 18px; margin-top: 22px; }
.cr-published-section { padding: 18px; border: 1px solid var(--border); border-radius: 20px; background: rgba(2, 6, 23, .46); }
.cr-published-section > header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; margin-bottom: 13px; }
.cr-published-section > header h3 { margin: 0; color: #fff; font-size: 1.16rem; }
.cr-published-section > header p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.cr-published-section > header > strong { color: var(--portal-accent); font-size: .82rem; white-space: nowrap; }
.cr-published-section-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--portal-accent) 18%, #111827); font-size: 1.35rem; }
.cr-resource-folder { margin-top: 10px; border: 1px solid var(--border); border-radius: 15px; background: rgba(15, 23, 42, .64); overflow: hidden; }
.cr-resource-folder > summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.cr-resource-folder > summary strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #f8fafc; }
.cr-resource-folder > summary small { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.cr-resource-folder-content { padding: 0 10px 10px; }
.cr-resource-depth-1 { margin-left: 12px; }
.cr-resource-depth-2 { margin-left: 22px; }
.cr-resource-depth-3, .cr-resource-depth-4 { margin-left: 30px; }
.cr-published-files { display: grid; gap: 9px; margin-top: 9px; }
.cr-published-file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: rgba(30, 41, 59, .62); }
.cr-published-file-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(2, 6, 23, .7); font-size: 1.25rem; }
.cr-published-file-copy { min-width: 0; }
.cr-published-file-copy strong, .cr-published-file-copy span, .cr-published-file-copy small { display: block; min-width: 0; overflow-wrap: anywhere; }
.cr-published-file-copy strong { color: #fff; }
.cr-published-file-copy span { margin-top: 2px; color: #cbd5e1; font-size: .86rem; }
.cr-published-file-copy small { margin-top: 4px; color: var(--muted); line-height: 1.45; }
.cr-published-file-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.cr-published-file-meta span { padding: 3px 7px; border-radius: 999px; color: #cbd5e1; background: rgba(2, 6, 23, .68); font-size: .7rem; font-weight: 800; }
.cr-published-file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.cr-published-file-actions a { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 8px 11px; border: 1px solid var(--border); border-radius: 10px; color: #fff; background: color-mix(in srgb, var(--portal-accent) 18%, #0f172a); text-decoration: none; font-size: .8rem; font-weight: 850; }
.cr-published-file-actions a:hover { border-color: var(--portal-accent); }
.cr-published-empty, .cr-published-message { margin-top: 20px; padding: 28px; border: 1px dashed var(--border); border-radius: 18px; color: var(--muted); background: rgba(2,6,23,.35); text-align: center; }
.cr-published-empty > span { font-size: 2.5rem; }
.cr-published-empty h3 { margin: 8px 0 0; color: #fff; }
.cr-published-empty p { margin: 6px 0 0; line-height: 1.55; }
.cr-published-message.is-warning { color: #fde68a; border-color: rgba(245,158,11,.45); background: rgba(120,53,15,.3); }
@media (max-width: 700px) {
    .cr-published-section > header { grid-template-columns: auto minmax(0, 1fr); }
    .cr-published-section > header > strong { grid-column: 2; }
    .cr-published-file { grid-template-columns: auto minmax(0, 1fr); }
    .cr-published-file-actions { grid-column: 2; justify-content: flex-start; }
    .cr-resource-depth-1, .cr-resource-depth-2, .cr-resource-depth-3, .cr-resource-depth-4 { margin-left: 8px; }
}

.main-hero-title{
    font-size: clamp(2.15rem, 4.35vw, 3.45rem);
    line-height: 1.02;
    letter-spacing: -0.05em;
    max-width: 100%;
}
@media (min-width: 900px) {
    .main-hero-title{
        white-space: nowrap;
    }
}

/* Student account and class magic-link additions */
.portal-account-nav{display:flex;align-items:center;gap:.55rem;flex-wrap:wrap}.student-account-chip{display:inline-flex;align-items:center;padding:.45rem .7rem;border-radius:999px;background:rgba(37,99,235,.12);font-weight:800}.student-account-entry{margin-top:1.2rem;padding:1rem;border:1px solid rgba(99,102,241,.25);border-radius:14px;background:rgba(99,102,241,.08)}.student-account-entry p{margin:.35rem 0 .75rem}.student-account-entry .admin-link{margin-right:.55rem}.magic-link-cell{max-width:420px}.magic-link-value{display:block;overflow-wrap:anywhere;font-size:.78rem}.token-inline-actions{display:flex;flex-wrap:wrap;gap:.4rem}.token-inline-actions form{margin:0}.copy-link-button{white-space:nowrap}
