/* ═══════════════════════════════════════════
   ТОЧКА ОПОРЫ — Design System
   GitHub Dark Minimalist Aesthetic (Desktop & Mobile)
   ═══════════════════════════════════════════ */

/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* ── GitHub Dark Palette (Default) ── */
    --bg-primary: #0d1117;
    --bg-secondary: #010409;
    --bg-sidebar: #010409;
    --bg-card: #161b22;
    --bg-hover: #21262d;
    --bg-active: #282e33;

    --text-primary: #e6edf3;
    --text-secondary: #848d97;
    --text-muted: #656c76;

    --accent: #58a6ff;
    --accent-btn: #1f6feb;
    --accent-glow: rgba(56, 139, 253, 0.15);
    --accent-warm: #d29922;

    --border: #30363d;
    --border-light: #21262d;

    --quote-bg: rgba(56, 139, 253, 0.06);
    --quote-border: #2f81f7;

    --hw-bg: rgba(46, 160, 67, 0.08);
    --hw-border: #3fb950;

    --insight-bg: rgba(163, 113, 247, 0.08);
    --insight-border: #a371f7;

    --warning-bg: rgba(187, 128, 9, 0.08);
    --warning-border: #d29922;

    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --sidebar-width: 290px;
    --content-max: 780px;

    --bg-fade-transparent: rgba(13, 17, 23, 0);
    --bg-fade-solid: #0d1117;

    --transition: 0.2s cubic-bezier(0.3, 0, 0.5, 1);
}

/* Light theme (GitHub Light) */
body.light {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-sidebar: #f6f8fa;
    --bg-card: #ffffff;
    --bg-hover: #eaeef2;
    --bg-active: #e1e4e8;

    --bg-fade-transparent: rgba(255, 255, 255, 0);
    --bg-fade-solid: #ffffff;

    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;

    --accent: #0969da;
    --accent-btn: #1f883d;
    --accent-glow: rgba(9, 105, 218, 0.1);

    --border: #d0d7de;
    --border-light: #e1e4e8;

    --quote-bg: #f6f8fa;
    --quote-border: #0969da;

    --hw-bg: #dafbe1;
    --hw-border: #1a7f37;

    --insight-bg: #fbefff;
    --insight-border: #8250df;

    --warning-bg: #fff8c5;
    --warning-border: #9a6700;
}

/* Teaser & Paywall Fade Overlay */
.teaser-content {
    max-height: 560px;
    overflow: hidden;
    position: relative;
}

.teaser-fade-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 220px;
    background: linear-gradient(to bottom, var(--bg-fade-transparent) 0%, var(--bg-primary) 92%);
    pointer-events: none;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

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

a:hover {
    text-decoration: underline;
    color: #79c0ff;
}

body.light a:hover {
    color: #0550ae;
}

/* ── Progress Bar ── */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 1000;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s ease-out;
}

/* ── Mobile Menu Toggle ── */
.menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1006;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background var(--transition), border-color var(--transition);
}

.menu-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.menu-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform var(--transition), opacity var(--transition);
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* ── Mobile Sidebar Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(1, 4, 9, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1004;
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

body.light .sidebar-overlay {
    background: rgba(31, 35, 40, 0.45);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* ── Sidebar (GitHub Dark / Light Sidebar Tree) ── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition), background var(--transition);
}

.sidebar-header {
    padding: 22px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* ── Language Switcher (Flags Only, Clean Inline, No Outer Container Background) ── */
.lang-switch-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.lang-badge-active,
.lang-badge-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 6px;
    text-decoration: none !important;
    line-height: 1;
    transition: all var(--transition);
    user-select: none;
    cursor: pointer;
}

.lang-badge-active {
    background: #1f6feb;
    border: 1px solid #388bfd;
    box-shadow: 0 1px 3px rgba(31, 111, 235, 0.35);
}

body.light .lang-badge-active {
    background: #0969da;
    border-color: #0550ae;
}

.lang-badge-link {
    background: rgba(110, 118, 129, 0.1);
    border: 1px solid var(--border);
    opacity: 0.65;
}

