:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #eaf1f4;
  --line: #d6e0e6;
  --text: #16242f;
  --muted: #5d7081;
  --primary: #0f6e63;
  --primary-dark: #0a4f47;
  --danger: #b13a3a;
  --danger-soft: #fff0ef;
  --success: #1f7a4d;
  --shadow: 0 12px 30px rgba(15, 40, 50, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 650;
  min-height: 38px;
  padding: 0 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.38;
}

h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

#sourceSummary {
  color: var(--muted);
  margin-top: 5px;
}

.brand h1 {
  background: linear-gradient(90deg, var(--primary), #1a9b86);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--primary);
}

.actions,
.answer-actions,
.answer-controls,
.review-controls,
.type-tabs,
.collection-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.type-tabs,
.collection-tabs {
  margin: 10px 0;
}

.tab {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.tab span {
  color: var(--muted);
  font-size: 13px;
  margin-left: 8px;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.tab.active span {
  color: rgba(255, 255, 255, 0.82);
}

.collection.active {
  background: #1f3540;
  border-color: #1f3540;
}

.practice-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 2px;
}

.order-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.order-toggle .tab {
  border: none;
  border-radius: 0;
  background: var(--surface);
  min-height: 36px;
}

.order-toggle .tab + .tab {
  border-left: 1px solid var(--line);
}

.order-toggle .tab.active {
  background: var(--primary);
  color: #ffffff;
}

.search-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 240px;
  min-width: 180px;
}

.search-box input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 110, 99, 0.14);
}

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 14px;
  flex: 1 1 auto;
}

