/* ─── Base tokens ─── */
:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-hover: #F5F4F0;
  --text: #0E0E10;
  --text-dim: #56565A;
  --text-mute: #8E8E93;
  --border: rgba(14,14,16,0.08);
  --border-strong: rgba(14,14,16,0.16);
  --accent: #FFCD1F;
  --accent-strong: #FDB400;
  --accent-soft: rgba(255,205,31,0.16);
  --shadow-sm: 0 1px 2px rgba(14,14,16,0.04);
  --shadow-md: 0 8px 24px rgba(14,14,16,0.06);
  --shadow-lg: 0 20px 48px rgba(14,14,16,0.08);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --font-display: "Fraunces", "Playfair Display", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 300px;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}
[data-theme="dark"] {
  --bg: #0B0B0D;
  --surface: #131316;
  --surface-hover: #1C1C20;
  --text: #F4F4F0;
  --text-dim: #B8B8BD;
  --text-mute: #7A7A80;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --accent: #FFD54A;
  --accent-strong: #FFCD1F;
  --accent-soft: rgba(255,205,31,0.12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.4);
}

* { margin:0; padding:0; box-sizing:border-box; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; }
::selection { background: var(--accent); color: #0E0E10; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  padding: 28px 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.logo { width: 40px; height: 40px; color: var(--text); flex-shrink: 0; display: grid; place-items: center; }
.logo svg { width: 100%; height: 100%; display: block; }
.brand { font-family: var(--font-display); font-size: 19px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
.brand span { color: var(--text-mute); font-style: italic; font-weight: 400; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px 20px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.nav-module { margin-bottom: 4px; }
.nav-module-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; letter-spacing: -0.005em;
  color: var(--text); cursor: pointer; transition: background var(--transition);
}
.nav-module-head:hover { background: var(--surface-hover); }
.nav-module-head .nm-left { display: flex; align-items: center; min-width: 0; }
.nav-module-head .num { font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-mute); margin-right: 8px; min-width: 18px; }
.nav-module-head .nm-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-module-head .chev { width: 14px; height: 14px; opacity: .45; transition: transform var(--transition); flex-shrink: 0; }
.nav-module.open .nav-module-head .chev { transform: rotate(90deg); }

.nav-lessons { max-height: 0; overflow: hidden; transition: max-height 300ms ease; }
.nav-module.open .nav-lessons { max-height: 2000px; }
.nav-lesson {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 38px; font-size: 13px; color: var(--text-dim);
  border-radius: var(--radius-sm); position: relative;
  transition: color var(--transition), background var(--transition); text-decoration: none;
}
.nav-lesson:hover { color: var(--text); background: var(--surface-hover); }
.nav-lesson.active { color: var(--text); background: var(--accent-soft); font-weight: 500; }
.nav-lesson.active::before {
  content: ""; position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; background: var(--accent-strong); border-radius: 2px;
}
.nav-lesson .l-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.dot.done { background: var(--accent-strong); }

.sidebar-foot {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
/* Кнопка сворачивания — кружок на границе сайдбара */
.sidebar-toggle {
  display: none;
  position: fixed;
  left: calc(var(--sidebar-w) - 12px);
  top: 50vh;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.14);
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--text-mute);
  z-index: 100;
  padding: 0;
  transition: left 0.2s ease, background var(--transition), color var(--transition);
}
.sidebar-toggle svg { width: 12px; height: 12px; pointer-events: none; }
.sidebar-toggle:hover { background: var(--accent); color: #000; border-color: transparent; box-shadow: 0 2px 8px rgba(0,0,0,.18); }

/* Collapsed sidebar — desktop only */
@media (min-width: 961px) {
  .sidebar-toggle { display: flex; }
  .app.sidebar-collapsed { grid-template-columns: 64px 1fr; }
  .app.sidebar-collapsed .sidebar-head { padding: 20px 12px; justify-content: center; }
  .app.sidebar-collapsed .sidebar-head .brand { display: none; }
  .app.sidebar-collapsed .sidebar-nav { display: none; }
  .app.sidebar-collapsed .sidebar-foot { display: none; }
  .app.sidebar-collapsed .sidebar-toggle { left: calc(64px - 12px); }
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #FFCD1F 0%, #FDB400 100%);
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  color: #0E0E10; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-logout { font-size: 12px; color: var(--text-mute); transition: color var(--transition); }
.user-logout:hover { color: var(--text); }

/* ─── Main ─── */
.main { padding: 0; position: relative; min-width: 0; }
.topbar {
  position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 48px; display: flex; align-items: center; justify-content: space-between; z-index: 10;
}
.topbar-crumb { font-size: 13px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.topbar-crumb a { color: inherit; transition: color var(--transition); }
.topbar-crumb a:hover { color: var(--text); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.topbar-user { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--radius-sm); transition: background var(--transition); }
.topbar-user:hover { background: var(--surface-hover); }
.topbar-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-strong); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.topbar-user-info { display: flex; flex-direction: column; gap: 1px; }
.topbar-user-name { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.2; }
.topbar-user-logout { font-size: 11px; color: var(--text-mute); text-decoration: none; transition: color var(--transition); }
.topbar-user-logout:hover { color: var(--text); }
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center;
  color: var(--text-dim); transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.view { padding: 72px 48px 120px; max-width: 1040px; }

/* ─── Dashboard ─── */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-mute); font-weight: 500; margin-bottom: 20px;
}
.eyebrow .line { width: 28px; height: 1px; background: var(--border-strong); }

