
:root {
  --bg: #f7f8fa; --bg-soft: #fff; --bg-card: #fff; --bg-elev: #f1f3f6;
  --bg-tint: #eef3f9;
  --border: #dde3ec; --border-strong: #c5cfdc;
  --text: #0e1a2b; --text-dim: #4a5568; --text-muted: #6b7689;
  --accent: #1f5fb3; --accent-hover: #1a519a; --accent-soft: #e7eef8;
  --green: #047857; --green-soft: #e6f4ee;
  --red: #b42318; --red-soft: #fbeae7;
  --shadow-sm: 0 1px 2px rgba(14,26,43,0.05);
  --shadow: 0 1px 3px rgba(14,26,43,0.05), 0 4px 12px -2px rgba(14,26,43,0.05);
  --shadow-lg: 0 8px 24px -8px rgba(14,26,43,0.10), 0 2px 6px rgba(14,26,43,0.05);
  --radius: 6px; --radius-lg: 10px;
}
:root.dark {
  --bg: #0d1320; --bg-soft: #131a2a; --bg-card: #161e2f; --bg-elev: #1c2438;
  --bg-tint: #1a2540;
  --border: #2a3349; --border-strong: #3b4763;
  --text: #e7ecf3; --text-dim: #a8b2c4; --text-muted: #7e8aa1;
  --accent: #6ba6e8; --accent-hover: #8fbcef; --accent-soft: #1a2742;
  --green: #4ade80; --green-soft: rgba(74,222,128,0.10);
  --red: #f87171; --red-soft: rgba(248,113,113,0.10);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px -2px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 24px -8px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- Topbar ---------- */
header.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px; height: 56px;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.brand .badge { background: var(--accent); color: #fff; padding: 3px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 700; }
.brand .brand-title { color: var(--text-dim); font-weight: 500; font-size: 13px; }
.brand-sep { color: var(--border-strong); }
.topnav { display: flex; gap: 0; align-items: center; height: 100%; }
.topnav a {
  padding: 18px 14px 16px; color: var(--text-dim); cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none;
}
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }
.search-input {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px 7px 32px; border-radius: var(--radius);
  font-size: 13px; width: 240px; font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7689' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat; background-position: 10px center;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-toggle {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  width: 32px; height: 32px; border-radius: var(--radius); cursor: pointer; font-size: 14px;
}
.theme-toggle:hover { background: var(--bg-elev); color: var(--text); }

/* ---------- Layout ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- Hero / progress ---------- */
.hero {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-lg);
  padding: 22px 28px; margin-bottom: 22px;
}
.hero .eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 6px; }
.hero h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.hero p { margin: 0; max-width: 75ch; color: var(--text-dim); font-size: 14px; }

.progress-overview {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 22px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.progress-overview .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); font-weight: 600; }
.progress-overview .stat-block { display: flex; flex-direction: column; gap: 2px; }
.progress-overview .stat-num { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -0.01em; }
.progress-overview .stat-num.done { color: var(--green); }
.progress-overview .progress-bar-wide { flex: 1; min-width: 200px; height: 8px; background: var(--bg-elev); border-radius: 99px; overflow: hidden; }
.progress-overview .progress-bar-wide .fill { height: 100%; background: var(--green); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--bg-soft); border: 1px solid var(--border); padding: 14px 16px; border-radius: var(--radius-lg); position: relative; }
.kpi .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .icon { position: absolute; top: 14px; right: 14px; font-size: 16px; opacity: 0.4; }

