:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #182033;
  --muted: #657189;
  --primary: #182744;
  --primary-2: #263c64;
  --accent: #c49b55;
  --line: #dfe5ef;
  --success: #0f7a55;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 14px 40px rgba(22, 37, 66, 0.13);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top left, #eef3ff 0, transparent 34rem), var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; }
a { color: inherit; }
code { background: #eef2f8; padding: 0.1rem 0.3rem; border-radius: 0.35rem; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem max(1rem, env(safe-area-inset-left)) .75rem max(1rem, env(safe-area-inset-left));
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid rgba(223,229,239,.9);
  backdrop-filter: blur(14px);
}
.icon-btn, .install-btn, .primary-btn, .secondary-btn, .ghost-btn, .danger-btn {
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.icon-btn:active, .install-btn:active, .primary-btn:active, .secondary-btn:active, .ghost-btn:active, .danger-btn:active { transform: translateY(1px); }
.icon-btn {
  width: 42px;
  height: 42px;
  background: #eef2f8;
  color: var(--primary);
  font-size: 1.35rem;
}
.install-btn, .primary-btn {
  background: var(--primary);
  color: #fff;
  padding: .85rem 1rem;
  box-shadow: 0 9px 20px rgba(24,39,68,.20);
}
.install-btn { margin-left: auto; padding: .65rem .95rem; }
.secondary-btn {
  background: #f0e7d7;
  color: #573b10;
  padding: .85rem 1rem;
}
.ghost-btn {
  background: #edf2fb;
  color: var(--primary);
  padding: .78rem 1rem;
}
.danger-btn {
  background: #fff1f0;
  color: var(--danger);
  padding: .78rem 1rem;
}
button[disabled] { opacity: .55; cursor: not-allowed; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--primary), var(--primary-2));
  color: var(--accent);
  font-weight: 900;
  font-size: 1.4rem;
  box-shadow: 0 10px 25px rgba(24,39,68,.18);
}
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand small { color: var(--muted); margin-top: .15rem; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(86vw, 330px);
  padding: 5rem 1rem 1rem;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-105%);
  transition: transform .18s ease;
  z-index: 40;
}
.drawer.open { transform: translateX(0); }
.drawer nav { display: grid; gap: .35rem; }
.drawer a {
  display: block;
  padding: .95rem 1rem;
  text-decoration: none;
  border-radius: 14px;
  color: var(--primary);
  font-weight: 750;
}
.drawer a.active, .drawer a:hover { background: #eef2f8; }
.drawer-note {
  margin-top: 1.2rem;
  padding: .9rem;
  border-radius: 14px;
  background: #fff9ee;
  color: #5e431b;
  font-size: .92rem;
}
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 16, 29, .34);
  z-index: 35;
}
.backdrop.open { display: block; }

