:root {
  color-scheme: dark;
  --bg: #121212;
  --bg-2: #1e1e1e;
  --panel-grad-top: rgba(41,41,41,0.08);
  --panel-grad-bottom: rgba(255,255,255,0.02);
  --card-fg: rgba(255,255,255,0.02);
  --border: rgba(255,255,255,0.06);
  --text: #ffffff;
  --muted: rgba(205,205,205,0.66);
  --muted-strong: rgba(205,205,205,0.66);
  --success: rgba(240, 255, 243, 0.9);
  --danger: rgba(255, 244, 247, 0.95);
  --shadow: 0 1rem 2.5rem rgba(0,0,0,0.55);
  --radius: 1.8rem;
  --radius-sm: 1.1rem;
  --space: 0.9rem;
  --anim: 200ms;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, 'SF Pro Text', 'SF Pro Display', system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: linear-gradient(135deg, #1e1e1e, #121212);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 22%, rgba(var(--accent-rgb), 0.08), transparent 14%),
    radial-gradient(circle at 85% 15%, rgba(var(--danger-rgb), 0.06), transparent 12%);
  pointer-events: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
  color: inherit;
  background: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(130, 167, 255, 0.35);
  outline-offset: 2px;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.app-shell {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 0.9rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page-header {
  display: grid;
  gap: 0.6rem;
  padding: 1rem 1rem 1.1rem;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-grad-top), var(--panel-grad-bottom));
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.02);
}

.page-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin-bottom: 0.5rem;
}

.page-header p {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(19rem, 100%), 1fr));
}

.glass-card {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 1rem 1rem;
  border-radius: 1.8rem;
  background: linear-gradient(180deg, var(--panel-grad-top), var(--panel-grad-bottom));
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.02);
}

.test-card {
  display: grid;
  gap: 0.8rem;
}

.test-card h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.8vw, 1.45rem);
}

.test-card p,
.test-card .meta {
  margin: 0;
  color: var(--muted);
}

.test-card .meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.test-card .test-actions {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.button {
  min-height: 3.2rem;
  padding: 0.6rem 1rem;
  border-radius: 1.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
  text-transform: none;
  transition: transform var(--anim) ease, background-color var(--anim) ease, border-color var(--anim) ease, box-shadow var(--anim) ease;
  background: linear-gradient(180deg, rgba(81,81,81,0.18), rgba(255,255,255,0.06));
  backdrop-filter: blur(20px) saturate(160%);
  border-radius: 1.8rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.23), inset 0 1px 0 rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

.button:active {
  transform: scale(0.97);
}

.button-primary {
  color: var(--text);
  background: linear-gradient(180deg, rgba(81,81,81,0.18), rgba(255,255,255,0.06));
  backdrop-filter: blur(20px) saturate(160%);
  border-radius: 1.8rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.23), inset 0 1px 0 rgba(255,255,255,0.07);
  border: 1px solid var(--border);
}

.button-secondary {
  color: var(--text);
  background: linear-gradient(180deg, rgba(40,40,40,0.12), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.04);
}

.button-warning {
  color: #fde68a;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.16), rgba(88, 61, 16, 0.12));
  border: 1px solid rgba(245, 158, 11, 0.24);
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.23), inset 0 1px 0 rgba(255,255,255,0.07);
}

.button-danger {
  color: #fecaca;
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.16), rgba(88, 28, 28, 0.12));
  border: 1px solid rgba(239, 68, 68, 0.24);
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.23), inset 0 1px 0 rgba(255,255,255,0.07);
}

.button[disabled], .button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-ghost {
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.75rem;
  justify-content: flex-start;
}

.wide-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.wide-actions .button {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  text-align: center;
  white-space: normal;
}

.question-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  justify-self: stretch;
}

.question-actions * {
  box-sizing: border-box;
}

.question-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.question-action-row .button {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  text-align: center;
  white-space: normal;
}

.question-action-row .button.hidden {
  display: none;
}

.question-action-row-primary .next-button {
  grid-column: 1 / -1;
}

.tag {
  display: inline-flex;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.92rem;
}

.fieldset {
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
  border-radius: 1.8rem;
  background: linear-gradient(180deg, var(--panel-grad-top), var(--panel-grad-bottom));
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  font-size: 1rem;
}

.fieldset legend {
  font-weight: 700;
  color: var(--text);
}

.radio-grid {
  display: grid;
  gap: 0.85rem;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: 1.4rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.radio-item:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.radio-item input {
  accent-color: var(--accent);
}

.input-group {
  display: grid;
  gap: 0.9rem;
}

input[type="search"],
input[type="text"] {
  width: 100%;
  min-height: 3.4rem;
  border-radius: 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 1rem 1.15rem;
}

input::placeholder {
  color: var(--muted);
}

.question-box {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 1.8rem;
  background: linear-gradient(180deg, var(--panel-grad-top), var(--panel-grad-bottom));
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
}

.question-title {
  display: grid;
  gap: 0.55rem;
  width: 100%;
  min-width: 0;
}

.question-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.question-title p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.hard-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.36);
  background: rgba(245, 158, 11, 0.13);
  color: #fbbf24;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.review-question-title {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.review-answer-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
}

.details-card summary .hard-badge {
  flex-shrink: 0;
}

.question-title h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.15vw, 1.72rem);
  line-height: 1.2;
}

.progress-panel {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.75rem;
  border-radius: 1.2rem;
  background: linear-gradient(180deg, rgba(30,30,30,0.12), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.03);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted-strong);
  font-size: 0.95rem;
}