.lang-badge-link:hover {
    opacity: 1;
    background: var(--bg-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.lang-flag-svg {
    display: block;
    width: 20px;
    height: 14px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

/* ── Table of Contents ── */
.toc {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.toc-module {
    padding: 12px 20px 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.toc-item {
    display: block;
    padding: 7px 20px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all var(--transition);
    line-height: 1.4;
}

.toc-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    text-decoration: none;
}

.toc-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-glow);
    font-weight: 600;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-sidebar);
}

.sidebar-footer .sidebar-consult-btn,
.sidebar-footer .sidebar-tg,
.sidebar-footer .sidebar-pdf {
    flex-basis: 100%;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.book-progress {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-consult-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none;
    cursor: pointer;
    box-sizing: border-box;
    width: 100%;
}

.sidebar-consult-btn:hover {
    background: var(--bg-hover);
    border-color: #58a6ff;
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-consult-btn:active,
.sidebar-consult-btn:focus,
.sidebar-consult-btn:focus-visible {
    outline: none !important;
    border-color: #58a6ff;
    box-shadow: none !important;
}

.sidebar-consult-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.8rem;
}

.sidebar-consult-label svg {
    color: #58a6ff;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sidebar-consult-btn:hover .sidebar-consult-label svg {
    transform: scale(1.1);
}

.sidebar-consult-price {
    font-size: 0.72rem;
    font-weight: 700;
    color: #58a6ff;
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.25);
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

[data-theme="light"] .sidebar-consult-price {
    color: #0969da;
    background: rgba(9, 105, 218, 0.08);
    border-color: rgba(9, 105, 218, 0.2);
}



.sidebar-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
}

.sidebar-pdf:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    text-decoration: none;
}

.sidebar-tg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #58a6ff;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
}

.sidebar-tg:hover {
    background: var(--bg-hover);
    border-color: #58a6ff;
    text-decoration: none;
}

.sidebar-socials {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 6px;
}

.sidebar-social-btn {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.sidebar-social-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
    text-decoration: none;
}

.sidebar-social-btn svg {
    width: 14px;
    height: 14px;
}

/* ── Main Content ── */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 40px 32px 80px;
    overflow-x: hidden;
    max-width: 100vw;
    transition: margin-left var(--transition);
}

/* ── Breadcrumb Navigation ── */
.breadcrumb {
    max-width: var(--content-max);
    width: 100%;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    line-height: 1.4;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-muted);
    user-select: none;
}

/* ── Chapter Article ── */
.chapter {
    max-width: var(--content-max);
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.chapter-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    color: var(--text-secondary);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Typography & GitHub Markdown Styles ── */
.chapter h1 {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 16px 0;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.chapter h1 + p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.chapter h1 + p em,
.chapter h1 + p > em:only-child {
    color: var(--text-secondary);
    font-style: italic;
}

.chapter h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 36px 0 14px 0;
    color: var(--text-primary);
    letter-spacing: -0.015em;
    line-height: 1.35;
}

.chapter h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 26px 0 12px 0;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.chapter p {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chapter strong {
    color: var(--text-primary);
    font-weight: 600;
}

.chapter em {
    color: var(--text-secondary);
}

/* ── Blockquotes (GitHub Style Callouts) ── */
.chapter blockquote {
    margin: 20px 0;
    padding: 12px 18px;
    background: var(--quote-bg);
    border-left: 3.5px solid var(--quote-border);
    border-radius: 0 6px 6px 0;
    color: var(--text-primary);
    font-size: 0.94rem;
    line-height: 1.65;
}

.chapter blockquote p {
    margin-bottom: 6px;
}

.chapter blockquote p:last-child {
    margin-bottom: 0;
}

.chapter .hw,
.chapter blockquote:has(strong:first-child) {
    background: var(--hw-bg);
    border-left-color: var(--hw-border);
}

/* ── Lists ── */
.chapter ul,
.chapter ol {
    margin: 14px 0 18px;
    padding-left: 24px;
}

.chapter li {
    margin-bottom: 6px;
    color: var(--text-primary);
    line-height: 1.65;
}

.chapter li::marker {
    color: var(--text-secondary);
}

/* ── Horizontal rule ── */
.chapter hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 28px 0;
}

/* ── Tables (GitHub Styled & Mobile Scrollable) ── */
.chapter table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.88rem;
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.chapter th {
    background: var(--bg-card);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.chapter td {
    padding: 8px 14px;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.chapter tr:nth-child(even) {
    background: var(--bg-card);
}

.chapter tr:hover td {
    background: var(--bg-hover);
}

/* ── Code & Preformatted Blocks ── */
.chapter pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 18px;
    margin: 20px 0;
    overflow-x: auto;
    font-size: 0.84rem;
    line-height: 1.5;
}

.chapter pre code {
    font-family: var(--font-mono);
    font-size: inherit;
    color: var(--text-primary);
    background: transparent;
    padding: 0;
    border: none;
    display: block;
}

.chapter code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    color: var(--text-primary);
    background: rgba(110, 118, 129, 0.4);
    border-radius: 4px;
    padding: 2px 6px;
}

body.light .chapter code {
    background: rgba(175, 184, 193, 0.2);
}

/* ── Chapter navigation buttons ── */
.chapter-nav {
    max-width: var(--content-max);
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.nav-btn,
.chapter-nav-btn {
    padding: 9px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none !important;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
}

.nav-btn:hover:not(:disabled),
.chapter-nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
    text-decoration: none !important;
}

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

/* ── SEO Landing CTA Buttons ── */
.seo-cta-btn,
.seo-cta-btn:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    background: #238636;
    color: #ffffff !important;
    text-decoration: none !important;
    border: 1px solid rgba(240, 246, 252, 0.1);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all var(--transition);
    box-shadow: 0 1px 0 rgba(27, 31, 36, 0.1);
}