.content {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.1rem 1rem 5rem;
  flex: 1;
}
.hero {
  position: relative;
  overflow: hidden;
  padding: 1.3rem;
  border-radius: 26px;
  background: linear-gradient(135deg, var(--primary), #2f4d7c);
  color: #fff;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "§";
  position: absolute;
  right: -1rem;
  top: -4rem;
  font-size: 13rem;
  opacity: .08;
  font-weight: 900;
}
.hero h1 { margin: 0; font-size: clamp(1.7rem, 7vw, 3.1rem); line-height: 1.05; }
.hero p { color: rgba(255,255,255,.86); max-width: 65ch; }
.hero-actions, .actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; }
.hero .secondary-btn { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.28); }
.hero .primary-btn { background: #fff; color: var(--primary); box-shadow: none; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 8px 28px rgba(38, 60, 100, .07);
}
.card h2, .card h3, .card p:first-child { margin-top: 0; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: #c9d5e8; transform: translateY(-1px); }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 1.4rem 0 .75rem;
}
.section-title h2 { margin: 0; font-size: 1.25rem; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  background: #edf2fb;
  color: var(--primary);
  font-size: .82rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.nowrap { white-space: nowrap; }
.badge.gold { background: #fff3dd; color: #78520f; }
.badge.green { background: #eafaf3; color: var(--success); }
.badge.red { background: #fff1f0; color: var(--danger); }
.badge.warn { background: #fff7ed; color: var(--warning); }
.meta { color: var(--muted); font-size: .92rem; }
.muted { color: var(--muted); }
.kpi { display: grid; gap: .25rem; }
.kpi strong { font-size: 1.9rem; color: var(--primary); }
.notice {
  border: 1px solid #f4d8a7;
  background: #fff9ee;
  color: #5e431b;
  border-radius: var(--radius);
  padding: .95rem 1rem;
}
.notice strong { color: #332103; }

.list { display: grid; gap: .75rem; }
.exam-item, .case-item, .source-item {
  display: grid;
  gap: .45rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}
.exam-item h3, .case-item h3 { margin: 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; overflow: visible; }

.quiz-shell { display: grid; gap: 1rem; }
.quiz-top {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}
.progress-wrap {
  height: 10px;
  background: #e6ecf5;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--primary-2));
  transition: width .2s ease;
}
.question-card h2 { font-size: clamp(1.15rem, 4.5vw, 1.55rem); margin: 0 0 .7rem; }
.options { display: grid; gap: .65rem; }
.option-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .95rem;
  background: #fff;
  cursor: pointer;
  display: flex;
  gap: .7rem;
  align-items: flex-start;
}
.option-btn:hover { border-color: #bdcbe0; background: #fbfdff; }
.option-btn.selected { border-color: var(--primary-2); background: #eef3ff; }
.option-btn.correct { border-color: #97d7bf; background: #edfbf5; }
.option-btn.wrong { border-color: #f2aaa6; background: #fff5f4; }
.option-letter {
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #edf2fb;
  color: var(--primary);
  font-weight: 900;
}
.feedback {
  padding: .9rem;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}
.feedback.correct { border-color: #98d8bf; background: #effcf6; }
.feedback.wrong { border-color: #f0aaa4; background: #fff5f4; }
.timer { font-variant-numeric: tabular-nums; font-weight: 900; color: var(--primary); }

.searchbox {
  width: 100%;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
}
.searchbox:focus { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(38, 60, 100, .10); }

.result-row {
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.result-row mark { background: #fff1b8; padding: 0 .1rem; border-radius: .2rem; }
.case-body { white-space: pre-wrap; }
.source-item a { color: var(--primary-2); font-weight: 800; }
.footer {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1rem calc(1rem + var(--safe-bottom));
  color: var(--muted);
  font-size: .88rem;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.72);
}
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state .big { font-size: 3rem; }

@media (max-width: 780px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .brand small { display: none; }
  .content { padding-left: .85rem; padding-right: .85rem; }
  .hero { padding: 1.1rem; border-radius: 22px; }
  .topbar { gap: .5rem; }
  .install-btn { padding: .58rem .8rem; }
}

@media (min-width: 1040px) {
  .drawer {
    transform: none;
    top: 76px;
    bottom: auto;
    left: calc(50% - 550px);
    width: 230px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    z-index: 10;
  }
  .drawer nav a { background: rgba(255,255,255,.72); border: 1px solid rgba(223,229,239,.7); }
  .drawer-note { display: none; }
  .content { padding-left: 260px; }
  #menuButton { display: none; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1726;
    --card: #141f33;
    --text: #edf2fb;
    --muted: #aeb9cc;
    --primary: #dce7ff;
    --primary-2: #9bb7e7;
    --line: #26364f;
  }
  body { background: radial-gradient(circle at top left, #172846 0, transparent 34rem), var(--bg); }
  .topbar, .card, .exam-item, .case-item, .source-item, .result-row, .option-btn, .searchbox { background: #141f33; }
  .drawer { background: #101a2b; }
  .drawer a.active, .drawer a:hover, .icon-btn, .ghost-btn, code, .option-letter { background: #1f304d; color: #eaf1ff; }
  .notice, .drawer-note { background: #2b2416; color: #f2d19a; border-color: #59441f; }
  .feedback { background: #111c2e; }
  .footer { background: rgba(20,31,51,.75); }
}


.pdf-practice-layout {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 1rem;
  margin-top: 1rem;
}
.answer-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.answer-sheet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
}
.answer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .5rem;
  border: 1px solid rgba(18, 32, 61, .12);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
}
.answer-number {
  font-weight: 800;
  color: var(--ink);
  min-width: 2ch;
}
.answer-options {
  display: flex;
  gap: .35rem;
}
.mini-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.3rem;
  min-height: 2.2rem;
  border: 1px solid rgba(18, 32, 61, .18);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}
.mini-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mini-option.selected {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
@media (max-width: 780px) {
  .pdf-practice-layout { grid-template-columns: 1fr; }
  .answer-sheet { grid-template-columns: 1fr; }
}


/* v0.8.9 – по-удобен режим за решаване на всички тестове */
.test-list-card .actions { gap: .55rem; }
.compact-progress { margin: .75rem 0 1rem; }
.compact-progress .progress-wrap { margin-bottom: .35rem; }
.solving-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 1rem;
  align-items: start;
}
.document-panel, .answer-panel { min-width: 0; }
.document-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: .85rem;
}
.small-actions { margin-top: 0; }
.pdf-frame {
  width: 100%;
  min-height: 72vh;
  border: 1px solid rgba(18, 32, 61, .14);
  border-radius: 18px;
  background: #f7f8fb;
}
.answer-panel-sticky {
  position: sticky;
  top: 92px;
}
.big-choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
  margin: .85rem 0 1rem;
}
.big-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.2rem;
  border: 1px solid rgba(18, 32, 61, .18);
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(18, 32, 61, .06);
}
.big-choice input { position: absolute; opacity: 0; pointer-events: none; }
.big-choice.selected {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  transform: translateY(-1px);
}
.nav-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.question-nav-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .35rem;
  margin-top: 1rem;
}
.question-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  border-radius: 999px;
  border: 1px solid rgba(18, 32, 61, .14);
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  background: rgba(255,255,255,.75);
}
.question-pill.answered { background: #e9f8ef; border-color: #b8dfc5; }
.question-pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.compact-summary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.summary-row { justify-content: center; gap: .45rem; }
@media (max-width: 980px) {
  .solving-workspace { grid-template-columns: 1fr; }
  .answer-panel-sticky { position: static; }
  .pdf-frame { min-height: 62vh; }
}
@media (max-width: 560px) {
  .document-head { display: block; }
  .pdf-frame { min-height: 58vh; }
  .question-nav-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .compact-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .big-choice { min-height: 3.7rem; }
}


/* v1.0.0 – по-четими бутони и карти в „Допълнителни материали“ */
.supplemental-group-title {
  align-items: flex-end;
}
.materials-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}
.material-card {
  display: grid;
  gap: .7rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 8px 26px rgba(38, 60, 100, .08);
  min-width: 0;
}
.material-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.material-kind {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
}
.material-title {
  margin: 0;
  color: var(--text);
  font-size: 1.08rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.material-note {
  margin: 0;
  color: var(--muted);
  font-size: .94rem;
}
.material-open-btn {
  display: grid;
  gap: .15rem;
  width: 100%;
  padding: .9rem 1rem;
  border-radius: 16px;
  text-decoration: none;
  background: #182744;
  color: #fff !important;
  box-shadow: 0 10px 22px rgba(24,39,68,.18);
  line-height: 1.25;
}
.material-open-btn span {
  font-size: .82rem;
  opacity: .86;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.material-open-btn strong {
  display: block;
  font-size: 1rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}
.material-open-btn:hover {
  background: #263c64;
  transform: translateY(-1px);
}
@media (max-width: 780px) {
  .materials-grid { grid-template-columns: 1fr; }
  .material-card { padding: .9rem; }
  .material-open-btn { border-radius: 14px; }
}
@media (prefers-color-scheme: dark) {
  .material-open-btn {
    background: #dce7ff;
    color: #101a2b !important;
    box-shadow: none;
  }
  .material-open-btn:hover { background: #cfe0ff; }
}




/* v1.2.0 – AI/SEO статична секция */
.ai-seo-content {
  width: min(1080px, calc(100% - 2rem));
  margin: 1.25rem auto 0;
}
.ai-seo-inner {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(245,247,251,.92));
  border-radius: 24px;
  padding: clamp(1.1rem, 2vw, 1.7rem);
  box-shadow: 0 16px 44px rgba(38, 60, 100, .08);
}
.seo-eyebrow {
  margin: 0 0 .35rem;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
}
.ai-seo-content h2 {
  margin: 0 0 .7rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.15;
  color: var(--text);
}
.ai-seo-content p {
  color: var(--muted);
  line-height: 1.65;
}
.ai-seo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
  margin: 1rem 0;
}
.ai-seo-grid article {
  padding: 1rem;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
}
.ai-seo-grid h3, .ai-seo-faq h3 {
  margin: 0 0 .4rem;
  color: var(--text);
  font-size: 1.05rem;
}
.ai-seo-grid p { margin: 0; }
.ai-seo-faq {
  display: grid;
  gap: .55rem;
  margin-top: 1rem;
}
.ai-seo-faq details {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .8rem 1rem;
  background: var(--card);
}
.ai-seo-faq summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
}
.ai-seo-faq p { margin: .55rem 0 0; }
@media (max-width: 860px) {
  .ai-seo-grid { grid-template-columns: 1fr; }
  .ai-seo-content { width: min(100% - 1rem, 1080px); }
}
@media (prefers-color-scheme: dark) {
  .ai-seo-inner { background: linear-gradient(180deg, rgba(21,31,50,.92), rgba(16,26,43,.92)); }
}


/* v1.2.2 – корекция на припокриването между страничното меню и AI/SEO секцията */
@media (min-width: 1040px) {
  .ai-seo-content {
    width: min(1100px, 100%);
    margin: 1.25rem auto 0;
    padding-left: 260px;
    padding-right: 1rem;
  }
  .ai-seo-inner {
    position: relative;
    z-index: 1;
  }
}