.vol-banner {
  margin: 28px 0 14px; padding: 10px 14px;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.vol-banner:first-child { margin-top: 0; }

.section-block { margin-bottom: 24px; }
.section-block .section-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 8px 0; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-block .section-head .sec-num {
  background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.section-block .section-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; flex: 1; }
.section-block .section-head .progress { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.section-block .section-head .progress.complete { color: var(--green); font-weight: 600; }

/* ---------- Home grid ---------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.home-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; gap: 6px;
  text-decoration: none; color: inherit;
}
.home-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.home-card.done { border-left: 3px solid var(--green); }
.home-card.done:hover { border-color: var(--green); }
.home-card.planned { opacity: 0.66; cursor: not-allowed; background: var(--bg); }
.home-card.planned:hover { border-color: var(--border); box-shadow: none; opacity: 0.85; }
.home-card .ch-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); font-weight: 500; }
.home-card .ch-num-pill {
  background: var(--bg-elev); color: var(--accent);
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  border: 1px solid var(--border);
}
.home-card.done .ch-num-pill { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.home-card.planned .ch-num-pill { color: var(--text-muted); }
.home-card .status-dot { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-left: auto; }
.home-card.done .status-dot { color: var(--green); }
.home-card.planned .status-dot { color: var(--text-muted); }
.home-card .status-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.home-card .ch-vol { color: var(--text-muted); font-size: 11px; }
.home-card h4 { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
.home-card.planned h4 { color: var(--text-dim); }
.home-card .stats { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.home-card .stat { background: var(--bg-elev); padding: 2px 7px; border-radius: 4px; border: 1px solid var(--border); font-size: 10.5px; font-weight: 500; color: var(--text-dim); display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.home-card.done .stats .stat { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 600; }

/* ---------- Chapter page ---------- */
.chapter-header {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 24px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.chapter-header .ch-num-pill {
  background: var(--green-soft); color: var(--green); border: 1px solid var(--green);
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.chapter-header h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; flex: 1; min-width: 0; }
.chapter-header .meta { color: var(--text-muted); font-size: 12.5px; }
.chapter-header .prevnext { display: flex; gap: 6px; }

.mode-tabs {
  display: flex; gap: 0; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 4px;
  margin-bottom: 16px;
}
.mode-tabs a {
  padding: 8px 16px; color: var(--text-dim); border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.mode-tabs a:hover { background: var(--bg-elev); color: var(--text); }
.mode-tabs a.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------- Markdown ---------- */
.md-shell { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 44px; }
.md-content { max-width: 76ch; font-size: 15px; line-height: 1.7; }
.md-content h1 { font-size: 22px; padding-bottom: 10px; margin: 0 0 16px; font-weight: 700; letter-spacing: -0.015em; border-bottom: 1px solid var(--border); }
.md-content h2 { font-size: 17px; margin: 28px 0 10px; font-weight: 700; letter-spacing: -0.01em; padding-left: 10px; border-left: 3px solid var(--accent); }
.md-content h3 { font-size: 14.5px; font-weight: 700; margin: 20px 0 6px; }
.md-content h4 { font-size: 13.5px; color: var(--text-dim); font-weight: 600; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.md-content p { margin: 0 0 12px; }
.md-content ul, .md-content ol { padding-left: 22px; margin: 6px 0 12px; }
.md-content li { margin-bottom: 4px; }
.md-content li::marker { color: var(--accent); }
.md-content code { background: var(--bg-elev); padding: 1px 5px; border-radius: 3px; font-size: 12.5px; color: var(--accent); border: 1px solid var(--border); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.md-content pre { background: var(--bg-elev); padding: 12px 14px; border-radius: var(--radius); overflow-x: auto; border: 1px solid var(--border); font-size: 13px; }
.md-content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px; border: 1px solid var(--border); }
.md-content th, .md-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.md-content th { background: var(--bg-elev); font-weight: 600; font-size: 12.5px; }
.md-content tr:nth-child(even) td { background: var(--bg); }
.md-content blockquote { border-left: 3px solid var(--accent); margin: 14px 0; padding: 6px 14px; background: var(--accent-soft); font-size: 13.5px; }
.md-content blockquote p:last-child { margin-bottom: 0; }
.md-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.md-content img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.md-content strong { font-weight: 700; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px 12px; }
.toolbar .progress-bar { flex: 1; min-width: 100px; max-width: 280px; height: 4px; background: var(--bg-elev); border-radius: 99px; overflow: hidden; }
.toolbar .progress-fill { height: 100%; background: var(--accent); transition: width 0.3s; }
.fc-progress { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; font-weight: 500; min-width: 64px; }
.fc-stats { display: flex; gap: 8px; font-size: 12px; font-weight: 600; }
.fc-stats .stat-correct, .fc-stats .stat-wrong { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.fc-stats .stat-correct { background: var(--green-soft); color: var(--green); }
.fc-stats .stat-wrong { background: var(--red-soft); color: var(--red); }

/* ---------- Flashcard ---------- */
.fc-stage { min-height: 240px; }
.flashcard {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 32px; min-height: 220px;
  display: flex; flex-direction: column; cursor: pointer; position: relative;
  border-left: 3px solid var(--accent);
}
.flashcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.flashcard.flipped { border-left-color: var(--green); }
.flashcard .card-side { font-size: 16px; line-height: 1.65; }
.flashcard .card-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); font-weight: 700; margin-bottom: 12px; align-self: flex-start; }
.flashcard.flipped .card-label { color: var(--green); }
.flashcard .answer { display: none; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); font-size: 15.5px; line-height: 1.65; }
.flashcard .answer .ans-label { color: var(--green); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; display: block; margin-bottom: 6px; }
.flashcard.flipped .answer { display: block; }
.flashcard .hint { position: absolute; bottom: 10px; right: 14px; font-size: 11px; color: var(--text-muted); }

/* ---------- Quiz ---------- */
.quiz-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius-lg); padding: 26px 30px;
}
.quiz-card .stem { font-size: 15.5px; line-height: 1.7; margin-bottom: 18px; }
.quiz-card .options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.quiz-card .opt { padding: 11px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 14px; text-align: left; color: var(--text); font-family: inherit; transition: all 0.12s; }
.quiz-card .opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.quiz-card .opt.correct { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 600; }
.quiz-card .opt.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.quiz-card .opt.disabled { cursor: default; }
.quiz-card .explanation { background: var(--accent-soft); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; line-height: 1.65; display: none; white-space: pre-wrap; margin-top: 4px; }
.quiz-card .explanation.visible { display: block; }
.quiz-card .explanation strong { color: var(--accent); font-weight: 700; }
.quiz-nav { display: flex; gap: 8px; margin-top: 16px; }

.btn { padding: 8px 14px; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius); cursor: pointer; font-weight: 500; font-size: 13px; font-family: inherit; display: inline-flex; align-items: center; gap: 5px; line-height: 1.4; text-decoration: none; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.ghost { background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { background: #036348; border-color: #036348; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #931a13; border-color: #931a13; }

/* ---------- Atlas ---------- */
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.atlas-tile { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; }
.atlas-tile:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.atlas-tile .img-wrap { position: relative; overflow: hidden; background: #000; }
.atlas-tile img { width: 100%; height: 150px; object-fit: cover; display: block; }
.atlas-tile .meta { padding: 7px 10px; font-size: 11.5px; color: var(--text-dim); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 6px; line-height: 1.3; }
.atlas-tile .meta .fig { color: var(--accent); font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(14,26,43,0.92); display: none; z-index: 1000; align-items: center; justify-content: center; padding: 32px; flex-direction: column; -webkit-tap-highlight-color: transparent; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 76vh; object-fit: contain; border-radius: var(--radius); user-select: none; -webkit-user-drag: none; touch-action: pan-y; }
.lightbox .lb-caption { color: #f1f5ff; max-width: 86vw; padding: 12px 18px; font-size: 13.5px; text-align: center; line-height: 1.55; background: rgba(255,255,255,0.06); border-radius: var(--radius); margin-top: 14px; max-height: 22vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.lightbox .lb-close,
.lightbox .lb-back {
  position: absolute; background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.20);
  color: #fff; padding: 9px 14px; border-radius: var(--radius); cursor: pointer;
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.2;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.lightbox .lb-close { top: 18px; right: 22px; }
.lightbox .lb-back  { top: 18px; left: 22px; }
.lightbox .lb-close:hover,
.lightbox .lb-back:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.32); }
.lightbox .lb-close:active,
.lightbox .lb-back:active { transform: scale(0.96); }
.lightbox .lb-back .arr { font-size: 16px; line-height: 1; }
.lightbox .lb-counter { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.7); font-size: 12px; font-variant-numeric: tabular-nums; background: rgba(255,255,255,0.06); padding: 5px 11px; border-radius: 99px; }
body.lb-locked { overflow: hidden; }

/* ---------- Page title ---------- */
.page-title { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.page-title .row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-title h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }
.page-title .subtitle { color: var(--text-muted); font-size: 12.5px; }
.page-title .breadcrumb { color: var(--text-muted); font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.page-title .breadcrumb a { color: var(--text-muted); }
.page-title .breadcrumb a:hover { color: var(--accent); }
.page-title .breadcrumb .sep { margin: 0 6px; color: var(--border-strong); }

/* ---------- Empty/info ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 40px; color: var(--text-dim); text-align: center; }
.empty-state h2 { margin: 0 0 6px 0; color: var(--text); font-size: 18px; font-weight: 600; }

/* ---------- Responsive (mobil & tablet) ---------- */
@media (max-width: 900px) {
  .page { padding: 20px 16px 60px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .md-shell { padding: 22px 26px; }
  .topnav a .lbl { display: none; }
  .topnav a { padding: 18px 10px 16px; }
  .search-input { width: 160px; }
  header.topbar { gap: 10px; padding: 0 14px; }
  .home-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .atlas-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .atlas-tile img { height: 130px; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .page { padding: 14px 12px 80px; }

  /* topbar: kompakt */
  header.topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .brand .brand-title, .brand-sep { display: none; }
  .brand .badge { font-size: 10px; padding: 3px 7px; }
  .topnav { gap: 0; }
  .topnav a { padding: 16px 8px 14px; font-size: 13px; }
  .topnav a span:first-child { font-size: 15px; }
  .search-input { width: 110px; padding: 6px 10px 6px 28px; background-position: 8px center; font-size: 12px; }
  .search-input:focus { width: 180px; }
  .theme-toggle { width: 30px; height: 30px; }

  /* hero kompakt */
  .hero { padding: 16px 18px; margin-bottom: 16px; }
  .hero h1 { font-size: 19px; line-height: 1.3; }
  .hero p { font-size: 13.5px; }
  .hero .eyebrow { font-size: 10px; letter-spacing: 1px; }

  /* progress/kpi */
  .progress-overview { padding: 12px 14px; gap: 12px; }
  .progress-overview .stat-num { font-size: 17px; }
  .progress-overview .progress-bar-wide { min-width: 100%; flex-basis: 100%; order: 99; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px 12px; }
  .kpi .value { font-size: 22px; }
  .kpi .icon { top: 10px; right: 10px; font-size: 14px; }

  .vol-banner { font-size: 11.5px; padding: 8px 12px; margin: 20px 0 12px; }
  .section-block .section-head { gap: 8px; padding: 6px 0; }
  .section-block .section-head h3 { font-size: 13.5px; }
  .section-block .section-head .progress { font-size: 10.5px; }

  /* card grids → tek kolon */
  .home-grid { grid-template-columns: 1fr; gap: 8px; }
  .home-card { padding: 12px 14px; }
  .home-card h4 { font-size: 14px; }

  /* chapter header */
  .chapter-header { padding: 14px 16px; gap: 10px; }
  .chapter-header h1 { font-size: 18px; flex-basis: 100%; order: 2; }
  .chapter-header .meta { font-size: 12px; }
  .chapter-header .prevnext { margin-left: auto; }

  /* mode tabs - yatay scroll */
  .mode-tabs {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 4px;
    flex-wrap: nowrap;
  }
  .mode-tabs::-webkit-scrollbar { display: none; }
  .mode-tabs a { padding: 7px 12px; font-size: 12.5px; flex-shrink: 0; }

  /* markdown / özet */
  .md-shell { padding: 16px 14px; border-radius: 8px; }
  .md-content { font-size: 14.5px; line-height: 1.65; }
  .md-content h1 { font-size: 19px; }
  .md-content h2 { font-size: 15.5px; padding-left: 8px; }
  .md-content h3 { font-size: 13.5px; }
  .md-content table { font-size: 12.5px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .md-content th, .md-content td { padding: 6px 10px; }
  .md-content pre { font-size: 12px; }

  /* atlas */
  .atlas-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .atlas-tile img { height: 120px; }
  .atlas-tile .meta { padding: 6px 8px; font-size: 11px; }

  /* flashcard / quiz */
  .toolbar { padding: 8px 10px; gap: 8px; }
  .toolbar .progress-bar { min-width: 80px; max-width: 160px; }
  .fc-progress { min-width: 50px; font-size: 12px; }
  .fc-stats { font-size: 11.5px; }
  .flashcard { padding: 22px 20px; min-height: 200px; border-radius: 8px; }
  .flashcard .card-side { font-size: 15px; }
  .flashcard .answer { font-size: 14.5px; }
  .quiz-card { padding: 20px 18px; border-radius: 8px; }
  .quiz-card .stem { font-size: 14.5px; }
  .quiz-card .opt { padding: 10px 12px; font-size: 13.5px; }
  .quiz-nav { flex-wrap: wrap; }
  .quiz-nav .btn { flex: 1; min-width: 100px; justify-content: center; }

  /* page title */
  .page-title h2 { font-size: 17px; }
  .page-title .subtitle { font-size: 12px; }

  /* lightbox - mobile fullscreen */
  .lightbox { padding: 0; background: rgba(8,14,26,0.96); }
  .lightbox img { max-width: 100vw; max-height: 70vh; border-radius: 0; }
  .lightbox .lb-caption { max-width: 100vw; margin: 12px 0 0; border-radius: 0; padding: 11px 16px; font-size: 12.5px; max-height: 25vh; }
  .lightbox .lb-close { top: max(12px, env(safe-area-inset-top)); right: 12px; padding: 8px 12px; font-size: 13px; }
  .lightbox .lb-back  { top: max(12px, env(safe-area-inset-top)); left: 12px; padding: 8px 12px; font-size: 13px; }
  .lightbox .lb-counter { bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .topnav a { padding: 16px 6px 14px; }
  .atlas-grid { grid-template-columns: 1fr; }
  .atlas-tile img { height: 180px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