.seo-cta-btn:hover {
    background: #2ea043;
    color: #ffffff !important;
    text-decoration: none !important;
}

.seo-cta-pdf,
.seo-cta-pdf:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-card);
    color: var(--text-primary) !important;
    text-decoration: none !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition);
}

.seo-cta-pdf:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent) !important;
    text-decoration: none !important;
}

.seo-cta-socials {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 14px;
}

.seo-cta-social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    text-decoration: none !important;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.seo-cta-social-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
    text-decoration: none !important;
}

/* ═══════════════════════════════════════════
   GitHub-Grade Paywall Card
   ═══════════════════════════════════════════ */
.paywall-container {
    max-width: 620px;
    margin: 32px auto;
    padding: 32px 28px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 16px 36px rgba(1, 4, 9, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

body.light .paywall-container {
    box-shadow: 0 12px 28px rgba(140, 149, 159, 0.2);
}

.paywall-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 14px;
}

.paywall-icon-glow {
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.paywall-title {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.paywall-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Feature grid */
.paywall-benefits {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 auto 20px;
    text-align: left;
    max-width: 500px;
}

@media (max-width: 540px) {
    .paywall-benefits {
        grid-template-columns: 1fr;
    }
}

.paywall-benefit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
}

.paywall-benefit-item svg {
    flex-shrink: 0;
    color: #3fb950;
}

/* Price & CTA Box */
.paywall-cta-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 18px;
    margin-bottom: 20px;
}

.paywall-price-tag {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
}

.paywall-price-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.paywall-buy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 380px;
    margin: 12px auto 0;
    padding: 11px 20px;
    background: #238636;
    border: 1px solid rgba(240, 246, 252, 0.1);
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(27, 31, 36, 0.1);
    transition: background 0.2s ease, transform 0.1s ease;
}

.paywall-buy-btn:hover {
    background: #2ea043;
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-1px);
}

.paywall-secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    max-width: 380px;
    padding: 8px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-primary) !important;
    text-decoration: none !important;
    font-size: 0.84rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition);
}

.paywall-secondary-btn:hover {
    background: var(--bg-active);
    border-color: var(--text-muted);
    color: var(--accent) !important;
    text-decoration: none !important;
}

/* ── Sidebar Consultation Button (Premium GitHub Styled) ── */
.sidebar-consult-btn {
    width: 100%;
    flex-basis: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 10px;
    margin-bottom: 6px;
    background: linear-gradient(180deg, rgba(31, 111, 235, 0.08) 0%, rgba(31, 111, 235, 0.02) 100%);
    border: 1px solid rgba(56, 139, 253, 0.28);
    border-radius: 6px;
    color: #58a6ff !important;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none !important;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    transition: all var(--transition);
    cursor: pointer;
    box-sizing: border-box;
}

