:root {
  --kb-navy: #0B2D5B;
  --kb-cyan: #21A9C9;
  --yc-orange: #FF8A1F;
  --yc-purple: #5A1468;
  --bg: #F5F8FB;
  --surface: #FFFFFF;
  --text: #172033;
  --muted: #64748B;
  --border: #DDE7F0;
  --success: #12A66A;
  --danger: #D64545;
  --shadow: 0 18px 40px rgba(11, 45, 91, .12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at top, #ffffff 0, var(--bg) 58%, #eaf2f8 100%);
  font-family: Barlow, Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.host-page {
  display: block;
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: flex-start;
  width: 84px;
  height: calc(100vh - 48px);
  margin: 24px 0 24px 24px;
  padding: 18px 12px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(180deg, #0c3974 0%, #071f49 100%);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 34px;
  border: 3px solid #fff;
  border-radius: 8px;
  font-size: 26px;
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 12px;
}

.sidebar a {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 64px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
}

.sidebar a span {
  font-size: 11px;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(255, 255, 255, .12);
}

.app-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 18px 24px 48px;
}

.top-brand-bar {
  display: flex;
  direction: ltr;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #111827;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.participant-brand {
  width: min(420px, calc(100% - 24px));
  margin: 12px auto 0;
}

.top-brand-bar img {
  max-width: 116px;
  max-height: 32px;
  object-fit: contain;
}

.hero-header {
  display: grid;
  grid-template-columns: 260px 1fr 330px;
  align-items: center;
  gap: 26px;
  min-height: 120px;
}

.compact-hero {
  grid-template-columns: 1fr auto;
  min-height: 98px;
}

.logo {
  max-width: 100%;
  object-fit: contain;
}

.keybox-logo {
  height: 82px;
  object-position: left center;
}

.yc-logo {
  height: 92px;
  object-position: right center;
}

.title-block {
  text-align: center;
}

.title-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.app-icon {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--kb-navy);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.title-block h1 {
  margin: 0;
  color: var(--kb-navy);
  font-size: clamp(42px, 5vw, 70px);
  line-height: .95;
  letter-spacing: 0;
}

.title-block h1 span {
  color: var(--kb-cyan);
  font-size: .46em;
  font-weight: 800;
  vertical-align: middle;
}

.mobile-header span {
  color: var(--kb-cyan);
}

.title-block p:last-child {
  margin: 10px 0 0;
  color: #243653;
  font-size: 22px;
}

.language-switcher {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.language-switcher button,
.screen-tabs button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--kb-navy);
  font-weight: 900;
}

.language-switcher button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
}

.language-switcher img {
  width: 22px;
  height: 15px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(11, 45, 91, .12);
}

.language-switcher button.active,
.screen-tabs button.active {
  color: #fff;
  border-color: var(--kb-navy);
  background: var(--kb-navy);
}

.screen-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0 22px;
}

.screen-tabs button {
  min-height: 54px;
  font-size: 16px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(560px, 1.1fr) minmax(420px, .9fr);
  gap: 24px;
  align-items: start;
}

#launchPanel .panel {
  max-width: 1040px;
  margin: 0 auto;
}

.panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.panel-heading > div {
  flex: 1;
}

.panel-heading h2,
.panel h3 {
  margin: 0;
  color: #071f49;
}

.panel-heading.compact {
  align-items: flex-start;
}

.btn {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(11, 45, 91, .16);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--kb-cyan), #0b7eb2);
}

.ghost {
  color: var(--kb-navy);
  border-color: #9fc8df;
  background: #fff;
}

.danger {
  color: #fff;
  background: var(--danger);
}

.session-form {
  display: grid;
  gap: 18px;
}

label span,
legend {
  display: block;
  margin-bottom: 8px;
  color: var(--kb-navy);
  font-weight: 800;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c9d9e8;
  border-radius: 7px;
  padding: 13px 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--kb-cyan);
  box-shadow: 0 0 0 3px rgba(33, 169, 201, .16);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.type-card {
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  text-align: left;
}

.type-card strong {
  display: block;
  margin: 8px 0 4px;
  color: #001b4c;
}

.type-card small {
  color: var(--muted);
}

.type-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: var(--kb-cyan);
  font-weight: 900;
}

