/* ============================================
   CRIO - Stylesheet
   Organizado por componentes
   ============================================ */

/* --------------------------------------------
   1. RESET & BASE
   -------------------------------------------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

/* Smooth anchor scrolling when user hasn't requested reduced motion */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

img,
video,
iframe,
pre,
code {
    max-width: 100%;
    height: auto;
}

/* Images inside article content should be responsive and not overflow */
#content img {
    display: block;
    margin: 1rem auto;
    max-height: 60vh;
    object-fit: contain;
}

/* Touch-friendly interactive elements */
button,
a,
.progress-marker,
.nav-toggle {
    min-height: 44px; /* iOS recommended minimum touch target */
    min-width: 44px;
}

@media (pointer: fine) {
    /* Desktop/mouse users get smaller targets */
    button,
    a,
    .progress-marker,
    .nav-toggle {
        min-height: auto;
        min-width: auto;
    }
}

/* Skip to main content link - visible only on focus */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--emergence);
    color: var(--void);
    padding: 0.5rem 1rem;
    text-decoration: none;
    font-weight: bold;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 0;
    outline: 2px solid var(--emergence);
    outline-offset: 2px;
}

/* --------------------------------------------
   2. THEME VARIABLES
   -------------------------------------------- */

:root {
    --void: #0a0a0a;
    --emergence: #f0f0f0;
    --trace: #666;
    --glow: rgba(255, 255, 255, 0.1);
    --particle-glow-inner: rgba(255, 255, 255, 1);
    --particle-glow-mid: rgba(255, 255, 255, 0.95);
    --particle-glow-outer: rgba(255, 255, 255, 0.85);
}

body.light-theme {
    --void: #f0f0f0;
    --emergence: #0a0a0a;
    --trace: #999;
    --glow: rgba(0, 0, 0, 0.1);
    --particle-glow-inner: rgba(0, 0, 0, 1);
    --particle-glow-mid: rgba(0, 0, 0, 0.95);
    --particle-glow-outer: rgba(0, 0, 0, 0.85);
}

/* --------------------------------------------
   3. TYPOGRAPHY & LAYOUT
   -------------------------------------------- */

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--void);
    color: var(--emergence);
    line-height: 1.9; /* Increased for better readability */
    padding: clamp(0.75rem, 2vw, 2.5rem);
    min-height: 100vh;
    cursor: default; /* crosshair reduced for usability; keep pointer only on interactive elements */
    transition: background 0.6s ease, color 0.6s ease;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    font-size: 18px; /* Base size for better readability */
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Touch optimization */
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    touch-action: pan-y; /* Optimize vertical scrolling */
    /* Hyphenation for better text wrapping */
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
    hyphenate-limit-chars: 6 3 3; /* minimum word length, min chars before break, min chars after break */
}

main {
    max-width: min(1000px, 90%);
    margin: 0 auto;
    width: 100%;
    padding: 0;
    --tremor-intensity: 0;
    animation: tremor 0.1s infinite;
    transition: filter 0.3s ease;
}

main.high-tremor {
    filter: blur(0.3px);
    text-shadow: 
        0 0 2px var(--emergence),
        0 0 4px var(--emergence);
}

#content {
    opacity: 1;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

#content.loaded {
    animation: emerge 2s ease-out forwards;
}

/* Permitir seleção de texto em elementos de conteúdo */
#content p,
#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6,
#content li,
#content blockquote,
#content .riz∅ma-link {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
}

.loading {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--trace);
    font-style: italic;
    min-height: 200px;
}

/* Headings - accessible focus styles */
h1, h2, h3, h4, h5, h6 {
    scroll-margin-top: 100px;
}

h1:focus-visible,
h2:focus-visible,
h3:focus-visible,
h4:focus-visible,
h5:focus-visible,
h6:focus-visible {
    outline: 2px solid var(--emergence);
    outline-offset: 4px;
}

h1 {
    font-size: clamp(1.5rem, 6vw, 4rem);
    font-weight: 300;
    letter-spacing: 0.05em;
    margin-bottom: 2rem;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Divisórias especiais para headers de PARTE/SEÇÃO */
h1:not(:first-of-type) {
    margin-top: 6rem;
    padding-top: 4rem;
    position: relative;
}

h1:not(:first-of-type)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--glow) 20%,
        var(--emergence) 50%,
        var(--glow) 80%,
        transparent
    );
    opacity: 0.8;
}

h1:not(:first-of-type)::after {
    content: '◈';
    position: absolute;
    top: -0.8rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--emergence);
    font-size: 1.5rem;
    opacity: 0.9;
    text-shadow: 0 0 10px var(--glow);
}

/* Títulos de PARTE com estilo destacado */
h1[id^="parte-"],
h1:has(+ hr) {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.02) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0.02) 100%
    );
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-theme h1:not(:first-of-type)::before {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(10, 10, 10, 0.2) 20%,
        rgba(10, 10, 10, 0.4) 50%,
        rgba(10, 10, 10, 0.2) 80%,
        transparent
    );
}

body.light-theme h1[id^="parte-"],
body.light-theme h1:has(+ hr) {
    background: linear-gradient(
        135deg,
        rgba(10, 10, 10, 0.02) 0%,
        rgba(10, 10, 10, 0.05) 50%,
        rgba(10, 10, 10, 0.02) 100%
    );
    border-color: rgba(10, 10, 10, 0.1);
}

h2 {
    font-size: clamp(1.5rem, 5vw, 1.8rem);
    font-weight: 400;
    margin: 3.5rem 0 1.5rem 0;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glow);
    padding-bottom: 0.5rem;
    text-align: center;
    line-height: 1.3;
}

h3 {
    font-size: clamp(1.2rem, 4vw, 1.3rem);
    font-weight: 400;
    margin: 2.5rem 0 1rem 0;
    color: var(--trace);
    font-style: italic;
    text-align: center;
    line-height: 1.4;
}

h4, h5, h6 {
    font-weight: 400;
    margin: 2rem 0 1rem 0;
    color: var(--emergence);
    text-align: center;
    line-height: 1.4;
}

/* Font Size Controls */
body.font-small {
    font-size: 14px;
}

body.font-medium {
    font-size: 16px;
}

body.font-large {
    font-size: 18px;
}

body.font-small p,
body.font-small li {
    line-height: 1.8;
}

body.font-large p,
body.font-large li {
    line-height: 2.0;
}

/* Text Elements */
p {
    margin-bottom: 1.5rem;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    max-width: 75ch; /* Optimal line length for readability */
    margin-left: auto;
    margin-right: auto;
    line-height: 1.9;
}

/* Table of Contents - no justification */
.toc p {
    text-align: center;
    hyphens: none;
    -webkit-hyphens: none;
    -moz-hyphens: none;
}

/* Lists for better readability */
ul, ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
    line-height: 1.9;
    text-align: justify;
}

li {
    margin-bottom: 0.75rem;
    text-align: justify;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

/* Emphasis and strong */
em {
    font-style: italic;
    color: var(--trace);
}

strong {
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Links - accessible styles */
a:not(.riz∅ma-link) {
    color: var(--emergence);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: all 0.3s ease;
}

a:not(.riz∅ma-link):hover {
    text-decoration-thickness: 2px;
    opacity: 0.8;
}

a:not(.riz∅ma-link):focus-visible {
    outline: 2px solid var(--emergence);
    outline-offset: 4px;
    border-radius: 2px;
}

/* Color contrast for WCAG AA compliance:
   Dark theme: #f0f0f0 on #0a0a0a = 18.6:1 ratio (exceeds WCAG AAA 7:1)
   Light theme: #0a0a0a on #f0f0f0 = 18.6:1 ratio (exceeds WCAG AAA 7:1)
*/

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

blockquote {
    margin: 2.5rem auto;
    padding: 2rem;
    max-width: 65ch; /* Slightly narrower for quotes */
    border-left: 4px solid var(--emergence);
    background: rgba(255, 255, 255, 0.02);
    font-style: italic;
    color: var(--trace);
    text-align: center;
    line-height: 2;
    font-size: 1.1em;
    letter-spacing: 0.02em;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

blockquote p {
    margin-bottom: 1rem;
}

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

/* Enhanced blockquotes with highlighted quote system */
.crio-quote {
    position: relative;
    margin: 3.5rem auto;
    padding: 2.5rem 2rem 2.5rem 4.5rem;
    max-width: 70ch;
    border-left: 4px solid var(--emergence);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    opacity: 0.7;
    transform: translateX(-20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.15em;
    line-height: 2;
    letter-spacing: 0.03em;
}

body.light-theme .crio-quote {
    background: rgba(0, 0, 0, 0.03);
}

.crio-quote.quote-visible {
    opacity: 1;
    transform: translateX(0);
}

.crio-quote.quote-emphasized {
    background: rgba(255, 255, 255, 0.05);
    border-left-width: 5px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
}

body.light-theme .crio-quote.quote-emphasized {
    background: rgba(0, 0, 0, 0.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Anchor quotes - first quote after each section heading */
.crio-quote.anchor-quote {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    border-left: 5px solid var(--emergence);
    padding: 2.5rem 2.5rem 2.5rem 4.5rem;
}

body.light-theme .crio-quote.anchor-quote {
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.05) 0%,
        rgba(0, 0, 0, 0.02) 100%
    );
}

.crio-quote.anchor-quote.quote-emphasized {
    border-left-width: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

/* Quote decorator (void symbol) */
.quote-decorator {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    opacity: 0.3;
    transition: all 0.3s ease;
    pointer-events: none;
    line-height: 1;
}

.crio-quote.quote-emphasized .quote-decorator {
    opacity: 0.6;
    font-size: 2.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.crio-quote.anchor-quote .quote-decorator {
    font-size: 2.5rem;
    opacity: 0.4;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-50%) scale(1.1);
    }
}

/* Quote content wrapper */
.quote-content {
    position: relative;
    z-index: 1;
}

.crio-quote .quote-content p {
    font-size: 1.05rem;
    line-height: 2;
    color: var(--emergence);
    margin: 0;
    max-width: none; /* Override paragraph max-width */
}

.crio-quote.anchor-quote .quote-content p {
    font-size: 1.2rem;
    line-height: 2.1;
    font-weight: 500;
    letter-spacing: 0.025em;
}

/* Hover effect for interactive feel */
.crio-quote:hover {
    border-left-color: var(--trace);
}

.crio-quote.anchor-quote:hover {
    border-left-color: var(--emergence);
}

#content > blockquote:first-child {
    margin-top: 1rem;
    margin-bottom: 3rem;
    text-align: center;
    font-size: 1.1rem;
}

blockquote p {
    margin: 0;
    text-align: center;
}

strong {
    font-weight: 600;
    color: var(--emergence);
}

em {
    font-style: italic;
}

/* Lists */
ul, ol {
    margin: 1.5rem 0 1.5rem 2rem;
}

/* Nested lists */
ul ul, ol ol, ul ol, ol ul {
    margin: 0.5rem 0 0.5rem 2rem;
}

li {
    margin-bottom: 0.8rem;
}

li p {
    margin-bottom: 0.5rem;
}

/* Horizontal Rule */
hr {
    border: none;
    height: 1px;
    background: transparent;
    margin: 6rem auto;
    position: relative;
    max-width: 100%;
}

/* Divisória decorativa com ornamento central */
hr::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--glow) 20%,
        var(--emergence) 50%,
        var(--glow) 80%,
        transparent
    );
    transform: translateY(-50%);
    opacity: 0.6;
}