.sidebar-consult-btn svg {
    flex-shrink: 0;
    color: #58a6ff;
    transition: transform 0.2s ease;
}

.sidebar-consult-price {
    font-size: 0.72rem;
    font-weight: 700;
    color: #79c0ff;
    background: rgba(56, 139, 253, 0.18);
    border: 1px solid rgba(56, 139, 253, 0.3);
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.2;
}

.sidebar-consult-btn:hover {
    background: linear-gradient(180deg, rgba(56, 139, 253, 0.2) 0%, rgba(31, 111, 235, 0.12) 100%);
    border-color: #58a6ff;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(56, 139, 253, 0.2);
}

.sidebar-consult-btn:hover svg {
    color: #ffffff;
    transform: scale(1.08);
}

.sidebar-consult-btn:hover .sidebar-consult-price {
    background: rgba(56, 139, 253, 0.35);
    color: #ffffff;
    border-color: rgba(56, 139, 253, 0.6);
}

.sidebar-consult-btn:focus,
.sidebar-consult-btn:focus-visible,
.sidebar-consult-btn:active {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(56, 139, 253, 0.35);
}

body.light .sidebar-consult-btn {
    background: linear-gradient(180deg, rgba(9, 105, 218, 0.06) 0%, rgba(9, 105, 218, 0.02) 100%);
    border-color: rgba(9, 105, 218, 0.25);
    color: #0969da !important;
}

body.light .sidebar-consult-btn svg {
    color: #0969da;
}

body.light .sidebar-consult-price {
    color: #0969da;
    background: rgba(9, 105, 218, 0.08);
    border-color: rgba(9, 105, 218, 0.2);
}

body.light .sidebar-consult-btn:hover {
    background: linear-gradient(180deg, rgba(9, 105, 218, 0.12) 0%, rgba(9, 105, 218, 0.06) 100%);
    border-color: #0969da;
    color: #0550ae !important;
    box-shadow: 0 2px 8px rgba(9, 105, 218, 0.15);
}

/* ── Non-Intrusive Floating Consultation Toast ── */
.consult-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    max-width: 380px;
    width: calc(100% - 32px);
    background: rgba(22, 27, 34, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(56, 139, 253, 0.35);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 1px rgba(56, 139, 253, 0.5);
    z-index: 99999 !important;
    font-size: 0.84rem;
    color: var(--text-primary);
    animation: toastSlideUp 0.3s ease-out;
}

body.light .consult-toast {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(9, 105, 218, 0.25);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.consult-toast-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    padding-right: 32px; /* Protects from close button overlap */
}

.consult-toast-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(56, 139, 253, 0.12);
    border: 1px solid rgba(56, 139, 253, 0.25);
    border-radius: 8px;
    flex-shrink: 0;
    color: #58a6ff;
    margin-top: 1px;
}

body.light .consult-toast-icon-wrap {
    background: rgba(9, 105, 218, 0.08);
    border-color: rgba(9, 105, 218, 0.2);
    color: #0969da;
}

.consult-toast-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.consult-toast-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.consult-toast-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(56, 139, 253, 0.12);
    border: 1px solid rgba(56, 139, 253, 0.3);
    color: #58a6ff;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

body.light .consult-toast-badge {
    background: rgba(9, 105, 218, 0.08);
    border-color: rgba(9, 105, 218, 0.25);
    color: #0969da;
}

.consult-toast-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    z-index: 2;
}

.consult-toast-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.consult-toast-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 6px 0 12px;
    line-height: 1.45;
}

.consult-toast-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.consult-toast-links.en {
    grid-template-columns: repeat(2, 1fr);
}

.consult-toast-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 32px;
    padding: 0 8px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none !important;
    transition: all var(--transition);
    text-align: center;
}

.consult-toast-btn svg {
    flex-shrink: 0;
}

.consult-toast-btn.tg {
    background: #1f6feb;
    color: #ffffff !important;
}
.consult-toast-btn.tg:hover {
    background: #388bfd;
    box-shadow: 0 2px 8px rgba(31, 111, 235, 0.35);
}

.consult-toast-btn.max {
    background: #6e40c9;
    color: #ffffff !important;
}
.consult-toast-btn.max:hover {
    background: #8957e5;
    box-shadow: 0 2px 8px rgba(110, 64, 201, 0.35);
}