.progress-panel {
  margin-bottom: 16px;
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.progress-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.progress-stats {
  font-size: 12px;
  color: var(--muted);
}

.progress-stats b {
  font-weight: 800;
}

.progress-stats .stat-correct {
  color: var(--success);
}

.progress-stats .stat-wrong {
  color: var(--danger);
}

.progress-bar {
  position: relative;
  display: flex;
  height: 12px;
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.progress-seg {
  height: 100%;
  transition: width 0.35s ease;
}

.progress-seg.correct {
  background: linear-gradient(90deg, #2aa870, #1f7a4d);
}

.progress-seg.wrong {
  background: linear-gradient(90deg, #d16060, #b13a3a);
}

.question-pane,
.feedback-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 620px;
  padding: 20px;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.progress {
  color: var(--muted);
  flex: 0 0 auto;
  font-weight: 700;
  padding-top: 3px;
}

.options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.option {
  align-items: flex-start;
  background: #fbfdfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 36px minmax(0, 1fr);
  min-height: 48px;
  padding: 11px 12px;
}

.option:hover {
  border-color: var(--primary);
}

.option input {
  margin-top: 4px;
}

.option-mark {
  align-items: center;
  background: var(--surface-soft);
  border-radius: 6px;
  color: var(--primary-dark);
  display: inline-flex;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  width: 32px;
}

.option-text {
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.review-correct-option .option-text {
  color: var(--danger);
  font-weight: 700;
}

.review-correct-option .option-mark {
  background: var(--danger-soft);
  color: var(--danger);
}

.review-correct-option input {
  accent-color: var(--danger);
}

.answer-actions {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 16px;
}

.answer-controls[hidden],
.review-controls[hidden] {
  display: none;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: #e6f1ee;
  border-color: #cfe5df;
  color: #0a4f47;
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  background: var(--danger-soft);
  border-color: #f0c5c1;
  color: var(--danger);
}

.answer-block {
  background: #f6faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  padding: 14px;
}

.answer-block p + p {
  margin-top: 8px;
}

.feedback-pane {
  position: sticky;
  top: 16px;
}

.feedback-pane.flash {
  animation: feedback-flash 0.65s ease-out;
}

@keyframes feedback-flash {
  0% {
    border-color: #d9822b;
    box-shadow: 0 0 0 4px rgba(217, 130, 43, 0.25), var(--shadow);
  }
  100% {
    border-color: var(--line);
    box-shadow: var(--shadow);
  }
}

.feedback-empty {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  min-height: 180px;
  padding: 18px;
}

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

.feedback-options {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.feedback-option {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

.feedback-option span {
  align-items: center;
  background: var(--surface-soft);
  border-radius: 6px;
  color: var(--primary-dark);
  display: inline-flex;
  font-weight: 800;
  height: 26px;
  justify-content: center;
}

.feedback-option.correct-option {
  background: #eef8f2;
  border-color: #b6d8c4;
}

.feedback-option.correct-option span {
  background: #dcefe3;
  color: var(--success);
}

.feedback-option.selected-option {
  outline: 2px solid #d9822b;
  outline-offset: 1px;
}

.feedback-analysis {
  background: #fff8ea;
  border: 1px solid #edd8a8;
  border-radius: 8px;
  margin-top: 14px;
  padding: 13px;
}

.empty-state {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  min-height: 260px;
  padding: 20px;
}

.site-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.site-footer .dot {
  opacity: 0.5;
}

@media (max-width: 900px) {
  body {
    font-size: 13px;
    line-height: 1.28;
  }

  button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 13px;
  }

  .app-shell {
    padding: 8px;
  }

  .topbar,
  .pane-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 6px;
    margin-bottom: 6px;
  }

  h1 {
    display: none;
  }

  h2 {
    font-size: 15px;
    line-height: 1.28;
  }

  h3 {
    font-size: 14px;
    margin-bottom: 5px;
  }

  #sourceSummary {
    font-size: 12px;
    margin-top: 0;
  }

  #resetAllButton {
    display: none;
  }

  .actions,
  .answer-actions,
  .answer-controls,
  .review-controls,
  .type-tabs,
  .collection-tabs {
    gap: 5px;
  }

  .type-tabs,
  .collection-tabs {
    margin: 5px 0;
  }

  .practice-toolbar {
    gap: 6px;
    margin: 2px 0;
  }

  .order-toggle .tab {
    min-height: 30px;
  }

  .search-box {
    flex: 1 1 100%;
    order: 3;
  }

  .search-box input {
    height: 32px;
  }

  .progress-panel {
    margin-bottom: 10px;
  }

  .progress-head {
    margin-bottom: 5px;
  }

  .tab span {
    font-size: 11px;
    margin-left: 4px;
  }

  .practice-layout {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 6px;
  }

  .question-pane,
  .feedback-pane {
    min-height: auto;
    padding: 10px;
    border-radius: 6px;
    box-shadow: none;
  }

  .feedback-pane {
    position: static;
  }

  .pane-header {
    gap: 6px;
    margin-bottom: 8px;
  }

  .eyebrow {
    font-size: 11px;
    margin-bottom: 3px;
  }

  .progress {
    font-size: 12px;
    padding-top: 0;
  }

  .options {
    gap: 6px;
    margin: 9px 0;
  }

  .option {
    gap: 7px;
    grid-template-columns: auto 28px minmax(0, 1fr);
    min-height: 34px;
    padding: 7px 8px;
    border-radius: 6px;
  }

  .option input {
    margin-top: 2px;
  }

  .option-mark {
    height: 22px;
    width: 26px;
    border-radius: 5px;
    font-size: 12px;
  }

  .option-text {
    font-size: 13px;
  }

  .answer-actions {
    margin-top: 10px;
    padding-top: 8px;
  }

  .answer-controls {
    justify-content: flex-end;
    width: 100%;
  }

  .answer-controls button {
    flex: 0 0 auto;
  }

  .review-controls {
    flex-wrap: nowrap;
    width: 100%;
  }

  .review-controls button {
    flex: 1 1 0;
  }

  .answer-block {
    margin-top: 10px;
    padding: 9px;
  }

  .feedback-empty {
    min-height: 70px;
    padding: 10px;
  }

  .feedback-row {
    margin-top: 8px;
    padding-top: 8px;
  }

  .feedback-options {
    gap: 5px;
    margin-top: 8px;
  }

  .feedback-option {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
    border-radius: 6px;
  }

  .feedback-option span {
    height: 22px;
    font-size: 12px;
  }

  .feedback-analysis {
    margin-top: 8px;
    padding: 8px;
  }

  .empty-state {
    min-height: 90px;
    padding: 10px;
  }

  .answer-actions button,
  .actions button {
    flex: 1 1 96px;
  }
}
