:root {
  --ink: #080a0d;
  --charcoal: #121416;
  --panel: rgba(16, 17, 17, 0.72);
  --panel-strong: rgba(18, 18, 17, 0.9);
  --paper: #f3ead6;
  --muted: rgba(243, 234, 214, 0.66);
  --faint: rgba(243, 234, 214, 0.36);
  --line: rgba(182, 139, 76, 0.32);
  --bronze: #b68b4c;
  --bronze-bright: #d4ad68;
  --teal: #6bb7b8;
  --teal-strong: #81e0df;
  --bad: #d98a68;
  --good: #9ed6a1;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
  --font-display: "STSong", "Songti SC", "SimSun", "Noto Serif CJK SC", serif;
  --font-body: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-data: "Consolas", "Microsoft YaHei UI", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 62% 14%, rgba(182, 139, 76, 0.16), transparent 30%),
    radial-gradient(circle at 68% 70%, rgba(107, 183, 184, 0.12), transparent 34%),
    linear-gradient(125deg, #070809 0%, #111315 46%, #08090b 100%);
  z-index: 0;
}

#three-field {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 1;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: screen;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 304px;
  height: 100vh;
  min-height: 680px;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.14), transparent 34%, rgba(0, 0, 0, 0.18));
}

.index-panel,
.status-panel {
  min-width: 0;
  background: rgba(8, 9, 10, 0.68);
  backdrop-filter: blur(18px);
  border-color: var(--line);
  border-style: solid;
}

.index-panel {
  border-width: 0 1px 0 0;
  padding: 32px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.status-panel {
  border-width: 0 0 0 1px;
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(27px, 2.4vw, 36px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 0;
  text-shadow: 0 0 24px rgba(243, 234, 214, 0.18);
}

.brand p,
.micro-label,
.question-meta,
.save-state,
.stats dt,
.index-tools,
.feedback {
  color: var(--muted);
}

.brand p {
  margin: 12px 0 0;
  font-size: 13px;
}

.icon-button,
.text-button,
.auto-button,
.hint-button,
.mode-button,
.nav-button,
.wide-button,
.action-button,
.pill-button {
  border: 1px solid var(--line);
  background: rgba(13, 14, 15, 0.66);
  border-radius: 8px;
  min-height: 42px;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.icon-button:hover,
.text-button:hover,
.auto-button:hover,
.hint-button:hover,
.mode-button:hover,
.nav-button:hover,
.wide-button:hover,
.action-button:hover,
.pill-button:hover {
  border-color: rgba(129, 224, 223, 0.7);
  color: var(--teal-strong);
  background: rgba(22, 34, 34, 0.72);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.icon-button {
  width: 44px;
  display: grid;
  place-items: center;
}

.icon-lines,
.icon-lines::before,
.icon-lines::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  opacity: 0.75;
}

.icon-lines {
  position: relative;
}

.icon-lines::before,
.icon-lines::after {
  content: "";
  position: absolute;
  left: 0;
}

.icon-lines::before {
  top: -6px;
}

.icon-lines::after {
  top: 6px;
}

.index-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid rgba(243, 234, 214, 0.16);
  font-size: 14px;
}

.text-button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--paper);
}

.auto-button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--teal-strong);
  border-color: rgba(129, 224, 223, 0.48);
  background: rgba(24, 51, 51, 0.5);
}

.auto-button.is-off {
  color: var(--muted);
  border-color: rgba(243, 234, 214, 0.16);
  background: rgba(13, 14, 15, 0.66);
}

.question-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  display: grid;
  align-content: start;
  gap: 8px;
  overscroll-behavior: contain;
}

.question-list::-webkit-scrollbar,
.prompt::-webkit-scrollbar,
.answer-zone::-webkit-scrollbar {
  width: 8px;
}

.question-list::-webkit-scrollbar-thumb,
.prompt::-webkit-scrollbar-thumb,
.answer-zone::-webkit-scrollbar-thumb {
  background: rgba(182, 139, 76, 0.35);
  border-radius: 99px;
}

.question-item {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr 22px;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-bottom-color: rgba(243, 234, 214, 0.1);
  background: transparent;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
}

.question-item .num {
  font-family: var(--font-data);
  font-size: 20px;
  color: var(--paper);
}

.question-item .name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 14px;
}

.question-item .dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(243, 234, 214, 0.35);
}

.question-item.is-current {
  border-color: rgba(129, 224, 223, 0.7);
  background: rgba(28, 52, 52, 0.42);
  box-shadow: 0 0 22px rgba(107, 183, 184, 0.16);
}

.question-item.is-correct .dot {
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 0 12px rgba(107, 183, 184, 0.55);
}

.question-item.is-partial .dot,
.question-item.is-wrong .dot {
  background: var(--bronze);
  border-color: var(--bronze);
}

