/* ═══════════════════════════════════════════════════════════════════════════════
   TMT Book Website — Professional Academic Stylesheet
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ─── */
:root {
    --font-serif: 'Source Serif 4', 'Georgia', 'Times New Roman', serif;
    --font-sans: 'Source Sans 3', 'Helvetica Neue', 'Arial', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;

    --color-bg: #fafaf8;
    --color-text: #1a1a1a;
    --color-text-muted: #555;
    --color-text-light: #888;
    --color-heading: #111;

    --color-sidebar-bg: #0f1319;
    --color-sidebar-text: #a0a8b8;
    --color-sidebar-heading: #e8eaef;
    --color-sidebar-active: #6c9bff;
    --color-sidebar-hover: #1a2030;

    --color-link: #1a5276;
    --color-link-hover: #2980b9;

    --color-border: #ddd;
    --color-border-light: #eee;

    --color-accent: #1a3a5c;
    --color-accent-light: #2563eb;

    --color-result-bg: #ebf5ff;
    --color-result-border: #191970;
    --color-scaffold-bg: #fff8eb;
    --color-scaffold-border: #b8860b;
    --color-proven-bg: #ebffeb;
    --color-proven-border: #228b22;
    --color-keyeq-bg: #ffffeb;
    --color-keyeq-border: #b22222;
    --color-interpret-bg: #f0f0ff;
    --color-interpret-border: #191970;

    --color-physical-bg: #eff6ff;
    --color-physical-border: #3b82f6;
    --color-analogy-bg: #f0fdf4;
    --color-analogy-border: #22c55e;
    --color-thought-bg: #fefce8;
    --color-thought-border: #eab308;
    --color-whynot-bg: #fef2f2;
    --color-whynot-border: #ef4444;
    --color-roadmap-bg: #ecfeff;
    --color-roadmap-border: #06b6d4;
    --color-derivmap-bg: #faf5ff;
    --color-derivmap-border: #a855f7;
    --color-mathrem-bg: #f9fafb;
    --color-mathrem-border: #6b7280;
    --color-caution-bg: #fff7ed;
    --color-caution-border: #f97316;

    --sidebar-width: 300px;
    --content-max-width: 820px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-serif);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INDEX / LANDING PAGE
   ═══════════════════════════════════════════════════════════════════════════════ */

.index-page {
    min-height: 100vh;
    padding: 0;
    display: block;
}

/* ─── Hero Section ─── */
.index-hero {
    background: #0a0e14;
    color: #fff;
    padding: 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.index-hero-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
    filter: saturate(0.85) contrast(1.1);
    z-index: 0;
}

.index-hero-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(10, 14, 20, 0.2) 0%, rgba(10, 14, 20, 0.7) 70%),
        linear-gradient(180deg, rgba(10, 14, 20, 0.1) 0%, rgba(10, 14, 20, 0.3) 60%, rgba(10, 14, 20, 0.95) 100%);
    z-index: 1;
    pointer-events: none;
}

.index-hero-content {
    position: relative;
    z-index: 2;
    padding: 5rem 2rem 4rem;
    max-width: 800px;
}

.index-edition {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: rgba(108, 155, 255, 0.8);
    margin: 0 0 1.2rem;
    background: rgba(108, 155, 255, 0.08);
    display: inline-block;
    padding: 0.35em 1em;
    border-radius: 3px;
    border: 1px solid rgba(108, 155, 255, 0.15);
}

.index-book-title {
    font-family: var(--font-serif);
    font-size: 3.4rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.08;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 30px rgba(0, 0, 0, 0.5);
}

.index-subtitle {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: rgba(255,255,255,0.65);
    font-style: italic;
    margin: 0.8rem 0 0;
    font-weight: 300;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}

.index-author {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    color: rgba(255,255,255,0.45);
    margin: 1.2rem 0 0;
    font-weight: 400;
    letter-spacing: 0.06em;
}

/* Postulate Display */
.index-postulate {
    margin: 2rem auto 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1rem 2.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.index-postulate-label {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.4);
}

.index-postulate-eq {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 300;
    color: rgba(255, 215, 120, 0.9);
    letter-spacing: 0.04em;
    text-shadow: 0 0 20px rgba(255, 200, 80, 0.15);
}

.index-stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.index-stat {
    text-align: center;
}

.index-stat-number {
    display: block;
    font-family: var(--font-sans);
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.index-stat-label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.35rem;
}

/* ─── About Section ─── */
.index-about {
    background: #fff;
    border-bottom: 1px solid var(--color-border-light);
}

.index-about-inner {
    max-width: 920px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
    text-align: center;
}

.index-about-heading {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-heading);
    margin: 0 0 1rem;
    line-height: 1.3;
}

.index-about-text {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    color: var(--color-text-muted);
    line-height: 1.75;
    max-width: 720px;
    margin: 0 auto 2.5rem;
}

.index-highlights {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-top: 2rem;
}

.index-highlight {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    background: var(--color-bg);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.index-highlight:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.index-highlight-icon {
    font-size: 1.6rem;
    color: var(--color-accent-light);
    margin-bottom: 0.6rem;
    line-height: 1;
}

.index-highlight h3 {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-heading);
    margin: 0 0 0.4rem;
}

.index-highlight p {
    font-family: var(--font-sans);
    font-size: 0.84rem;
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ─── TOC Container ─── */
.index-toc-container {
    max-width: 920px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
}

/* ─── Search Bar ─── */
.index-search {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-bg);
    padding: 1.2rem 0;
    margin-bottom: 1rem;
}

.index-search-wrapper {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.index-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-light);
    font-size: 0.95rem;
    pointer-events: none;
}

.index-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.6rem;
    border: 1px solid var(--color-border);
    border-radius: 50px;
    background: #fff;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.index-search input::placeholder {
    color: var(--color-text-light);
}

.index-search input:focus {
    border-color: var(--color-accent-light);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ─── TOC Heading ─── */
.index-toc-heading {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-light);
    margin: 0 0 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--color-border-light);
}

