:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #172026;
  --muted: #64717b;
  --line: #d8e0e6;
  --line-strong: #bdc9d2;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #dff3ef;
  --warn: #b45309;
  --warn-soft: #fff3d9;
  --danger: #b42318;
  --dark: #111827;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
html {
  color: var(--ink);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
textarea { resize: vertical; min-height: 116px; }

.shell { min-height: 100vh; padding: 18px 0 44px; }
.container { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }
.page-gap { margin-top: 16px; }

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 10px;
  background: rgba(244, 246, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 850; white-space: nowrap; }
.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: white;
  background: var(--accent);
}
.links, .row, .spread { display: flex; align-items: center; gap: 10px; }
.links, .row { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}
.nav-link:hover, .nav-link.is-active { color: var(--accent-dark); background: var(--accent-soft); }

.dashboard-hero, .session-head, .panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.dashboard-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}
.learning-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  background: #fffdf4;
  border-color: #efe7cf;
}
.learning-qr {
  width: 132px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 7px;
}
.session-head { padding: 18px; }
.session-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}
.session-aside { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.crumb a { color: var(--accent-dark); }
.visual-tone { border-color: rgba(15, 118, 110, 0.35); }
.display-tone { background: #101820; color: #f8fafc; border-color: rgba(248,250,252,.18); }
.display-tone .muted, .display-tone .crumb, .display-tone .crumb a { color: rgba(248,250,252,.72); }

.session-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.session-share {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.session-share-main { display: grid; gap: 10px; min-width: 0; }
.join-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.join-line .break { flex: 1 1 260px; margin: 0; }
.session-qr {
  width: 128px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 7px;
  justify-self: end;
}
.tab {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
}
.tab:hover, .tab.is-active {
  color: var(--accent-dark);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.stat-strip div {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.stat-strip span { display: block; font-size: 22px; line-height: 1.1; font-weight: 900; color: var(--accent-dark); }
.stat-strip small { display: block; margin-top: 2px; color: var(--muted); font-weight: 750; }
.display-tone .stat-strip div { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); }
.display-tone .stat-strip span, .display-tone .stat-strip small { color: #f8fafc; }

.panel { padding: 18px; }
.card { padding: 14px; }
.grid { display: grid; gap: 16px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.admin-card {
  background: #fbfffd;
  border-color: #b8dcd3;
}
.admin-card.soft { background: #f2fbf8; }
.audience-card {
  background: #f5fbff;
  border-color: #bfdbfe;
}
.display-card {
  background: #fffdf4;
  border-color: #efe7cf;
}
.role-grid .h2 { font-size: 20px; }
.plain-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 14px;
}
.terms-box {
  display: grid;
  gap: 10px;
  max-height: min(46vh, 420px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.terms-box h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}
.terms-box p { margin: 0; }
.terms-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.35rem;
}
.terms-list li { padding-left: 2px; }
.terms-list strong {
  display: block;
  margin-bottom: 2px;
}
.terms-list span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}
.terms-consent {
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.password-update {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.event-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.topic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topic-tab {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 850;
}
.topic-tab:hover, .topic-tab.is-active {
  color: var(--accent-dark);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.topic-help { align-self: center; color: var(--muted); font-size: 13px; font-weight: 750; }
.topic-current {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.audience-theme {
  --accent: #0b79a6;
  --accent-dark: #075985;
  --accent-soft: #dff3ff;
}
.audience-theme .session-head, .audience-theme .panel, .audience-theme .card {
  border-color: #bfdbfe;
  box-shadow: 0 12px 32px rgba(7, 89, 133, 0.08);
}
.audience-theme .topic-current, .audience-theme .choice, .audience-theme .word-cloud, .audience-theme .network, .audience-theme .wall-question {
  background: #f0f9ff;
  border-color: #bfdbfe;
}
.display-theme {
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #e8f6f1;
}
.display-theme .session-head, .display-theme .panel, .display-theme .card {
  background: #fffef8;
  border-color: #efe7cf;
}

.kicker {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
}
.h1 { font-size: 34px; line-height: 1.12; margin: 0 0 8px; }
.h2 { font-size: 24px; line-height: 1.18; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.h1, .h2, .muted, .node, .big-node, .read-next, .memory, .word, .code { overflow-wrap: anywhere; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { color: white; background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { color: white; background: var(--accent-dark); }
.btn.warn { color: var(--danger); }
.btn.selected { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }
.btn.disabled, .btn:disabled { opacity: .58; cursor: not-allowed; }
.check, .choice {
  display: flex;
  gap: 8px;
  font-weight: 750;
  min-height: 44px;
  align-items: center;
}
.choice {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}
.check input, .choice input { flex: 0 0 auto; }
.notice { border-color: rgba(180, 83, 9, 0.35); background: #fffaf0; }
.error { border-color: rgba(180, 35, 24, 0.35); background: #fff1f0; color: var(--danger); }
.success { border-color: rgba(15, 118, 110, 0.35); background: #effaf7; color: var(--accent-dark); }
.qr {
  width: clamp(200px, 70vw, 260px);
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px;
  align-self: center;
}
.break { overflow-wrap: anywhere; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 7px;
  padding: 11px 12px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}
.label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}
.badge.green { color: var(--accent-dark); background: var(--accent-soft); }
.badge.orange { color: var(--warn); background: var(--warn-soft); }
.code {
  width: fit-content;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--dark);
  color: white;
  border-radius: 7px;
  padding: 9px 11px;
  font-weight: 900;
  letter-spacing: 0;
}
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.node { white-space: pre-wrap; font-size: 16px; margin: 0; }
.big-node { white-space: pre-wrap; font-size: 28px; line-height: 1.25; margin: 0; }

.progress { height: 10px; background: #e4eaee; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; width: var(--w); background: var(--accent); }
.memory {
  white-space: pre-wrap;
  overflow: auto;
  background: var(--dark);
  color: #f8fafc;
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
}

.word-cloud {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.word {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  color: var(--accent-dark);
  font-weight: 850;
  line-height: 1.16;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  text-align: center;
}
.word.hot { color: var(--warn); text-shadow: 0 1px 0 rgba(17, 24, 39, 0.08); }
.stage-shell {
  min-height: 100vh;
  padding: 18px;
  background: #fffdf4;
  color: var(--ink);
}
.word-stage {
  min-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.word-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stage-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.word-stage .word-cloud {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 28px;
  gap: 18px 24px;
  background: #fffffb;
  border-color: #efe7cf;
  overflow: auto;
}
.stage-topic {
  padding: 14px 16px;
  border-radius: 8px;
  background: #fffffb;
  border: 1px solid #efe7cf;
  color: var(--accent-dark);
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.15;
}
.word-stage .word {
  line-height: 1.18;
  max-width: 100%;
}
.question-wall { display: grid; gap: 10px; }
.wall-question {
  padding: 12px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.wall-question.hot {
  border-color: rgba(15, 118, 110, 0.35);
  background: #effaf7;
}
.wall-question p {
  margin: 0;
  color: var(--ink);
  font-size: var(--size);
  line-height: 1.25;
  font-weight: 850;
  overflow-wrap: anywhere;
}
.wall-question.hot p {
  color: var(--accent-dark);
  font-weight: 920;
}
.wall-meta {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.network {
  width: 100%;
  min-height: 340px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.network p { padding: 18px; text-align: center; }
.network svg { display: block; width: 100%; height: 360px; }
.network line { stroke: rgba(15,118,110,.28); stroke-width: var(--w); }
.network circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.network text {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.rank { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.rank-bar { height: 9px; background: #e4eaee; border-radius: 999px; overflow: hidden; grid-column: 1 / -1; }
.rank-bar span { display: block; height: 100%; width: var(--w); background: var(--accent); }
.poll-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.poll-stage-card, .poll-stage-empty {
  background: #fffffb;
  color: var(--ink);
  border: 1px solid #efe7cf;
  border-radius: 8px;
  padding: 18px;
}
.poll-stage-empty {
  display: grid;
  place-items: center;
  min-height: 48vh;
  font-size: 22px;
  font-weight: 850;
}
.poll-stage-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}
.poll-stage-title {
  margin: 10px 0 5px;
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.14;
  overflow-wrap: anywhere;
}
.poll-stage-total {
  flex: 0 0 auto;
  color: var(--accent-dark);
  font-size: clamp(22px, 3vw, 38px);
  line-height: 1;
}
.poll-stage-results {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.poll-stage-rank { display: grid; gap: 8px; }
.poll-stage-rank-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: clamp(15px, 1.7vw, 22px);
  line-height: 1.22;
  font-weight: 850;
}
.poll-stage-rank-head span { overflow-wrap: anywhere; }
.poll-stage-rank-head strong { flex: 0 0 auto; color: var(--accent-dark); }
.poll-stage-bar {
  height: clamp(12px, 1.4vw, 18px);
  overflow: hidden;
  border-radius: 999px;
  background: #dde7eb;
}
.poll-stage-bar span { display: block; width: var(--w); height: 100%; background: var(--accent); }
.insight { border-left: 4px solid var(--accent); }
.insight.warn { border-left-color: var(--warn); }
.ticker {
  display: flex;
  gap: 12px;
  overflow: hidden;
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--dark);
  color: #f8fafc;
}
.ticker span { white-space: nowrap; font-weight: 800; animation: ticker 26s linear infinite; }
.live-card { background: var(--dark); color: #f8fafc; border-color: rgba(255,255,255,.18); }
.live-card .muted, .live-card .small { color: rgba(248,250,252,.72); }
.live-card .badge { color: #f8fafc; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); }
.read-next { font-size: 34px; line-height: 1.18; margin: 0; }
.meter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.meter-item { padding: 12px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); }
.meter-value { display: block; font-size: 26px; line-height: 1; font-weight: 900; color: var(--accent-dark); }
.pulse-live { display: grid; gap: 10px; }
.ai-panel { border: 1px solid rgba(15,118,110,.28); background: linear-gradient(180deg, #ffffff, #edf7f5); }
.ai-headline { font-size: 24px; line-height: 1.28; margin: 0; font-weight: 900; }
.cluster-list { display: grid; gap: 10px; }
.cluster { border-radius: 8px; padding: 13px; background: var(--surface); border: 1px solid var(--line); }
.footer { margin-top: 18px; color: var(--muted); }
.empty { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 14px; color: var(--muted); }

@keyframes ticker { from { transform: translateX(18%); } to { transform: translateX(-118%); } }

@media (max-width: 900px) {
  .two, .three { grid-template-columns: 1fr; }
  .meter, .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .poll-stage-grid { grid-template-columns: 1fr; }
  .session-main, .dashboard-hero { grid-template-columns: 1fr; flex-direction: column; }
  .session-aside { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .session-share { grid-template-columns: 1fr; }
  .session-qr { justify-self: start; }
  .learning-card { grid-template-columns: 1fr; }
  .learning-qr { justify-self: start; }
  .word-stage-head { align-items: flex-start; flex-direction: column; }
  .stage-actions { justify-content: flex-start; }
  .spread { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .container { width: min(100% - 20px, 1200px); }
  .nav { align-items: flex-start; flex-direction: column; }
  .brand, .links { width: 100%; }
  .nav-link { flex: 1 1 30%; justify-content: center; }
  .session-tabs { grid-template-columns: 1fr; }
  .meter, .stat-strip { grid-template-columns: 1fr; }
  .password-update { grid-template-columns: 1fr; }
  .poll-stage-top, .poll-stage-rank-head { flex-direction: column; }
  .panel { padding: 14px; }
  .card { padding: 12px; }
  .grid, .stack { gap: 10px; }
  .row .btn { flex: 1 1 140px; }
}