.type-card.active {
  border-color: var(--kb-cyan);
  box-shadow: inset 0 0 0 2px rgba(33, 169, 201, .14);
}

.type-card:nth-child(3n) .type-icon,
.choice-pill:nth-child(3n) .choice-letter {
  background: var(--yc-orange);
}

.type-card:nth-child(4n) .type-icon,
.choice-pill:nth-child(4n) .choice-letter {
  background: var(--yc-purple);
}

.options-box {
  display: grid;
  gap: 10px;
}

.option-line {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

.small-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.choice-toggle {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--kb-navy);
  font-weight: 800;
}

.choice-toggle.active {
  color: #fff;
  background: var(--kb-navy);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.projection-panel {
  min-height: calc(100vh - 240px);
}

.projection-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  grid-template-areas:
    "question qr"
    "results qr"
    "results activity";
  gap: 18px;
}

.projection-question {
  grid-area: question;
  min-height: 150px;
}

.projection-results {
  grid-area: results;
  min-height: 430px;
}

.projection-qr {
  grid-area: qr;
  min-height: 340px;
}

.projection-activity {
  grid-area: activity;
}

.projection-panel .result-head strong {
  font-size: clamp(46px, 6vw, 82px);
}

.projection-panel .chart-area.empty {
  min-height: 330px;
  font-size: 20px;
}

.projection-panel .bar-row {
  grid-template-columns: minmax(140px, 1fr) 3fr 70px;
  font-size: 18px;
}

.projection-panel .bar-track {
  height: 26px;
}

.projection-panel .word-cloud {
  min-height: 340px;
}

.projection-panel .metric-value {
  min-height: 150px;
  font-size: 56px;
}

.question-card,
.result-card,
.activity-card,
.qr-card {
  min-height: 190px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.question-card {
  display: flex;
  gap: 14px;
}

.number-dot,
.choice-letter {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  background: var(--kb-cyan);
  font-weight: 900;
}

.question-card p,
.qr-card p {
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--kb-navy);
  background: #edf6fb;
  font-size: 12px;
  font-weight: 800;
}

.status-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf6fb;
  color: var(--kb-navy);
  font-weight: 800;
}

.status-badge.live {
  color: var(--success);
  background: #e9f8f1;
}

.status-badge.closed {
  color: var(--danger);
  background: #fff0f0;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.result-head strong {
  display: block;
  color: #071f49;
  font-size: 34px;
  line-height: 1;
}

.live-dot {
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}

.chart-area.empty {
  display: grid;
  place-items: center;
  min-height: 150px;
  color: var(--muted);
  text-align: center;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(82px, 1fr) 2fr 52px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf3f8;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--kb-cyan);
}

.bar-row:nth-child(2n) .bar-fill {
  background: var(--yc-orange);
}

.bar-row:nth-child(3n) .bar-fill {
  background: var(--yc-purple);
}

.metric-box {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
}

.metric-value {
  display: grid;
  place-items: center;
  min-height: 96px;
  border-radius: 8px;
  color: #fff;
  background: var(--kb-navy);
  font-size: 34px;
  font-weight: 900;
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  min-height: 150px;
}

.word-cloud span {
  color: var(--kb-navy);
  font-weight: 900;
}

.word-cloud span:nth-child(2n) {
  color: var(--kb-cyan);
}

.word-cloud span:nth-child(3n) {
  color: var(--yc-orange);
}

.word-cloud span:nth-child(4n) {
  color: var(--yc-purple);
}

.answer-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.answer-item {
  padding: 12px;
  border-left: 4px solid var(--kb-cyan);
  border-radius: 7px;
  background: #f8fbfd;
}

.activity-card ul {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: #18345e;
}

.qr-card {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 14px;
  align-items: center;
}

.qr-card a {
  display: inline-block;
  max-width: 100%;
  color: var(--kb-cyan);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.join-access-box {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  text-align: left;
}

.join-access-box > div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfd;
}

.join-access-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.join-access-box strong {
  display: block;
  color: var(--kb-navy);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: .08em;
}

.qr-placeholder {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border: 1px dashed #aac5d8;
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
}

.projection-qr {
  grid-template-columns: 1fr;
  align-content: start;
  justify-items: center;
}

.projection-qr .qr-placeholder,
.projection-qr #qrcode {
  width: 220px;
  height: 220px;
}

