:root {
  --bg: #e9edf1;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --line: #d8e0e8;
  --line-strong: #b7c6d4;
  --text: #2a3742;
  --muted: #667684;
  --blue: #0b88c3;
  --blue-dark: #0b6ea0;
  --blue-soft: #dff3fd;
  --green: #3ba76d;
  --green-soft: #e2f7ea;
  --red: #d45d5d;
  --red-soft: #fbe4e4;
  --shadow: 0 10px 30px rgba(36, 67, 97, 0.12);
  --radius: 24px;
  --panel-radius: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(11, 136, 195, 0.12), transparent 32%),
    linear-gradient(180deg, #eef3f7 0%, #e5eaee 100%);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.home-screen {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.home-card {
  width: min(880px, 100%);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 251, 253, 0.98) 100%);
  border: 1px solid #dbe5ec;
  box-shadow: var(--shadow);
  padding: 34px;
}

.home-card h1 {
  margin: 0 0 12px;
  font-size: 2.4rem;
  font-weight: 600;
  color: #42525e;
}

.home-lead {
  margin: 0 0 24px;
  max-width: 62ch;
  color: #5d6d79;
  line-height: 1.65;
}

.home-form {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.home-label {
  font-weight: 700;
  color: #445560;
}

.home-input,
.home-textarea {
  width: 100%;
  border: 1px solid #bfd1dc;
  border-radius: 18px;
  background: #fff;
  padding: 14px 16px;
  color: #334754;
}

.home-input {
  max-width: 220px;
}

.home-textarea {
  resize: vertical;
  min-height: 110px;
}

.home-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.home-card a,
.protected-page a {
  color: var(--blue-dark);
}

.end-card {
  max-width: 760px;
}

.end-summary-body {
  display: grid;
  gap: 16px;
  margin: 18px 0 24px;
}

.end-praise {
  border-radius: 22px;
  padding: 22px;
  background: linear-gradient(135deg, #0b82bc 0%, #36a6d8 100%);
  color: #fff;
}

.end-praise h2,
.end-stat-card h3 {
  margin: 0 0 8px;
}

.end-score {
  font-size: 3rem;
  font-weight: 700;
}

.end-stat-card {
  border: 1px solid #dbe4eb;
  border-radius: 18px;
  padding: 18px;
  background: #fff;
}

.end-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.end-stat {
  border-radius: 16px;
  background: #f4f8fb;
  border: 1px solid #dbe7ef;
  padding: 14px;
}

.end-stat strong {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 4px;
  color: #315062;
}

.topbar {
  background: linear-gradient(90deg, #0c7bb1 0%, #0b8cc9 100%);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 8px 22px rgba(7, 67, 100, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.brand-kicker,
.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  opacity: 0.72;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  gap: 3px;
  padding: 8px;
}

.brand-mark span {
  display: block;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
}

.brand-mark span:nth-child(1) {
  clip-path: polygon(0 15%, 100% 0, 85% 100%, 0 78%);
}

.brand-mark span:nth-child(2) {
  clip-path: polygon(10% 12%, 88% 28%, 100% 100%, 0 100%);
}

.brand-mark span:nth-child(3) {
  clip-path: polygon(0 0, 100% 18%, 84% 100%, 14% 86%);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-card {
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: #2e4e62;
  min-width: 118px;
  min-height: 56px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: 0 8px 18px rgba(14, 51, 77, 0.2);
  cursor: pointer;
}

.icon-card.large {
  min-width: 124px;
  flex-direction: column;
  gap: 2px;
}

.exit-card {
  min-width: 96px;
}

.summary-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5f7584;
}

.icon-grid {
  width: 20px;
  height: 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}

.icon-grid::before,
.icon-grid::after,
.icon-grid span::before,
.icon-grid span::after {
  content: "";
}

.icon-grid,
.icon-grid::before,
.icon-grid::after {
  background:
    linear-gradient(#647c8b, #647c8b) 0 0 / 8px 8px no-repeat,
    linear-gradient(#647c8b, #647c8b) 12px 0 / 8px 8px no-repeat,
    linear-gradient(#647c8b, #647c8b) 0 12px / 8px 8px no-repeat,
    linear-gradient(#647c8b, #647c8b) 12px 12px / 8px 8px no-repeat;
}

.timer-card {
  min-width: 110px;
  font-size: 1.55rem;
  font-weight: 700;
  justify-content: space-between;
}

.timer-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #6fd16b;
  box-shadow: 0 0 0 4px rgba(111, 209, 107, 0.18);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 18px 10px;
}

.side-rail {
  display: flex;
  justify-content: center;
  padding-top: 56px;
}

.task-badge {
  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7fd5ff 0%, #4fa9d9 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(59, 124, 162, 0.22);
}

.main-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 10px 0;
}

.stage-header h2 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 500;
  color: #495863;
}

.stage-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.mini-stat {
  min-width: 118px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(183, 198, 212, 0.8);
  box-shadow: 0 10px 18px rgba(38, 75, 102, 0.08);
}

.mini-stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.panel-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 620px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.context-panel {
  border-radius: var(--panel-radius) 0 0 var(--panel-radius);
}

.question-panel {
  border-radius: 0 var(--panel-radius) var(--panel-radius) 0;
}

.panel + .panel {
  border-left: 0;
}

.panel-inner {
  padding: 30px 28px 28px;
}

.panel-corner {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: #1b2730;
  font-size: 1.8rem;
  font-weight: 700;
  cursor: pointer;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 2rem;
  font-weight: 500;
}

.context-lead,
.question-intro,
.question-support,
.context-extra,
.feedback-box,
.option-help {
  color: #556673;
  line-height: 1.58;
}

.figure-box {
  margin-top: 18px;
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f1f6fa 100%);
  border: 1px solid #dbe5ec;
  min-height: 300px;
}

.context-extra {
  margin-top: 16px;
  font-size: 0.96rem;
}

.question-prompt {
  margin: 0 0 8px;
}

.question-support {
  margin-bottom: 18px;
}

.answer-area {
  display: grid;
  gap: 14px;
}

.table-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.96rem;
}

.task-table th {
  background: #0d7cb4;
  color: #fff;
  font-weight: 700;
  padding: 12px 10px;
  text-align: left;
}

.task-table td {
  padding: 10px;
  border-top: 1px solid #e4edf3;
  background: #fff;
}

.task-table tr:nth-child(even) td {
  background: #f8fbfd;
}

.tf-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
}

.pill-btn,
.choice-btn,
.chip-btn,
.placement-tag,
.slot-select,
.nav-btn,
.ghost-btn,
.primary-btn {
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.pill-btn {
  min-width: 76px;
  padding: 10px 16px;
  background: #edf2f6;
  color: #51616e;
  font-weight: 700;
  cursor: pointer;
}

.pill-btn.active {
  background: linear-gradient(180deg, #69b8e1 0%, #3d9ecf 100%);
  color: #fff;
  border-color: #3490bc;
}

.choice-list,
.check-list,
.placement-controls,
.summary-list {
  display: grid;
  gap: 10px;
}

.choice-btn,
.check-btn {
  width: 100%;
  text-align: left;
  background: #fff;
  padding: 14px 16px;
  cursor: pointer;
  border: 1px solid #d9e3ea;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.choice-btn.active,
.check-btn.active {
  background: #eef8fd;
  border-color: #7cc3e7;
}

.choice-copy {
  display: block;
  flex: 1;
}

.choice-letter,
.check-mark {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #dde4ea;
  color: #60727f;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: 0 0 auto;
}

.choice-btn.active .choice-letter,
.check-btn.active .check-mark {
  background: #5ab0da;
  color: #fff;
}

.check-btn {
  border-radius: 16px;
}

.time-row,
.numeric-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.time-row select,
.numeric-row input,
.slot-select {
  border-radius: 12px;
  border: 1px solid #b7cada;
  min-height: 46px;
  padding: 0 14px;
  background: #fff;
}

.placement-layout {
  margin-top: 12px;
  border: 2px solid #8d8a35;
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(180deg, #f8f8e7 0%, #f2f0d2 100%);
}

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

.placement-slot {
  min-height: 130px;
  border: 5px solid #8b8b34;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.placement-slot h4 {
  margin: 0;
  font-size: 0.94rem;
  color: #5a5f21;
}

.ordering-list {
  display: grid;
  gap: 10px;
}

.order-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid #dbe5ec;
  border-radius: 16px;
  padding: 14px 16px;
}

.order-meta {
  font-size: 0.88rem;
  color: #60717e;
}

.order-controls {
  display: flex;
  gap: 8px;
}

.chip-btn {
  min-width: 38px;
  min-height: 38px;
  background: #f3f7fa;
  cursor: pointer;
}

.feedback-box {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid transparent;
}

.feedback-box.good {
  background: var(--green-soft);
  border-color: #b9e8cc;
}

.feedback-box.bad {
  background: var(--red-soft);
  border-color: #efc1c1;
}

.feedback-box.hidden {
  display: none;
}

.question-support ol,
.question-support ul {
  margin: 0;
  padding-left: 1.25rem;
}

.nav-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 18px 18px;
}

.site-footnote {
  padding: 0 18px 18px;
  text-align: center;
  font-size: 0.72rem;
  color: #7a8b97;
}

.nav-btn,
.ghost-btn,
.primary-btn {
  min-height: 46px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid #90a5b4;
  background: linear-gradient(180deg, #8799a6 0%, #738894 100%);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.ghost-btn {
  background: #fff;
  color: #5e6f7b;
  border-color: #cad6e0;
}

.primary-btn {
  background: linear-gradient(180deg, #0c88c5 0%, #0b72a6 100%);
  border-color: #0b6b98;
}

.footer-actions {
  display: flex;
  gap: 12px;
}

.drawer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer.open {
  pointer-events: auto;
  opacity: 1;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 44, 58, 0.42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100%;
  background: #fff;
  box-shadow: -14px 0 34px rgba(24, 42, 56, 0.18);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.drawer-header h3 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 500;
}

.drawer-close {
  border: 0;
  background: #eff4f7;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  font-size: 1.5rem;
  cursor: pointer;
}

.group-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.group-chip {
  border-radius: 999px;
  padding: 8px 12px;
  background: #f1f6fa;
  border: 1px solid #d4e0e8;
  font-size: 0.84rem;
  color: #5b6d79;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.overview-item {
  border: 1px solid #dbe4eb;
  border-radius: 16px;
  min-height: 72px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  font-weight: 700;
  color: #4c606d;
}

.overview-item span {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: #6a7d89;
}

.overview-item.current {
  border-color: #2a9fd6;
  box-shadow: inset 0 0 0 2px rgba(42, 159, 214, 0.18);
}

.overview-item.answered {
  background: #eef8fd;
}

.overview-item.correct {
  background: #e6f8ed;
  border-color: #91d5ad;
}

.summary-panel {
  width: min(620px, 100vw);
}

.summary-body {
  display: grid;
  gap: 16px;
  overflow: auto;
}

.summary-hero {
  border-radius: 24px;
  padding: 22px;
  background: linear-gradient(135deg, #0b82bc 0%, #36a6d8 100%);
  color: #fff;
}

.summary-hero h4,
.summary-card h4 {
  margin: 0 0 8px;
}

.summary-score {
  font-size: 3rem;
  font-weight: 700;
}

.summary-card {
  border: 1px solid #dbe4eb;
  border-radius: 18px;
  padding: 18px;
  background: #fff;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid #edf2f6;
}

.summary-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.summary-actions {
  display: flex;
  justify-content: flex-end;
}

body.context-collapsed .panel-wrap {
  grid-template-columns: minmax(0, 72px) 1fr;
}

body.context-collapsed .context-panel .panel-inner {
  display: none;
}

body.context-collapsed .context-panel {
  min-width: 72px;
}

body.home-mode .topbar,
body.home-mode .workspace,
body.home-mode .nav-footer {
  display: none;
}

body.test-mode .home-screen {
  display: none;
}

body.finished-mode .topbar,
body.finished-mode .workspace,
body.finished-mode .nav-footer {
  display: none;
}

body.finished-mode #homeScreen {
  display: none;
}

body.home-mode #endScreen,
body.test-mode #endScreen {
  display: none;
}

.protected-page {
  min-height: 100vh;
  padding: 28px 18px 18px;
}

.protected-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.protected-card,
.task-view-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #dbe5ec;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.password-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.password-row input {
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid #b7cada;
  padding: 0 14px;
  min-width: min(340px, 100%);
}

.viewer-toolbar,
.task-view-grid {
  display: grid;
  gap: 16px;
}

.viewer-toolbar {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: end;
}

.task-view-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.task-view-card h3 {
  margin: 0 0 8px;
}

.task-view-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.task-view-meta span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef6fb;
  border: 1px solid #d1e3ef;
  font-size: 0.82rem;
  color: #55707f;
}

.answer-key {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f4faf6;
  border: 1px solid #cfe7d4;
}

.svg-wrap {
  width: 100%;
  overflow: hidden;
}

.svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.muted-note {
  color: #718390;
  font-size: 0.92rem;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-rail {
    display: none;
  }

  .panel-wrap {
    grid-template-columns: 1fr;
  }

  .context-panel,
  .question-panel {
    border-radius: var(--panel-radius);
  }

  .panel + .panel {
    border-left: 1px solid var(--line);
    margin-top: 14px;
  }
}

@media (max-width: 760px) {
  .topbar,
  .nav-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .home-card {
    padding: 24px 18px;
  }

  .topbar-actions,
  .footer-actions,
  .stage-stats,
  .password-row {
    width: 100%;
  }

  .icon-card,
  .icon-card.large,
  .timer-card,
  .nav-btn,
  .ghost-btn,
  .primary-btn {
    width: 100%;
  }

  .stage-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-inner {
    padding: 22px 18px 20px;
  }

  .panel h3,
  .stage-header h2 {
    font-size: 1.6rem;
  }
}