.stage {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  padding: 26px 34px 24px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 70px;
  gap: 12px;
}

.stage-top {
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.micro-label {
  margin: 0 0 8px;
  font-size: 12px;
}

.stage-top h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(23px, 1.9vw, 36px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-state {
  font-size: 12px;
  border: 1px solid rgba(243, 234, 214, 0.16);
  border-radius: 99px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.22);
}

.hint-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  color: var(--paper);
}

.bulb {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50% 50% 42% 42%;
  position: relative;
}

.bulb::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  left: 3px;
  bottom: -6px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor;
}

.exercise-card {
  position: relative;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(243, 234, 214, 0.055), transparent 40%),
    rgba(16, 16, 15, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  padding: clamp(18px, 2vw, 30px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

.card-corners,
.card-corners::before,
.card-corners::after {
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(182, 139, 76, 0.18);
}

.card-corners::before,
.card-corners::after {
  content: "";
  inset: -6px auto auto -6px;
  width: 36px;
  height: 36px;
  border-right: 0;
  border-bottom: 0;
}

.card-corners::after {
  inset: auto -6px -6px auto;
  border: 1px solid rgba(182, 139, 76, 0.28);
  border-left: 0;
  border-top: 0;
}

.question-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-data);
  font-size: 14px;
}

#question-number {
  font-size: 30px;
  color: var(--bronze-bright);
}

.prompt {
  position: relative;
  z-index: 1;
  min-height: 0;
  max-height: clamp(190px, 32vh, 310px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  font-family: var(--font-display);
  font-size: clamp(22px, 1.95vw, 32px);
  line-height: 1.66;
  color: rgba(243, 234, 214, 0.95);
  white-space: pre-wrap;
}

.blank-mark {
  display: inline-block;
  min-width: 5.2em;
  border-bottom: 1px solid rgba(243, 234, 214, 0.54);
  transform: translateY(-0.12em);
}

.hint-panel {
  position: relative;
  z-index: 1;
  border-left: 2px solid var(--teal);
  padding: 12px 14px;
  color: rgba(243, 234, 214, 0.84);
  background: rgba(35, 58, 58, 0.36);
  font-size: 14px;
  line-height: 1.55;
  max-height: 82px;
  overflow: auto;
}

.answer-zone {
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.sub-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pill-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
}

.pill-button.is-active {
  color: var(--teal-strong);
  border-color: rgba(129, 224, 223, 0.72);
  background: rgba(30, 67, 67, 0.42);
}

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

.answer-field {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(243, 234, 214, 0.14);
  background: rgba(0, 0, 0, 0.24);
  border-radius: 8px;
}

.answer-field span {
  color: var(--bronze-bright);
  font-family: var(--font-data);
}

.answer-field input,
.jump-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(243, 234, 214, 0.12);
  color: var(--paper);
  background: rgba(243, 234, 214, 0.06);
  border-radius: 6px;
}

.answer-field input {
  height: 44px;
  padding: 0 12px;
}

.answer-field.is-correct {
  border-color: rgba(158, 214, 161, 0.68);
}

.answer-field.is-wrong {
  border-color: rgba(217, 138, 104, 0.72);
}

.choice-list {
  display: grid;
  gap: 12px;
  padding-bottom: 8px;
}

.choice-row {
  border: 1px solid rgba(243, 234, 214, 0.13);
  background: rgba(0, 0, 0, 0.24);
  border-radius: 8px;
  padding: 12px;
}

.choice-title {
  margin-bottom: 8px;
  color: var(--bronze-bright);
  font-family: var(--font-data);
}

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

.option-button {
  border: 1px solid rgba(243, 234, 214, 0.13);
  background: rgba(243, 234, 214, 0.045);
  color: rgba(243, 234, 214, 0.88);
  border-radius: 8px;
  min-height: 50px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: clamp(18px, 1.45vw, 24px);
  line-height: 1.35;
}

.option-button.is-selected {
  border-color: var(--teal);
  color: var(--teal-strong);
  background: rgba(30, 67, 67, 0.38);
}

.assemble-board {
  display: grid;
  gap: 12px;
}

.target-strip {
  min-height: 64px;
  border: 1px solid rgba(129, 224, 223, 0.28);
  background: rgba(10, 20, 20, 0.44);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-display);
  font-size: clamp(20px, 1.7vw, 28px);
  line-height: 1.45;
}

.token-pool,
.assembled-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.token {
  min-width: 42px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(243, 234, 214, 0.15);
  background: rgba(243, 234, 214, 0.07);
  color: var(--paper);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: clamp(20px, 1.55vw, 26px);
}

.token.is-used {
  opacity: 0.3;
  pointer-events: none;
}

