:root {
  --bg: #f4f9f7;
  --page: #ffffff;
  --soft: #f2faf6;
  --ink: #0f2a25;
  --text: #44645d;
  --muted: #6f8d85;
  --line: #dcebe6;
  --brand: #00bfb1;
  --brand-2: #b8ffd7;
  --deep: #0d8f85;
  --accent: #d8d360;
  --shadow: 0 16px 40px rgba(15, 90, 75, .10);
  --soft-shadow: 0 8px 22px rgba(15, 90, 75, .07);
  --grad: linear-gradient(135deg, #00bfb1, #b8ffd7);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, #eaf4ef 100%);
  font: 14px/1.72 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, Arial, sans-serif;
  overflow-x: hidden;
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 191, 177, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 191, 177, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), rgba(0,0,0,.05));
}
.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2000;
  background: var(--grad);
  box-shadow: 0 0 16px rgba(0, 191, 177, .45);
}
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}
.sidebar {
  position: sticky; top: 18px; height: calc(100vh - 36px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}
.brand { padding: 18px; border-bottom: 1px solid var(--line); }
.brand-row { display: flex; align-items: center; gap: 11px; }
.logo { width: 46px; height: 46px; border-radius: 10px; box-shadow: 0 10px 24px rgba(0, 191, 177, .25); }
.brand h1 { font-size: 17px; line-height: 1.25; }
.brand p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stat {
  border: 1px solid var(--line); border-radius: 10px; background: var(--soft);
  padding: 8px; text-align: center; color: var(--muted); font-size: 12px;
}
.stat strong { display: block; color: var(--ink); font-size: 17px; line-height: 1.1; }
.side-tools { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 9px; }
.control {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); outline: none; padding: 0 12px; font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.control:focus { border-color: rgba(0, 191, 177, .6); box-shadow: 0 0 0 4px rgba(0, 191, 177, .10); }
.chips { display: flex; gap: 7px; overflow: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 30px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--text); padding: 0 11px; font-size: 12px; font-weight: 800;
  cursor: pointer; white-space: nowrap; transition: transform .18s ease, color .18s ease, border-color .18s ease;
}
.chip:hover { transform: translateY(-1px); border-color: rgba(0, 191, 177, .35); color: var(--deep); }
.chip.active { border-color: transparent; background: var(--grad); color: #0b5d55; }
.lesson-list { flex: 1; overflow: auto; padding: 10px; list-style: none; }
.lesson-item { margin-bottom: 8px; opacity: 0; transform: translateY(8px); animation: itemIn .34s ease forwards; }
.lesson-link {
  position: relative; display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center;
  min-height: 58px; padding: 10px; border-radius: 10px; border: 1px solid transparent;
  background: rgba(255, 255, 255, .78); color: var(--text); text-decoration: none; cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease, color .2s ease;
}
.lesson-link:hover { transform: translateX(4px); border-color: rgba(0, 191, 177, .28); background: #fff; color: var(--deep); box-shadow: var(--soft-shadow); }
.lesson-link.active { color: #fff; background: linear-gradient(135deg, #00bfb1, #0d8f85); box-shadow: 0 14px 30px rgba(0, 191, 177, .28); }
.lesson-no {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: rgba(0, 191, 177, .10); color: var(--deep);
  font-weight: 900; font-size: 12px; font-variant-numeric: tabular-nums;
}
.lesson-link.active .lesson-no { background: rgba(255, 255, 255, .22); color: #fff; }
.lesson-main { min-width: 0; }
.lesson-title { display: block; font-weight: 900; line-height: 1.35; }
.lesson-cat { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.lesson-link.active .lesson-cat { color: rgba(255, 255, 255, .78); }
.lesson-empty { padding: 22px 10px; text-align: center; color: var(--muted); }

.reader { min-width: 0; }
.topbar { display: none; position: sticky; top: 0; z-index: 850; border-bottom: 1px solid rgba(220, 235, 230, .9); background: rgba(255, 255, 255, .94); backdrop-filter: blur(16px); box-shadow: 0 8px 24px rgba(15, 90, 75, .08); }
.topbar-inner { padding: 10px; display: grid; grid-template-columns: 42px 34px 1fr 42px; gap: 8px; align-items: center; }
.mobile-logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 8px 18px rgba(0, 191, 177, .2); }
.top-title { min-width: 0; text-align: center; font-weight: 900; line-height: 1.25; }
.top-title small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }
.icon-btn {
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
  height: 42px; width: 42px; font-size: 19px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.icon-btn:hover { transform: translateY(-1px); color: var(--deep); border-color: rgba(0, 191, 177, .3); box-shadow: var(--soft-shadow); }
button:focus-visible, a:focus-visible, .table-scroll:focus-visible { outline: 3px solid rgba(0, 191, 177, .38); outline-offset: 2px; }

.page { min-height: calc(100vh - 36px); display: flex; flex-direction: column; gap: 16px; }
.hero {
  position: relative; border: 1px solid rgba(220, 235, 230, .92); border-radius: 14px;
  background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(14px);
}
.hero::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: var(--grad); background-size: 220% 100%; animation: barFlow 8s linear infinite;
}
.hero-inner { padding: 24px 26px 22px; position: relative; z-index: 1; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.badge {
  display: inline-flex; align-items: center; min-height: 28px; padding: 4px 12px; border-radius: 9px;
  border: 1px solid rgba(0, 191, 177, .22); background: rgba(0, 191, 177, .08); color: var(--deep); font-weight: 900;
}
.page-title { font-size: clamp(24px, 3.2vw, 38px); line-height: 1.24; }
.page-desc { margin-top: 9px; color: var(--muted); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.primary-btn {
  height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 900; border: 0;
  color: #0b5d55; background: var(--grad); box-shadow: 0 12px 26px rgba(0, 191, 177, .3);
  transition: transform .18s ease, box-shadow .18s ease; cursor: pointer;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.ghost-btn {
  height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 900;
  border: 1px solid var(--line); color: var(--text); background: #fff; cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.ghost-btn:hover { transform: translateY(-1px); box-shadow: var(--soft-shadow); }

.page-stage { position: relative; flex: 1; display: flex; min-height: 420px; }
.content-page {
  position: relative; flex: 1; min-height: 100%; border: 1px solid rgba(220, 235, 230, .92);
  border-radius: 14px; background: #fff; box-shadow: 0 12px 32px rgba(15, 90, 75, .08);
  overflow: hidden; animation: pageIn .28s ease both;
}
.content-page::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, #00bfb1, #b8ffd7);
}
.content-inner { position: relative; z-index: 1; padding: 26px; }
.content-inner img { max-width: 100%; height: auto; border-radius: 10px; }
.content-inner video, .content-inner audio { max-width: 100%; border-radius: 10px; }
.content-inner h2 { font-size: 20px; margin: 22px 0 10px; }
.content-inner h3 { font-size: 17px; margin: 18px 0 9px; }
.content-inner p { margin: 10px 0; color: var(--text); }
.content-inner ul, .content-inner ol { margin: 10px 0 12px 22px; }
.content-inner li { margin: 6px 0; color: var(--text); }
.content-inner blockquote { border-left: 4px solid var(--brand); background: var(--soft); padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 12px 0; color: var(--text); }
.content-inner pre { background: #0f2a25; color: #b8ffd7; border-radius: 10px; padding: 14px; overflow: auto; margin: 12px 0; }
.content-inner code { font-family: Consolas, monospace; font-size: 13px; }
.content-inner a {
  display: inline-block;
  background: linear-gradient(135deg, #00bfb1, #b8ffd7);
  color: #0f2a25;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  line-height: 1.5;
  vertical-align: baseline;
  margin: 2px 2px;
  box-shadow: 0 4px 12px rgba(0, 191, 177, .18);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.content-inner a:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 191, 177, .25);
}
.content-inner p > a:only-child,
.content-inner li > a:only-child,
.content-inner blockquote > a:only-child,
.content-inner h2 > a:only-child,
.content-inner h3 > a:only-child,
.content-inner h4 > a:only-child,
.content-inner div > a:only-child {
  display: inline-block;
  background: linear-gradient(135deg, #00bfb1, #b8ffd7);
  color: #0f2a25;
  padding: 12px 30px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
  text-decoration: none;
  margin: 8px 4px 8px 0;
  box-shadow: 0 8px 20px rgba(0, 191, 177, .25);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.content-inner p > a:only-child:hover,
.content-inner li > a:only-child:hover,
.content-inner blockquote > a:only-child:hover,
.content-inner h2 > a:only-child:hover,
.content-inner h3 > a:only-child:hover,
.content-inner h4 > a:only-child:hover,
.content-inner div > a:only-child:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 191, 177, .32);
}
.content-inner a[href^="tg://"],
.content-inner a.telegram-lang-btn {
  display: inline-block;
  background: linear-gradient(135deg, #00bfb1, #b8ffd7);
  color: #0f2a25;
  padding: 12px 30px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
  text-decoration: none;
  margin: 8px 4px 8px 0;
  box-shadow: 0 8px 20px rgba(0, 191, 177, .25);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.content-inner a[href^="tg://"]:hover,
.content-inner a.telegram-lang-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 191, 177, .32);
}
.table-scroll { max-width: 100%; overflow-x: auto; margin: 12px 0; border-radius: 8px; }
.content-inner table { border-collapse: collapse; width: 100%; min-width: max-content; margin: 0; }
.content-inner th, .content-inner td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.content-inner th { background: var(--soft); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.doc-block {
  border: 1px solid var(--line); border-radius: 12px; background: var(--soft);
  padding: 20px; margin-bottom: 16px; transition: box-shadow .2s ease, border-color .2s ease;
}
.doc-block:hover { border-color: rgba(0, 191, 177, .28); box-shadow: var(--soft-shadow); }
.tip-box { padding: 13px 16px; border-radius: 10px; margin: 14px 0; font-size: 13px; border-left: 4px solid var(--brand); background: #ecfaf4; color: #0b6b5d; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager-card {
  min-height: 76px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255, 255, 255, .92); padding: 12px 16px; color: var(--text); text-align: left;
  box-shadow: var(--soft-shadow); cursor: pointer; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.pager-card:hover { transform: translateY(-2px); border-color: rgba(0, 191, 177, .3); box-shadow: var(--shadow); }
.pager-card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.pager-card strong { display: block; color: var(--ink); line-height: 1.35; }
.footer { padding: 20px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.sheet-mask {
  position: fixed; inset: 0; z-index: 1200; background: rgba(15, 42, 37, .32);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-mask.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; left: 8px; right: 8px; bottom: 8px; max-height: 78vh;
  display: flex; flex-direction: column; border-radius: 16px;
  background: #fff; box-shadow: 0 24px 60px rgba(15, 42, 37, .3);
  transform: translateY(110%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet-mask.open .sheet { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 10px; }
.sheet-title { font-weight: 900; font-size: 16px; }
.sheet-hint { color: var(--muted); font-size: 12px; }
.sheet-tools { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 0 16px 10px; }
.sheet-list { overflow: auto; padding: 6px 10px 16px; list-style: none; }

.bottom-nav {
  display: none; position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 900;
  grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; padding: 8px;
  border: 1px solid rgba(220, 235, 230, .9); border-radius: 14px;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(16px); box-shadow: 0 14px 36px rgba(15, 90, 75, .18);
}
.bottom-nav button {
  height: 46px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--text); font-weight: 900; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px; line-height: 1.05;
}
.bottom-nav .center { border: 0; color: #0b5d55; background: var(--grad); box-shadow: 0 10px 24px rgba(0, 191, 177, .3); }
.bottom-nav .center small { font-size: 10px; font-weight: 800; opacity: .9; }
.back-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 850; width: 42px; height: 42px;
  border: 0; border-radius: 10px; color: #0b5d55; background: var(--grad);
  box-shadow: 0 12px 28px rgba(0, 191, 177, .32); opacity: 0; transform: translateY(12px);
  pointer-events: none; transition: opacity .2s ease, transform .2s ease; cursor: pointer; font-size: 18px;
}
.back-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

@keyframes itemIn { to { opacity: 1; transform: translateY(0); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(16px) scale(.992); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes barFlow { to { background-position: 220% 0; } }

@media (max-width: 980px) {
  .topbar { display: block; }
  .shell { display: block; padding: 0 10px 96px; }
  .sidebar { display: none; }
  .page { min-height: auto; padding-top: 10px; }
  .hero { display: none; }
  .page-stage { min-height: 0; }
  .content-inner { padding: 18px; }
  .content-inner { overflow-wrap: anywhere; }
  .pager { display: none; }
  .bottom-nav { display: grid; }
  .back-top { display: none; }
}
@media (max-width: 520px) {
  .topbar-inner { grid-template-columns: 40px 32px 1fr 40px; padding: 8px; }
  .icon-btn { width: 40px; height: 40px; }
  .content-inner { padding: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