/* ─── Part Sections (Collapsible) ─── */
.index-part {
    margin-bottom: 0.5rem;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s;
}

.index-part:hover {
    box-shadow: var(--shadow-sm);
}

.index-part-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.2rem;
    cursor: pointer;
    user-select: none;
    background: #fff;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
    transition: background-color 0.15s;
}

.index-part-header:hover {
    background: #f8f9fa;
}

.index-part-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-heading);
    margin: 0;
    flex: 1;
}

.index-part-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.index-part-count {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--color-text-light);
    background: #f0f1f3;
    padding: 0.2em 0.6em;
    border-radius: 50px;
    font-weight: 600;
}

.index-part-chevron {
    font-size: 0.75rem;
    color: var(--color-text-light);
    transition: transform 0.25s ease;
    line-height: 1;
}

.index-part.open .index-part-chevron {
    transform: rotate(180deg);
}

.index-part-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.index-part.open .index-part-body {
    max-height: 2000px;
}

.index-chapter-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--color-border-light);
}

.index-chapter-list li {
    margin: 0;
}

.index-chapter-list li a {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.55rem 1.2rem 0.55rem 1.6rem;
    color: var(--color-text);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    line-height: 1.4;
    transition: background-color 0.12s, color 0.12s;
    border-bottom: 1px solid #f5f5f5;
}

.index-chapter-list li:last-child a {
    border-bottom: none;
}

.index-chapter-list li a:hover {
    background: #f0f4ff;
    color: var(--color-accent-light);
}

.index-chapter-list li a .ch-num {
    font-weight: 600;
    color: var(--color-text-light);
    font-size: 0.8rem;
    min-width: 2.2rem;
    flex-shrink: 0;
}

.index-chapter-list li a:hover .ch-num {
    color: var(--color-accent-light);
}

/* ─── No results message ─── */
.index-no-results {
    display: none;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-light);
    font-family: var(--font-sans);
    font-size: 0.95rem;
}

.index-no-results.visible {
    display: block;
}

/* ─── Footer ─── */
.index-footer {
    background: var(--color-sidebar-bg);
    color: rgba(255, 255, 255, 0.5);
    padding: 0;
    margin-top: 2rem;
}

.index-footer-inner {
    max-width: 920px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 0.82rem;
}

.index-footer-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.index-footer-subtitle {
    font-size: 0.75rem;
    font-style: italic;
    color: rgba(255, 255, 255, 0.3);
    margin: 0.2rem 0 0;
}

.index-footer-meta {
    text-align: right;
}

.index-footer-meta p {
    margin: 0;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.78rem;
}

.index-footer-copy {
    margin-top: 0.3rem !important;
    font-size: 0.7rem !important;
    color: rgba(255, 255, 255, 0.2) !important;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   CHAPTER PAGES — SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 20px rgba(0,0,0,0.15);
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar-header {
    padding: 1.5rem 1.2rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.15);
}

.book-title-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.book-title-link:hover {
    text-decoration: none;
}

.book-title {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-sidebar-heading);
    margin: 0;
    line-height: 1.3;
}

.book-subtitle {
    font-size: 0.75rem;
    color: var(--color-sidebar-text);
    margin: 0.3rem 0 0;
    opacity: 0.5;
    font-style: italic;
}

.sidebar-search {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    color: var(--color-sidebar-heading);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.sidebar-search input::placeholder {
    color: rgba(255,255,255,0.3);
}

.sidebar-search input:focus {
    border-color: var(--color-sidebar-active);
    background: rgba(255,255,255,0.08);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.4rem 0;
}

.nav-section {
    margin-bottom: 0.15rem;
}

.nav-section-title {
    padding: 0.7rem 1rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-sidebar-active);
    opacity: 0.8;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list li a {
    display: block;
    padding: 0.32rem 1rem 0.32rem 1.5rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    font-size: 0.78rem;
    line-height: 1.4;
}

.nav-list li a:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-heading);
    text-decoration: none;
}

.nav-list li.active a {
    border-left-color: var(--color-sidebar-active);
    background: rgba(108, 155, 255, 0.1);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.72rem;
    opacity: 0.4;
}

.sidebar-footer p { margin: 0; }

/* ─── Mobile sidebar toggle ─── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    background: var(--color-sidebar-bg);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: background-color 0.15s;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: #1a2030;
}

/* ─── Sidebar backdrop (mobile) ─── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.visible {
    opacity: 1;
}

/* ─── Reading Progress Bar ─── */
.reading-progress {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 3px;
    z-index: 80;
    background: transparent;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent-light), #8b5cf6);
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   CHAPTER PAGES — MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════════ */

.content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.chapter {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 3rem 2.5rem 4rem;
}

/* ─── Chapter Header ─── */
.chapter-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-border);
}

.chapter-label {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent-light);
    margin-bottom: 0.5rem;
    background: rgba(37,99,235,0.06);
    padding: 0.2em 0.7em;
    border-radius: 3px;
}

.chapter-title {
    font-family: var(--font-serif);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--color-heading);
    margin: 0;
    line-height: 1.2;
}

/* ─── Chapter TOC ─── */
.chapter-toc {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.2rem 1.5rem;
    margin-bottom: 2.5rem;
    font-family: var(--font-sans);
    box-shadow: var(--shadow-sm);
}

.chapter-toc h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-light);
    margin: 0 0 0.8rem;
}

.chapter-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.chapter-toc li {
    margin: 0.25rem 0;
}

.chapter-toc a {
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.88rem;
    padding: 0.15rem 0;
    display: inline-block;
    transition: color 0.15s;
}

.chapter-toc a:hover {
    color: var(--color-link-hover);
}

.chapter-toc a.active {
    color: var(--color-accent-light);
    font-weight: 600;
}

/* ─── Section Headings ─── */
h2.section-heading {
    font-family: var(--font-serif);
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--color-heading);
    margin: 2.8rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border-light);
}

