:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eef3f4;
  --text: #162023;
  --muted: #66757c;
  --line: #dde5e8;
  --brand: #0f8f7f;
  --brand-2: #116d9a;
  --accent: #d56a3a;
  --good: #1f8b55;
  --bad: #c43d3d;
  --warn: #a86d00;
  --shadow: 0 14px 34px rgba(22, 32, 35, 0.1);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1416;
  --panel: #172022;
  --panel-2: #202c2f;
  --text: #eef5f4;
  --muted: #9fafb4;
  --line: #304044;
  --brand: #43c7b7;
  --brand-2: #58a8d5;
  --accent: #f08a5c;
  --good: #6cd395;
  --bad: #ff8585;
  --warn: #f0c36a;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100dvh;
  padding-bottom: 78px;
}

.content {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.content-tight {
  padding-top: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar strong {
  display: block;
  font-size: 17px;
}

.topbar span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.icon-btn,
.plain-link {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.plain-link {
  background: transparent;
}

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 28%),
    radial-gradient(circle at 90% 80%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 30%),
    var(--bg);
}

.auth-panel {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.logo-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  font-weight: 800;
}

.auth-brand h1,
.section-head h1,
.section-head h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
}

.auth-brand p,
.section-head p,
.hero-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

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

input {
  min-height: 46px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel);
  outline: none;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

[data-theme="dark"] .btn.primary {
  color: #061412;
}

.btn.light {
  color: var(--brand);
  background: white;
  border-color: rgba(255, 255, 255, 0.4);
}

.btn.small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button-grid {
  display: grid;
  gap: 10px;
}

.button-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.error {
  min-height: 22px;
  color: var(--bad);
}

.tabbar {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.tabbar button {
  min-height: 48px;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
}

.tabbar button.active {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  min-height: 154px;
  border-radius: var(--radius);
  color: white;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand) 88%, #092526), color-mix(in srgb, var(--brand-2) 82%, #122a36)),
    var(--brand);
  box-shadow: var(--shadow);
}

.hero-panel h1 {
  margin: 4px 0 0;
  font-size: 38px;
  line-height: 1;
}

.hero-panel p,
.hero-panel .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0;
}

.quick-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.action-card,
.type-pill,
.path-item,
.panel,
.question-panel,
.review-item,
.result-item,
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(20, 32, 36, 0.04);
}

.action-card {
  min-height: 132px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 15px;
  text-align: left;
  color: var(--text);
}

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

.action-card strong {
  font-size: 26px;
}

.action-card small,
.path-item small {
  color: var(--muted);
  line-height: 1.45;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 22px 0 10px;
}

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

.type-pill {
  min-height: 74px;
  display: grid;
  gap: 4px;
  place-items: center;
  color: var(--text);
}

.type-pill span {
  color: var(--muted);
  font-size: 13px;
}

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

.path-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  color: var(--text);
  text-align: left;
}

.path-item b {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: white;
  background: var(--brand);
}

.path-item span {
  display: grid;
  gap: 3px;
}

.practice-shell,
.exam-shell {
  display: grid;
  gap: 10px;
}

.practice-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.practice-progress div {
  text-align: center;
}

.practice-progress strong {
  display: block;
}

.practice-progress span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.progress-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.question-panel {
  min-height: calc(100dvh - 206px);
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
}

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

.question-meta > span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  font-size: 13px;
}

.flag-actions {
  display: flex;
  gap: 6px;
}

.flag-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
}

.flag-actions button.on {
  color: white;
  background: var(--accent);
}

.question-panel h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.58;
}

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

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 56px;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.option b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--panel-2);
}

.option span {
  line-height: 1.5;
}

.option.selected {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
}

.option.correct {
  border-color: var(--good);
}

.option.wrong {
  border-color: var(--bad);
}