.hello { font-family: var(--font-display); font-weight: 400; font-size: clamp(44px, 6vw, 72px); line-height: 1.02; letter-spacing: -0.035em; margin-bottom: 18px; }
.hello em { font-style: italic; color: var(--text-dim); font-weight: 300; }
.hello-sub { font-size: 18px; color: var(--text-dim); max-width: 560px; line-height: 1.55; margin-bottom: 48px; }

.progress-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px 32px; display: grid; grid-template-columns: 1fr auto;
  gap: 24px; align-items: center; margin-bottom: 72px; box-shadow: var(--shadow-sm);
}
.progress-info { display: flex; flex-direction: column; gap: 16px; }
.progress-nums { display: flex; align-items: baseline; gap: 14px; }
.progress-big { font-family: var(--font-display); font-size: 40px; font-weight: 400; line-height: 1; letter-spacing: -0.03em; }
.progress-big em { font-style: italic; color: var(--text-mute); font-size: 26px; }
.progress-label { font-size: 13px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; }
.progress-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.progress-bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%); border-radius: 99px; transition: width 600ms ease; }
.progress-ring { position: relative; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring .ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 22px; letter-spacing: -0.02em; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; }
.section-title h2 { font-family: var(--font-display); font-weight: 400; font-size: 28px; letter-spacing: -0.025em; }
.section-title h2 em { font-style: italic; color: var(--text-mute); }
.section-count { font-size: 13px; color: var(--text-mute); font-variant-numeric: tabular-nums; }

.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.module-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative; cursor: pointer; overflow: hidden; display: block; color: inherit; text-decoration: none;
}
.module-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(600px circle at var(--x,50%) var(--y,50%), var(--accent-soft), transparent 40%);
  opacity: 0; transition: opacity var(--transition); pointer-events: none;
}
.module-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.module-card:hover::after { opacity: 1; }
.module-num { font-family: var(--font-display); font-size: 44px; line-height: 1; font-weight: 300; letter-spacing: -0.03em; color: var(--text-mute); margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; }
.module-num .glyph { font-size: 18px; color: var(--text); background: var(--bg); width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--border); }
.module-card h3 { font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: -0.02em; margin-bottom: 8px; line-height: 1.2; }
.module-card p { font-size: 14px; color: var(--text-mute); margin-bottom: 24px; line-height: 1.5; }
.module-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; font-size: 13px; color: var(--text-dim); padding-top: 18px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.mini-progress { display: flex; gap: 2px; flex-shrink: 0; }
.mini-progress .seg { width: 10px; height: 3px; background: var(--border-strong); border-radius: 99px; }
.mini-progress .seg.done { background: var(--accent-strong); }

