:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --text: #14161a;
  --muted: #676d7a;
  --border: #e7e8f0;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0fe;
  --primary-text: #ffffff;
  --correct: #16a34a;
  --correct-bg: #dcfce7;
  --wrong: #dc2626;
  --wrong-bg: #fee2e2;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 20px rgba(16, 24, 40, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d11;
    --surface: #16181d;
    --surface-2: #1c1f26;
    --text: #edeef1;
    --muted: #9aa1ad;
    --border: #272a33;
    --primary: #6366f1;
    --primary-dark: #818cf8;
    --primary-soft: rgba(99, 102, 241, 0.16);
    --correct-bg: #113322;
    --wrong-bg: #3a1414;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header / Nav ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.brand-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary-soft);
  flex-shrink: 0;
}

.brand-icon {
  width: 17px;
  height: 17px;
  color: var(--primary);
}

.header-stats {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-nav {
  display: flex;
  gap: 4px;
  padding: 2px 12px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.main-nav button {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: auto;
  transition: background 0.15s, color 0.15s;
}

.main-nav button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.main-nav button i {
  width: 15px;
  height: 15px;
}

.main-nav button.active {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: var(--shadow-sm);
}

.main-nav button.active:hover {
  background: var(--primary);
}

/* ---------- Layout ---------- */

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

.hero {
  padding: 6px 2px 22px;
}

.hero h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-stats {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  flex-direction: column;
}

.hero-stat strong {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.hero-stat span {
  font-size: 0.76rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}

.mode-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 560px) {
  .mode-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.mode-card {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}

.mode-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.mode-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 12px;
}

.mode-card-icon i {
  width: 19px;
  height: 19px;
}

.mode-card h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mode-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* ---------- Buttons ---------- */

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 11px 16px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

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

button.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

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

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

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.progress-text {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.timer {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer.low {
  color: var(--wrong);
}

/* ---------- Daily tasks ---------- */

.daily-card {
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--surface) 55%);
}

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

.streak-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

.streak-badge i {
  width: 15px;
  height: 15px;
}

.daily-task {
  margin-bottom: 14px;
}

.daily-task:last-of-type {
  margin-bottom: 0;
}

.daily-task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.daily-task-count {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.daily-task-count.done {
  color: var(--correct);
}

.daily-complete {
  margin: 14px 0 0;
  color: var(--correct);
  font-weight: 600;
}

/* ---------- Exam live stats ---------- */

.exam-stats {
  margin-bottom: 12px;
}

.exam-stats-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.exam-stats-correct {
  color: var(--correct);
}

.exam-stats-wrong {
  color: var(--wrong);
}

.exam-progress {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

.exam-progress-correct {
  background: var(--correct);
  height: 100%;
}

.exam-progress-wrong {
  background: var(--wrong);
  height: 100%;
}

/* ---------- Questions ---------- */

.question-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 14px;
}

.question-image {
  max-width: 100%;
  border-radius: var(--radius);
  margin-bottom: 14px;
  display: block;
}

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

.answer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

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

.answer input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.answer.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.answer.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.answer.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.answer.revealed {
  cursor: default;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
}

.feedback.ok {
  background: var(--correct-bg);
  color: var(--correct);
}

.feedback.no {
  background: var(--wrong-bg);
  color: var(--wrong);
}

/* ---------- Results / history ---------- */

.result-summary {
  text-align: center;
}

.result-score {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 10px 0;
}

.result-score.pass { color: var(--correct); }
.result-score.fail { color: var(--wrong); }

.result-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-pill.pass { background: var(--correct-bg); color: var(--correct); }
.result-pill.fail { background: var(--wrong-bg); color: var(--wrong); }

.review-item {
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}

.review-item .answer-list {
  margin-top: 8px;
}

.small-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.link-button {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: auto;
}

.link-button:hover {
  text-decoration: underline;
  border-color: transparent;
}

.date-filter {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.date-filter label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.date-filter input[type="date"] {
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
}

.rate-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 8px;
  flex-wrap: wrap;
}

.rate-number {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rate-number.pass { color: var(--correct); }
.rate-number.fail { color: var(--wrong); }

.progress-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s;
}

.progress-bar-fill.pass { background: var(--correct); }
.progress-bar-fill.fail { background: var(--wrong); }

.progress-bar-target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--text);
  opacity: 0.5;
}

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 48px;
  margin: 4px 0 2px;
}

.sparkline-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.sparkline-bar.pass { background: var(--correct); }
.sparkline-bar.fail { background: var(--wrong); }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.history-item:first-child {
  border-top: none;
  padding-top: 0;
}

/* ---------- Legislație ---------- */

.pill-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.pill-filter::-webkit-scrollbar { display: none; }

.pill-filter button {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  min-height: auto;
}

.pill-filter button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.sign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.sign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  text-align: center;
}

.sign-card img {
  width: 100%;
  height: 76px;
  object-fit: contain;
  margin-bottom: 8px;
  background: #ffffff;
  border-radius: var(--radius-sm);
}

.sign-card .sign-code {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.sign-card .sign-name {
  font-size: 0.82rem;
  line-height: 1.3;
}

.quiz-score {
  text-align: center;
  margin: 0 0 10px;
  font-weight: 600;
}

.sign-quiz-card {
  text-align: center;
}

.sign-quiz-image {
  width: 100%;
  max-width: 260px;
  max-height: 220px;
  object-fit: contain;
  background: #ffffff;
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 auto 18px;
  display: block;
  box-shadow: var(--shadow-sm);
}

.quiz-options {
  display: grid;
  gap: 10px;
  text-align: left;
}

.quiz-option {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

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

.quiz-option.revealed {
  cursor: default;
}

.quiz-option.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
}

.quiz-option.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
}

.speed-table {
  display: grid;
  gap: 8px;
}

.speed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.speed-row .loc {
  font-size: 0.92rem;
  font-weight: 500;
}

.speed-row .value {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary);
  white-space: nowrap;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 10px;
}

.note-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  display: grid;
  gap: 6px;
}