.answer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 0;
  padding-bottom: 2px;
  flex-wrap: wrap;
  position: relative;
  z-index: 4;
}

.action-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-button {
  min-height: 42px;
  padding: 0 16px;
}

.action-button.primary {
  color: #07100f;
  border-color: var(--teal-strong);
  background: linear-gradient(135deg, var(--teal-strong), #6ab1ad);
  box-shadow: 0 0 22px rgba(107, 183, 184, 0.2);
}

.feedback {
  min-height: 18px;
  position: relative;
  z-index: 1;
  font-size: 14px;
}

.feedback.good {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(9, 10, 10, 0.68);
  backdrop-filter: blur(18px);
  border-radius: 8px;
  overflow: hidden;
  align-self: stretch;
  min-height: 0;
}

.mode-button {
  border-radius: 0;
  border: 0;
  border-right: 1px solid rgba(243, 234, 214, 0.12);
  min-height: 70px;
  font-size: clamp(18px, 1.45vw, 24px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  color: rgba(243, 234, 214, 0.58);
  background: transparent;
}

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

.mode-button.is-active {
  color: var(--teal-strong);
  background: rgba(25, 55, 55, 0.5);
  box-shadow: inset 0 0 0 1px rgba(129, 224, 223, 0.45), 0 0 28px rgba(107, 183, 184, 0.14);
}

.mode-icon {
  font-family: var(--font-data);
}

.progress-card,
.jump-card {
  border: 1px solid rgba(243, 234, 214, 0.16);
  background: rgba(0, 0, 0, 0.22);
  padding: 22px;
}

.progress-card h3,
.jump-card h3 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.ring {
  --angle: calc(var(--progress) * 3.6deg);
  width: 166px;
  height: 166px;
  margin: 6px auto 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--angle), rgba(243, 234, 214, 0.1) 0);
  box-shadow: 0 0 34px rgba(107, 183, 184, 0.12);
}

.ring::before {
  content: "";
  position: absolute;
}

.ring > div {
  width: 124px;
  height: 124px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: #0b0c0d;
}

.ring strong {
  font-family: var(--font-display);
  font-size: 38px;
}

.ring span {
  color: var(--muted);
  font-family: var(--font-data);
}

.stats {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid rgba(243, 234, 214, 0.16);
}

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.stats dt,
.stats dd {
  margin: 0;
}

.stats dd {
  color: var(--paper);
}

.jump-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 10px;
}

.nav-button {
  font-size: 30px;
}

.jump-row input {
  text-align: center;
  font-family: var(--font-data);
  font-size: 18px;
}

.wide-button {
  width: 100%;
  margin-top: 12px;
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(129, 224, 223, 0.45);
  background: rgba(7, 12, 12, 0.9);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.list-collapsed .app-shell {
  grid-template-columns: 88px minmax(0, 1fr) 304px;
}

body.list-collapsed .brand h1,
body.list-collapsed .brand p,
body.list-collapsed .index-tools,
body.list-collapsed .question-item .name {
  display: none;
}

body.list-collapsed .question-item {
  grid-template-columns: 1fr;
  place-items: center;
}

body.list-collapsed .question-item .dot {
  display: none;
}

@media (max-width: 1180px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell,
  body.list-collapsed .app-shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .index-panel,
  .status-panel {
    border-width: 0 0 1px;
  }

  .index-panel {
    padding: 20px;
    height: auto;
    overflow: visible;
  }

  .question-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(92px, 130px);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .question-item {
    grid-template-columns: 1fr;
    min-height: 70px;
    text-align: center;
  }

  .question-item .name,
  .question-item .dot {
    display: none;
  }

  .stage {
    padding: 22px;
  }

  .exercise-card {
    grid-template-rows: auto minmax(170px, 0.95fr) auto minmax(220px, 1.05fr) auto;
  }

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

@media (max-height: 760px) and (min-width: 1181px) {
  .stage {
    padding: 22px 30px 20px;
    grid-template-rows: auto minmax(0, 1fr) 64px;
    gap: 10px;
  }

  .stage-top h2 {
    font-size: clamp(22px, 1.65vw, 30px);
  }

  .exercise-card {
    padding: 18px 24px;
    grid-template-rows: auto minmax(150px, 0.9fr) auto minmax(170px, 1.1fr) auto;
    gap: 10px;
  }

  .prompt {
    font-size: clamp(19px, 1.55vw, 27px);
    line-height: 1.5;
  }

  .mode-button {
    min-height: 62px;
  }
}

@media (max-width: 760px) {
  .stage-top,
  .top-actions,
  .answer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .input-grid,
  .choice-options,
  .status-panel {
    grid-template-columns: 1fr;
  }

  .mode-button {
    min-height: 60px;
    font-size: 16px;
    gap: 8px;
  }

  .exercise-card {
    padding: 22px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
