:root {
  color-scheme: light;
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-raised: #edf3fc;
  --line: #d5dbe3;
  --text: #202124;
  --muted: #515b68;
  --accent: #0b57d0;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --radius: 18px;
  font-family: Roboto, Arial, system-ui, sans-serif;
  font-synthesis: none;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button, .button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
.topbar {
  height: 76px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; border-bottom: 1px solid #0b57d010;
  background: #f8fafd; position: relative; z-index: 2;
}
.wordmark { display: inline-flex; gap: 11px; align-items: center; text-decoration: none; font-size: 1.28rem; font-weight: 800; letter-spacing: -.045em; }
#actions { display: flex; gap: 10px; align-items: center; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 11px; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); font-size: .95rem; font-weight: 800; line-height: 1.2;
}
.button:hover { filter: brightness(1.08); }
.secondary { background: var(--surface-raised); color: var(--text); border-color: var(--line); }
.danger { background: #fce8e6; color: #a12820; border-color: #f0bcb6; }
.text-button { background: transparent; border: 0; padding: 6px 2px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.landing {
  min-height: calc(100svh - 76px); display: grid; align-items: center; justify-items: center;
  padding: clamp(36px, 7vw, 88px) 18px;
  background: radial-gradient(ellipse at 50% 31%, #383361 0%, #1a1c30 45%, transparent 75%),
    radial-gradient(circle, #c8c1ff24 1px, transparent 1.5px) 50% 50% / 22px 22px, #141625;
}
.panel {
  width: min(100%, 480px); background: #ffffff; border: 1px solid #444865;
  border-radius: 26px; padding: clamp(24px, 6vw, 45px);
  box-shadow: 0 22px 80px #06071080, inset 0 1px 0 #ffffff0c;
}
.join-panel { text-align: center; }
.join-panel h1 { font-family: "Titan One", Nunito, system-ui, sans-serif; font-weight: 400; letter-spacing: -.04em; }
.panel-icon {
  display: inline-grid; place-items: center; width: 68px; height: 68px; margin-bottom: 19px;
  border: 1px solid #626391; border-radius: 22px; background: #353759; color: #e0daff;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 2.75rem); letter-spacing: -.065em; line-height: 1.03; font-weight: 850; }
.description { color: var(--muted); line-height: 1.5; margin-top: 12px; }
.form { display: grid; gap: 15px; margin-top: 24px; text-align: left; }
.form label, .code-field { display: grid; gap: 7px; color: #354354; font-weight: 700; font-size: .95rem; }
input, textarea {
  width: 100%; color: var(--text); background: #ffffff; border: 1px solid #89939f;
  min-height: 46px; border-radius: 11px; padding: 10px 12px;
}
input::placeholder, textarea::placeholder { color: #858ba9; }
textarea { min-height: 118px; resize: vertical; }
.code-input {
  font-size: clamp(2rem, 8vw, 2.8rem); line-height: 1; font-weight: 800; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: .34em; text-indent: .34em; height: 78px;
  margin-bottom: 2px; display: grid; place-content: center;
  background: #ffffff; border: 1px solid #89939f; border-radius: 11px;
  color: var(--text); white-space: nowrap; overflow: hidden;
}
.code-input:empty::before { content: "0000"; color: #858ba9; pointer-events: none; }
.join-panel .button, .auth-panel .button { width: 100%; min-height: 50px; }
.status { color: var(--muted); font-size: .95rem; line-height: 1.45; }
.status.error { color: var(--danger); }
.auth-panel .divider { display: flex; align-items: center; gap: 12px; margin-top: 19px; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-options { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 12px; margin-top: 13px; }
.auth-panel #google { margin-top: 22px; }
.teacher-home .button { margin-top: 20px; width: 100%; }
.room {
  width: min(100% - 36px, 1440px); margin: 30px auto 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 325px); gap: 22px;
}
.room-heading { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.room-heading h1 { font-size: clamp(1.9rem, 4vw, 2.65rem); }
.room-controls, .share-actions, .code-pill { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.code-pill {
  background: var(--surface); border: 1px solid var(--line); padding: 4px 5px 4px 13px; border-radius: 12px;
  color: var(--muted); font-size: .89rem; min-height: 44px;
}
.code-pill strong { font-size: 1.14rem; color: var(--text); letter-spacing: .13em; font-variant-numeric: tabular-nums; }
.icon-button { min-width: 38px; min-height: 36px; background: transparent; color: inherit; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 8px; }
.icon-button:hover { background: #0b57d010; }
.room-main { min-width: 0; }
.stage {
  width: 100%; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; position: relative;
  background: radial-gradient(ellipse at 50% 42%, #2d304a, #161827 70%); border: 1px solid var(--line); border-radius: var(--radius);
}
.stage:fullscreen { border: 0; border-radius: 0; background: #000; }
.stage video, .annotation { position: absolute; display: block; }
.stage video { width: 100%; height: 100%; inset: 0; object-fit: contain; pointer-events: none; }
.annotation { z-index: 1; color: red; }
.annotation.active { touch-action: none; cursor: none; }
.annotation-pointer-layer { position: absolute; z-index: 2; overflow: hidden; pointer-events: none; }
.stage video[hidden] ~ .annotation-pointer-layer { display: none; }
.annotation-pointer-layer svg {
  position: absolute; inset: 0 auto auto 0; display: block; will-change: transform;
  fill: currentColor; stroke: #171926; stroke-width: 2; stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px #0008);
}
.session-badge {
  position: absolute; z-index: 2; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: .12em; padding: .25em .6em .32em;
  border: 1px solid #0b57d055; border-radius: .5em; color: var(--text);
  background: #ffffffee; box-shadow: 0 4px 18px #0005;
  white-space: nowrap; pointer-events: none; user-select: none;
}
.session-badge span:first-child { font-size: .45em; color: var(--muted); }
.session-badge strong { line-height: 1; letter-spacing: .11em; font-variant-numeric: tabular-nums; }
.session-badge.movable { cursor: grab; pointer-events: auto; touch-action: none; }
.session-badge.movable:active { cursor: grabbing; }
.code-resize {
  position: absolute; right: 3px; bottom: 3px; width: 13px; height: 13px;
  border: solid var(--accent); border-width: 0 2px 2px 0; border-radius: 0 0 4px 0;
  cursor: nwse-resize;
}
.tool.shape-select { appearance: none; padding-right: 23px; cursor: pointer; }
.tool.shape-select, .form select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 12px center, right 8px center;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.shape-select:valid:not([data-idle]) { color: var(--text); }
.form select {
  appearance: none; width: 100%; min-height: 46px;
  color: var(--text); background-color: #ffffff; font: inherit;
  border: 1px solid #89939f; border-radius: 11px; padding: 10px 25px 10px 12px;
}
.resource-row { display: flex; align-items: center; gap: 3px; }
.resource-row > :first-child { flex: 1; min-width: 0; }
.resource-action { min-width: 26px; min-height: 30px; color: var(--muted); }
.resource-item .code-language { font-size: .85rem; }
.resource-item pre { margin: 7px 0 0; padding: 8px; overflow: auto; background: #e9eef5; border-radius: 8px; }
.code-entry, .resource-item code { font-family: ui-monospace, monospace; }
.form .drop-file {
  place-items: center; position: relative; padding: 24px 12px; text-align: center;
  border: 1px dashed #72799b; border-radius: 11px; background: #f6f9ff; cursor: pointer;
}
.drop-file.dragging, .drop-file:focus-within { border-color: var(--accent); background: #d3e3fd; }
.drop-file small { color: var(--muted); }
.drop-file input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.waiting { text-align: center; padding: 16px; position: relative; z-index: 1; }
.waiting .panel-icon { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 12px; }
.waiting h2 { font-size: clamp(1rem, 3vw, 1.4rem); }
.waiting p { color: var(--muted); margin-top: 6px; font-size: .95rem; }
.stage-meta { min-height: 54px; margin-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); flex-wrap: wrap; }
.live-status { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 700; }
.live-status.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.toolbar { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tool { color: var(--muted); font-size: .86rem; font-weight: 700; display: inline-flex; gap: 6px; padding: 8px; min-height: 36px; border: 1px solid transparent; background: transparent; border-radius: 8px; align-items: center; }
.ink-color { cursor: pointer; }
.ink-color input {
  width: 26px; height: 26px; min-height: 0; padding: 2px;
  border-radius: 7px; cursor: pointer;
}
.tool:hover { background: #0b57d010; }
.tool[aria-pressed="true"] { background: #d3e3fd; border-color: #a8c7fa; color: var(--accent); }
.tool:disabled { opacity: .46; cursor: default; }
.resources { align-self: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; min-width: 0; }
.resources-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.resources-heading h2 { font-size: 1.15rem; }
.resources-heading .button { min-height: 36px; padding: 6px 10px; }
#resource-list { display: grid; gap: 9px; }
.resource-item { background: #f8fafd; border: 1px solid #dce1e8; border-radius: 10px; padding: 11px; min-width: 0; }
.resource-item h3, .resource-item a { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; font-size: .96rem; font-weight: 750; }
.resource-item a { color: var(--accent); text-underline-offset: 3px; }
.resource-item svg { flex-shrink: 0; }
.resource-item p { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; line-height: 1.47; }
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 5; max-width: calc(100% - 40px); background: #2f324b; border: 1px solid #5c6289; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 35px #0005; }
dialog { width: min(calc(100% - 32px), 460px); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
dialog::backdrop { background: #080915a8; }
.dialog-heading, .segments { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.segments { margin-top: 14px; }
.segments button { flex: 1; }
.segments button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (max-width: 860px) {
  .room { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 500px) {
  .topbar { height: 66px; }
  .landing { min-height: calc(100svh - 66px); }
  .room { margin-top: 22px; }
  .stage { min-height: 188px; }
  .room-controls { gap: 6px; }
  .room-controls .button { padding-inline: 10px; }
}
.history { border-top: 1px solid var(--line); margin-top: 23px; padding-top: 18px; }
.history h2 { font-size: 1.08rem; margin-bottom: 10px; }
.history summary { color: var(--muted); padding: 7px 0; cursor: pointer; }
.history-items { display: grid; gap: 7px; margin: 5px 0 10px; }

@media (max-width: 420px) { .segments .button { padding-inline: 8px; } }

.topbar { background:white; border-bottom:1px solid var(--line); }
.wordmark { font-size:1.5rem; font-weight:500; letter-spacing:-.05em; }
.landing { background:white; display:grid; grid-template-columns:minmax(0,430px) minmax(0,510px); justify-content:center; align-content:center; gap:clamp(32px,7vw,110px); padding:64px clamp(24px,6vw,90px); }
.panel { background:transparent; border:0; box-shadow:none; padding:0; width:100%; text-align:left; }
.classroom-art { display:block; width:100%; height:auto; }
.panel-icon { width:54px; height:54px; background:#e8f0fe; color:#1558c2; border:0; border-radius:16px; margin-bottom:22px; }
h1,.join-panel h1 { font:500 clamp(2.3rem,4.5vw,4rem)/1.08 Roboto,Arial,sans-serif; letter-spacing:-.055em; }
.description { font-size:1.1rem; margin-top:16px; }
.form { margin-top:28px; }
.button,.tool,.form label { font-weight:550; }
.button { border-radius:24px; transition:background .16s,box-shadow .16s,transform .12s; }
.button:hover { filter:none; box-shadow:0 2px 6px #263c5b26; }
.button:active,.icon-button:active,.tool:active { transform:scale(.97); }
.secondary { background:white; color:var(--accent); }
.code-input { display:block; text-align:left; height:auto; padding:13px 17px; font:500 1.65rem/1.25 ui-monospace,monospace; letter-spacing:.25em; text-indent:0; }
.code-input:empty::before { color:#738091; }
.join-panel .button { width:fit-content; padding-inline:24px; justify-self:start; }
input:focus,textarea:focus,.code-input:focus,select:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
.stage { background:#202124; color:white; }
.waiting p { color:#ccd3dc; }
.session-badge { background:#fff; }
.icon-button,.tool { transition:background .15s,transform .12s; }
.icon-button:hover,.tool:hover { background:#e7effb; }
.live-status.live::before { background:#188038; }
.toast { background:#303134; color:white; border:0; }
.status:not([hidden]),.toast:not([hidden]),dialog[open],.panel,.classroom-art { animation:arrive .22s ease-out both; }
@keyframes arrive { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }
@media(max-width:720px) { .landing { grid-template-columns:minmax(0,460px); gap:32px; padding:40px 24px; align-content:start; } .classroom-art { max-width:340px; } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; } }
.button,button.tool,.icon-button { position:relative; overflow:hidden; }
.ripple { pointer-events:none; position:absolute; border-radius:50%; aspect-ratio:1; background:currentColor; }
.code-input { transition:background-color .18s,border-color .18s; }
.code-input.complete { background:#eef5ff; border-color:#0b57d0; }
.code-input[aria-invalid="true"] { border-color:#b3261e; outline-color:#b3261e; }

.button,.icon-button,.tool,.text-button,.history summary {
  transition:background-color 150ms ease-out,color 150ms ease-out,box-shadow 150ms ease-out,transform 100ms ease-out;
}
@media (hover:hover) {
  .button:not(.secondary,.danger,.sharing):hover:enabled,.button:not(.secondary,.danger):is(a):hover { background:#0848ac; }
  .secondary:hover,.text-button:hover,.segments .button:hover,.history summary:hover { background:#edf3fd; }
  .danger:hover,.button.sharing:hover { background:#f9d6d2; }
  .icon-button:hover,.tool:hover:enabled { background:#dfe9f8; }
}
.text-button { border-radius:8px; padding:8px; }
.code-input { caret-color:var(--accent); font-family:Roboto,Arial,sans-serif; font-variant-numeric:tabular-nums; outline:none; }
.code-input::placeholder { color:#87919f; }
.code-input:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.code-input[aria-invalid=true] { border-color:var(--danger); box-shadow:0 0 0 1px var(--danger); }
.history details { background:white; border:1px solid var(--line); border-radius:16px; margin-top:8px; overflow:hidden; }
.history summary { display:flex; align-items:center; gap:14px; list-style:none; padding:14px 16px; color:var(--text); }
.history summary::-webkit-details-marker { display:none; }
.history summary svg:first-child { color:var(--accent); }
.history summary small { display:block; font-size:.8rem; color:var(--muted); margin-top:4px; }
.history summary svg:last-child { margin-left:auto; transition:transform .18s; }
.history details[open] summary svg:last-child { transform:rotate(180deg); }
.history-items { padding:0 14px 4px; }
.stage:has(.waiting:not([hidden])) { background:radial-gradient(ellipse at center,#303841,#202429 74%); }
.waiting h2 { font-weight:500; letter-spacing:-.025em; }
.waiting .panel-icon { background:#354861; color:#b9d4ff; border-radius:50%; }
#cancel-count { margin:16px auto 0; }
.live-status.live { background:#ddf3e4; color:#146235; padding:7px 12px; border-radius:20px; }
.button.sharing { color:#92231c; background:#fce8e6; }
.segments { gap:0; border:1px solid var(--line); border-radius:24px; overflow:hidden; }
.segments .button { border:0; border-radius:0; color:var(--muted); }
.segments .button[aria-pressed=true] { background:#d3e3fd; color:#153e77; }
#import-code { padding:5px; color:var(--muted); font-weight:400; cursor:pointer; }
#import-code::file-selector-button { font:inherit; font-weight:500; color:var(--accent); background:#e9f1fd; padding:8px 14px; border:0; border-radius:8px; margin-right:10px; cursor:pointer; }
#import-code:hover::file-selector-button { background:#d3e3fd; }
@media(prefers-reduced-motion:reduce) { .history summary svg:last-child { transition:none; } }

.session-badge { background:#f1f6ff; color:#173562; border:1px solid #a8c7fa; box-shadow:0 3px 12px #10264933; padding:.36em .72em .42em; border-radius:.55em; gap:.15em; }
.session-badge .badge-label { display:flex; align-items:center; gap:.4em; color:#355983; font-size:.42em; font-weight:550; }
.badge-label svg { width:1.25em; height:1.25em; }
.session-badge strong { font-weight:550; }
.code-resize { width:.34em; height:.34em; right:.18em; bottom:.18em; }
.end-dialog { border:0; border-radius:28px; padding:28px; background:#f5f8ff; box-shadow:0 18px 80px #101b302e; }
.end-dialog h2 { font-size:1.45rem; font-weight:500; letter-spacing:-.03em; }
.end-dialog .description { font-size:1rem; }
.end-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:28px; }
.end-actions .danger { color:white; background:#b3261e; }
.end-actions .danger:hover { background:#912019; }
.stage-media { position:absolute; z-index:2; pointer-events:none; overflow:hidden; }
.stage-object { position:absolute; touch-action:none; user-select:none; }
.stage .stage-object :is(img,video) { position:static; width:100%; height:100%; display:block; pointer-events:none; }
.stage-object span { position:absolute; pointer-events:none; }
.stage-object.selected span { border:2px solid #8ab4f8; box-shadow:inset 0 0 0 1px #124792; }
.stage:has(.annotation.active) .stage-object { cursor:grab; pointer-events:auto; }
.stage:has(.annotation.active) .stage-object:active { cursor:grabbing; }
.stage:has(.annotation.active:is([data-tool="pen"],[data-tool="text"],[data-tool="circle"],[data-tool="rectangle"],[data-tool="star"])) .stage-media { z-index:0; }
.stage .session-badge { z-index:3; }
.stage.drop-ready { outline:3px solid #4285f4; outline-offset:-3px; }
.media-picker { position:relative; cursor:pointer; overflow:hidden; }
.media-picker input { position:absolute; inset:0; opacity:0; cursor:pointer; }
.media-picker:focus-within { outline:2px solid var(--accent); }
.media-tools { display:flex; flex-wrap:wrap; align-items:center; gap:16px; background:white; padding:10px 16px; border:1px solid var(--line); border-radius:16px; margin:10px 0; }
.media-tools label { display:inline-flex; align-items:center; gap:8px; font-size:.875rem; }
.media-tools input { width:90px; min-height:24px; accent-color:var(--accent); }
.media-tools summary { color:var(--accent); cursor:pointer; padding:8px; }
.crop-edges { display:flex; flex-wrap:wrap; gap:10px; }