/* Ornamento central */
hr::after {
    content: '◈';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--emergence);
    font-size: 1.5rem;
    opacity: 0.9;
    background: var(--void);
    padding: 0 1rem;
    text-shadow: 0 0 20px var(--glow);
    z-index: 1;
}

body.light-theme hr::after {
    background: #f5f5f5;
    text-shadow: 0 0 15px rgba(0, 170, 102, 0.3);
}

@media (max-width: 768px) {
    hr {
        max-width: 90%;
    }
    
    hr::before,
    hr::after {
        font-size: 1rem;
        left: -1.5rem;
    }
    
    hr::after {
        right: -1.5rem;
    }
}

/* Anchor nav-index to top small devices (reduces visual overlap) */
@media (max-width: 420px) {
    .nav-index { 
        top: 1.5rem;
        left: 50%;
        transform: translateX(-50%); 
        width: calc(100vw - 2rem);
        max-width: 100%;
        padding: 1rem;
    }
}

body.light-theme hr {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(10, 10, 10, 0.2) 20%,
        rgba(10, 10, 10, 0.4) 50%,
        rgba(10, 10, 10, 0.2) 80%,
        transparent
    );
}

/* Code */
code {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

pre {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

pre code {
    background: none;
    padding: 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

thead {
    background: var(--glow);
    color: var(--void);
    font-weight: 600;
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--emergence);
    background: rgba(255, 255, 255, 0.05);
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Alternating row colors for better readability */
tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

tbody tr:nth-child(even):hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Responsive tables - horizontal scroll on mobile */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    th, td {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Light theme adjustments for tables */
body.light-theme table {
    background: rgba(10, 10, 10, 0.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.light-theme th {
    background: rgba(10, 10, 10, 0.05);
    border-bottom-color: var(--emergence);
}

body.light-theme td {
    border-bottom-color: rgba(10, 10, 10, 0.08);
}

body.light-theme tbody tr:hover {
    background: rgba(10, 10, 10, 0.05);
}

body.light-theme tbody tr:nth-child(even) {
    background: rgba(10, 10, 10, 0.02);
}

body.light-theme tbody tr:nth-child(even):hover {
    background: rgba(10, 10, 10, 0.06);
}

/* Links */
a:not(.riz∅ma-link) {
    color: var(--emergence);
    text-decoration: none;
    border-bottom: 1px solid var(--glow);
    transition: border-color 0.3s ease;
}

a:not(.riz∅ma-link):hover {
    border-bottom-color: var(--emergence);
}

/* Centralização de conteúdo */
div[align="center"] {
    text-align: center;
}

div[align="center"] ul,
div[align="center"] ol {
    list-style-position: inside;
    text-align: center;
    padding: 0;
}

div[align="center"] li {
    text-align: center;
    margin: 0.5em 0;
}

/* --------------------------------------------
   4. ANIMATIONS
   -------------------------------------------- */

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

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
    html { scroll-behavior: auto; }
}

@keyframes tremor {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(calc(var(--tremor-intensity) * -1.5px), calc(var(--tremor-intensity) * 1px)); }
    20% { transform: translate(calc(var(--tremor-intensity) * 1px), calc(var(--tremor-intensity) * -1.5px)); }
    30% { transform: translate(calc(var(--tremor-intensity) * -1px), calc(var(--tremor-intensity) * -1px)); }
    40% { transform: translate(calc(var(--tremor-intensity) * 1.5px), calc(var(--tremor-intensity) * 1px)); }
    50% { transform: translate(calc(var(--tremor-intensity) * -1.5px), calc(var(--tremor-intensity) * 0.5px)); }
    60% { transform: translate(calc(var(--tremor-intensity) * 1px), calc(var(--tremor-intensity) * 1.5px)); }
    70% { transform: translate(calc(var(--tremor-intensity) * -1px), calc(var(--tremor-intensity) * -1.5px)); }
    80% { transform: translate(calc(var(--tremor-intensity) * 1.5px), calc(var(--tremor-intensity) * -1px)); }
    90% { transform: translate(calc(var(--tremor-intensity) * -1px), calc(var(--tremor-intensity) * 1.5px)); }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0.3; }
}

@keyframes pulse-counter {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* --------------------------------------------
   5. PARTICLES SYSTEM
   -------------------------------------------- */

.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

@keyframes float {
    0% { 
        transform: translate(0, 0) rotate(0deg);
        opacity: 0.8;
    }
    25% { 
        transform: translate(var(--tx1), var(--ty1)) rotate(90deg);
        opacity: 1;
    }
    50% { 
        transform: translate(var(--tx2), var(--ty2)) rotate(180deg);
        opacity: 0.9;
    }
    75% { 
        transform: translate(var(--tx3), var(--ty3)) rotate(270deg);
        opacity: 1;
    }
    100% { 
        transform: translate(0, 0) rotate(360deg);
        opacity: 0.8;
    }
}

@keyframes tremor-particle {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(calc(var(--shake-x1) * var(--chaos-intensity, 1)), calc(var(--shake-y1) * var(--chaos-intensity, 1))); }
    20% { transform: translate(calc(var(--shake-x2) * var(--chaos-intensity, 1)), calc(var(--shake-y2) * var(--chaos-intensity, 1))); }
    30% { transform: translate(calc(var(--shake-x3) * var(--chaos-intensity, 1)), calc(var(--shake-y3) * var(--chaos-intensity, 1))); }
    40% { transform: translate(calc(var(--shake-x4) * var(--chaos-intensity, 1)), calc(var(--shake-y4) * var(--chaos-intensity, 1))); }
    50% { transform: translate(calc(var(--shake-x5) * var(--chaos-intensity, 1)), calc(var(--shake-y5) * var(--chaos-intensity, 1))); }
    60% { transform: translate(calc(var(--shake-x6) * var(--chaos-intensity, 1)), calc(var(--shake-y6) * var(--chaos-intensity, 1))); }
    70% { transform: translate(calc(var(--shake-x7) * var(--chaos-intensity, 1)), calc(var(--shake-y7) * var(--chaos-intensity, 1))); }
    80% { transform: translate(calc(var(--shake-x8) * var(--chaos-intensity, 1)), calc(var(--shake-y8) * var(--chaos-intensity, 1))); }
    90% { transform: translate(calc(var(--shake-x9) * var(--chaos-intensity, 1)), calc(var(--shake-y9) * var(--chaos-intensity, 1))); }
}

.particle {
    position: fixed;
    width: 40px;
    height: 40px;
    background: var(--emergence);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    transition: opacity 3s ease-out, box-shadow 0.3s ease, filter 0.3s ease;
    --chaos-intensity: 1;
    --glow-intensity: 1;
    box-shadow: 
        0 0 calc(80px * var(--glow-intensity)) var(--particle-glow-inner), 
        0 0 calc(250px * var(--glow-intensity)) var(--particle-glow-mid),
        0 0 calc(400px * var(--glow-intensity)) var(--particle-glow-outer);
    filter: blur(calc(12px * var(--glow-intensity)));
    mix-blend-mode: screen;
    /* Enable GPU acceleration for better performance */
    will-change: transform, opacity;
    transform: translateZ(0); /* Force GPU layer */
}

body.light-theme .particle {
    mix-blend-mode: multiply;
}

.particle.floating {
    animation: 
        float var(--float-duration) infinite ease-in-out,
        tremor-particle var(--tremor-duration) infinite;
    animation-duration: calc(var(--float-duration) / var(--speed-multiplier, 1)), var(--tremor-duration);
}

.particle.stabilized {
    animation-play-state: paused !important;
}

/* --------------------------------------------
   6. VOID SYMBOL
   -------------------------------------------- */

@keyframes void-tremor {
    0% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(1); }
    10% { transform: translate(-50%, -50%) translate(-30px, 20px) rotate(-15deg) scale(1.02); }
    20% { transform: translate(-50%, -50%) translate(25px, -30px) rotate(12deg) scale(0.98); }
    30% { transform: translate(-50%, -50%) translate(-20px, -25px) rotate(-8deg) scale(1.03); }
    40% { transform: translate(-50%, -50%) translate(35px, 15px) rotate(20deg) scale(0.97); }
    50% { transform: translate(-50%, -50%) translate(-25px, 30px) rotate(-18deg) scale(1.04); }
    60% { transform: translate(-50%, -50%) translate(20px, -20px) rotate(10deg) scale(0.99); }
    70% { transform: translate(-50%, -50%) translate(-35px, 25px) rotate(-22deg) scale(1.02); }
    80% { transform: translate(-50%, -50%) translate(30px, -35px) rotate(16deg) scale(1.01); }
    90% { transform: translate(-50%, -50%) translate(-15px, 20px) rotate(-12deg) scale(0.98); }
    100% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg) scale(1); }
}