.consult-toast-btn.email {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary) !important;
}
.consult-toast-btn.email:hover {
    color: var(--text-primary) !important;
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

@media (max-width: 480px) {
    .consult-toast {
        bottom: 12px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        padding: 14px;
    }

    .consult-toast-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

.paywall-methods-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 12px 0 0;
}

.paywall-method-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding: 0 8px;
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #1f2328;
    user-select: none;
}

.paywall-method-badge svg {
    display: block;
    flex-shrink: 0;
}

/* Activate key section */
.paywall-key-section {
    border-top: 1px solid var(--border);
    padding-top: 18px;
    margin-top: 18px;
}

.paywall-key-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.paywall-form-compact {
    display: flex;
    gap: 6px;
    max-width: 380px;
    margin: 0 auto;
}

@media (max-width: 480px) {
    .paywall-form-compact {
        flex-direction: column;
    }
}

.paywall-input-compact {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.86rem;
    font-family: var(--font-body);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.paywall-input-compact:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}

.paywall-btn-compact {
    padding: 8px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.84rem;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.paywall-btn-compact:hover {
    background: var(--bg-active);
    border-color: var(--text-muted);
}

/* ── PDF Download Button (licensed users only) ── */
.pdf-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 20px;
}

.pdf-download-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Responsive & Mobile Refinements ── */
body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(310px, 85vw);
        top: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 1005;
        background: var(--bg-sidebar);
        border-right: 1px solid var(--border);
        box-shadow: 12px 0 36px rgba(1, 4, 9, 0.85);
    }

    body.light .sidebar {
        box-shadow: 8px 0 24px rgba(31, 35, 40, 0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        padding: 16px 18px 14px 62px;
        min-height: 70px;
    }

    .sidebar-title {
        font-size: 1.05rem;
    }

    .sidebar-subtitle {
        font-size: 0.72rem;
    }

    .content {
        margin-left: 0;
        padding: 56px 20px 80px;
    }

    .chapter h1 {
        font-size: 1.65rem;
    }

    .chapter h2 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 56px 18px 80px;
    }

    .chapter h1 {
        font-size: 1.4rem;
    }

    .chapter h2 {
        font-size: 1.15rem;
    }

    .chapter pre {
        font-size: 0.75rem;
        padding: 10px 12px;
        margin: 14px 0;
        border-radius: 6px;
    }

    .chapter th,
    .chapter td {
        padding: 8px 10px;
    }

    .chapter-nav {
        flex-direction: column;
    }

    .paywall-container {
        padding: 24px 16px 20px;
        margin: 24px auto;
        border-radius: 8px;
    }

    .paywall-title {
        font-size: 1.25rem;
    }

    .paywall-price-tag {
        font-size: 1.6rem;
    }
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Selection ── */
::selection {
    background: rgba(56, 139, 253, 0.35);
    color: #ffffff;
}

/* ── Print Styles ── */
@media print {
    .sidebar,
    .menu-toggle,
    .progress-bar,
    .paywall-container,
    .chapter-nav,
    .theme-toggle,
    .seo-cta-socials {
        display: none !important;
    }

    .content {
        margin-left: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    .chapter h1 {
        font-size: 20pt;
        color: #000 !important;
        page-break-after: avoid;
    }

    .chapter h2 {
        font-size: 15pt;
        color: #000 !important;
        page-break-after: avoid;
        border-bottom: 1px solid #ccc;
    }

    .chapter h3 {
        font-size: 13pt;
        color: #000 !important;
        page-break-after: avoid;
    }

    .chapter p,
    .chapter li {
        color: #111 !important;
    }

    .chapter strong {
        color: #000 !important;
    }

    .chapter em {
        color: #333 !important;
    }

    .chapter blockquote {
        background: #f5f5f5 !important;
        border-left: 3px solid #666 !important;
        color: #333 !important;
        page-break-inside: avoid;
    }

    .chapter .hw,
    .chapter blockquote:has(strong:first-child) {
        background: #f0f8f0 !important;
        border-left-color: #2e7d32 !important;
    }

    .chapter hr {
        background: #ccc !important;
    }

    .chapter a {
        color: #000 !important;
        text-decoration: underline;
    }
}