:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #15201d;
  --muted: #65736f;
  --line: #d9e3df;
  --green: #176b5c;
  --green-2: #0f4f45;
  --orange: #cf6f2c;
  --blue: #2f66b3;
  --red: #b93b3b;
  --ok: #198754;
  --shadow: 0 14px 40px rgba(20, 39, 33, 0.09);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 92px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 5vw, 34px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.45;
  letter-spacing: 0;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.top-stats {
  display: grid;
  min-width: 76px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}

.top-stats span {
  color: var(--green);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.top-stats small {
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 14px;
}

.rail {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(217, 227, 223, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(20, 39, 33, 0.14);
  backdrop-filter: blur(10px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav-item.active {
  background: var(--green);
  color: #fff;
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

.tab-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.controls-grid.two {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #c8d7d2;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 107, 92, 0.16);
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe8;
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 180ms ease;
}

.question-panel {
  min-height: 360px;
  padding: 18px;
}

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

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f1ee;
  color: var(--green-2);
  font-size: 12px;
  font-weight: 800;
}

.option-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.option {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.option:hover {
  border-color: #9bbdb4;
}

.option.selected {
  border-color: var(--blue);
  background: #edf4ff;
}

.option.correct {
  border-color: var(--ok);
  background: #ecf8f1;
}

.option.wrong {
  border-color: var(--red);
  background: #fff0ef;
}

.option-key {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #eef4f1;
  color: var(--green-2);
  font-weight: 900;
}

.result-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.result-box strong {
  display: block;
  margin-bottom: 6px;
}

.result-ok {
  color: var(--ok);
}

.result-bad {
  color: var(--red);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

.primary,
.secondary,
.danger,
.icon-button,
.ghost {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.primary {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
}

.primary:disabled,
.secondary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary,
.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.danger {
  border: 1px solid #f0c0bd;
  background: #fff5f4;
  color: var(--red);
}

.icon-button {
  width: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--orange);
  font-size: 24px;
  line-height: 1;
}

.empty {
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
}

.list-panel {
  display: grid;
  gap: 0;
  max-height: min(68vh, 760px);
  overflow: auto;
}

.list-row {
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.row-title {
  margin: 0;
  line-height: 1.55;
  font-weight: 800;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.segment {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

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

.stat-tile {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-tile b {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-size: 28px;
  line-height: 1;
}

.stat-tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.type-stats {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}

.type-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mini-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe8;
}

.mini-bar span {
  display: block;
  height: 100%;
  background: var(--orange);
}

@media (min-width: 740px) {
  .app-shell {
    padding: 24px;
  }

  .layout {
    grid-template-columns: 170px minmax(0, 1fr);
    align-items: start;
  }

  .rail {
    position: sticky;
    top: 24px;
    display: grid;
    grid-template-columns: 1fr;
    align-self: start;
    padding: 10px;
  }

  .nav-item {
    grid-template-columns: 28px 1fr;
    place-items: center start;
    min-height: 48px;
    padding: 0 12px;
    font-size: 14px;
  }

  .controls-grid {
    grid-template-columns: 1fr 1fr 1fr auto;
    align-items: end;
  }

  .controls-grid.two {
    grid-template-columns: 1.5fr 260px;
  }

  .question-panel {
    min-height: 420px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .controls-grid,
  .action-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    padding: 16px 14px;
  }

  .question-panel,
  .controls-grid,
  .progress-wrap,
  .action-row,
  .stats-grid,
  .segmented {
    padding-right: 14px;
    padding-left: 14px;
  }
}
