:root {
  color-scheme: dark;
  --bg-0: #0b0f14;
  --bg-1: #0f141c;
  --bg-2: #141b24;
  --surface: #131a24;
  --surface-2: #1a2331;
  --surface-3: #202b3c;
  --text: #e7edf6;
  --muted: #98a9bf;
  --accent: #7ee0b2;
  --accent-2: #5aa0ff;
  --warning: #f7c66a;
  --danger: #ff7d7d;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.35);
  --glow: rgba(126, 224, 178, 0.18);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-body: "SF Pro Text", "Neue Haas Grotesk", "Helvetica Neue", sans-serif;
  --font-display: "New York", "Iowan Old Style", "Palatino", serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-0: #f4f6fb;
  --bg-1: #eef1f7;
  --bg-2: #e6ebf4;
  --surface: #f8f9fc;
  --surface-2: #ffffff;
  --surface-3: #f0f3f9;
  --text: #101319;
  --muted: #4c5a6b;
  --accent: #1e7f5a;
  --accent-2: #2563eb;
  --warning: #b7791f;
  --danger: #c53030;
  --border: rgba(14, 21, 34, 0.12);
  --shadow: rgba(31, 41, 55, 0.18);
  --glow: rgba(37, 99, 235, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: radial-gradient(circle at top, rgba(90, 160, 255, 0.14), transparent 45%),
    radial-gradient(circle at 20% 20%, rgba(126, 224, 178, 0.12), transparent 40%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  color: var(--text);
  min-height: 100vh;
}

[data-theme="light"] body {
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 50%),
    radial-gradient(circle at 20% 20%, rgba(30, 127, 90, 0.08), transparent 45%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(126, 224, 178, 0.6), rgba(90, 160, 255, 0.6));
  box-shadow: 0 12px 30px rgba(90, 160, 255, 0.35);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.4px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search input {
  width: 320px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.search input::placeholder {
  color: var(--muted);
}

.stat-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

button {
  font-family: inherit;
}

button.ghost,
button.primary {
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

button.primary {
  background: linear-gradient(145deg, rgba(126, 224, 178, 0.2), rgba(90, 160, 255, 0.24));
  border-color: rgba(126, 224, 178, 0.5);
  box-shadow: 0 10px 30px rgba(90, 160, 255, 0.25);
}

button.ghost:hover,
button.primary:hover {
  transform: translateY(-1px);
  border-color: rgba(126, 224, 178, 0.6);
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px 32px 48px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.panel-title {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 14px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.field select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.toggle input {
  accent-color: var(--accent);
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.progress-meta,
.progress-flags {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.panel-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.content-header h1 {
  margin: 0 0 6px 0;
  font-family: var(--font-display);
  font-size: 28px;
}

.content-header p {
  margin: 0;
  color: var(--muted);
}

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

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 22px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.question-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(145deg, rgba(126, 224, 178, 0.08), transparent 40%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.question-card:hover::after {
  opacity: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.meta-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.meta-tag {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.meta-tag.mcq {
  color: var(--accent);
}

.meta-tag.emq {
  color: var(--accent-2);
}

.meta-tag.viva {
  color: var(--warning);
}

.question-text {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.question-images,
.explanation-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}

.question-images img,
.explanation-images img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.option:hover {
  border-color: rgba(126, 224, 178, 0.6);
  transform: translateY(-1px);
}

.option.is-correct {
  border-color: rgba(126, 224, 178, 0.8);
  box-shadow: 0 0 0 1px rgba(126, 224, 178, 0.5);
}

.option.is-incorrect {
  border-color: rgba(255, 125, 125, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 125, 125, 0.5);
}

.answer-reveal {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: none;
}

.question-card.is-answered .answer-reveal {
  display: block;
}

.answer-line {
  font-weight: 600;
  margin-bottom: 8px;
}

.explanation-text {
  color: var(--muted);
  line-height: 1.6;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.card-actions button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.card-actions button.is-active {
  border-color: rgba(126, 224, 178, 0.6);
  color: var(--text);
}

.card-actions button.error.is-active {
  border-color: rgba(255, 125, 125, 0.8);
  color: var(--danger);
}

.viva-answer {
  margin-top: 12px;
}

.viva-answer summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
}

.viva-answer div {
  padding-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.load-more {
  display: flex;
  justify-content: center;
  padding: 10px 0 40px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 999px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .search input {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .topbar,
  .layout {
    padding: 20px;
  }

  .question-card {
    padding: 18px;
  }
}