@keyframes void-pulse {
    0%, 100% {
        text-shadow: 
            0 0 40px var(--emergence),
            0 0 80px var(--emergence),
            0 0 120px var(--emergence);
    }
    50% {
        text-shadow: 
            0 0 60px var(--emergence),
            0 0 120px var(--emergence),
            0 0 180px var(--emergence);
    }
}

@keyframes void-tremor-zoom {
    0% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg); }
    10% { transform: translate(-50%, -50%) translate(-30px, 20px) rotate(-15deg); }
    20% { transform: translate(-50%, -50%) translate(25px, -30px) rotate(12deg); }
    30% { transform: translate(-50%, -50%) translate(-20px, -25px) rotate(-8deg); }
    40% { transform: translate(-50%, -50%) translate(35px, 15px) rotate(20deg); }
    50% { transform: translate(-50%, -50%) translate(-25px, 30px) rotate(-18deg); }
    60% { transform: translate(-50%, -50%) translate(20px, -20px) rotate(10deg); }
    70% { transform: translate(-50%, -50%) translate(-35px, 25px) rotate(-22deg); }
    80% { transform: translate(-50%, -50%) translate(30px, -35px) rotate(16deg); }
    90% { transform: translate(-50%, -50%) translate(-15px, 20px) rotate(-12deg); }
    100% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg); }
}

@keyframes void-appear {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes void-zoom {
    0% { font-size: 20rem; }
    100% { font-size: 1000rem; }
}

@keyframes fill-with-symbol-color {
    0% { 
        background: var(--void);
    }
    50% {
        background: var(--emergence);
        filter: brightness(1.5);
    }
    100% { 
        background: var(--emergence);
        filter: brightness(1);
    }
}

/* Tema claro inverte */
body.light-theme.symbol-takeover {
    animation: fill-with-symbol-color-light 12s ease-in forwards;
}

@keyframes fill-with-symbol-color-light {
    0% { 
        background: var(--void);
    }
    50% {
        background: var(--void);
        filter: brightness(0.5);
    }
    100% { 
        background: var(--void);
        filter: brightness(1);
    }
}

.void-symbol {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20rem;
    color: var(--emergence);
    opacity: 0.15;
    z-index: 1;
    pointer-events: none;
    text-shadow: 
        0 0 40px var(--emergence),
        0 0 80px var(--emergence),
        0 0 120px var(--emergence);
    white-space: nowrap;
    animation: void-tremor 0.05s infinite, void-pulse 4s ease-in-out infinite;
    transition: opacity 0.5s ease, font-size 0.5s ease;
}

.void-symbol.active {
    animation: void-tremor 0.05s infinite, void-appear 3s ease-out forwards;
    opacity: 1;
    z-index: 10000;
}

.void-symbol.zoom {
    animation: void-tremor-zoom 0.05s infinite, void-zoom 12s ease-in forwards !important;
}

/* Void symbol mais visível no tema claro */
body.light-theme .void-symbol {
    opacity: 0.25;
    text-shadow: 
        0 0 40px var(--emergence),
        0 0 80px var(--emergence),
        0 0 120px var(--emergence),
        0 0 160px var(--emergence);
}

body.symbol-takeover {
    animation: fill-with-symbol-color 12s ease-in forwards;
}

/* --------------------------------------------
   6.1 VOID MESSAGE (END OF PAGE)
   -------------------------------------------- */

.void-message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* Sem overlay escuro - deixar o símbolo fazer o trabalho */
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 2s ease-out;
}

.void-message-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.void-message {
    text-align: center;
    color: var(--emergence);
    animation: void-message-appear 3s ease-out forwards;
    background: rgba(0, 0, 0, 0.7); /* Fundo só na mensagem */
    padding: 3rem;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 2px solid var(--emergence);
    box-shadow: 0 0 40px var(--emergence);
}

/* Tema claro */
body.light-theme .void-message {
    background: rgba(255, 255, 255, 0.8);
    color: var(--void);
    border-color: var(--void);
    box-shadow: 0 0 40px var(--void);
}

.void-text {
    font-size: 3rem;
    font-weight: bold;
    margin: 0 0 1rem 0;
    text-shadow: 
        0 0 20px var(--emergence),
        0 0 40px var(--emergence);
    animation: void-tremor 0.1s infinite;
    --tremor-intensity: 2;
}

.void-subtext {
    font-size: 1.5rem;
    margin: 0;
    opacity: 0.8;
    letter-spacing: 0.2em;
}

@keyframes void-message-appear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive void message */
@media (max-width: 768px) {
    .void-text {
        font-size: 2rem;
    }
    
    .void-subtext {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .void-text {
        font-size: 1.5rem;
    /* nav-index placement for very small viewports handled later */
    }
    
    .void-subtext {
        font-size: 1rem;
    }
}

/* --------------------------------------------
   7. AUDIO CONTROLS
   -------------------------------------------- */

/* --------------------------------------------
   7. AUDIO CONTROLS
   -------------------------------------------- */

.audio-ui {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glow);
    color: var(--emergence);
    padding: 0.5rem;
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
    border-radius: 6px;
    backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
    width: auto;
}

/* Center audio controls on smaller devices to avoid overlapping the left edge */
@media (max-width: 640px) {
    .audio-ui {
        left: 0.5rem;
        right: auto;
        transform: none;
        bottom: 0.75rem;
        gap: 0.25rem;
        padding: 0.4rem;
        width: auto;
        justify-content: flex-start;
    }
    
    /* Hide all buttons except hamburger on mobile */
    .audio-ui > *:not(.nav-toggle) {
        display: none;
    }
    
    .audio-ui .nav-toggle {
        display: inline-flex;
    }
}

/* Page title next to hamburger */
.page-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--emergence);
    opacity: 0.9;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .page-title {
        display: none;
    }
}

/* Nav toggle button (now inside audio-ui) */
.nav-toggle,
.riz∅ma-button,
.referencias-button,
.void-button,
.livro-button,
.font-size-button,
.export-button,
.github-button,
.reader-button,
.auto-scroll-button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--emergence);
    padding: 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
    overflow: visible;
}

/* Hamburger Menu Animation */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    width: 18px;
    height: 14px;
    position: relative;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background: var(--emergence);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hamburger active state (X) */
.nav-toggle[aria-expanded="true"] .hamburger {
    gap: 0;
    justify-content: center;
}

.nav-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translateY(0px);
    position: absolute;
}

.nav-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translateY(0px);
    position: absolute;
}

.nav-toggle:hover .hamburger-line {
    background: var(--glow);
    box-shadow: 0 0 4px var(--emergence);
}

.riz∅ma-button {
    font-size: 1.1rem;
}

.referencias-button {
    font-size: 1rem;
}

.void-button {
    font-size: 1.3rem;
    font-weight: 300;
}

.livro-button {
    font-size: 1.1rem;
}

.font-size-button {
    font-size: 1rem;
    font-weight: bold;
}

.export-button {
    font-size: 1rem;
}

.github-button {
    font-size: 1rem;
}

.reader-button {
    font-size: 1rem;
}

