:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-strong: #f0f7ff;
  --text: #182230;
  --muted: #637083;
  --line: #d9e2ec;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #12805c;
  --green-soft: #dcfce7;
  --red: #c2410c;
  --red-soft: #ffedd5;
  --yellow: #facc15;
  --shadow: 0 18px 45px rgba(24, 34, 48, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 280px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.brand {
  display: grid;
  gap: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 22px 22px 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

.panel-body {
  padding: 18px 22px 22px;
}

.field {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.field label,
.field-title {
  color: #304052;
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.segment {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment[aria-pressed="true"] {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

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

.week-button {
  display: grid;
  gap: 4px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #304052;
  padding: 10px 12px;
  text-align: left;
}

.week-button[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green-soft);
  color: #065f46;
}

.week-number {
  font-weight: 900;
}

.week-topic {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.week-button[aria-pressed="true"] .week-topic {
  color: #047857;
}

.count-control {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 8px;
}

.count-control button {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.count-control input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: var(--text);
  color: #fff;
}

.panel-body > .primary-button {
  width: 100%;
}

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

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

.ghost-button {
  border: 0;
  background: transparent;
  color: var(--blue);
}

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

.metric {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.metric strong {
  display: block;
  margin-bottom: 6px;
  font-size: 24px;
}

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

.quiz-header {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.quiz-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.share-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: min(100%, 620px);
}

.share-panel {
  display: grid;
  gap: 6px;
  width: min(100%, 620px);
}

.share-label {
  color: #304052;
  font-size: 13px;
  font-weight: 800;
}

.share-box input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
}

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

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.question-panel {
  padding: 24px;
}

.question-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.question-text {
  margin: 18px 0 20px;
  font-size: 22px;
  line-height: 1.55;
  letter-spacing: 0;
}

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

.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
}

.choice:hover {
  border-color: #93c5fd;
}

.choice:disabled {
  cursor: default;
  opacity: 1;
}

.choice[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.choice-label {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-weight: 900;
}

.choice[aria-pressed="true"] .choice-label {
  background: var(--blue);
  color: #fff;
}

.choice[data-result="correct"] {
  border-color: var(--green);
  background: var(--green-soft);
}

.choice[data-result="correct"] .choice-label {
  background: var(--green);
  color: #fff;
}

.choice[data-result="incorrect"] {
  border-color: var(--red);
  background: var(--red-soft);
}

.choice[data-result="incorrect"] .choice-label {
  background: var(--red);
  color: #fff;
}

.answer-feedback {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  line-height: 1.5;
}

.answer-feedback.correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: #065f46;
}

.answer-feedback.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: #9a3412;
}

.answer-feedback span {
  color: var(--text);
}

.explain-placeholder {
  margin-top: 16px;
  border: 1px dashed #b8c5d6;
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 14px;
  color: var(--muted);
}

.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

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

.error-box {
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  background: var(--red-soft);
  color: var(--red);
  padding: 12px 14px;
  line-height: 1.5;
}

.question-panel > .error-box {
  margin-bottom: 16px;
}

.result-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 24px;
}

.score-number {
  font-size: 44px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.result-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.result-item {
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
}

.result-item.correct {
  border-left-color: var(--green);
}

.result-item.wrong {
  border-left-color: var(--red);
}

.result-item h3 {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: 0;
}

.answer-lines {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.answer-lines strong {
  color: var(--text);
}

.loading {
  display: grid;
  min-height: 260px;
  place-items: center;
  color: var(--muted);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .layout,
  .result-summary {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .badge-row {
    justify-content: flex-start;
  }

  .question-panel,
  .result-summary {
    padding: 18px;
  }

  .question-text {
    font-size: 18px;
  }

  .quiz-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .action-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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

  .segmented,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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

  .share-box {
    grid-template-columns: 1fr;
  }
}
