:root {
  color-scheme: dark;
  --bg: #071011;
  --bg-2: #0c1718;
  --panel: #111d1f;
  --panel-2: #152426;
  --ink: #edf8f4;
  --text: #d5e3df;
  --muted: #88a09b;
  --line: #274143;
  --line-strong: #3b6769;
  --teal: #22d1bf;
  --teal-2: #117e78;
  --amber: #f7bd43;
  --orange: #ef8042;
  --red: #ff5b55;
  --green: #52d986;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  --r: 8px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 10%, rgba(34, 209, 191, 0.08), transparent 30%),
    linear-gradient(135deg, #050a0b 0%, #0a1415 48%, #050909 100%);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: 330px minmax(360px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(5, 12, 13, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: var(--teal);
  background: linear-gradient(145deg, #0b1718, #172527);
}

.brand h1 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

.tabs {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: #101b1d;
}

.tab {
  min-width: 136px;
  height: 48px;
  padding: 0 18px;
  color: var(--text);
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  font-weight: 700;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  color: #051313;
  background: var(--teal);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #101c1e;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--bg);
  background: linear-gradient(145deg, var(--teal), #8ef3e5);
  font-weight: 900;
}

.user-meta {
  min-width: 0;
  flex: 1;
}

.user-meta strong,
.user-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta strong {
  color: var(--ink);
  font-size: 14px;
}

.user-meta span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.ghost-btn,
.primary-btn,
.danger-btn {
  min-height: 40px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--text);
  background: #0b1516;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.ghost-btn:hover {
  border-color: var(--teal);
  color: var(--ink);
}

.primary-btn {
  border-color: #35d8cb;
  background: linear-gradient(180deg, #28cfc0, #149186);
  color: #041312;
  box-shadow: 0 12px 28px rgba(34, 209, 191, 0.2);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-btn {
  border-color: rgba(255, 91, 85, 0.45);
  color: #ffd6d3;
}

.shell {
  width: min(1740px, calc(100vw - 28px));
  margin: 14px auto;
  display: grid;
  grid-template-columns: 220px minmax(560px, 1fr) 410px;
  gap: 12px;
  flex: 1;
}

.panel {
  background: rgba(14, 24, 26, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.rail {
  padding: 18px 14px;
}

.rail-title,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
  margin-bottom: 14px;
}

.rail-list {
  display: grid;
  gap: 8px;
}

.stage-button {
  width: 100%;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: transparent;
  color: var(--text);
  padding: 10px 8px;
  position: relative;
}

.stage-button::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 48px;
  bottom: -14px;
  width: 1px;
  background: var(--line);
}

.stage-button:last-child::before {
  display: none;
}

.stage-button.active {
  border-color: rgba(34, 209, 191, 0.65);
  background: linear-gradient(90deg, rgba(34, 209, 191, 0.16), rgba(34, 209, 191, 0.04));
}

.stage-button.locked {
  opacity: 0.55;
}

.stage-index {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: #0a1415;
  z-index: 1;
}

.stage-button.done .stage-index {
  color: #062019;
  border-color: var(--green);
  background: var(--green);
}

.stage-button.active .stage-index {
  color: #041312;
  border-color: var(--teal);
  background: var(--teal);
}

.stage-label strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
}

.stage-label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  margin-top: 4px;
}

.reward-box {
  margin-top: 18px;
  border: 1px solid rgba(247, 189, 67, 0.45);
  border-radius: var(--r);
  padding: 14px;
  background: rgba(247, 189, 67, 0.08);
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
}

.reward-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r);
  display: grid;
  place-items: center;
  color: #261904;
  background: var(--amber);
}

.reward-box strong {
  display: block;
  color: var(--amber);
  margin-bottom: 4px;
}

.reward-box span {
  color: var(--muted);
  font-size: 13px;
}

.mission {
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr) auto;
  gap: 10px;
}

.mission-head {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 18px;
}

.mission-title {
  min-width: 0;
}

.mission-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
}

.mission-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 8px 10px;
  color: var(--teal);
  background: #0b1718;
  font-weight: 800;
}

.case-strip {
  margin: 0 18px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #0a1314;
  color: var(--text);
  line-height: 1.65;
}