.riz∅ma-button::after {
    content: 'RIZOMA';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.riz∅ma-button:hover::after {
    opacity: 0.7;
}

.referencias-button::after {
    content: 'REFS';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.referencias-button:hover::after {
    opacity: 0.7;
}

.void-button::after {
    content: 'CRIOS';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.void-button:hover::after {
    opacity: 0.7;
}

.livro-button::after {
    content: 'LIVRO';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.livro-button:hover::after {
    opacity: 0.7;
}

.font-size-button::after {
    content: 'FONTE';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.font-size-button:hover::after {
    opacity: 0.7;
}

.auto-scroll-button::after {
    content: 'AUTO';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.auto-scroll-button:hover::after {
    opacity: 0.7;
}

.export-button::after {
    content: 'EXPORT';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.export-button:hover::after {
    opacity: 0.7;
}

.github-button::after {
    content: 'GITHUB';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.github-button:hover::after {
    opacity: 0.7;
}

.reader-button::after {
    content: 'READER';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.1em;
}

.reader-button:hover::after {
    opacity: 0.7;
}

.nav-toggle:hover,
.riz∅ma-button:hover,
.referencias-button:hover,
.void-button:hover,
.livro-button:hover,
.font-size-button:hover,
.export-button:hover,
.github-button:hover,
.reader-button:hover,
.auto-scroll-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--emergence);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.nav-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--emergence);
}

.nav-toggle[aria-expanded="true"]:hover {
    background: rgba(255, 255, 255, 0.12);
}

.nav-toggle:focus-visible,
.riz∅ma-button:focus-visible,
.referencias-button:focus-visible,
.void-button:focus-visible,
.livro-button:focus-visible,
.font-size-button:focus-visible,
.export-button:focus-visible,
.github-button:focus-visible,
.reader-button:focus-visible,
.auto-scroll-button:focus-visible {
    outline: 2px solid var(--emergence);
    outline-offset: 2px;
}

.nav-toggle:active,
.riz∅ma-button:active,
.referencias-button:active,
.void-button:active,
.livro-button:active,
.font-size-button:active,
.export-button:active,
.github-button:active,
.reader-button:active,
.auto-scroll-button:active {
    transform: scale(0.95);
}

/* Autoscroll button active state */
.auto-scroll-button.active {
    background: var(--emergence);
    color: var(--void);
    border-color: var(--emergence);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--emergence);
    }
    50% {
        box-shadow: 0 0 15px var(--emergence), 0 0 25px var(--emergence);
    }
}

/* Play and mute buttons - mesmo estilo dos demais */
.play-button,
.mute-button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--emergence);
    padding: 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.1rem;
    line-height: 1;
    text-align: center;
    transition: all 0.3s ease;
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-sizing: border-box;
}

.play-button:hover,
.mute-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--emergence);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.play-button:focus-visible,
.mute-button:focus-visible {
    outline: 2px solid var(--emergence);
    outline-offset: 2px;
}

.play-button:active,
.mute-button:active {
    transform: scale(0.95);
}

.mute-button {
    font-size: 1.4rem;
    font-weight: normal;
    line-height: 1;
}

.mute-button #mute-label {
    display: block;
}

.theme-icon {
    display: inline-block;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.mute-button:hover .theme-icon {
    transform: rotate(20deg) scale(1.1);
}

body.light-theme .theme-icon {
    color: #f39c12;
    text-shadow: 0 0 8px rgba(243, 156, 18, 0.5);
}

body:not(.light-theme) .theme-icon {
    color: #bdc3c7;
    text-shadow: 0 0 8px rgba(189, 195, 199, 0.3);
}

.audio-status {
    font-size: 0.85rem;
    color: var(--trace);
    opacity: 0.7;
    white-space: nowrap;
}

.audio-status:empty {
    display: none;
}

/* --------------------------------------------
   8. NAVIGATION INDEX
   -------------------------------------------- */

/* .nav-toggle now defined in section 7 (AUDIO CONTROLS) */

.nav-index {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    max-width: 480px;
    max-height: 80vh;
    background: var(--void);
    border: 1px solid var(--glow);
    border-radius: 8px;
    padding: 2rem;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--glow) transparent;
}

.nav-index::-webkit-scrollbar {
    width: 6px;
}

.nav-index::-webkit-scrollbar-track {
    background: transparent;
}

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

.nav-index.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: all;
    animation: menuCenterIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile adjustments for nav-index */
@media (max-width: 768px) {
    .nav-index {
        max-width: calc(100vw - 3rem);
        max-height: 85vh;
        padding: 1.5rem;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) scale(0.95);
    }
    
    .nav-index.visible {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes menuCenterIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes menuMobileIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.nav-index h3 {
    font-size: 1rem;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glow);
    color: var(--emergence);
    text-align: center;
    opacity: 0;
    transform: translateY(-10px);
}

.nav-index.visible h3 {
    animation: fadeInDown 0.4s ease forwards;
}

@keyframes fadeInDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-index h4 {
    font-size: 0.85rem;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--emergence);
    text-align: center;
    opacity: 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transform: translateY(-10px);
}

.nav-index.visible h4 {
    animation: fadeInDown 0.4s ease forwards 0.45s;
}

.nav-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
    opacity: 0;
    transform: scaleX(0);
}

.nav-index.visible .nav-divider {
    animation: expandWidth 0.5s ease forwards 0.4s;
}

@keyframes expandWidth {
    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

body.light-theme .nav-divider {
    border-top-color: rgba(10, 10, 10, 0.1);
}

/* Navigation Action Buttons */
.nav-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.nav-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.8rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--emergence);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.85rem;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.4s ease forwards;
}

.nav-action-btn:nth-child(1) { animation-delay: 0.05s; }
.nav-action-btn:nth-child(2) { animation-delay: 0.1s; }
.nav-action-btn:nth-child(3) { animation-delay: 0.15s; }
.nav-action-btn:nth-child(4) { animation-delay: 0.2s; }
.nav-action-btn:nth-child(5) { animation-delay: 0.25s; }
.nav-action-btn:nth-child(6) { animation-delay: 0.3s; }
.nav-action-btn:nth-child(7) { animation-delay: 0.35s; }
.nav-action-btn:nth-child(8) { animation-delay: 0.4s; }

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

.nav-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--emergence);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-action-btn:active {
    transform: translateY(0);
}

/* Active state for auto-scroll button */
.nav-action-btn.active {
    background: var(--emergence);
    color: var(--void);
    border-color: var(--emergence);
}

.nav-action-btn.active .nav-action-icon {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.nav-action-icon {
    font-size: 1.4rem;
    line-height: 1;
}

/* CRIO Navigation Header */
.crio-nav-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glow);
}

.crio-symbol {
    font-size: 2.5rem;
    color: var(--connection);
    line-height: 1;
    opacity: 0;
    animation: fadeInScale 0.5s ease forwards;
}

.crio-title {
    flex: 1;
    opacity: 0;
    animation: fadeInRight 0.5s ease forwards 0.1s;
}

.crio-title h3 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.4rem;
    text-align: left;
    color: var(--emergence);
    transform: none;
}

.crio-subtitle {
    margin: 0.2rem 0 0 0;
    font-size: 0.75rem;
    color: var(--emergence);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Navigation Grid */
.nav-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.nav-grid-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--emergence);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.85rem;
    opacity: 0;
    transform: scale(0.9);
}

.nav-grid-btn:nth-child(1) { animation: fadeInScale 0.4s ease forwards 0.2s; }
.nav-grid-btn:nth-child(2) { animation: fadeInScale 0.4s ease forwards 0.3s; }
.nav-grid-btn:nth-child(3) { animation: fadeInScale 0.4s ease forwards 0.4s; }
.nav-grid-btn:nth-child(4) { animation: fadeInScale 0.4s ease forwards 0.5s; }

.nav-grid-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.nav-grid-btn.ontologica:hover {
    background: rgba(102, 204, 255, 0.1);
    border-color: rgba(102, 204, 255, 0.5);
}

.nav-grid-btn.epistemica:hover {
    background: rgba(255, 153, 102, 0.1);
    border-color: rgba(255, 153, 102, 0.5);
}

.nav-grid-btn.fundacional:hover {
    background: rgba(153, 102, 255, 0.1);
    border-color: rgba(153, 102, 255, 0.5);
}

.nav-grid-btn.pratica:hover {
    background: rgba(153, 204, 255, 0.1);
    border-color: rgba(153, 204, 255, 0.5);
}

.nav-grid-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.nav-grid-label {
    font-weight: 500;
    letter-spacing: 0.05em;
}

.nav-description {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards 0.6s;
}

.nav-description p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--emergence);
    opacity: 0.7;
    font-style: italic;
}

.nav-action-text {
    font-size: 0.75rem;
    opacity: 0.8;
    letter-spacing: 0.02em;
}

body.light-theme .nav-action-btn {
    background: rgba(10, 10, 10, 0.03);
    border-color: rgba(10, 10, 10, 0.1);
}

body.light-theme .nav-action-btn:hover {
    background: rgba(10, 10, 10, 0.08);
    border-color: var(--emergence);
}

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

.nav-index.visible li {
    opacity: 0;
    transform: translateX(-10px);
    animation: slideInLeft 0.4s ease forwards;
}

.nav-index.visible li:nth-child(1) { animation-delay: 0.5s; }
.nav-index.visible li:nth-child(2) { animation-delay: 0.55s; }
.nav-index.visible li:nth-child(3) { animation-delay: 0.6s; }
.nav-index.visible li:nth-child(4) { animation-delay: 0.65s; }
.nav-index.visible li:nth-child(5) { animation-delay: 0.7s; }
.nav-index.visible li:nth-child(6) { animation-delay: 0.75s; }
.nav-index.visible li:nth-child(7) { animation-delay: 0.8s; }
.nav-index.visible li:nth-child(8) { animation-delay: 0.85s; }
.nav-index.visible li:nth-child(9) { animation-delay: 0.9s; }
.nav-index.visible li:nth-child(10) { animation-delay: 0.95s; }
.nav-index.visible li:nth-child(11) { animation-delay: 1s; }
.nav-index.visible li:nth-child(12) { animation-delay: 1.05s; }