/* ─── Module view ─── */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-mute); margin-bottom: 36px; transition: color var(--transition); text-decoration: none; }
.back-link:hover { color: var(--text); }
.back-link svg { width: 13px; height: 13px; }

.module-header { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: end; margin-bottom: 64px; padding-bottom: 48px; border-bottom: 1px solid var(--border); }
.module-header .eyebrow { margin-bottom: 12px; }
.module-header h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(40px, 5vw, 60px); line-height: 1.02; letter-spacing: -0.03em; margin-bottom: 16px; }
.module-header h1 em { font-style: italic; color: var(--text-dim); font-weight: 300; }
.module-header p { font-size: 17px; color: var(--text-dim); max-width: 560px; line-height: 1.55; }
.module-stats { display: flex; gap: 32px; padding-bottom: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-family: var(--font-display); font-size: 32px; font-weight: 400; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; }

.lesson-list { display: flex; flex-direction: column; }
.lesson-row {
  display: grid; grid-template-columns: 44px 1fr auto auto;
  align-items: center; gap: 18px; padding: 22px 8px;
  border-bottom: 1px solid var(--border); transition: background var(--transition);
  text-decoration: none; color: inherit; position: relative;
}
.lesson-row:last-child { border-bottom: none; }
.lesson-row::before {
  content: ""; position: absolute; left: -16px; right: -16px; top: 0; bottom: 0;
  background: var(--surface-hover); border-radius: var(--radius); opacity: 0;
  transition: opacity var(--transition); z-index: -1;
}
.lesson-row:hover::before { opacity: 1; }
.lesson-idx { font-family: var(--font-display); font-size: 22px; font-weight: 400; color: var(--text-mute); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.lesson-row.done .lesson-idx { color: var(--accent-strong); }
.lesson-title-row { font-size: 16px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
.lesson-duration { font-size: 13px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; transition: background var(--transition), border-color var(--transition); }
.lesson-row.done .check { background: var(--accent); border-color: var(--accent); }
.check svg { width: 11px; height: 11px; stroke: #0E0E10; stroke-width: 3; opacity: 0; transition: opacity var(--transition); }
.lesson-row.done .check svg { opacity: 1; }

/* ─── Lesson reader ─── */
.reader-layout { display: grid; grid-template-columns: 1fr 220px; gap: 64px; align-items: start; }
.reader { max-width: 680px; min-width: 0; }
.reader-meta { font-size: 13px; color: var(--text-mute); display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.reader-meta .dotmeta { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }
.reader > h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 4.2vw, 48px); line-height: 1.08; letter-spacing: -0.03em; margin-bottom: 32px; }
.reader > h1 em { font-style: italic; color: var(--text-dim); font-weight: 300; }

.reader-body h1 { font-family: var(--font-display); font-weight: 400; font-size: 32px; letter-spacing: -0.025em; margin: 40px 0 20px; line-height: 1.15; }
.reader-body h2 { font-family: var(--font-display); font-weight: 400; font-size: 28px; letter-spacing: -0.02em; margin: 48px 0 18px; line-height: 1.2; }
.reader-body h3 { font-family: var(--font-display); font-weight: 500; font-size: 21px; letter-spacing: -0.015em; margin: 32px 0 14px; line-height: 1.25; }
.reader-body p { margin-bottom: 18px; font-size: 16.5px; line-height: 1.72; color: var(--text); }
.reader-body strong { font-weight: 600; }
.reader-body em { font-style: italic; }
.reader-body a { color: var(--text); border-bottom: 1px solid var(--accent); transition: color var(--transition), border-color var(--transition); }
.reader-body a:hover { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }
.reader-body ul, .reader-body ol { margin: 0 0 22px 22px; }
.reader-body li { margin-bottom: 10px; font-size: 16.5px; line-height: 1.65; }
.reader-body ul ul, .reader-body ol ol, .reader-body ul ol, .reader-body ol ul { margin-top: 10px; margin-bottom: 0; }
.reader-body code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13.5px; background: var(--surface-hover); padding: 2px 6px; border-radius: 5px; }
.reader-body pre { background: var(--surface-hover); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; overflow-x: auto; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.6; margin: 24px 0; color: var(--text); }
.reader-body pre code { background: none; padding: 0; font-size: inherit; }
.reader-body blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 20px; margin: 24px 0; color: var(--text-dim); font-style: italic; }
.reader-body blockquote p { margin-bottom: 10px; }
.reader-body blockquote p:last-child { margin-bottom: 0; }
.reader-body hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }
.reader-body img { max-width: 100%; height: auto; border-radius: var(--radius); margin: 20px 0; display: block; }
.reader-body table { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 15px; }
.reader-body th, .reader-body td { padding: 10px 14px; border: 1px solid var(--border); text-align: left; }
.reader-body th { background: var(--surface-hover); font-weight: 600; }
.reader-body .video-wrapper { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; margin: 26px 0; border-radius: var(--radius); background: #000; }
.reader-body .video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

.toc { position: sticky; top: 84px; font-size: 13px; }
.toc-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-mute); margin-bottom: 14px; font-weight: 500; }
.toc a { display: block; padding: 6px 0 6px 12px; color: var(--text-mute); border-left: 1.5px solid var(--border); transition: color var(--transition), border-left-color var(--transition); line-height: 1.45; text-decoration: none; }
.toc a:hover { color: var(--text); border-left-color: var(--border-strong); }
.toc a.active { color: var(--text); border-left-color: var(--accent-strong); font-weight: 500; }

