:root {
  color-scheme: light;
  --ink: #172e50;
  --muted: #64748b;
  --blue: #245bc5;
  --line: #dae3ed;
  --paper: #f4f7fb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.55; }
a { color: var(--blue); }
.site-header { max-width: 1280px; margin: auto; padding: 24px 32px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.site-header a { text-decoration: none; font-weight: 650; }
.course-label, .small { color: var(--muted); font-size: .85rem; }
main { max-width: 1180px; margin: 0 auto; padding: 48px 24px; }
.intro { margin-bottom: 40px; }
.eyebrow, .section-label { font-size: .75rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 750; color: var(--blue); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.4rem, 5.5vw, 4.5rem); line-height: 1.12; letter-spacing: -.045em; margin-bottom: 20px; }
h2 { font-size: 1.4rem; letter-spacing: -.025em; margin: 10px 0 12px; }
h3 { font-size: 1.25rem; }
.subtitle { font-size: 1.15rem; color: var(--muted); }
.landing-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 24px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 4px 20px #172e5004; }
.join-panel { background: #eaf1fc; border-color: #d6e3f8; }
label, legend { display: block; font-size: .9rem; font-weight: 650; margin-bottom: 8px; }
input, textarea { width: 100%; font: inherit; color: var(--ink); border: 1px solid #bdcce0; border-radius: 9px; background: white; padding: 12px 14px; margin-bottom: 18px; }
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 3px solid #bcd2fa; border-color: var(--blue); }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 18px; border-radius: 9px; border: 1px solid transparent; background: var(--blue); color: white; font: inherit; font-weight: 650; font-size: .9rem; padding: 12px 18px; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { filter: brightness(.94); }
button:focus-visible, a:focus-visible { outline: 3px solid #8eb8ff; outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .6; }
.secondary { color: var(--ink); background: white; border-color: var(--line); }
.text-button { background: transparent; color: var(--blue); padding: 0 0 20px; border-radius: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.answer-row { display: flex; align-items: center; gap: 10px; }
.answer-row input { margin-bottom: 10px; }
.answer-row button { padding: 7px 10px; margin-bottom: 10px; }
.choice-letter { display: flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; border-radius: 7px; background: #eef3fa; color: var(--blue); font-size: .8rem; font-weight: 750; }
#create-button, #vote-button { width: 100%; }
.mini-chart { height: 100px; display: flex; gap: 10px; align-items: flex-end; justify-content: center; margin: 36px auto 20px; }
.mini-chart span { width: 36px; border-radius: 7px 7px 2px 2px; background: #b5cbed; height: 45%; }
.mini-chart span:nth-child(2) { height: 85%; background: #6690d5; }
.mini-chart span:nth-child(3) { height: 62%; background: #8dacdf; }
.mini-chart span:nth-child(4) { height: 35%; }
.message { margin-bottom: 24px; border-radius: 10px; border: 1px solid #eec9a4; background: #fff4e9; color: #783d14; padding: 14px 18px; }
.recent { margin-top: 36px; }
#recent-list { display: flex; gap: 12px; flex-wrap: wrap; }
#recent-list a { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; text-decoration: none; }
.poll-heading { margin-bottom: 32px; }
.poll-heading h1 { font-size: clamp(2rem, 4vw, 3.4rem); max-width: 1000px; overflow-wrap: anywhere; }
.poll-meta { display: flex; gap: 14px; align-items: center; margin: 16px 0; color: var(--muted); font-size: .9rem; }
.badge { background: #e0f2eb; color: #13674d; border-radius: 30px; padding: 5px 12px; font-weight: 650; }
.badge.closed { background: #edf0f5; color: #536174; }
.poll-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
body.host .poll-grid, body.present .poll-grid { grid-template-columns: 1fr 290px; }
.vote-choice { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 15px; margin-bottom: 12px; cursor: pointer; overflow-wrap: anywhere; }
.vote-choice:has(input:checked) { border-color: var(--blue); background: #eff5ff; }
.vote-choice input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; accent-color: var(--blue); }
.results-heading { display: flex; align-items: center; justify-content: space-between; }
.live-label { color: #21816b; font-size: .75rem; font-weight: 700; }
.live-label::before { content: ''; display: inline-block; width: 7px; height: 7px; background: currentColor; border-radius: 50%; margin-right: 6px; }
.empty-results { padding: 0 12px 22px; text-align: center; color: var(--muted); }
.empty-results h3 { color: var(--ink); }
.chart-row { margin: 24px 0; }
.chart-label { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; font-weight: 600; margin-bottom: 8px; }
.chart-label span:first-child { overflow-wrap: anywhere; }
.chart-label span:last-child { white-space: nowrap; color: var(--muted); font-size: .85em; }
.bar-track { height: 30px; background: #eff3f9; border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; background: #3971cf; border-radius: inherit; transition: width .4s ease; }
.chart-row:nth-child(2) .bar-fill { background: #468c9c; }
.chart-row:nth-child(3) .bar-fill { background: #8984bb; }
.chart-row:nth-child(4) .bar-fill { background: #c59155; }
.qr-panel { text-align: center; }
#qr-code { background: white; padding: 8px; margin: 16px auto; max-width: 240px; }
#qr-code svg { width: 100%; height: auto; display: block; }
.student-link { display: block; overflow-wrap: anywhere; font-size: .8rem; margin-bottom: 18px; }
.qr-panel .small { margin-top: 18px; }
.host-controls { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 24px; align-items: center; }
.host-controls p { margin: 8px 0 0; }
.control-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.confirmation { background: #e8f5ef; color: #13674d; border-radius: 10px; padding: 16px; margin-top: 18px; }
.present-controls { text-align: right; margin-top: 20px; }
body.present main { max-width: 1500px; }
body.present .poll-heading h1 { font-size: clamp(2.4rem, 4.5vw, 4.4rem); }
body.present .poll-heading h1 { max-width: none; }
body.present .chart-label { font-size: 1.45rem; }
body.present .bar-track { height: 42px; }
body.present .poll-grid { grid-template-columns: 1fr 340px; }
body.present #qr-code { max-width: 280px; }
body.present .site-header, body.present footer { display: none; }
@media (min-width: 761px) and (max-height: 900px) {
  body.present main { padding-top: 24px; padding-bottom: 24px; }
  body.present .poll-heading { margin-bottom: 22px; }
  body.present .poll-heading h1 { font-size: clamp(2rem, 3.3vw, 3.3rem); }
  body.present .chart-label { font-size: 1.15rem; }
  body.present .chart-row { margin: 18px 0; }
  body.present .bar-track { height: 32px; }
  body.present .qr-panel { padding: 22px; }
  body.present #qr-code { max-width: 220px; margin: 12px auto; }
}
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px 24px 36px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .site-header { padding: 18px 20px; }
  main { padding: 30px 18px; }
  .landing-grid, .poll-grid, body.host .poll-grid, body.present .poll-grid { grid-template-columns: 1fr; }
  .panel { padding: 22px; }
  .intro { margin-bottom: 28px; }
  .host-controls { align-items: stretch; }
  .control-buttons { width: 100%; }
  .control-buttons > * { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