@keyframes slideInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-index li {
    margin: 0;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.nav-index li.active {
    background: rgba(255, 255, 255, 0.03);
}

.nav-index li.completed {
    opacity: 0.6;
}

.nav-index a {
    display: flex;
    flex-direction: column;
    padding: 0.8rem 1rem;
    color: var(--emergence);
    text-decoration: none;
    border: none;
    border-left: 3px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
    align-items: center;
    text-align: center;
}

.nav-number {
    font-size: 0.75rem;
    opacity: 0.5;
    font-weight: 600;
    margin-bottom: 0.2rem;
    letter-spacing: 0.05em;
}

.nav-title {
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.nav-preview {
    font-size: 0.75rem;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.3;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme adjustments for navigation */
body.light-theme .nav-preview {
    color: rgba(10, 10, 10, 0.6);
}

body.light-theme .nav-number {
    color: rgba(10, 10, 10, 0.5);
}

body.light-theme .nav-index {
    background: rgba(240, 240, 240, 0.95);
    border-color: rgba(10, 10, 10, 0.2);
}

body.light-theme .nav-index h3 {
    border-bottom-color: rgba(10, 10, 10, 0.2);
}

body.light-theme .nav-index a:hover {
    background: rgba(10, 10, 10, 0.05);
}

body.light-theme .nav-index a.active {
    background: rgba(10, 10, 10, 0.08);
}

.nav-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background: linear-gradient(90deg, var(--emergence), var(--void-pulse));
    transition: transform 240ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 0 6px var(--emergence);
}

.nav-index a:hover {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--emergence);
    padding-left: 1.2rem;
    transform: translateX(2px);
}

.nav-index a:hover .nav-preview {
    opacity: 1;
    max-height: 100px;
    margin-top: 0.3rem;
}

.nav-index a:hover .nav-number {
    opacity: 0.8;
}

.nav-index a:focus-visible {
    outline: 2px solid var(--emergence);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.08);
}

.nav-index a.active {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--emergence);
    font-weight: 500;
}

.nav-index a.active .nav-number {
    opacity: 1;
    color: var(--emergence);
}

.nav-index a.completed {
    opacity: 0.7;
}

.nav-index a.completed::before {
    content: '✓';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    opacity: 0.4;
}

.nav-index .intro-link {
    font-style: italic;
    opacity: 0.8;
}

/* --------------------------------------------
   9. PROGRESS INDICATORS
   -------------------------------------------- */

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 2000;
    pointer-events: none;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--emergence) 0%, var(--emergence) 100%);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 120ms linear;
    will-change: transform;
    box-shadow: 0 0 10px var(--emergence);
}

.progress-markers {
    position: fixed;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.progress-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid var(--glow);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

.progress-marker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0%;
    height: 0%;
    border-radius: 50%;
    background: var(--emergence);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-marker:hover,
.progress-marker:focus-visible {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.4);
    border-color: var(--emergence);
}

.progress-marker:focus-visible {
    outline: 2px solid var(--emergence);
    outline-offset: 3px;
}

.progress-marker.active {
    background: var(--emergence);
    box-shadow: 0 0 12px var(--emergence), 0 0 24px rgba(255, 255, 255, 0.3);
    transform: scale(1.3);
    border-color: var(--emergence);
}

.progress-marker.active::before {
    width: var(--progress, 0%);
    height: var(--progress, 0%);
    opacity: 0.5;
}

.progress-marker.completed {
    background: var(--emergence);
    border-color: var(--emergence);
    opacity: 0.7;
}

.progress-marker.completed::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: var(--void);
    font-weight: bold;
}

.progress-marker-label {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--void);
    border: 1px solid var(--glow);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(4px);
}

.progress-marker:hover .progress-marker-label {
    opacity: 1;
}

.reading-info {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glow);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #fff;
    backdrop-filter: blur(4px);
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

body.light-theme .reading-info {
    color: #0a0a0a;
}

.reading-info.visible {
    opacity: 1;
}

/* --------------------------------------------
   10. RIZOMA CONCEPT LINKS
   -------------------------------------------- */

.riz∅ma-link {
    position: relative;
    color: var(--concept-color) !important;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--concept-color) !important;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0 2px;
    filter: brightness(1.3) saturate(1.3) contrast(1.1);
}

.riz∅ma-link:hover {
    color: var(--concept-color) !important;
    text-decoration-style: solid;
    background: rgba(255, 255, 255, 0.1);
    filter: brightness(1.5) saturate(1.4) contrast(1.2) drop-shadow(0 0 8px var(--concept-color));
    border-radius: 2px;
}