.progress-track {
  position: relative;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  transition: width var(--anim) ease;
}

.answers-grid {
  display: grid;
  gap: 0.6rem;
}

.answer-card {
  position: relative;
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-radius: 1.1rem;
  background: linear-gradient(120deg, rgba(35,35,35,0.75), rgba(20,20,20,0.70));
  border: 1px solid rgba(255,255,255,0.04);
  transition: transform var(--anim) ease, border-color var(--anim) ease, background-color var(--anim) ease, box-shadow var(--anim) ease;
  cursor: pointer;
}

.answer-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.answer-card.selected {
  background: linear-gradient(120deg, rgba(48,48,48,0.85), rgba(28,28,28,0.8));
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 10px 26px rgba(0,0,0,0.5);
}

/* Show white outline when the contained input is checked (modern browsers) */
.answer-card:has(input:checked) {
  border: 1.6px solid rgba(255, 255, 255, 0.492);
  box-shadow: 0 10px 28px rgba(0,0,0,0.55), 0 0 0 4px rgba(255,255,255,0.02);
}

.answer-card.correct {
  background: linear-gradient(180deg, rgba(30, 60, 40, 0.223), rgba(30, 60, 40, 0.158));
  border: 2px solid rgba(72,187,142,1);
  box-shadow: 0 10px 36px rgba(72, 187, 143, 0.422);
}

.answer-card.wrong {
  background: linear-gradient(180deg, rgba(70, 35, 35, 0.223), rgba(70, 35, 35, 0.295));
  border: 2px solid rgba(235,120,100,1);
  box-shadow: 0 10px 36px rgba(235,120,100,0.14);
}

.answer-card.missed {
  background: linear-gradient(180deg, rgba(30, 60, 40, 0.196), rgba(30, 60, 40, 0.152));
  border: 1.6px solid rgba(72,187,142,0.8);
  box-shadow: 0 8px 26px rgba(72,187,142,0.08);
}

.answer-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: auto;
}

.answer-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
}

.answer-bullet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-weight: 700;
}

.answer-text {
  color: var(--text);
  line-height: 1.5;
  font-size: 0.98rem;
}

.feedback-panel {
  display: grid;
  gap: 1rem;
  padding: 1.35rem 1.35rem;
  border-radius: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.feedback-icon {
  font-size: 1.25rem;
}

.feedback-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}

.feedback-explanation {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.feedback-header.success .feedback-title { color: var(--success); }
.feedback-header.error .feedback-title { color: var(--danger); }

.summary-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.stat-card {
  padding: 1.1rem 1.2rem 1.25rem;
  border-radius: 1.2rem;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel-grad-top), var(--panel-grad-bottom));
  backdrop-filter: blur(24px) saturate(160%);
}

.stat-card strong {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.stat-card span {
  display: block;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  color: var(--text);
}

.review-list {
  display: grid;
  gap: 1rem;
}

.review-list article h3 {
  margin: 0 0 0.6rem 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.review-list .answer-item span:first-child {
  color: var(--muted);
}

.review-list .answer-item span:last-child {
  color: var(--muted);
  font-size: 0.95rem;
}

.details-card {
  border-radius: 1.6rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel-grad-top), var(--panel-grad-bottom));
  backdrop-filter: blur(24px) saturate(160%);
}

.details-card summary {
  list-style: none;
  padding: 1.2rem 1.2rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  color: var(--text);
  font-weight: 600;
}

.details-card summary::-webkit-details-marker {
  display: none;
}

.details-card .detail-body {
  padding: 1rem 1.2rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 1rem;
}

.details-card .detail-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.details-card .detail-body .answer-line {
  display: grid;
  gap: 0.6rem;
}

.details-card .detail-body .answer-line span {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: 1.4rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

/* Review / summary result items */
.answer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 1.1rem;
  background: linear-gradient(120deg, rgba(35,35,35,0.75), rgba(20,20,20,0.70));
  border: 1px solid rgba(255,255,255,0.03);
}

.answer-item.correct {
  border: 2px solid rgba(72,187,142,1);
  background: linear-gradient(180deg, rgba(30,60,40,0.12), rgba(30,60,40,0.04));
}

.answer-item.wrong {
  border: 2px solid rgba(235,120,100,1);
  background: linear-gradient(180deg, rgba(70,35,35,0.12), rgba(70,35,35,0.04));
}

.review-list article + article {
  margin-top: 0.9rem;
}

.details-card .detail-body .answer-line span.correct {
  border-left: 4px solid var(--success);
}

.details-card .detail-body .answer-line span.wrong {
  border-left: 4px solid var(--danger);
}

.empty-state {
  padding: 1.4rem 1.3rem;
  border-radius: 1.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin: 0;
  line-height: 1.75;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.3rem;
  transform: translateX(-50%);
  padding: 0.9rem 1.2rem;
  border-radius: 999px;
  background: rgba(54, 38, 8, 0.98);
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #fde68a;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35), 0 0 28px rgba(245, 158, 11, 0.12);
  z-index: 20;
}

.hidden {
  display: none;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 1.1rem 0.95rem 1.8rem;
  }

  .question-box,
  .fieldset,
  .glass-card,
  .details-card {
    padding: 1rem;
  }
}

@media (max-width: 560px) {
  .page-header {
    padding: 1rem;
  }

  .question-title h2 {
    font-size: 1.3rem;
  }

  .answer-card {
    padding: 1rem;
  }
}