.viewer {
  margin: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #050909;
  min-height: 430px;
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto;
  overflow: hidden;
}

.image-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  background: #0d1718;
  overflow-x: auto;
  padding: 8px;
}

.image-tab {
  border: 0;
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.image-tab.active {
  background: rgba(34, 209, 191, 0.14);
  color: var(--teal);
}

.scan-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  min-height: 320px;
}

.scan-frame {
  position: relative;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  background:
    linear-gradient(rgba(34, 209, 191, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 209, 191, 0.12) 1px, transparent 1px),
    #020506;
  background-size: 25% 50%, 33.3% 50%;
}

.scan-frame.is-panning {
  cursor: grab;
}

.scan-frame.is-panning:active {
  cursor: grabbing;
}

.scan-canvas {
  position: relative;
  display: block;
  width: 100%;
  transform: translate(var(--scan-pan-x), var(--scan-pan-y)) scale(var(--scan-zoom));
  transform-origin: center;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.scan-canvas img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border: 1px solid rgba(66, 101, 102, 0.8);
  background: #000;
  filter: var(--scan-filter);
}

.tools {
  display: grid;
  align-content: center;
  gap: 8px;
  border-left: 1px solid var(--line);
  background: #0a1415;
  padding: 8px;
}

.tool {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #101b1d;
}

.tool:hover {
  color: var(--teal);
  border-color: var(--teal);
}

.tool.active {
  color: #041312;
  border-color: var(--teal);
  background: var(--teal);
}

.viewer-hud {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: calc(100% - 36px);
  border: 1px solid rgba(34, 209, 191, 0.45);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--ink);
  background: rgba(3, 10, 11, 0.82);
  font-size: 12px;
  line-height: 1.25;
  pointer-events: none;
}

.caption {
  min-height: 52px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.5;
}

.clue-row {
  margin: 0 18px 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.clue-item {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  background: #0c1718;
  min-width: 0;
}

.clue-item strong {
  display: block;
  color: var(--teal);
  font-size: 13px;
  margin-bottom: 6px;
}

.clue-item span {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.challenge {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  align-self: start;
  max-height: calc(100vh - 176px);
  position: sticky;
  top: 92px;
}

.challenge h3,
.teacher h2,
.knowledge h2 {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.25;
}

.question-list {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-right: 3px;
  flex: 1 1 auto;
  min-height: 0;
}

.question {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.question-title {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--ink);
  line-height: 1.55;
  margin-bottom: 10px;
}

.q-index {
  color: var(--teal);
  font-weight: 900;
}

.options {
  display: grid;
  gap: 7px;
}

.option {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 9px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 8px;
  color: var(--text);
}

.option input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.option:hover {
  border-color: var(--line);
  background: #0b1516;
}

.text-answer {
  width: 100%;
  min-height: 42px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #071011;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.text-answer:focus {
  border-color: var(--teal);
}

.challenge-actions {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) minmax(150px, 1.4fr) minmax(96px, 0.8fr);
  gap: 8px;
}

.feedback {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #0b1516;
  padding: 12px;
  line-height: 1.6;
}

.feedback.good {
  border-color: rgba(82, 217, 134, 0.55);
}

.feedback.warn {
  border-color: rgba(247, 189, 67, 0.55);
}

.feedback strong {
  color: var(--ink);
}

.feedback p {
  margin: 8px 0 0;
  color: var(--muted);
}

.statusbar {
  width: min(1740px, calc(100vw - 28px));
  margin: 0 auto 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: rgba(14, 24, 26, 0.94);
  box-shadow: var(--shadow);
}

.status-item {
  min-height: 88px;
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.status-item:last-child {
  border-right: 0;
}

.status-icon {
  color: var(--muted);
}

.status-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-item strong {
  display: block;
  color: var(--ink);
  font-size: 28px;
  margin-top: 4px;
  line-height: 1;
}

.status-item strong.teal {
  color: var(--teal);
}

.status-item strong.amber {
  color: var(--amber);
}

.teacher,
.knowledge {
  width: min(1740px, calc(100vw - 28px));
  margin: 14px auto;
  display: grid;
  gap: 12px;
}

.teacher-grid {
  display: grid;
  grid-template-columns: 1fr 410px;
  gap: 12px;
}

.teacher-main,
.teacher-side,
.knowledge-section {
  padding: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px;
  background: #0b1516;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 26px;
  margin-top: 6px;
}

.metric strong.good {
  color: var(--green);
}

.metric strong.warn {
  color: var(--amber);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #091314;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--ink);
  background: #101b1d;
  font-weight: 800;
}

td {
  color: var(--text);
}

tr:last-child td {
  border-bottom: 0;
}

.bar {
  height: 9px;
  width: 78px;
  border-radius: 99px;
  overflow: hidden;
  background: #243335;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--green);
}

.bar.mid i {
  background: var(--amber);
}

.bar.low i {
  background: var(--red);
}

.teacher-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.weak-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.weak-row {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.weak-row:last-child {
  border-bottom: 0;
}

.weak-row strong {
  color: var(--ink);
  font-size: 14px;
}

.weak-row span {
  color: var(--muted);
  font-size: 12px;
}

.weak-score {
  text-align: right;
  color: var(--amber);
  font-weight: 900;
}

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

.knowledge-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  background: #0b1516;
}

.knowledge-card h3 {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 17px;
}

.knowledge-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.65;
}

.login-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(4, 9, 10, 0.88), rgba(4, 9, 10, 0.94)),
    url("./public/design/escape-room-concept.png") center / cover;
  z-index: 50;
}