.riz∅ma-link:focus-visible {
    outline: 2px solid var(--concept-color) !important;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Tooltip antigo desabilitado - agora usando sistema de tooltips avançado */
.riz∅ma-link::after {
    display: none !important;
}

/* Manter responsividade para compatibilidade */
@media (max-width: 768px) {
    .riz∅ma-link::after {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .riz∅ma-link::after {
        display: none !important;
    }
}

.riz∅ma-link:hover::after {
    display: none !important;
}

/* Light theme adjustments */
.light-theme .riz∅ma-link {
    color: var(--concept-color) !important;
    filter: brightness(0.7) saturate(1.5) contrast(1.2);
}

.light-theme .riz∅ma-link:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    filter: brightness(0.6) saturate(1.6) contrast(1.3) drop-shadow(0 0 4px var(--concept-color));
}

.light-theme .riz∅ma-link::after {
    background: rgba(255, 255, 255, 0.98);
    color: var(--emergence);
    border-color: var(--concept-color) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* --------------------------------------------
   11. CLICK COUNTER FEEDBACK
   -------------------------------------------- */

.click-counter {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    color: var(--emergence);
    opacity: 0;
    pointer-events: none;
    z-index: 10001;
    transition: all 0.3s ease;
    text-shadow: 0 0 20px var(--emergence);
}

.click-counter.visible {
    opacity: 1;
    animation: pulse-counter 0.3s ease-out;
}

.ripple-effect {
    position: fixed;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid var(--emergence);
    pointer-events: none;
    z-index: 10000;
    animation: ripple 1s ease-out forwards;
}

/* --------------------------------------------
   12. RESPONSIVE DESIGN
   -------------------------------------------- */

/* Large Desktop (≥1200px) */
@media (min-width: 1200px) {
    body {
        padding: 3rem;
        font-size: 19px;
    }

    p {
        max-width: 80ch;
        line-height: 2;
    }

    h1 {
        font-size: 4rem;
        margin-bottom: 2.5rem;
    }

    h2 {
        font-size: 2.25rem;
        margin: 4rem 0 2rem 0;
    }
    
    .crio-quote {
        max-width: 70ch;
        padding: 3rem 2.5rem 3rem 5rem;
        margin: 3.5rem 0;
    }
    
    .crio-quote.anchor-quote {
        padding: 4rem 3rem 4rem 6rem;
    }
    
    .quote-decorator {
        font-size: 3rem;
        left: 1.5rem;
    }
    
    .nav-index {
        max-width: 380px;
        padding: 2rem;
    }
    
    .progress-markers {
        right: 1.5rem;
    }
    
    .audio-ui {
        left: 1.5rem;
        bottom: 1.5rem;
        padding: 0.6rem 0.8rem;
    }
}

/* Tablet (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    body {
        padding: 1.5rem;
        font-size: 17px;
        line-height: 1.85;
    }

    p {
        text-align: justify;
        max-width: 70ch;
        line-height: 1.85;
    }

    h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.75rem;
        margin: 3rem 0 1.5rem 0;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.35rem;
        line-height: 1.4;
    }
    
    /* Adjust quotes for tablet */
    .crio-quote {
        margin: 2.5rem 0;
        padding: 2rem 1.5rem 2rem 3.5rem;
        transform: translateX(-15px);
        font-size: 1.05em;
        line-height: 1.85;
        max-width: 65ch;
    }
    
    .crio-quote.anchor-quote {
        padding: 2.5rem 2rem 2.5rem 4rem;
    }
    
    .quote-decorator {
        font-size: 2rem;
        left: 1rem;
    }
    
    .crio-quote.quote-emphasized .quote-decorator {
        font-size: 2.5rem;
    }

    .nav-index {
        top: 4rem;
        right: 0.75rem;
        left: auto;
        max-width: 320px;
        max-height: 70vh;
    }

    .progress-markers {
        right: 0.5rem;
    }
    
    .progress-bar {
        height: 3px;
    }

    .reading-info {
        bottom: 1rem;
        font-size: 0.75rem;
        padding: 0.5rem 1rem;
    }
    
    .audio-ui {
        left: 0.75rem;
        bottom: 0.75rem;
        padding: 0.4rem 0.5rem;
        gap: 0.4rem;
    }
    
    .audio-control-btn {
        min-width: 2.2rem;
        padding: 0.35rem 0.5rem;
        font-size: 0.95rem;
    }
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
    body {
        padding: 1.5rem !important;
        font-size: 16px; /* Slightly smaller on mobile */
        line-height: 1.8;
        text-align: center;
    }

    p {
        text-align: center;
        max-width: none;
        line-height: 1.8;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        text-align: center;
    }

    h1 {
        font-size: 1.5rem;
        line-height: 1.2;
        letter-spacing: 0.03em;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Ajustar espaçamento dos headers de PARTE/SEÇÃO */
    h1:not(:first-of-type) {
        margin-top: 3rem !important;
        padding-top: 2rem !important;
    }

    /* Decoradores responsivos */
    h1:not(:first-of-type)::before {
        width: 120px !important;
    }

    h1:not(:first-of-type)::after {
        font-size: 1.2rem !important;
        top: -0.6rem !important;
    }

    /* Títulos de PARTE com padding reduzido */
    h1[id^="parte-"],
    h1:has(+ hr) {
        padding: 1.25rem 0.75rem !important;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    h2 {
        font-size: 1.5rem;
        margin: 2.5rem 0 1.25rem 0;
        line-height: 1.3;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    h3 {
        font-size: 1.2rem;
        line-height: 1.4;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Adjust quotes for mobile */
    .crio-quote {
        margin: 2rem 0;
        padding: 1.5rem 1rem 1.5rem 3rem;
        transform: translateX(-10px);
        font-size: 1em;
        line-height: 1.8;
        max-width: none;
    }
    
    .crio-quote.anchor-quote {
        padding: 2rem 1.5rem 2rem 3.5rem;
    }
    
    .quote-decorator {
        font-size: 1.5rem;
        left: 0.75rem;
    }
    
    .crio-quote.quote-emphasized .quote-decorator {
        font-size: 1.8rem;
    }
    
    .crio-quote .quote-content p {
        font-size: 1rem;
        line-height: 1.8;
    }
    
    .crio-quote.anchor-quote .quote-content p {
        font-size: 1.05rem;
        line-height: 1.9;
    }
    
    blockquote {
        font-size: 1em;
        line-height: 1.8;
        padding: 1.5rem;
        max-width: none;
    }
    
    ul, ol {
        padding-left: 1.5rem;
    }
    
    li {
        margin-bottom: 0.6rem;
    }

    /* Audio controls on mobile - only hamburger visible */
    .audio-ui {
        left: 0.5rem;
        right: auto;
        bottom: 0.5rem;
        padding: 0.3rem 0.4rem;
        gap: 0.2rem;
        width: auto;
        justify-content: flex-start;
        transform: none;
    }
    
    /* Hide all buttons except hamburger on mobile */
    .audio-ui > *:not(.nav-toggle) {
        display: none;
    }
    
    /* Make hamburger button larger on mobile */
    .nav-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        font-size: 1rem;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .hamburger {
        width: 20px;
        height: 16px;
    }
    
    /* Keep other buttons sized normally (though they're hidden) */
    .riz∅ma-button,
    .referencias-button,
    .void-button,
    .livro-button,
    .font-size-button,
    .auto-scroll-button,
    .play-button,
    .mute-button {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        padding: 0.25rem;
        font-size: 0.9rem;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .hamburger {
        width: 16px;
        height: 12px;
    }
    
    .mute-button {
        font-size: 0.7rem;
    }

    .nav-index {
        top: 50%;
        left: 1rem;
        right: 1rem;
        max-width: none;
        max-height: 70vh;
        transform: translateY(-50%) !important;
        animation: none !important;
        padding: 1.25rem;
    }
    
    .nav-index.visible {
        transform: translateY(-50%) !important;
        animation: none !important;
    }

    .progress-markers {
        display: none;
    }
    
    .progress-bar {
        height: 4px;
    }

    .reading-info {
        bottom: auto;
        top: 4rem;
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
    body {
        padding: 1rem !important;
        font-size: 15px;
    }

    h1 {
        font-size: 1.35rem;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        letter-spacing: 0.02em;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Ajustar ainda mais espaçamento em telas muito pequenas */
    h1:not(:first-of-type) {
        margin-top: 2.5rem !important;
        padding-top: 1.5rem !important;
    }

    /* Decoradores menores */
    h1:not(:first-of-type)::before {
        width: 80px !important;
        height: 2px !important;
    }

    h1:not(:first-of-type)::after {
        font-size: 1rem !important;
        top: -0.5rem !important;
    }

    /* Títulos de PARTE compactos */
    h1[id^="parte-"],
    h1:has(+ hr) {
        padding: 1rem 0.5rem !important;
        margin-left: 0.25rem;
        margin-right: 0.25rem;
        border-radius: 8px;
    }

    h2 {
        font-size: 1.3rem;
        margin: 2rem 0 1rem 0;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    
    /* Compact quotes for small screens */
    .crio-quote {
        margin: 1.5rem 0;
        padding: 1.25rem 1rem 1.25rem 2.5rem;
        font-size: 0.95em;
    }
    
    .crio-quote.anchor-quote {
        padding: 1.75rem 1rem 1.75rem 3rem;
    }
    
    .quote-decorator {
        font-size: 1.3rem;
        left: 0.5rem;
    }
    
    .crio-quote.quote-emphasized .quote-decorator {
        font-size: 1.6rem;
    }

    .nav-index {
        top: 50%;
        left: 0.75rem;
        right: 0.75rem;
        max-height: 65vh;
        padding: 1rem;
        transform: translateY(-50%) !important;
        animation: none !important;
    }
    
    .nav-index.visible {
        transform: translateY(-50%) !important;
        animation: none !important;
    }
    
    .nav-index h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .nav-index ul {
        gap: 0.4rem;
    }
    
    .nav-index a {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .reading-info {
        top: 3.5rem;
        font-size: 0.65rem;
        padding: 0.3rem 0.6rem;
        gap: 0.4rem;
    }
    
    .audio-ui {
        left: 0.5rem;
        right: auto;
        bottom: 0.5rem;
        padding: 0.25rem 0.3rem;
        gap: 0.15rem;
        width: auto;
        justify-content: flex-start;
        transform: none;
    }
    
    /* Hide all buttons except hamburger on mobile */
    .audio-ui > *:not(.nav-toggle) {
        display: none;
    }
    
    /* Make hamburger button larger on small mobile */
    .nav-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .hamburger {
        width: 20px;
        height: 16px;
    }
    
    /* Other buttons (hidden) */
    .riz∅ma-button,
    .referencias-button,
    .void-button,
    .livro-button,
    .font-size-button,
    .auto-scroll-button,
    .mute-button {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        padding: 0.2rem;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .mute-button {
        font-size: 0.65rem;
    }
    
    .audio-control-btn {
        min-width: 2rem;
        padding: 0.3rem 0.4rem;
        font-size: 0.85rem;
    }
    
    .click-counter {
        font-size: 2.5rem;
    }
    
    .void-symbol {
        font-size: 8rem;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .nav-index {
        max-height: 70vh;
        font-size: 0.85rem;
    }
    
    .reading-info {
        display: none; /* Hide in landscape to save space */
    }
    
    .progress-markers {
        display: none; /* Hide in landscape */
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .particle {
        filter: blur(10px); /* Slightly less blur on retina for sharper appearance */
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .particle {
        animation: none !important;
    }
    
    .crio-quote {
        opacity: 1 !important;
        transform: translateX(-20px) !important;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .nav-toggle,
    .nav-index,
    .progress-bar,
    .progress-markers,
    .reading-info,
    .audio-ui,
    .particle,
    .void-symbol,
    .click-counter {
        display: none !important;
    }
    
    .crio-quote {
        border-left-color: #333;
        background: #f5f5f5;
        page-break-inside: avoid;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* --------------------------------------------
   11.5 MOBILE-SPECIFIC OPTIMIZATIONS
   -------------------------------------------- */

/* Enhanced touch targets for mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Coarse pointer = touch device */
    
    /* Larger touch targets (min 44x44px per iOS/Android guidelines) */
    button,
    .nav-toggle,
    .theme-toggle,
    .play-button,
    .mute-button,
    .progress-marker {
        min-width: 44px;
        min-height: 44px;
        padding: 0.75rem;
    }
    
    /* Increase nav link touch areas */
    .nav-index a {
        padding: 1rem 1.5rem;
        margin: 0.25rem 0;
    }
    
    /* Better tap feedback */
    button:active,
    .nav-toggle:active,
    .progress-marker:active {
        opacity: 0.7;
        transform: scale(0.95);
    }
    
    /* Prevent text selection on rapid taps */
    button,
    .nav-toggle,
    .progress-marker,
    .theme-toggle {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Improve scrolling momentum on iOS */
    body,
    .nav-index {
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile landscape optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce header sizes in landscape to maximize content */
    h1 {
        font-size: 2rem;
        margin: 1.5rem 0;
    }
    
    h2 {
        font-size: 1.5rem;
        margin: 1.25rem 0;
    }
    
    /* Compact navigation in landscape */
    .nav-index {
        width: 250px;
        font-size: 0.85rem;
    }
    
    /* Smaller progress markers */
    .progress-marker {
        width: 10px;
        height: 10px;
    }
    
    /* Hide reading time in landscape to save space */
    .reading-info {
        font-size: 0.75rem;
    }
    
    /* Compact audio controls */
    .audio-ui {
        gap: 0.5rem;
    }
    
    .play-button,
    .mute-button {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Safe area insets for notched devices (iPhone X+, etc.) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .progress-bar {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .theme-toggle {
        right: max(1rem, calc(1rem + env(safe-area-inset-right)));
    }
    
    .reading-info {
        right: max(1rem, calc(1rem + env(safe-area-inset-right)));
    }
}

/* Optimize for smaller mobile screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    /* Further reduce font sizes */
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    h3 {
        font-size: 1.2rem;
    }
    
    /* Compact buttons */
    .audio-ui {
        gap: 0.5rem;
    }
    
    .hamburger {
        width: 18px;
        height: 14px;
    }
    
    .play-button,
    .mute-button {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    /* Reduce padding */
    main {
        padding: 1rem 0.75rem;
    }
    
    .nav-index {
        width: 85%;
        padding: 1rem;
    }
    
    .crio-quote {
        padding: 1rem;
        margin: 1.5rem 0;
    }
}

/* Specific adjustments for 412x915 and similar resolutions */
@media (min-width: 390px) and (max-width: 430px) {
    .audio-ui {
        left: 0.5rem;
        right: auto;
        bottom: 0.5rem;
        padding: 0.4rem 0.4rem;
        gap: 0.35rem;
        transform: none;
        justify-content: flex-start;
    }
    
    /* Hide all buttons except hamburger on mobile */
    .audio-ui > *:not(.nav-toggle) {
        display: none;
    }
    
    /* Make hamburger button touch-friendly */
    .nav-toggle {
        min-width: 48px;
        min-height: 48px;
        padding: 0.6rem;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .hamburger {
        width: 22px;
        height: 18px;
    }
    
    /* Other buttons (hidden) */
    .riz∅ma-button,
    .referencias-button,
    .void-button,
    .livro-button,
    .font-size-button,
    .auto-scroll-button,
    .play-button,
    .mute-button {
        min-width: 42px;
        min-height: 42px;
        padding: 0.45rem;
        margin: 0;
    }
}

/* Prevent zoom on input focus (iOS Safari) */
@media (max-width: 768px) {
    input,
    select,
    textarea {
        font-size: 16px; /* Prevents iOS zoom */
    }
}

/* Optimize animations for lower-end mobile devices */
@media (max-width: 768px) {
    /* Reduce particle count via display:none on nth-child */
    .particle:nth-child(n+6) {
        display: none;
    }
    
    /* Simplify animations */
    .crio-quote {
        animation-duration: 0.4s; /* Faster on mobile */
    }
    
    /* Reduce blur effects that can be expensive */
    .nav-index::before {
        backdrop-filter: none;
        background: rgba(10, 10, 10, 0.98);
    }
    
    body.light-theme .nav-index::before {
        background: rgba(240, 240, 240, 0.98);
    }
}

/* Battery-saving mode detection */
@media (prefers-reduced-data: reduce) {
    /* User has enabled data saver */
    
    /* Disable background image loading */
    .particle {
        display: none;
    }
    
    /* Simplify visual effects */
    .nav-index::before {
        backdrop-filter: none;
    }
    
    /* Disable all non-essential animations */
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* --------------------------------------------
   13. ERROR HANDLING
   -------------------------------------------- */

.error-container {
    max-width: 700px;
    margin: 4rem auto;
    padding: 3rem 2rem;
    background: var(--void);
    border: 2px solid var(--trace);
    border-radius: 12px;
    text-align: center;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.7;
}

.error-container h2 {
    color: var(--emergence);
    margin-bottom: 1rem;
    font-size: 2rem;
    line-height: 1.3;
}

.error-description {
    color: var(--trace);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.8;
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

.error-section {
    margin: 2.5rem 0;
    padding: 1.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    text-align: left;
    line-height: 1.8;
}

body.light-theme .error-section {
    background: rgba(0, 0, 0, 0.02);
}

.error-section h3 {
    color: var(--emergence);
    margin-bottom: 1rem;
    font-size: 1.3rem;
    line-height: 1.4;
}

.solution-options {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.solution {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--trace);
    border-radius: 4px;
    line-height: 1.8;
}

body.light-theme .solution {
    background: rgba(0, 0, 0, 0.05);
}

.solution strong {
    color: var(--emergence);
    display: block;
    margin-bottom: 0.5rem;
}

.error-list {
    list-style-position: inside;
    color: var(--trace);
    line-height: 1.9;
    padding-left: 0;
}

.error-list li {
    margin: 0.75rem 0;
}

.info-text {
    color: var(--trace);
    line-height: 1.8;
    margin: 0.75rem 0;
}

.error-details {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 4px;
    color: var(--trace);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

body.light-theme .error-details {
    background: rgba(0, 0, 0, 0.05);
}

.retry-button {
    margin-top: 2rem;
    padding: 1rem 2rem;
    background: var(--emergence);
    color: var(--void);
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.retry-button:active {
    transform: scale(0.95);
}

code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.9em;
    color: var(--emergence);
    letter-spacing: 0.01em;
    line-height: 1.6;
}

body.light-theme code {
    background: rgba(0, 0, 0, 0.1);
}

pre {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2rem 0;
    line-height: 1.6;
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.95em;
}

.cache-warning {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.warning-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.warning-content {
    flex: 1;
    text-align: left;
}

.warning-content strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--emergence);
}

.warning-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--trace);
}

.warning-close {
    background: none;
    border: none;
    color: var(--trace);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    transition: color 0.2s ease;
}

.warning-close:hover {
    color: var(--emergence);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 0.95;
    }
}

/* ========================================
   14. LOADING SKELETON
   ======================================== */

/* Skeleton loader for better perceived performance during initial load */
.skeleton-loader {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.skeleton-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Skeleton header */
.skeleton-header {
    margin-bottom: 3rem;
    text-align: center;
}

.skeleton-title {
    height: 3rem;
    width: 80%;
    max-width: 600px;
    margin: 0 auto 1rem;
    background: linear-gradient(
        90deg,
        var(--void) 25%,
        var(--trace) 50%,
        var(--void) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite ease-in-out;
    border-radius: 4px;
}

.skeleton-subtitle {
    height: 1.5rem;
    width: 60%;
    max-width: 400px;
    margin: 0 auto;
    background: linear-gradient(
        90deg,
        var(--void) 25%,
        var(--trace) 50%,
        var(--void) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite ease-in-out;
    animation-delay: 0.1s;
    border-radius: 4px;
}

/* Skeleton content lines */
.skeleton-content {
    max-width: 70ch;
    margin: 0 auto;
}

.skeleton-line {
    height: 1.2rem;
    width: 100%;
    margin-bottom: 0.8rem;
    background: linear-gradient(
        90deg,
        var(--void) 25%,
        var(--trace) 50%,
        var(--void) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite ease-in-out;
    border-radius: 3px;
}

.skeleton-line.short {
    width: 70%;
}

/* Stagger animation delays for more natural feel */
.skeleton-line:nth-child(1) { animation-delay: 0s; }
.skeleton-line:nth-child(2) { animation-delay: 0.05s; }
.skeleton-line:nth-child(3) { animation-delay: 0.1s; }
.skeleton-line:nth-child(4) { animation-delay: 0.15s; }
.skeleton-line:nth-child(5) { animation-delay: 0.2s; }
.skeleton-line:nth-child(6) { animation-delay: 0.25s; }
.skeleton-line:nth-child(7) { animation-delay: 0.3s; }
.skeleton-line:nth-child(8) { animation-delay: 0.35s; }

/* Skeleton spacer */
.skeleton-spacer {
    height: 2rem;
}

/* Skeleton quote block */
.skeleton-quote {
    margin: 2rem 0;
    padding: 1.5rem;
    border-left: 4px solid var(--trace);
    background: rgba(255, 255, 255, 0.02);
}

.skeleton-quote .skeleton-line {
    animation-delay: 0.4s;
}

.skeleton-quote .skeleton-line:last-child {
    animation-delay: 0.45s;
}

/* Shimmer animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Responsive skeleton */
@media (max-width: 768px) {
    .skeleton-loader {
        padding: 1.5rem;
    }
    
    .skeleton-title {
        height: 2.5rem;
        width: 90%;
    }
    
    .skeleton-subtitle {
        height: 1.2rem;
        width: 75%;
    }
}

@media (max-width: 480px) {
    .skeleton-loader {
        padding: 1rem;
    }
    
    .skeleton-title {
        height: 2rem;
        width: 100%;
    }
    
    .skeleton-subtitle {
        height: 1rem;
        width: 85%;
    }
    
    .skeleton-line {
        height: 1rem;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .skeleton-title,
    .skeleton-subtitle,
    .skeleton-line {
        animation: none;
        background: var(--trace);
    }
    
    .skeleton-loader {
        transition: none;
    }
}

/* --------------------------------------------
   15. FONT SIZE FEEDBACK
   -------------------------------------------- */

.font-size-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: var(--emergence);
    color: var(--void);
    padding: 2rem 3rem;
    border-radius: 12px;
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--void);
}

.font-size-feedback.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Responsive font size feedback */
@media (max-width: 768px) {
    .font-size-feedback {
        font-size: 1.4rem;
        padding: 1.5rem 2.5rem;
    }
}

@media (max-width: 480px) {
    .font-size-feedback {
        font-size: 1.2rem;
        padding: 1.2rem 2rem;
    }
}

/* --------------------------------------------
   16. GITHUB FAB BUTTON
   -------------------------------------------- */

.github-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--emergence);
    color: var(--void);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999;
    cursor: pointer;
}

.github-fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.github-fab:active {
    transform: scale(0.95);
}

body.light-theme .github-fab {
    background: var(--emergence);
    color: var(--void);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-theme .github-fab:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

@media (max-width: 768px) {
    .github-fab {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
        bottom: 16px;
        right: 16px;
    }
}

/* ============================================
   TOOLTIPS DE CONCEITOS
   ============================================ */

#tooltip-container {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
}

.concept-tooltip {
    position: fixed;
    background: var(--void);
    border: 1px solid var(--trace);
    border-radius: 8px;
    padding: 0;
    max-width: 320px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

.concept-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--trace);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tooltip-title {
    color: var(--emergence);
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}

.layer-tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid currentColor;
}

.tooltip-desc {
    padding: 12px 14px;
    color: var(--emergence);
    opacity: 0.9;
    margin: 0;
}

.tooltip-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--trace);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tooltip-connections {
    color: var(--trace);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tooltip-connections svg {
    flex-shrink: 0;
}

.tooltip-link {
    color: #66ccff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.tooltip-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Tema claro */
body.light-theme .concept-tooltip {
    background: var(--void);
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05);
}

body.light-theme .tooltip-header,
body.light-theme .tooltip-footer {
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .tooltip-title,
body.light-theme .tooltip-desc {
    color: var(--emergence);
}

body.light-theme .tooltip-connections {
    color: #666;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .concept-tooltip {
        max-width: calc(100vw - 40px);
        font-size: 0.85rem;
    }
    
    .tooltip-title {
        font-size: 0.95rem;
    }
    
    .tooltip-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ============================================
   PAINEL DE REFERÊNCIAS
   ============================================ */

.references-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--void);
    border-left: 1px solid var(--trace);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.references-sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--trace);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--void);
    z-index: 1;
}

.sidebar-header h3 {
    color: var(--emergence);
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--trace);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s ease;
    line-height: 1;
}

.sidebar-close-btn:hover {
    color: var(--emergence);
}

.sidebar-content {
    padding: 20px;
    flex: 1;
}

.chapter-info {
    margin-bottom: 30px;
}

.chapter-info h4 {
    color: var(--emergence);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.chapter-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--trace);
    font-size: 0.85rem;
}

.sidebar-section {
    margin-bottom: 30px;
}

.sidebar-section h5 {
    color: var(--emergence);
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.authors-list li {
    margin-bottom: 8px;
}

.authors-list a {
    color: #66ccff;
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.authors-list a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.concepts-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.concept-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(102, 204, 255, 0.1);
    border: 1px solid rgba(102, 204, 255, 0.3);
    border-radius: 4px;
    color: #66ccff;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.concept-tag:hover {
    background: rgba(102, 204, 255, 0.2);
    border-color: rgba(102, 204, 255, 0.5);
}

.mention-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: rgba(102, 204, 255, 0.3);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.layer-distribution {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.layer-bar {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    gap: 10px;
    align-items: center;
}

.layer-label {
    color: var(--emergence);
    font-size: 0.85rem;
    font-weight: 500;
}

.layer-bar-container {
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.layer-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.layer-count {
    color: var(--trace);
    font-size: 0.85rem;
    text-align: right;
}

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

.protocols-list li {
    margin-bottom: 8px;
}

.protocols-list a {
    color: #ff9966;
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.protocols-list a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.sidebar-placeholder {
    color: var(--trace);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

/* Botão de toggle do sidebar */
.references-toggle-btn {
    position: fixed;
    top: 120px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--emergence);
    color: var(--void);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999;
}

.references-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.references-toggle-btn svg {
    width: 24px;
    height: 24px;
}

/* Tema claro */
body.light-theme .references-sidebar {
    background: var(--void);
    border-left-color: rgba(0, 0, 0, 0.15);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

body.light-theme .sidebar-header {
    background: var(--void);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .references-toggle-btn {
    background: var(--emergence);
    color: var(--void);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-theme .references-toggle-btn:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .references-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .references-sidebar.open {
        right: 0;
    }
    
    .references-toggle-btn {
        top: 80px;
        right: 16px;
        width: 44px;
        height: 44px;
    }
    
    .layer-bar {
        grid-template-columns: 80px 1fr 35px;
        gap: 8px;
    }
}

/* ============================================
   PROTOCOLOS INTERATIVOS
   ============================================ */

.protocol-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--trace);
    border-radius: 8px;
    padding: 30px;
    margin: 40px 0;
}

.protocol-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--trace);
}

.protocol-header h4 {
    color: var(--emergence);
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.protocol-description {
    color: var(--trace);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.protocol-form {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.protocol-question {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 20px;
    align-items: start;
}

.question-number {
    width: 40px;
    height: 40px;
    background: rgba(102, 204, 255, 0.1);
    border: 2px solid rgba(102, 204, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #66ccff;
    font-weight: 600;
    font-size: 1.1rem;
}

.question-content {
    flex: 1;
}

.question-text {
    color: var(--emergence);
    font-size: 1rem;
    font-weight: 500;
    margin: 0 0 15px 0;
    line-height: 1.5;
}

.scale-input {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    color: var(--trace);
    font-size: 0.85rem;
}

.scale-options {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.scale-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.scale-option input[type="radio"] {
    display: none;
}

.scale-value {
    width: 40px;
    height: 40px;
    border: 2px solid var(--trace);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--trace);
    font-weight: 600;
    transition: all 0.2s ease;
}

.scale-option input[type="radio"]:checked + .scale-value {
    background: #66ccff;
    border-color: #66ccff;
    color: #0a0a0a;
    transform: scale(1.1);
}

.scale-option:hover .scale-value {
    border-color: #66ccff;
    color: #66ccff;
}

.yesno-input,
.multiselect-input {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.yesno-input label,
.multiselect-input label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--emergence);
    font-size: 1rem;
    cursor: pointer;
    padding: 12px;
    border: 1px solid var(--trace);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.yesno-input label:hover,
.multiselect-input label:hover {
    border-color: #66ccff;
    background: rgba(102, 204, 255, 0.05);
}

.yesno-input input,
.multiselect-input input {
    width: 20px;
    height: 20px;
}

.text-input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--trace);
    border-radius: 6px;
    color: var(--emergence);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: #66ccff;
}

.protocol-actions {
    display: flex;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--trace);
}

.protocol-submit-btn,
.protocol-reset-btn {
    padding: 14px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.protocol-submit-btn {
    background: #66ccff;
    color: #0a0a0a;
    flex: 1;
}

.protocol-submit-btn:hover {
    background: #80d4ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 204, 255, 0.3);
}

.protocol-reset-btn {
    background: transparent;
    color: var(--trace);
    border: 1px solid var(--trace);
    padding: 14px 20px;
}

.protocol-reset-btn:hover {
    border-color: var(--emergence);
    color: var(--emergence);
}

.protocol-result {
    margin-top: 30px;
    padding: 30px;
    background: rgba(102, 204, 255, 0.05);
    border: 2px solid rgba(102, 204, 255, 0.2);
    border-radius: 8px;
}

.result-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(102, 204, 255, 0.2);
}

.result-header h5 {
    color: var(--emergence);
    font-size: 1.3rem;
    margin: 0;
}

.result-score {
    color: var(--emergence);
    font-size: 1.1rem;
}

.result-score strong {
    color: #66ccff;
    font-size: 1.5rem;
}

.result-level {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-level.level-low {
    background: rgba(102, 255, 153, 0.2);
    color: #66ff99;
    border: 2px solid rgba(102, 255, 153, 0.5);
}

.result-level.level-medium {
    background: rgba(255, 255, 102, 0.2);
    color: #ffff66;
    border: 2px solid rgba(255, 255, 102, 0.5);
}

.result-level.level-high {
    background: rgba(255, 102, 102, 0.2);
    color: #ff6666;
    border: 2px solid rgba(255, 102, 102, 0.5);
}

.result-interpretation,
.result-recommendations {
    margin-bottom: 25px;
}

.result-interpretation h6,
.result-recommendations h6 {
    color: #66ccff;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-interpretation p {
    color: var(--emergence);
    line-height: 1.7;
    margin: 0;
}

.result-recommendations ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-recommendations li {
    color: var(--emergence);
    padding-left: 25px;
    position: relative;
    line-height: 1.6;
}

.result-recommendations li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: #66ccff;
    font-weight: bold;
}

.result-actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(102, 204, 255, 0.2);
}

.export-btn,
.history-btn {
    padding: 10px 20px;
    border: 1px solid #66ccff;
    background: transparent;
    color: #66ccff;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-btn:hover,
.history-btn:hover {
    background: rgba(102, 204, 255, 0.1);
}

/* Modal para histórico */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
}

.modal-content {
    background: var(--void);
    border: 1px solid var(--trace);
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--trace);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h4 {
    color: var(--emergence);
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--trace);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--emergence);
}

.modal-body {
    padding: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid var(--trace);
    border-radius: 6px;
    margin-bottom: 10px;
}

.history-date {
    color: var(--emergence);
    font-size: 0.9rem;
}

.history-score {
    color: #66ccff;
    font-weight: 600;
}

/* Tema claro */
body.light-theme .protocol-container {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .text-input {
    background: rgba(0, 0, 0, 0.03);
}

body.light-theme .modal-content {
    background: var(--void);
    border-color: rgba(0, 0, 0, 0.15);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .protocol-container {
        padding: 20px;
    }
    
    .protocol-question {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .question-number {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .scale-labels {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .scale-options {
        flex-wrap: wrap;
    }
    
    .scale-option {
        flex: 0 0 calc(20% - 8px);
    }
    
    .protocol-actions {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
    }
}