h3.section-heading {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-heading);
    margin: 2rem 0 0.8rem;
}

h4.section-heading {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1.5rem 0 0.6rem;
}

/* ─── Paragraph & Text ─── */
p {
    margin: 0 0 1rem;
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color 0.15s;
}

a:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

blockquote {
    border-left: 4px solid var(--color-accent-light);
    margin: 1.5rem 0;
    padding: 0.8rem 1.2rem;
    background: #f8f9fc;
    font-style: italic;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: #f0f0ec;
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

.small-caps {
    font-variant: small-caps;
    letter-spacing: 0.03em;
}

/* ─── Lists ─── */
ul, ol {
    margin: 0.8rem 0 1.2rem;
    padding-left: 1.8rem;
}

li {
    margin-bottom: 0.35rem;
}

/* ─── TMT Box Environments ─── */
.tmt-result-box,
.tmt-scaffold-box,
.tmt-proven-box,
.tmt-keyeq-box,
.tmt-interpret-box,
.tmt-physical-picture,
.tmt-analogy,
.tmt-thought-experiment,
.tmt-whynot,
.tmt-roadmap,
.tmt-derivation-map,
.tmt-math-reminder,
.tmt-caution {
    margin: 1.5rem 0;
    padding: 1.2rem 1.4rem;
    border-left: 4px solid;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    box-shadow: var(--shadow-sm);
}

.box-title {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 0.6rem;
}

.box-content { font-size: 0.97rem; }
.box-content p:last-child { margin-bottom: 0; }

.tmt-result-box     { background: var(--color-result-bg);   border-color: var(--color-result-border); }
.tmt-result-box .box-title { color: var(--color-result-border); }

.tmt-scaffold-box   { background: var(--color-scaffold-bg); border-color: var(--color-scaffold-border); }
.tmt-scaffold-box .box-title { color: var(--color-scaffold-border); }

.tmt-proven-box     { background: var(--color-proven-bg);   border-color: var(--color-proven-border); }
.tmt-proven-box .box-title { color: var(--color-proven-border); }

.tmt-keyeq-box      { background: var(--color-keyeq-bg);    border-color: var(--color-keyeq-border); }
.tmt-keyeq-box .box-title { color: var(--color-keyeq-border); }

.tmt-interpret-box   { background: var(--color-interpret-bg); border-color: var(--color-interpret-border); }
.tmt-interpret-box .box-title { color: var(--color-interpret-border); }

.tmt-physical-picture { background: var(--color-physical-bg); border-color: var(--color-physical-border); }
.tmt-physical-picture .box-title { color: var(--color-physical-border); }

.tmt-analogy         { background: var(--color-analogy-bg);  border-color: var(--color-analogy-border); }
.tmt-analogy .box-title { color: var(--color-analogy-border); }

.tmt-thought-experiment { background: var(--color-thought-bg); border-color: var(--color-thought-border); }
.tmt-thought-experiment .box-title { color: var(--color-thought-border); }

.tmt-whynot          { background: var(--color-whynot-bg);   border-color: var(--color-whynot-border); }
.tmt-whynot .box-title { color: var(--color-whynot-border); }

.tmt-roadmap         { background: var(--color-roadmap-bg);  border-color: var(--color-roadmap-border); }
.tmt-roadmap .box-title { color: var(--color-roadmap-border); }

.tmt-derivation-map  { background: var(--color-derivmap-bg); border-color: var(--color-derivmap-border); }
.tmt-derivation-map .box-title { color: var(--color-derivmap-border); }

.tmt-math-reminder   { background: var(--color-mathrem-bg);  border-color: var(--color-mathrem-border); }
.tmt-math-reminder .box-title { color: var(--color-mathrem-border); }

.tmt-caution         { background: var(--color-caution-bg);  border-color: var(--color-caution-border); }
.tmt-caution .box-title { color: var(--color-caution-border); }

/* ─── Status Box (ch-167) ─── */
.tmt-status-box {
    margin: 1.5rem 0;
    padding: 1.2rem 1.4rem;
    border-left: 4px solid #6366f1;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: #eef2ff;
    box-shadow: var(--shadow-sm);
}
.tmt-status-box .box-title { color: #4338ca; }

/* ─── Theorem Environments ─── */
.theorem-block {
    margin: 1.8rem 0;
    padding: 1.2rem 1.4rem;
    border-left: 4px solid #191970;
    background: #f8f8ff;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    box-shadow: var(--shadow-sm);
}

.theorem-block.postulate {
    border-color: #b22222;
    background: #fff8f8;
}

.theorem-block.definition {
    border-color: #2e8b57;
    background: #f5fff5;
}

.theorem-block.corollary {
    border-color: #4169e1;
    background: #f0f4ff;
}

.theorem-block.proposition {
    border-color: #6a5acd;
    background: #f5f3ff;
}

.theorem-block.lemma {
    border-color: #2e6b8b;
    background: #f0f7fa;
}

.theorem-block.observation,
.theorem-block.interpretation {
    border-color: #b8860b;
    background: #fefce8;
}

.theorem-block.axiom,
.theorem-block.principle {
    border-color: #9b2335;
    background: #fef2f2;
}

.theorem-block.example {
    border-color: #059669;
    background: #f0fdf4;
}

.theorem-block.remark,
.theorem-block.note {
    border-color: #6b7280;
    background: #f9fafb;
}

.theorem-block.conjecture,
.theorem-block.hypothesis {
    border-color: #d97706;
    background: #fffbeb;
}

.theorem-block.summary {
    border-color: #0891b2;
    background: #ecfeff;
}

.theorem-head {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    margin-bottom: 0.6rem;
    color: var(--color-heading);
}

.theorem-body { font-style: italic; }
.theorem-block.definition .theorem-body,
.theorem-block.remark .theorem-body,
.theorem-block.note .theorem-body,
.theorem-block.example .theorem-body,
.theorem-block.convention .theorem-body,
.theorem-block.observation .theorem-body,
.theorem-block.interpretation .theorem-body,
.theorem-block.summary .theorem-body {
    font-style: normal;
}

/* ─── Proof ─── */
.proof {
    margin: 1rem 0 1.5rem;
    padding-left: 1rem;
}

.proof-head {
    font-style: italic;
    font-weight: 600;
    margin-right: 0.5rem;
}

.qed {
    float: right;
    font-size: 1.1rem;
}

/* ─── Math Display ─── */
.display-math {
    margin: 1.2rem 0;
    overflow-x: auto;
    padding: 0.3rem 0;
}

.equation-numbered {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.equation-content {
    flex: 1;
    text-align: center;
}

.equation-number {
    font-family: var(--font-serif);
    font-size: 0.92rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 3rem;
    text-align: right;
}

/* ─── Tables ─── */
.table-wrapper {
    margin: 1.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
}

.table-caption {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.table-caption strong {
    color: var(--color-text);
}

.tmt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    font-family: var(--font-sans);
}

/* Fix <p> tags inside table cells from LaTeX conversion */
.tmt-table th p,
.tmt-table td p {
    margin: 0;
    display: inline;
}

/* Tables outside of .table-wrapper (inline tables) */
table.tmt-table:not(.table-wrapper .tmt-table) {
    margin: 1.5rem 0;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* Center-aligned wrapper divs (from LaTeX conversion) */
div[style*="text-align: center"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

div[style*="text-align: center"] > .tmt-table {
    margin-left: auto;
    margin-right: auto;
}

div[style*="text-align: center"] > table.tmt-table:only-child {
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
}

.tmt-table th,
.tmt-table td {
    padding: 0.6rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.tmt-table th {
    font-weight: 600;
    background: #f8f9fa;
    border-bottom: 2px solid var(--color-border);
}

.tmt-table tr:hover td {
    background: #fafbfc;
}

/* ─── Figures ─── */
figure.figure {
    margin: 2rem 0;
    text-align: center;
}

.figure-content {
    background: #fff;
    border: 1px solid var(--color-border-light);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* All tikz-img images, regardless of container */
.tikz-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Constrain image sizes to prevent overpowering text */
.figure-content .tikz-img {
    max-width: min(100%, 600px);
    max-height: 500px;
    width: auto;
    object-fit: contain;
}

figcaption {
    font-family: var(--font-sans);
    font-size: 0.84rem;
    color: var(--color-text-muted);
    margin-top: 0.7rem;
    line-height: 1.45;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

figcaption strong {
    color: var(--color-text);
}

/* ─── TikZ Diagrams (standalone, outside figure) ─── */
.tikz-diagram {
    text-align: center;
    margin: 2rem 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
}

.tikz-diagram .tikz-img {
    max-width: min(100%, 600px);
    max-height: 500px;
    object-fit: contain;
}

.tikz-placeholder {
    background: #f8f9fa;
    border: 1px dashed var(--color-border);
    padding: 1.5rem;
    text-align: center;
    color: var(--color-text-light);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
}

/* ─── Status Tags ─── */
.status {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2em 0.55em;
    border-radius: 3px;
    white-space: nowrap;
}

.status-postulate { color: #b22222; }
.status-proven, .status-established { color: #228b22; }
.status-derived { color: #4169e1; }
.status-conjectured { color: #b8860b; }
.status-observation { color: #4169e1; }
.status-empirical { color: #dc143c; }
.status-hypothesis { color: #da70d6; }

.papertag {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-variant: small-caps;
    color: var(--color-text-light);
}

.citation {
    color: #8b008b;
}

.error {
    color: #dc143c;
    font-weight: 700;
}

.ref {
    color: var(--color-link);
}

/* ─── Footnotes ─── */
.footnotes {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.88rem;
}

.footnotes h2 {
    font-size: 1rem;
    font-family: var(--font-sans);
}

.footnote-ref a {
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.75rem;
}

.footnote-back {
    text-decoration: none;
    margin-left: 0.3rem;
}

/* ─── Chapter Navigation ─── */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    gap: 1rem;
}

.chapter-nav a {
    color: var(--color-link);
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    white-space: nowrap;
}

.chapter-nav a:hover {
    background: #f0f4ff;
    border-color: var(--color-accent-light);
    color: var(--color-accent-light);
    text-decoration: none;
}

/* ─── Center ─── */
.center { text-align: center; }

/* ─── Derivation Chain ─── */
.derivation-chain {
    margin: 1rem 0;
    padding: 0.8rem;
    background: #fafaf8;
    border-radius: var(--radius-sm);
}

.derivation-chain ol {
    padding-left: 1.5rem;
}

/* ─── Disabled / Coming Soon Nav Items ─── */
.nav-disabled {
    color: var(--color-text-light) !important;
    cursor: default;
    pointer-events: none;
    opacity: 0.5;
}

.nav-disabled .not-available {
    font-size: 0.7rem;
    font-style: italic;
    color: #999;
    margin-left: 0.4rem;
}

.nav-list li.nav-disabled:hover {
    background: none;
}

/* ─── Back to Top Button ─── */
.back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.15s;
    z-index: 80;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}


/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .index-hero {
        min-height: 440px;
    }

    .index-hero-content {
        padding: 4rem 1.5rem 3rem;
    }

    .index-book-title {
        font-size: 2.6rem;
    }

    .index-toc-container {
        padding: 2rem 1.5rem 3rem;
    }

    .index-highlights {
        gap: 1.2rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    /* ─── Index Hero ─── */
    .index-hero {
        min-height: 400px;
    }

    .index-hero-content {
        padding: 3rem 1.25rem 2.5rem;
    }

    .index-book-title {
        font-size: 2rem;
    }

    .index-subtitle {
        font-size: 1.05rem;
    }

    .index-postulate {
        padding: 0.8rem 1.5rem;
    }

    .index-postulate-eq {
        font-size: 1.4rem;
    }

    .index-stats {
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    .index-stat-number {
        font-size: 1.4rem;
    }

    .index-about-inner {
        padding: 2.5rem 1.25rem;
    }

    .index-highlights {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .index-highlight {
        padding: 1.2rem 1rem;
    }

    .index-toc-container {
        padding: 1.5rem 1rem 3rem;
    }

    .index-search {
        padding: 0.8rem 0;
    }

    .index-part-header {
        padding: 0.8rem 1rem;
    }

    .index-part-title {
        font-size: 0.88rem;
    }

    .index-chapter-list li a {
        padding: 0.65rem 1rem 0.65rem 1.2rem;
        font-size: 0.85rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .index-footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .index-footer-meta {
        text-align: center;
    }

    /* ─── Sidebar ─── */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

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

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-backdrop {
        display: block;
    }

    .nav-list li a {
        padding: 0.45rem 1rem 0.45rem 1.5rem;
        min-height: 40px;
        display: flex;
        align-items: center;
    }

    /* ─── Content ─── */
    .content {
        margin-left: 0;
    }

    .reading-progress {
        left: 0;
    }

    .chapter {
        padding: 1.5rem 1rem 3rem;
    }

    .chapter-header {
        margin-bottom: 2rem;
        padding-bottom: 1.2rem;
    }

    .chapter-title {
        font-size: 1.7rem;
    }

    .chapter-label {
        font-size: 0.72rem;
    }

    h2.section-heading {
        font-size: 1.35rem;
        margin: 2.2rem 0 0.8rem;
        padding-top: 1.2rem;
    }

    h3.section-heading {
        font-size: 1.1rem;
        margin: 1.6rem 0 0.6rem;
    }

    h4.section-heading {
        font-size: 0.98rem;
    }

    /* ─── Math on mobile ─── */
    .display-math {
        margin: 1rem -0.5rem;
        padding: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .equation-numbered {
        flex-direction: column;
        gap: 0.3rem;
    }

    .equation-number {
        text-align: center;
        font-size: 0.85rem;
    }

    /* ─── Images on mobile ─── */
    .figure-content {
        padding: 0.8rem;
    }

    .figure-content .tikz-img {
        max-width: 100%;
        max-height: 400px;
    }

    .tikz-diagram {
        padding: 0.5rem;
        margin: 1.5rem 0;
    }

    .tikz-diagram .tikz-img {
        max-width: 100%;
        max-height: 400px;
    }

    figcaption {
        font-size: 0.8rem;
    }

    /* ─── Tables on mobile ─── */
    .table-wrapper {
        margin: 1.2rem -0.5rem;
        border-radius: 0;
    }

    .tmt-table {
        font-size: 0.82rem;
    }

    .tmt-table th,
    .tmt-table td {
        padding: 0.45rem 0.6rem;
    }

    /* ─── Navigation ─── */
    .chapter-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chapter-nav a {
        text-align: center;
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ─── Boxes on mobile ─── */
    .tmt-result-box,
    .tmt-scaffold-box,
    .tmt-proven-box,
    .tmt-keyeq-box,
    .tmt-interpret-box,
    .tmt-physical-picture,
    .tmt-analogy,
    .tmt-thought-experiment,
    .tmt-whynot,
    .tmt-roadmap,
    .tmt-derivation-map,
    .tmt-math-reminder,
    .tmt-caution,
    .tmt-status-box {
        padding: 1rem 1rem;
        margin: 1.2rem 0;
    }

    .theorem-block {
        padding: 1rem 1rem;
    }

    .box-title {
        font-size: 0.82rem;
    }

    .box-content {
        font-size: 0.93rem;
    }

    /* ─── Chapter TOC on mobile ─── */
    .chapter-toc {
        padding: 1rem 1.2rem;
    }

    .chapter-toc a {
        font-size: 0.84rem;
        padding: 0.2rem 0;
    }

    /* ─── Blockquote ─── */
    blockquote {
        margin: 1.2rem 0;
        padding: 0.6rem 1rem;
    }

    /* ─── Lists ─── */
    ul, ol {
        padding-left: 1.4rem;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
    }
}

/* ─── Small phones ─── */
@media (max-width: 400px) {
    .index-hero {
        min-height: 360px;
    }

    .index-hero-content {
        padding: 2.5rem 1rem 2rem;
    }

    .index-edition {
        font-size: 0.6rem;
    }

    .index-book-title {
        font-size: 1.65rem;
    }

    .index-subtitle {
        font-size: 0.92rem;
    }

    .index-postulate {
        padding: 0.7rem 1.2rem;
    }

    .index-postulate-eq {
        font-size: 1.2rem;
    }

    .index-stats {
        gap: 1rem;
    }

    .index-stat-number {
        font-size: 1.2rem;
    }

    .index-about-heading {
        font-size: 1.3rem;
    }

    .index-about-text {
        font-size: 0.95rem;
    }

    .chapter {
        padding: 1.2rem 0.75rem 2.5rem;
    }

    .chapter-title {
        font-size: 1.45rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   PASSWORD GATE
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Hide ALL page content by default until JS authenticates and adds .auth-ok */
body:not(.auth-ok) > *:not(#auth-gate):not(.noscript-gate) {
    display: none !important;
}

/* Noscript fallback gate */
.noscript-gate {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1319 0%, #1a2744 50%, #1e3a5f 100%);
    font-family: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
    color: #fff;
    text-align: center;
    padding: 2rem;
}

.noscript-gate .noscript-card {
    max-width: 420px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.noscript-gate h1 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.8rem;
    margin: 0 0 0.5rem;
}

.noscript-gate p {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1319 0%, #1a2744 50%, #1e3a5f 100%);
    padding: 1.5rem;
}

.auth-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: rgba(255,255,255,0.5);
    font-style: italic;
    margin: 0.5rem 0 0;
    font-weight: 300;
}

.auth-notice {
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: rgba(255,255,255,0.6);
    margin: 0 0 1.5rem;
}

.auth-input-group {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.auth-input-group input {
    flex: 1;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-right: none;
    border-radius: 8px 0 0 8px;
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.auth-input-group input::placeholder {
    color: rgba(255,255,255,0.35);
}

.auth-input-group input:focus {
    border-color: rgba(108,155,255,0.5);
    background: rgba(255,255,255,0.1);
}

.auth-input-group button {
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 0 8px 8px 0;
    background: #2563eb;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.auth-input-group button:hover {
    background: #1d4ed8;
}

.auth-error {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: #f87171;
    margin: 0.8rem 0 0;
    min-height: 1.2em;
}

.auth-footer {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    color: rgba(255,255,255,0.25);
    margin: 2rem 0 0;
}

.auth-shake {
    animation: authShake 0.4s ease;
}

@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }

    .auth-title {
        font-size: 1.5rem;
    }

    .auth-input-group {
        flex-direction: column;
        border-radius: 8px;
    }

    .auth-input-group input {
        border-right: 1px solid rgba(255,255,255,0.15);
        border-bottom: none;
        border-radius: 8px 8px 0 0;
    }

    .auth-input-group button {
        border-radius: 0 0 8px 8px;
        padding: 0.9rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   CHAPTER BANNER — HERO IMAGE AREA
   ═══════════════════════════════════════════════════════════════════════════════ */

.chapter-banner {
    position: relative;
    width: calc(100% + 5rem);
    margin: -3rem -2.5rem 0;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #0f1319 0%, #1a2744 50%, #1e3a5f 100%);
}

.chapter-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.35;
    filter: saturate(0.8) contrast(1.1);
    transition: opacity 0.6s ease;
}

.chapter-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(15, 19, 25, 0.1) 0%,
        rgba(15, 19, 25, 0.05) 40%,
        rgba(250, 250, 248, 0.5) 75%,
        var(--color-bg) 100%);
    pointer-events: none;
}

.chapter-banner .banner-part-label {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.3em 0.8em;
    border-radius: 3px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED CHAPTER HEADER (WITH BANNER)
   ═══════════════════════════════════════════════════════════════════════════════ */

.chapter-banner + .chapter-header {
    margin-top: -1rem;
    position: relative;
    z-index: 2;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DECORATIVE SECTION SEPARATORS
   ═══════════════════════════════════════════════════════════════════════════════ */

h2.section-heading {
    position: relative;
}

h2.section-heading::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, var(--color-accent-light), rgba(37, 99, 235, 0.15));
    margin-top: 0.5rem;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED BOX ENVIRONMENTS — ICONS & POLISH
   ═══════════════════════════════════════════════════════════════════════════════ */

.tmt-result-box .box-title::before     { content: '\2605 '; }   /* star */
.tmt-scaffold-box .box-title::before   { content: '\25B3 '; }   /* triangle */
.tmt-proven-box .box-title::before     { content: '\2713 '; }   /* checkmark */
.tmt-keyeq-box .box-title::before      { content: '\2261 '; }   /* triple bar */
.tmt-interpret-box .box-title::before  { content: '\25C6 '; }   /* diamond */
.tmt-physical-picture .box-title::before { content: '\25CE '; }  /* bullseye */
.tmt-analogy .box-title::before        { content: '\21C4 '; }   /* left right arrows */
.tmt-thought-experiment .box-title::before { content: '\2696 '; } /* scales */
.tmt-whynot .box-title::before         { content: '\2717 '; }   /* ballot x */
.tmt-roadmap .box-title::before        { content: '\2691 '; }   /* flag */
.tmt-derivation-map .box-title::before { content: '\21D2 '; }   /* double right arrow */
.tmt-math-reminder .box-title::before  { content: '\2211 '; }   /* sigma */
.tmt-caution .box-title::before        { content: '\26A0 '; }   /* warning */

/* Refined box top accent */
.tmt-result-box,
.tmt-scaffold-box,
.tmt-proven-box,
.tmt-keyeq-box,
.tmt-interpret-box,
.tmt-physical-picture,
.tmt-analogy,
.tmt-thought-experiment,
.tmt-whynot,
.tmt-roadmap,
.tmt-derivation-map,
.tmt-math-reminder,
.tmt-caution,
.tmt-status-box {
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.tmt-result-box:hover,
.tmt-scaffold-box:hover,
.tmt-proven-box:hover,
.tmt-keyeq-box:hover,
.tmt-interpret-box:hover,
.tmt-physical-picture:hover,
.tmt-analogy:hover,
.tmt-thought-experiment:hover,
.tmt-whynot:hover,
.tmt-roadmap:hover,
.tmt-derivation-map:hover,
.tmt-math-reminder:hover,
.tmt-caution:hover,
.tmt-status-box:hover {
    box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED THEOREM BLOCKS — ICONS
   ═══════════════════════════════════════════════════════════════════════════════ */

.theorem-block {
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.theorem-block:hover {
    box-shadow: var(--shadow-md);
}

.theorem-block.postulate .theorem-head::before  { content: '\2605 '; color: #b22222; }
.theorem-block.theorem .theorem-head::before    { content: '\25A0 '; color: #191970; }
.theorem-block.definition .theorem-head::before { content: '\25B6 '; color: #2e8b57; }
.theorem-block.corollary .theorem-head::before  { content: '\25C7 '; color: #4169e1; }
.theorem-block.proposition .theorem-head::before { content: '\25B7 '; color: #6a5acd; }
.theorem-block.lemma .theorem-head::before      { content: '\25B8 '; color: #2e6b8b; }
.theorem-block.example .theorem-head::before    { content: '\2794 '; color: #059669; }
.theorem-block.remark .theorem-head::before,
.theorem-block.note .theorem-head::before       { content: '\2055 '; color: #6b7280; }
.theorem-block.conjecture .theorem-head::before,
.theorem-block.hypothesis .theorem-head::before { content: '? '; color: #d97706; }
.theorem-block.summary .theorem-head::before    { content: '\2261 '; color: #0891b2; }

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED EQUATION DISPLAY
   ═══════════════════════════════════════════════════════════════════════════════ */

.display-math.equation-numbered {
    background: rgba(248, 249, 252, 0.6);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.03);
    margin: 1.5rem 0;
}

.equation-number {
    background: rgba(37, 99, 235, 0.06);
    padding: 0.15em 0.5em;
    border-radius: 3px;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED FIGURE STYLING
   ═══════════════════════════════════════════════════════════════════════════════ */

figure.figure {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.figure-content {
    background: #fff;
    border: 1px solid var(--color-border-light);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.figure-content:hover {
    box-shadow: var(--shadow-md);
}

figcaption {
    background: rgba(248, 249, 252, 0.8);
    padding: 0.6rem 1rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-left: 3px solid var(--color-accent-light);
    margin-top: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED CHAPTER NAVIGATION
   ═══════════════════════════════════════════════════════════════════════════════ */

.chapter-nav {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
}

.chapter-nav a {
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.chapter-nav a.nav-prev:hover,
.chapter-nav a.nav-next:hover {
    background: linear-gradient(135deg, #f0f4ff, #e8edff);
    border-color: var(--color-accent-light);
    color: var(--color-accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.chapter-nav a.nav-toc {
    background: rgba(37, 99, 235, 0.04);
    font-size: 0.82rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ENHANCED CHAPTER TOC
   ═══════════════════════════════════════════════════════════════════════════════ */

.chapter-toc {
    background: linear-gradient(135deg, #fff 0%, #f8f9fc 100%);
    border: 1px solid var(--color-border);
    border-top: 3px solid var(--color-accent-light);
    position: relative;
    overflow: hidden;
}

.chapter-toc::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top right, rgba(37, 99, 235, 0.03) 0%, transparent 60%);
    pointer-events: none;
}

.chapter-toc h3 {
    position: relative;
}

.chapter-toc h3::before {
    content: '\2630 ';
    margin-right: 0.3em;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BLOCKQUOTE ENHANCEMENT
   ═══════════════════════════════════════════════════════════════════════════════ */

blockquote {
    position: relative;
    background: linear-gradient(135deg, #f8f9fc 0%, #f0f3f9 100%);
    border-left: 4px solid var(--color-accent-light);
}

blockquote::before {
    content: '\201C';
    position: absolute;
    top: -0.2rem;
    left: 0.5rem;
    font-size: 2.5rem;
    color: rgba(37, 99, 235, 0.12);
    font-family: var(--font-serif);
    line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABLE ENHANCEMENT
   ═══════════════════════════════════════════════════════════════════════════════ */

.tmt-table th {
    background: linear-gradient(180deg, #f8f9fa, #f0f1f3);
    position: relative;
}

.tmt-table tbody tr:nth-child(even) td {
    background: rgba(248, 249, 252, 0.5);
}

.tmt-table tbody tr:hover td {
    background: rgba(37, 99, 235, 0.04);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SUBTLE PAGE LOAD ANIMATION
   ═══════════════════════════════════════════════════════════════════════════════ */

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

.chapter-header {
    animation: fadeInUp 0.5s ease-out;
}

.chapter-toc {
    animation: fadeInUp 0.5s ease-out 0.1s both;
}

.chapter-body {
    animation: fadeInUp 0.5s ease-out 0.2s both;
}

.chapter-banner {
    animation: fadeInUp 0.4s ease-out;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CHAPTER LABEL ENHANCEMENT
   ═══════════════════════════════════════════════════════════════════════════════ */

.chapter-label {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(139, 92, 246, 0.06));
    border: 1px solid rgba(37, 99, 235, 0.12);
    font-size: 0.75rem;
    padding: 0.25em 0.8em;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PROOF ENVIRONMENT POLISH
   ═══════════════════════════════════════════════════════════════════════════════ */

.proof {
    background: rgba(248, 249, 252, 0.4);
    border-left: 2px solid var(--color-border);
    padding: 0.8rem 1.2rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 1.2rem 0 1.8rem;
}

.proof-head {
    color: var(--color-accent);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — BANNER
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .chapter-banner {
        width: calc(100% + 2rem);
        margin: -1.5rem -1rem 0;
        height: 140px;
    }

    .chapter-banner .banner-part-label {
        font-size: 0.6rem;
        top: 0.8rem;
        right: 0.8rem;
    }

    .chapter-banner + .chapter-header {
        margin-top: -0.5rem;
    }

    .display-math.equation-numbered {
        padding: 0.5rem 0.6rem;
    }

    .chapter-nav {
        padding: 1rem;
    }
}

@media (max-width: 400px) {
    .chapter-banner {
        height: 110px;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY — FOCUS STATES
   ═══════════════════════════════════════════════════════════════════════════════ */

:focus-visible {
    outline: 2px solid var(--color-accent-light);
    outline-offset: 2px;
}

.index-part-header:focus-visible {
    outline: 2px solid var(--color-accent-light);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.sidebar-toggle:focus-visible {
    outline: 2px solid #6c9bff;
    outline-offset: 2px;
}

.back-to-top:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.nav-list li a:focus-visible {
    outline: 2px solid var(--color-sidebar-active);
    outline-offset: -2px;
}

.chapter-toc a:focus-visible {
    outline: 2px solid var(--color-accent-light);
    outline-offset: 1px;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FIREFOX SCROLLBAR
   ═══════════════════════════════════════════════════════════════════════════════ */

.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════════ */

@media print {
    .sidebar, .sidebar-toggle, .sidebar-backdrop,
    .chapter-nav, .chapter-toc, .reading-progress, .back-to-top,
    .chapter-banner,
    #auth-gate { display: none; }
    .content { margin-left: 0; }
    .chapter { max-width: 100%; padding: 0; }

    /* Remove all decorative effects for print */
    * {
        box-shadow: none !important;
        animation: none !important;
        transition: none !important;
        text-shadow: none !important;
    }

    .theorem-block,
    .tmt-result-box,
    .tmt-scaffold-box,
    .tmt-proven-box,
    .tmt-keyeq-box,
    .tmt-interpret-box,
    .tmt-physical-picture,
    .tmt-analogy,
    .tmt-thought-experiment,
    .tmt-whynot,
    .tmt-roadmap,
    .tmt-derivation-map,
    .tmt-math-reminder,
    .tmt-caution,
    .tmt-status-box {
        border-top: none;
        border-right: none;
        border-bottom: none;
        break-inside: avoid;
    }

    figure.figure {
        break-inside: avoid;
    }

    .display-math.equation-numbered {
        background: none;
        border: none;
    }

    h2.section-heading::after {
        display: none;
    }

    blockquote {
        border-image: none;
        border-left: 3px solid #999;
        background: none;
    }

    blockquote::before {
        display: none;
    }

    /* Index page print */
    .index-hero { background: none; color: #000; min-height: auto; }
    .index-hero-bg, .index-hero-overlay { display: none; }
    .index-hero-content { padding: 2rem; }
    .index-book-title { color: #000; }
    .index-subtitle { color: #333; }
    .index-postulate { border-color: #ccc; background: #f5f5f5; }
    .index-postulate-eq { color: #333; }
    .index-postulate-label { color: #666; }
    .index-edition { color: #333; border-color: #ccc; background: #eee; }
    .index-stat-number { color: #000; }
    .index-stat-label { color: #666; }
    .index-stats { border-top-color: #ccc; }
    .index-about { border: none; }
    .index-footer { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Verification Code Section
   ═══════════════════════════════════════════════════════════════════════════════ */

.verification-code {
    margin: 3rem 0 2rem;
    padding: 2rem 2.5rem;
    background: linear-gradient(135deg, #f8fafc, #f0f4ff);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent-light);
    border-radius: var(--radius-md);
}

.verification-code h2 {
    font-family: var(--font-sans);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-accent);
    margin: 0 0 0.5rem;
    letter-spacing: 0.02em;
}

.verification-intro {
    font-size: 0.92rem;
    color: var(--color-text-muted);
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

.verification-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.verification-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.verification-link:hover {
    border-color: var(--color-accent-light);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
    transform: translateX(4px);
}

.verification-icon {
    font-size: 1.4rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
}

.verification-lean .verification-icon {
    background: #ebf5ff;
    color: #1a5276;
}

.verification-python .verification-icon {
    background: #fff8eb;
    color: #b8860b;
}

.verification-mathematica .verification-icon {
    background: #ffebeb;
    color: #b22222;
}

.verification-details {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.verification-lang {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-heading);
}

.verification-desc {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.verification-status {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-light);
    background: #f0f0f0;
    padding: 0.3rem 0.7rem;
    border-radius: 12px;
    white-space: nowrap;
}

.verification-note {
    font-size: 0.82rem;
    color: var(--color-text-light);
    margin: 1.25rem 0 0;
    text-align: center;
}

.verification-note a {
    color: var(--color-link);
}

.verification-note a:hover {
    color: var(--color-link-hover);
}

/* Verification Index Page */
.verification-index-hero {
    background: linear-gradient(135deg, #0f1319, #1a2030);
    color: #fff;
    padding: 4rem 2rem 3rem;
    text-align: center;
}

.verification-index-hero h1 {
    font-family: var(--font-serif);
    font-size: 2.4rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.verification-index-hero p {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    color: #a0a8b8;
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.6;
}

.verification-index-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.verification-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
    padding: 1.5rem;
    margin-bottom: 2rem;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    flex-wrap: wrap;
}

.verification-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.lean { background: #1a5276; }
.legend-dot.python { background: #b8860b; }
.legend-dot.mathematica { background: #b22222; }

.verification-chapter-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    transition: all 0.15s ease;
}

.verification-chapter-card:hover {
    border-color: var(--color-accent-light);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.06);
}

.verification-ch-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.verification-ch-num {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    width: 2.5rem;
    flex-shrink: 0;
}

.verification-ch-title {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.verification-ch-title a {
    color: inherit;
    text-decoration: none;
}

.verification-ch-title a:hover {
    color: var(--color-link);
}

.verification-ch-links {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.verification-ch-links a {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
    opacity: 0.5;
    cursor: default;
}

.verification-ch-links a.lean-link {
    background: #ebf5ff;
    color: #1a5276;
    border: 1px solid #c4dff6;
}

.verification-ch-links a.python-link {
    background: #fff8eb;
    color: #b8860b;
    border: 1px solid #f0dca8;
}

.verification-ch-links a.math-link {
    background: #ffebeb;
    color: #b22222;
    border: 1px solid #f0b8b8;
}

.verification-ch-links a.available {
    opacity: 1;
    cursor: pointer;
}

.verification-ch-links a.available:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.verification-part-header {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 1.5rem 0 0.5rem;
    margin-top: 1rem;
    border-bottom: 2px solid var(--color-accent);
    margin-bottom: 0.75rem;
}

.verification-back {
    text-align: center;
    padding: 2rem 0 3rem;
}

.verification-back a {
    font-family: var(--font-sans);
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.95rem;
}

.verification-back a:hover {
    color: var(--color-link-hover);
}

@media (max-width: 768px) {
    .verification-code {
        padding: 1.5rem;
        margin: 2rem 0 1.5rem;
    }
    .verification-link {
        padding: 0.8rem 1rem;
    }
    .verification-chapter-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .verification-ch-links {
        width: 100%;
    }
    .verification-ch-links a {
        flex: 1;
        text-align: center;
    }
    .verification-legend {
        gap: 1rem;
    }
}

@media print {
    .verification-code { display: none; }
}