.login-panel {
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: rgba(10, 18, 19, 0.95);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.56);
  overflow: hidden;
}

.login-copy {
  padding: 34px;
  border-right: 1px solid var(--line);
  background: rgba(34, 209, 191, 0.07);
}

.login-copy h1 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 36px;
  line-height: 1.12;
}

.login-copy p {
  margin: 0;
  color: var(--text);
  line-height: 1.7;
}

.login-form {
  padding: 34px;
  display: grid;
  gap: 14px;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.role-switch button {
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-weight: 800;
}

.role-switch button:last-child {
  border-right: 0;
}

.role-switch button.active {
  background: var(--teal);
  color: #041312;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #071011;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
}

.field input[readonly] {
  color: var(--text);
  background: #0b1516;
}

.inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.small-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 12px 16px;
  color: var(--ink);
  background: #0b1516;
  box-shadow: var(--shadow);
  z-index: 100;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.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: 1320px) {
  .shell {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .rail {
    grid-row: 1 / span 2;
  }

  .mission,
  .challenge {
    grid-column: 2;
  }

  .challenge {
    position: static;
    max-height: none;
  }

  .question-list {
    overflow: visible;
  }
}

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

  .tabs,
  .user-chip {
    width: 100%;
  }

  .tab {
    flex: 1;
    min-width: 0;
  }

  .shell {
    grid-template-columns: 156px minmax(0, 1fr);
    gap: 10px;
  }

  .challenge {
    grid-column: 2;
    padding: 14px;
  }

  .rail {
    padding: 14px 10px;
  }

  .teacher-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .brand h1 {
    font-size: 24px;
  }

  .shell,
  .statusbar,
  .teacher,
  .knowledge {
    width: calc(100vw - 16px);
  }

  .shell {
    grid-template-columns: 1fr;
    margin-top: 8px;
  }

  .rail,
  .mission,
  .challenge {
    grid-column: auto;
    grid-row: auto;
  }

  .challenge {
    position: static;
    max-height: none;
  }

  .rail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-button::before {
    display: none;
  }

  .mission-head {
    grid-template-columns: 1fr;
  }

  .scan-stage {
    grid-template-columns: 1fr;
  }

  .tools {
    grid-template-columns: repeat(5, 1fr);
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .tool {
    width: 100%;
  }

  .challenge-actions {
    grid-template-columns: 1fr;
  }

  .clue-row,
  .metrics,
  .knowledge-grid,
  .statusbar {
    grid-template-columns: 1fr;
  }

  .status-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-item:last-child {
    border-bottom: 0;
  }

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

  .login-copy {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 24px;
  }

  .login-form {
    padding: 24px;
  }
}