.reader-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 72px; padding-top: 32px; border-top: 1px solid var(--border); }
.nav-tile { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition); background: var(--surface); text-decoration: none; color: inherit; display: block; }
.nav-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.nav-tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); margin-bottom: 6px; }
.nav-tile-title { font-family: var(--font-display); font-size: 17px; letter-spacing: -0.015em; font-weight: 400; line-height: 1.25; }
.nav-tile.next { text-align: right; }

.complete-bar {
  position: sticky; bottom: 16px; margin-top: 56px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px 14px 22px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-lg); z-index: 5; gap: 14px;
}
.complete-bar.is-done { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.complete-bar-text { font-size: 14px; color: var(--text-dim); }
.complete-bar form { margin: 0; }
.btn { background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 99px; font-size: 14px; font-weight: 500; letter-spacing: -0.005em; display: inline-flex; align-items: center; gap: 8px; transition: background var(--transition), transform var(--transition), box-shadow var(--transition); cursor: pointer; border: none; font-family: inherit; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.primary { background: var(--accent); color: #0E0E10; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: var(--surface-hover); }
.btn svg { width: 14px; height: 14px; }

/* ─── Floating support widget ─── */
.bob { position: fixed; bottom: 24px; right: 24px; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 10px 18px 10px 10px; box-shadow: var(--shadow-lg); transition: transform var(--transition); z-index: 20; max-width: 260px; text-decoration: none; color: inherit; }
.bob:hover { transform: translateY(-2px); }
.bob-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #FFCD1F, #FDB400); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.bob-text { min-width: 0; }
.bob-title { font-size: 13px; font-weight: 500; white-space: nowrap; }
.bob-sub { font-size: 11.5px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Auth page ─── */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { max-width: 440px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 48px 40px; text-align: center; box-shadow: var(--shadow-md); }
.auth-card .auth-logo { width: 56px; height: 56px; margin: 0 auto 22px; color: var(--text); }
.auth-card .auth-logo svg { width: 100%; height: 100%; }
.auth-card h1 { font-family: var(--font-display); font-size: 30px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 10px; }
.auth-card h1 em { font-style: italic; color: var(--text-dim); font-weight: 300; }
.auth-card .subtitle { font-size: 15px; color: var(--text-dim); line-height: 1.55; margin-bottom: 32px; }
.flash-message { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); color: var(--text); padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 20px; }
.bot-login-btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 14px 22px; background: #2AABEE; color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; border-radius: 10px; box-sizing: border-box; transition: background 150ms; }
.bot-login-btn:hover { background: #1f95d4; }
.auth-waiting { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 22px; padding: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.auth-spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: #2AABEE; border-radius: 50%; animation: auth-spin 0.9s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-waiting-text { font-size: 15px; font-weight: 500; margin: 0; color: var(--text); }
.auth-waiting-hint { font-size: 13px; color: var(--text-dim); margin: 0; text-align: center; }
.auth-hint { font-size: 13px; color: var(--text-dim); margin-top: 16px; text-align: center; }
.auth-hint a { color: var(--text); text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 16px; color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input { font-family: inherit; font-size: 15px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); outline: none; }
.auth-form input:focus { border-color: var(--text); }
.auth-form-btn { font-family: inherit; font-size: 15px; font-weight: 500; padding: 12px 14px; border: none; border-radius: 10px; background: var(--text); color: var(--bg); cursor: pointer; margin-top: 4px; }
.auth-form-btn:hover { opacity: 0.9; }

/* ─── Admin ─── */
.admin-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.admin-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
.admin-section h2 { font-family: var(--font-display); font-size: 22px; font-weight: 400; margin-bottom: 20px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; padding: 8px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); border-bottom: 1px solid var(--border); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-hover); }
.admin-actions { display: flex; gap: 8px; }
.admin-form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.admin-form label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); display: block; margin-bottom: 4px; }
.admin-form input:not([type="checkbox"]), .admin-form textarea, .admin-form select { font-family: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); outline: none; width: 100%; }
.admin-form input:not([type="checkbox"]):focus, .admin-form textarea:focus { border-color: var(--text); }
.tog { display: flex !important; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 10px; text-transform: none !important; letter-spacing: 0 !important; color: var(--text) !important; font-size: 14px !important; }
.tog input[type="checkbox"] { display: none !important; }
.tog-track { width: 40px; height: 22px; border-radius: 11px; background: var(--border); transition: background .2s; flex-shrink: 0; position: relative; }
.tog input[type="checkbox"]:checked + .tog-track { background: var(--accent-strong); }
.tog-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input[type="checkbox"]:checked + .tog-track::after { transform: translateX(18px); }
.admin-form textarea { min-height: 120px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 6px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ─── Mobile ─── */
.mobile-bar { display: none; }
.sidebar-overlay { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 280px; transform: translateX(-100%); transition: transform var(--transition); z-index: 30; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); opacity: 0; pointer-events: none; transition: opacity var(--transition); z-index: 25; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 15; }
  .mobile-bar .brand { font-size: 16px; }
  .topbar { padding: 14px 20px; }
  .view { padding: 48px 20px 120px; }
  .reader-layout { grid-template-columns: 1fr; gap: 32px; }
  .toc { display: none; }
  .module-header { grid-template-columns: 1fr; gap: 24px; align-items: start; }
  .module-stats { gap: 20px; }
  .progress-card { grid-template-columns: 1fr; }
  .bob { max-width: calc(100% - 48px); }
  .lesson-row { grid-template-columns: 32px 1fr auto; gap: 14px; padding: 18px 4px; }
  .lesson-row .lesson-duration { display: none; }
  .reader-nav { grid-template-columns: 1fr; }
  .nav-tile.next { text-align: left; }
  .complete-bar { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; border-left: none; border-right: none; border-bottom: none; padding: 12px 16px; gap: 10px; }
  .complete-bar-text { font-size: 13px; }
  body:has(.complete-bar) .view { padding-bottom: 180px; }
  body:has(.complete-bar) .bob { bottom: 84px; }
  .admin-layout { grid-template-columns: 1fr; }
}

@keyframes fadeUp { from { opacity: 0; } to { opacity: 1; } }
.view > * { animation: fadeUp 380ms cubic-bezier(.2,.8,.2,1) both; }
.view > *:nth-child(2) { animation-delay: 60ms; }
.view > *:nth-child(3) { animation-delay: 120ms; }
.view > *:nth-child(4) { animation-delay: 180ms; }
