:root {
  --bg: #f5f4f0;
  --surface: #fafaf8;
  --surface-alt: #efede8;
  --border: #d6d4cd;
  --border-strong: #b0aea6;
  --text: #1f1d18;
  --text-muted: #6e6d68;
  --text-faint: #a3a29c;
  --primary: #006d73;
  --primary-hover: #0a4f54;
  --ok: #3d6e1e;
  --ok-bg: #e6f0dc;
  --warn: #9e6316;
  --warn-bg: #f0e6d0;
  --bad: #8f2b70;
  --bad-bg: #eedce6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.07);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-alt: #282828;
  --border: #333;
  --border-strong: #444;
  --text: #e0e0e0;
  --text-muted: #999;
  --text-faint: #666;
  --primary: #4fc3c9;
  --primary-hover: #6dd4da;
  --ok: #7ec850;
  --ok-bg: #1e3a1a;
  --warn: #d4a04a;
  --warn-bg: #3a2e1a;
  --bad: #c75a9e;
  --bad-bg: #3a1a30;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.25s, color 0.25s;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  box-shadow: var(--shadow-sm);
}
.theme-toggle:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

/* ---- Hero ---- */
.hero {
  margin-bottom: 28px;
}

.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  margin: 0 0 6px;
}

h1 {
  font-family: "Inter", -apple-system, sans-serif;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.subtitle {
  color: var(--text-muted);
  max-width: 640px;
  font-size: 14px;
  margin: 0;
}

/* ---- Stats ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 24px;
}

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

.stat-value {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.3;
}

.stat.ok .stat-value { color: var(--ok); }
.stat.warn .stat-value { color: var(--warn); }
.stat.bad .stat-value { color: var(--bad); }
.stat.soft { background: var(--surface-alt); }

@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat.soft { grid-column: span 2; }
}

/* ---- Ticket toolbar ---- */
.ticket-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 10px;
  gap: 12px;
}

.ticket-toolbar h2 {
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
  box-shadow: var(--shadow-sm);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface);
}

/* ---- Cards ---- */
.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-head {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background 0.15s;
}

.card-head:hover { background: var(--surface-alt); }
.card-head:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-section {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface-alt);
  padding: 3px 8px;
  border-radius: 999px;
}

.card-num {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.card-title {
  font-family: "Inter", -apple-system, sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
}

.card-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.chevron {
  transition: transform 0.2s ease;
}

.card.open .chevron { transform: rotate(180deg); }

.card-body {
  padding: 0 18px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.15s ease, padding 0.25s ease;
  border-top: 1px solid transparent;
}

.card.open .card-body {
  max-height: 2400px;
  opacity: 1;
  padding: 16px 18px 20px;
  border-top-color: var(--border);
}

.full-text {
  font-size: 14px;
  color: var(--text);
  background: var(--surface-alt);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin: 0 0 14px;
  line-height: 1.5;
}

.full-text-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}

.theorem-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.theorem {
  border-left: 3px solid var(--primary);
  padding: 3px 0 3px 12px;
}

.theorem-name {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 3px;
  color: var(--text);
}

.theorem-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}

/* ---- Answer row ---- */
.answer-row {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.answer-prompt {
  font-weight: 600;
  font-size: 14px;
}

.answer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
}

.answer-btn:hover { border-color: var(--border-strong); }
.answer-btn.ok:hover    { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok); }
.answer-btn.warn:hover  { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.answer-btn.bad:hover   { background: var(--bad-bg);  border-color: var(--bad);  color: var(--bad); }

.recorded-msg {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  border: 1px solid rgba(67, 122, 34, 0.2);
}

/* ---- Footer ---- */
.footer {
  margin-top: 40px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer .dot { color: var(--text-faint); }

/* ---- Navigation ---- */
.nav-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

/* ---- Modal / Overlay ---- */
.page-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-md);
}

.modal-wide {
  max-width: 780px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

/* ---- Rating table ---- */
.rating-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rating-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.rating-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--surface-alt);
}

.rating-table tbody tr:hover {
  background: var(--surface-alt);
}

.rating-table .rank {
  font-weight: 600;
  color: var(--text-muted);
  width: 32px;
}

.rating-table .rname {
  font-weight: 600;
}

.rating-table .rnum,
.rating-table .rok,
.rating-table .rone,
.rating-table .rzero {
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rating-table .rok { color: var(--ok); }
.rating-table .rone { color: var(--warn); }
.rating-table .rzero { color: var(--bad); }

/* ---- Search bar ---- */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

/* ---- Questions list ---- */
.questions-list {
  padding: 6px 20px 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.q-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-alt);
  cursor: default;
}

.q-item:last-child {
  border-bottom: none;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.q-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--primary);
}

.q-num {
  font-size: 11px;
  color: var(--text-faint);
}

.q-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

/* ---- Q-item accordion ---- */
.q-head {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 0;
  font-family: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.q-head:hover .q-title {
  color: var(--primary);
}

.q-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.q-chevron {
  transition: transform 0.2s ease;
}

.q-open .q-chevron {
  transform: rotate(180deg);
}

.q-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.15s ease, padding 0.2s ease;
  padding: 0;
}

.q-open .q-body {
  max-height: 3000px;
  opacity: 1;
  padding: 4px 0 10px;
}

.q-full-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.q-full {
  font-size: 13px;
  color: var(--text);
  background: var(--surface-alt);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin: 0 0 10px;
  line-height: 1.5;
}

.q-theorems {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.q-theorem {
  border-left: 3px solid var(--primary);
  padding: 2px 0 2px 10px;
}

.q-theorem strong {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}

.q-theorem p {
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}

/* ---- Toggle filters in question list ---- */
.q-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  padding-left: 8px;
  user-select: none;
}

.q-toggle input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.q-toggle input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.q-toggle input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  font-weight: 700;
  line-height: 1;
}

.q-toggle input[type="checkbox"]:not(:checked) {
  background: transparent;
}

/* ---- Section filter header ---- */
.section-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 4px 0;
  border-bottom: 1px solid var(--surface-alt);
}

.section-filter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--primary);
}

.section-filter-toggle {
  font-size: 10px;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.section-filter-toggle:hover {
  color: var(--text-muted);
}
