body.teacher { background: var(--bg); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 10px 24px; background: rgb(255 255 255 / 92%); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -0.03em; }
.brand img { width: 32px; height: 32px; }
.save-state { color: var(--muted); font-size: 14px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.form-message { min-height: 1.4em; color: var(--danger); font-size: 14px; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }

/* List */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 36px; font-weight: 800; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #e9e9f2; }
.tab { padding: 6px 16px; border-radius: 999px; color: var(--muted); font-weight: 600; text-decoration: none; }
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.page .notice { margin-bottom: 16px; }
.survey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.survey-card { display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.survey-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(29 29 43 / 6%), 0 16px 36px rgb(29 29 43 / 10%); }
.survey-thumb { display: grid; place-items: center; aspect-ratio: 16 / 6; background: color-mix(in srgb, var(--tone) 15%, #fff); }
.thumb-bars { display: flex; align-items: flex-end; gap: 10px; height: 56%; }
.thumb-bars i { width: 22px; border-radius: 6px 6px 0 0; background: var(--tone); }
.thumb-bars i:nth-child(1) { height: 55%; opacity: .55; }
.thumb-bars i:nth-child(2) { height: 100%; }
.thumb-bars i:nth-child(3) { height: 75%; opacity: .75; }
.survey-card-body { display: grid; gap: 10px; padding: 18px 20px 20px; }
.survey-card-top, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.survey-card h2 { font-size: 20px; font-weight: 750; overflow-wrap: anywhere; }
.survey-card h2 a { color: inherit; text-decoration: none; }
.survey-card h2 a:hover { color: var(--brand-dark); }
.survey-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.empty-state { grid-column: 1 / -1; display: grid; justify-items: center; gap: 14px; padding: 56px 24px; text-align: center; }
.empty-state h2 { font-size: 24px; }

/* Sign-in */
.auth { max-width: 980px; margin: 0 auto; padding: 40px 24px; display: grid; gap: 28px; }
.auth > .brand { justify-self: center; font-size: 28px; }
.auth-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; align-items: start; }
.auth-card { display: grid; gap: 14px; padding: 32px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-card h1 { font-size: 44px; font-weight: 800; }
.auth-card h2 { font-size: 26px; }
.join-card { background: linear-gradient(160deg, #ffffff 0%, #efefff 100%); }
.code-field { min-height: 76px !important; font-size: 36px !important; font-weight: 800; letter-spacing: .12em; text-align: center; border-radius: 16px !important; }

/* Editor */
.editor { display: grid; grid-template-columns: 250px minmax(0, 1fr) 360px; grid-template-areas: "rail title panel" "rail canvas panel"; grid-template-rows: auto 1fr; column-gap: 28px; min-height: calc(100vh - 64px); }
.editor-title { grid-area: title; padding-top: 20px; }
.title-input { border: 0 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; padding: 6px 0 !important; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.title-input:focus { box-shadow: inset 0 -2px 0 var(--brand) !important; }
.editor-rail { grid-area: rail; display: flex; flex-direction: column; gap: 12px; padding: 20px 12px 24px 16px; border-right: 1px solid var(--line); background: #fff; }
.editor-canvas { grid-area: canvas; display: grid; align-content: start; gap: 10px; padding: 16px 0 32px; }
.canvas-hint { color: var(--faint); font-size: 13px; text-align: center; }
.editor-panel { grid-area: panel; display: grid; align-content: start; gap: 18px; padding: 20px 20px 32px; border-left: 1px solid var(--line); background: #fff; }
.rail-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.rail-item { position: relative; }
.rail-select { display: grid; grid-template-columns: 18px 40px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; padding: 8px; border: 2px solid transparent; border-radius: 12px; background: transparent; text-align: left; }
.rail-select:hover { background: var(--bg); }
.rail-item.selected .rail-select, .rail-item.current .rail-select { border-color: var(--brand); background: var(--brand-soft); }
.rail-number { color: var(--faint); font-size: 12px; font-weight: 700; text-align: center; }
.rail-thumb { display: grid; place-items: center; width: 40px; height: 30px; border-radius: 7px; background: color-mix(in srgb, var(--tone, #1d1d2b) 14%, #fff); color: var(--tone, var(--muted)); }
.rail-thumb .icon { width: 18px; height: 18px; }
.rail-text { font-size: 13px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.rail-tools { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; opacity: 0; transition: opacity .15s; }
.rail-item:hover .rail-tools, .rail-item:focus-within .rail-tools, .rail-item.selected .rail-tools { opacity: 1; }
.rail-tools .icon-button { width: 26px; height: 22px; background: #fff; }
.rail-count { min-width: 28px; padding: 1px 7px; border-radius: 999px; background: #fff; color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; box-shadow: 0 0 0 1px var(--line); }
.add-wrap { position: relative; }
.add-menu { position: absolute; left: 0; width: 320px; top: calc(100% + 8px); z-index: 10; display: grid; gap: 4px; padding: 8px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); }
.add-option { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.add-option:hover, .add-option:focus-visible { background: var(--bg); }
.add-option strong { display: block; font-size: 15px; }
.add-option small { display: block; color: var(--muted); font-size: 13px; line-height: 1.3; }
.add-option .add-icon { width: 36px; height: 36px; border-radius: 10px; }
.panel-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--bg); }
.panel-tab { flex: 1; padding: 7px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; }
.panel-tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.panel-section { display: grid; gap: 12px; }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-tile { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; font-size: 14px; text-align: left; }
.type-tile:hover { border-color: #cfcfdd; }
.type-tile.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.option-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.option-row { display: flex; align-items: center; gap: 8px; }
.option-dot { flex: none; width: 12px; height: 12px; border-radius: 4px; background: var(--tone); }
.choice-group { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 8px; }
.choice-card { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; }
.choice-card.active { border-color: var(--brand); background: var(--brand-soft); }
.choice-card input { margin-top: 3px; flex: none; }
.choice-card strong { display: block; }
.choice-card small { display: block; color: var(--muted); line-height: 1.35; }

/* Running a survey */
.run { max-width: 1480px; margin: 0 auto; padding: 20px 24px 48px; display: grid; gap: 16px; }
.run-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.run-title { display: grid; gap: 8px; min-width: 0; }
.run-title h1 { font-size: 28px; font-weight: 800; overflow-wrap: anywhere; }
.chip .icon { width: 14px; height: 14px; }
.run-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.join-info { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 16px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); }
.join-code { font-size: 20px; font-weight: 800; letter-spacing: .06em; color: var(--brand-dark); white-space: nowrap; }
.run-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.run-rail { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; padding: 10px; border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow); }
.rail-thumb.neutral { --tone: #1d1d2b; }
.run-center { display: grid; gap: 14px; min-width: 0; }
.run-stage { display: grid; gap: 6px; }
.stage-label { color: var(--faint); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.run-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); }
.control-sep { width: 1px; height: 26px; margin: 0 4px; background: var(--line); }
.beamer-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.run-panel { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; display: grid; gap: 12px; padding: 18px; border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-head h2 { font-size: 20px; }
.panel-question { font-weight: 600; overflow-wrap: anywhere; }
.panel-question .chip { margin-right: 6px; vertical-align: 1px; }

@media (max-width: 1180px) {
  .editor { grid-template-columns: 220px minmax(0, 1fr); grid-template-areas: "rail title" "rail canvas" "panel panel"; }
  .editor-panel { border-left: 0; border-top: 1px solid var(--line); }
  .run-grid { grid-template-columns: 210px minmax(0, 1fr); }
  .run-panel { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 14px; }
  .hide-small { display: none; }
  .page { padding: 20px 16px 48px; }
  .page-head h1 { font-size: 28px; }
  .auth { padding: 24px 16px; }
  .auth-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px; }
  .auth-card h1 { font-size: 34px; }
  .editor { display: flex; flex-direction: column; }
  .editor-title { padding: 14px 16px 0; }
  .editor-rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-canvas { padding: 12px 16px; }
  .add-menu { width: auto; right: 0; }
  .run { padding: 14px 12px 40px; }
  .run-grid { grid-template-columns: 1fr; }
  .run-rail { position: static; max-height: none; }
  .run-controls { border-radius: var(--radius-lg); }
  .run-controls .button > span { display: none; }
}