.answer-panel {
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.answer-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.answer-panel.good {
  border-color: color-mix(in srgb, var(--good) 62%, var(--line));
}

.answer-panel.bad {
  border-color: color-mix(in srgb, var(--bad) 62%, var(--line));
}

.answer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.panel {
  padding: 16px;
}

.form-panel {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

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

.exam-rule span {
  display: grid;
  place-items: center;
  min-height: 72px;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-2);
}

.exam-rule b {
  color: var(--text);
  font-size: 26px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.chip.active {
  color: white;
  background: var(--brand);
  border-color: var(--brand);
}

[data-theme="dark"] .chip.active {
  color: #061412;
}

.answer-sheet {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.answer-sheet button {
  aspect-ratio: 1;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
}

.answer-sheet button.done {
  color: var(--brand);
  border: 1px solid var(--brand);
}

.answer-sheet button.active {
  color: white;
  background: var(--brand);
}

.score-card {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 22px;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.score-card strong {
  margin-top: 6px;
  font-size: 48px;
}

.score-card p {
  margin: 0;
}

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

.mini-stats span,
.stat {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.mini-stats span {
  border-radius: var(--radius);
  background: var(--panel-2);
}

.result-list,
.review-list,
.recent-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.result-item,
.review-item {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.result-item > div,
.review-item > div,
.history-item,
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-item p,
.review-item p {
  margin: 0;
  line-height: 1.5;
}

.result-item small,
.review-item small {
  color: var(--muted);
  line-height: 1.45;
}

.result-item.ok {
  border-color: color-mix(in srgb, var(--good) 40%, var(--line));
}

.result-item.fail {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
}

.row-actions {
  justify-content: flex-start !important;
}

.learn-toolbar {
  position: sticky;
  top: 61px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  background: var(--bg);
}

.learn-toolbar span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learn-layout {
  display: grid;
  gap: 12px;
}

.knowledge-list {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: calc(66px + env(safe-area-inset-bottom));
  left: 0;
  width: min(320px, 86vw);
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px 12px 14px;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(-105%);
  transition: transform 0.18s ease;
}

.knowledge-list.open {
  transform: translateX(0);
}

.catalog-mask {
  position: fixed;
  z-index: 30;
  inset: 0 0 calc(66px + env(safe-area-inset-bottom)) 0;
  background: rgba(0, 0, 0, 0.36);
}

.knowledge-list button {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 13px;
  text-align: left;
  color: var(--text);
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.knowledge-list button.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
}

.knowledge-list span {
  color: var(--muted);
  font-size: 13px;
}

.reader {
  line-height: 1.75;
  padding-bottom: 94px;
}

.reader h1,
.reader h2,
.reader h3 {
  line-height: 1.28;
  margin: 22px 0 10px;
}

.reader h1 {
  font-size: 25px;
}

.reader h2 {
  font-size: 21px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.reader p,
.reader ul,
.reader table,
.reader pre {
  margin: 12px 0;
}

.reader table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.reader td {
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.reader code,
.reader pre {
  border-radius: 6px;
  background: var(--panel-2);
}

.reader code {
  padding: 2px 5px;
}

.reader pre {
  padding: 12px;
  overflow-x: auto;
}

.stat span,
.history-item span,
.recent-item span {
  color: var(--muted);
}

.stat strong {
  font-size: 25px;
}

.good-text {
  color: var(--good);
}

.bad-text {
  color: var(--bad);
}

.empty,
.loading {
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

@media (min-width: 760px) {
  .app {
    padding-bottom: 0;
    padding-left: 236px;
  }

  .content {
    padding: 24px;
  }

  .topbar {
    padding: 16px 24px;
  }

  .tabbar {
    inset: 0 auto 0 0;
    width: 236px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 24px 14px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .tabbar button {
    text-align: left;
    padding: 0 16px;
  }

  .quick-grid,
  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero-panel {
    min-height: 176px;
  }

  .practice-shell,
  .exam-shell {
    width: min(760px, 100%);
    margin: 0 auto;
  }

  .question-panel {
    min-height: auto;
  }

  .answer-sheet {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .learn-layout {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }

  .learn-toolbar {
    display: none;
  }

  .knowledge-list {
    position: sticky;
    z-index: 1;
    top: 84px;
    max-height: calc(100dvh - 110px);
    overflow: auto;
    width: auto;
    padding: 0;
    border-right: 0;
    box-shadow: none;
    transform: none;
    background: transparent;
  }

  .catalog-mask {
    display: none;
  }

  .reader {
    padding-bottom: 16px;
  }
}