.projection-qr .qr-placeholder img,
.projection-qr .qr-placeholder canvas,
.projection-qr #qrcode img,
.projection-qr #qrcode canvas {
  max-width: 204px;
  max-height: 204px;
}

.qr-placeholder img,
.qr-placeholder canvas {
  max-width: 120px;
  max-height: 120px;
}

.action-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.pdf-report {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 794px;
  padding: 44px;
  color: #071f49;
  background: #fff;
}

.pdf-report header {
  display: grid;
  grid-template-columns: 180px 1fr 220px;
  gap: 20px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 2px solid #d9e4ee;
}

.pdf-report header img {
  max-width: 100%;
  max-height: 74px;
  object-fit: contain;
}

.pdf-report h2 {
  margin: 0;
  text-transform: uppercase;
}

.pdf-report table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-size: 13px;
}

.pdf-report th,
.pdf-report td {
  padding: 8px;
  border: 1px solid #d9e4ee;
  text-align: left;
}

.phone-shell {
  width: min(420px, 100%);
  min-height: calc(100vh - 62px);
  margin: 0 auto;
  padding: 18px;
  background: #fff;
}

.mobile-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-align: center;
}

.mobile-header img {
  width: 58px;
}

.mobile-header strong {
  color: var(--kb-navy);
  font-size: 18px;
}

.mobile-header button {
  width: 40px;
  height: 40px;
  border: 0;
  background: #fff;
  color: var(--kb-navy);
  font-size: 24px;
}

.participant-card {
  margin-top: 22px;
}

.participant-card h1 {
  margin: 8px 0 16px;
  color: #071f49;
  font-size: 25px;
  line-height: 1.2;
}

.participant-meta {
  color: var(--kb-navy);
  font-weight: 800;
}

.join-code-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.join-code-form input {
  text-align: center;
  color: var(--kb-navy);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.join-code-form .btn {
  width: 100%;
}

.choice-list {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}

.choice-pill {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid #d6e4ef;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(33, 169, 201, .15), rgba(255, 255, 255, .8));
  text-align: left;
}

button.choice-pill {
  width: 100%;
  cursor: pointer;
}

.choice-pill input {
  position: absolute;
  opacity: 0;
}

.choice-pill.selected {
  border-color: var(--success);
  background: linear-gradient(90deg, rgba(18, 166, 106, .18), rgba(255, 255, 255, .88));
  box-shadow: 0 0 0 3px rgba(18, 166, 106, .16);
}

.choice-pill.selected .choice-letter,
.scale-btn.selected {
  color: #fff;
  background: var(--success);
}

.choice-text {
  display: grid;
  gap: 2px;
}

.choice-text small {
  color: var(--muted);
  font-weight: 700;
}

.scale-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 22px 0;
}

.scale-btn {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--kb-navy);
  font-weight: 900;
}

.success-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  text-align: center;
}

.success-check {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  font-size: 30px;
  font-weight: 900;
}

@media (max-width: 1100px) {
  .host-page {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .app-shell {
    width: 100%;
  }

  .hero-header,
  .workbench {
    grid-template-columns: 1fr;
  }

  .compact-hero,
  .projection-grid {
    grid-template-columns: 1fr;
  }

  .projection-grid {
    grid-template-areas:
      "question"
      "qr"
      "results"
      "activity";
  }

  .hero-header {
    text-align: center;
  }

  .language-switcher {
    justify-content: center;
  }

  .keybox-logo,
  .yc-logo {
    margin: 0 auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

  .panel-heading,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .type-grid,
  .live-grid,
  .qr-card {
    grid-template-columns: 1fr;
  }

  .top-brand-bar {
    flex-wrap: wrap;
    padding: 8px;
  }

  .screen-tabs {
    grid-template-columns: 1fr;
  }

  .language-switcher {
    flex-wrap: wrap;
  }

  .title-line {
    flex-direction: column;
    gap: 8px;
  }

  .qr-placeholder {
    width: 150px;
    height: 150px;
  }

  .bar-row,
  .metric-box {
    grid-template-columns: 1fr;
  }
}

@media print {
  body > :not(.app-shell),
  .app-shell > :not(.pdf-report) {
    display: none !important;
  }

  .pdf-report {
    position: static;
    width: auto;
    padding: 0;
  }
}
