:root {
    color-scheme: light;
    background: #f1f5f8;
    --navy: #10213c;
    --ink: #162841;
    --muted: #53647a;
    --border: #d5e0e9;
    --paper: #fff;
    --teal: #006e65;
    --teal-hover: #005a54;
    --teal-light: #eaf7f3;
    --alert: #9c2e35;
    --screen: #0d1c30;
    font-family: Inter, "Segoe UI", sans-serif;
    color: var(--ink);
    line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

.topbar { background: var(--navy); color: white; }
.topbar-inner {
    max-width: 1260px;
    min-height: 66px;
    margin-inline: auto;
    padding-inline: clamp(14px, 4vw, 36px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    min-height: 44px;
    display: inline-flex;
    gap: 10px;
    align-items: center;
    text-decoration: none;
    color: white;
    font-size: 1.08rem;
    font-weight: 780;
    letter-spacing: .035em;
}
.mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    background: #d6f4ec;
    color: #005c54;
    border-radius: 9px;
    font-weight: 800;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.quiet-link { color: var(--teal); font-weight: 680; text-underline-offset: 3px; }
.topbar .quiet-link { color: #d5ede9; }
:is(a, input, button):focus-visible { outline: 3px solid #008a7f; outline-offset: 3px; }
.topbar :is(a, button):focus-visible { outline-color: #93eadb; }

.layout { max-width: 1260px; margin: 0 auto; padding: 30px clamp(14px, 4vw, 36px) 48px; }
.intro { margin-bottom: 24px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -.045em; }
h2 { font-size: 1.2rem; letter-spacing: -.018em; }
h3 { font-size: 1.04rem; }
.intro p, .muted { color: var(--muted); }
.intro p { margin: 8px 0 0; }
.muted { margin: 7px 0 0; }
.session-label { font-size: .9rem; overflow-wrap: anywhere; }

.panel {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--paper);
    padding: clamp(16px, 3vw, 24px);
}
.join-panel, .login-panel { max-width: 650px; }
.login-panel { max-width: 460px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-pill {
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 100px;
    padding: 4px 9px;
    font-size: .8rem;
    font-weight: 720;
    white-space: nowrap;
}
.status-pill[data-state="waiting"], .status-pill[data-state="ended"] {
    background: #edf1f5;
    color: #40526a;
}
.status-pill[data-state="joined"] { background: #e5eef9; color: #234f80; }
.status-pill[data-state="sharing"] { background: #d9f5e9; color: #005b50; }

button, input { font: inherit; }
button {
    border: 1px solid transparent;
    font-weight: 690;
    border-radius: 9px;
    cursor: pointer;
    min-height: 44px;
    padding: 8px 14px;
}
button:disabled { opacity: .62; cursor: default; }
.primary { background: var(--teal); color: white; }
.primary:hover:not(:disabled) { background: var(--teal-hover); }
.secondary { background: var(--paper); color: var(--ink); border-color: var(--border); }
.secondary:hover:not(:disabled) { background: #eef4f9; }
.stop { background: var(--alert); color: white; }
.stop:hover:not(:disabled) { background: #86252b; }
.compact-button { font-size: .9rem; }
input {
    width: 100%;
    padding: 9px 11px;
    min-height: 44px;
    border: 1px solid #a8b9c9;
    border-radius: 8px;
    background: white;
    color: var(--ink);
}
.field { display: grid; gap: 5px; min-width: 0; }
.field label { font-weight: 650; font-size: .9rem; }
.form-row, .stack-form { margin-top: 16px; display: grid; gap: 12px; }
.form-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.stack-form { align-items: start; }
.stack-form button { justify-self: start; }
.form-error, .feedback { margin: 10px 0 0; font-size: .94rem; }
.form-error, .feedback[data-error="true"] { color: var(--alert); }
.notice { color: var(--muted); padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--paper); }

.participant-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.quiz-list { display: grid; margin-top: 17px; gap: 8px; }
.quiz {
    padding: 12px 14px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #f8fafc;
}
.quiz:hover { border-color: #96adaf; background: var(--teal-light); }
.quiz small { display: block; color: var(--muted); font-size: .87rem; margin-top: 2px; }
.course-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; }
.share-actions { margin-top: 15px; display: flex; gap: 8px; }
.screen {
    background: var(--screen);
    color: #d9e8f2;
    border-radius: 9px;
    overflow: hidden;
    padding: 0;
    aspect-ratio: 16 / 9;
    min-height: 120px;
    display: grid;
    place-items: center;
}
.screen video, .screen img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.screen-empty { padding: 18px; text-align: center; }
.preview, .viewer { margin-top: 13px; }

.stats {
    margin: 0 0 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.stats div { background: var(--paper); border: 1px solid var(--border); padding: 13px 17px; border-radius: 11px; }
.stats .highlight { background: var(--teal-light); border-color: #beded6; }
.stats dt { color: var(--muted); font-size: .92rem; font-weight: 650; }
.stats dd { margin: 3px 0 0; font-size: 1.65rem; font-weight: 790; line-height: 1.1; }
.admin-grid { display: grid; grid-template-columns: minmax(260px, .65fr) minmax(0, 1.35fr); align-items: start; gap: 16px; }
.invitation { border: 1px solid #b9ddd3; border-radius: 9px; background: var(--teal-light); padding: 12px; margin-top: 15px; display: grid; gap: 8px; }
.invitation button { justify-self: start; }
.session-list { display: grid; gap: 7px; padding: 0; list-style: none; margin: 16px 0 0; }
.session-list li { min-width: 0; }
.session-button {
    width: 100%;
    min-width: 0;
    text-align: left;
    background: var(--paper);
    color: var(--ink);
    border-color: var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.session-button:hover { background: #f3f7fa; }
.session-button[aria-pressed="true"] { background: var(--teal-light); border-color: var(--teal); }
.session-button > span:first-child { overflow-wrap: anywhere; }
.viewer-meta { display: flex; min-height: 44px; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; }
.viewer-meta p { margin: 0; font-size: .88rem; }
.events { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 8px; }
.event-list { list-style: none; padding: 0; margin: 8px 0 0; }
.event-list li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #ecf0f3; padding-block: 7px; }
.event-list time { color: var(--muted); font-size: .9rem; white-space: nowrap; }

@media (max-width: 770px) {
    .participant-grid, .admin-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
    .layout { padding-top: 20px; }
    .form-row { grid-template-columns: minmax(0, 1fr); }
    .form-row button { justify-self: start; }
    .stats { gap: 6px; }
    .stats div { padding-inline: 8px; }
    .stats dt { font-size: .77rem; }
    .panel-head { gap: 6px; flex-wrap: wrap; }
    .top-actions .quiet-link { font-size: .78rem; text-align: right; }
}
