:root {
    --bg-color: #06090c;
    --text-color: #b3cbbe;
    --accent-color: #00ff66;
    --accent-dim: #004d1f;
    --card-bg: #0d1317;
    --border-color: #17222a;
    --glitch-speed: 2s;

    --status-full-color: #00ff66;
    --status-full-bg: rgba(0, 255, 102, 0.05);
    --status-full-border: rgba(0, 255, 102, 0.2);

    --status-partial-color: #ffaa00;
    --status-alert-color: #ffaa00;
    --status-partial-bg: rgba(255, 170, 0, 0.05);
    --status-partial-border: rgba(255, 170, 0, 0.2);

    --status-encrypted-color: #00e5ff;
    --status-encrypted-bg: rgba(0, 229, 255, 0.05);
    --status-encrypted-border: rgba(0, 229, 255, 0.2);

    --status-corrupted-color: #ff3333;
    --status-corrupted-bg: rgba(255, 51, 51, 0.05);
    --status-corrupted-border: rgba(255, 51, 51, 0.2);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-image: linear-gradient(var(--border-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 100px 100px;
    background-position: center;
}

.container {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem; /* Reduced from 3rem to save vertical space */
    flex: 1;
}

/* Header & Navigation */
header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem; /* Restored generous padding for breathing room */
    margin-bottom: 3.5rem;  /* Increased from 1.5rem/3rem to enforce strong separation */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#doc-title {
    font-family: "Courier New", Courier, monospace;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: -0.5px;
    margin-top: 1rem;       /* Added explicit separation from the nav border above */
    margin-bottom: 2rem;    /* Generous spacing before the metadata block begins */
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.2);
}

header h1 a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: 2px;
    font-family: "Courier New", Courier, monospace;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    margin-left: 1.5rem;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--accent-color);
}

/* --- LANDING PAGE EXCLUSIVES --- */
.hero-section {
    border: 1px solid var(--border-color);
    background: rgba(13, 19, 23, 0.85);
    backdrop-filter: blur(4px);
    padding: 2.5rem;
    border-radius: 4px;
    position: relative;
    margin-bottom: 2rem;
}

.system-status {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.75rem;
    color: var(--accent-dim);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

.hero-title {
    font-family: "Courier New", Courier, monospace;
    color: #ffffff;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    letter-spacing: -0.5px;
}

.hero-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

.meta-item {
    font-family: "Courier New", Courier, monospace;
    font-size: 0.8rem;
}
.meta-item span { color: var(--accent-color); }

.enter-btn {
    display: inline-block;
    margin-top: 2rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--accent-color);
    background: transparent;
    color: var(--accent-color);
    font-family: "Courier New", Courier, monospace;
    text-decoration: none;
    font-weight: bold;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.enter-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.4);
}

.mobile-table-toggle {
    display: none;
    width: 100%;
    margin: 1rem 0;
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    background: rgba(23, 34, 42, 0.25); /* Subtle container background */
    border: 1px solid var(--border-color); /* Clean, uniform border on all four sides */
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.reading-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.reading-header-left span {
    font-family: "Courier New", Courier, monospace;
    font-weight: bold;
}

.reading-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.reading-header-left,
.reading-header-right {
    min-width: 0;
}

.reading-header-left span,
.reading-header-right span {
    white-space: normal;
}

.table-toggle-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0 0;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

.directive-label {
    display: inline-block;
}

/* --- CUSTOM TEXT SEPARATOR --- */
.sci-fi-hr {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 3rem 0;
    color: var(--accent-dim);
    font-family: "Courier New", Courier, monospace;
    font-size: 0.7rem;
    letter-spacing: 4px;
    user-select: none;
}

.sci-fi-hr::before, .sci-fi-hr::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.sci-fi-hr:not(:empty)::before { margin-right: 1.5rem; }
.sci-fi-hr:not(:empty)::after { margin-left: 1.5rem; }

/* --- ARCHIVE / SEARCH --- */
.search-box {
    width: 100%;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: #ffffff;
    border-radius: 4px;
    margin-bottom: 2rem;
    font-size: 1rem;
    font-family: "Courier New", Courier, monospace;
}
.search-box:focus { outline: 1px solid var(--accent-color); }

.arc-header {
    color: var(--accent-color);
    margin: 2.5rem 0 1rem 0;
    font-family: "Courier New", Courier, monospace;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.chapter-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(13, 19, 23, 0.7);
    border: 1px solid var(--border-color);
    margin-bottom: 0.6rem;
    border-radius: 4px;
    transition: border 0.2s;
}
.chapter-item:hover { border-color: var(--accent-dim); }
.chapter-item a { color: var(--text-color); text-decoration: none; font-weight: 500; }
.chapter-item a:hover { color: var(--accent-color); }

/* --- READING MODES --- */
.content-area {
    margin-top: 1rem; /* Reduced from 2rem */
}

/* Default Readable Style (For standard storytelling) */
.mode-chapter {
    font-family: "Georgia", Georgia, serif;
    font-size: 1.2rem;
    line-height: 1.85;
    color: #d1dfd6;

    background-color: rgba(13, 19, 23, 0.4);
    border: 1px solid rgba(23, 34, 42, 0.5);
    padding: 2.5rem 2rem;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.mode-chapter p { margin-bottom: 1.75rem; text-align: justify; }
.mode-chapter h1, .mode-chapter h2, .mode-chapter h3 {
    color: #ffffff;
    margin: 2rem 0 1rem 0;
}

/* Official Document Style (Stark, Legal, Administrative) */
.mode-document {
    font-family: "Courier New", Courier, monospace;
    font-size: 1rem;
    line-height: 1.5;
    background-color: rgba(4, 6, 8, 0.95);
    border: 1px solid var(--border-color);
    padding: 1.75rem 1.5rem; /* Reduced from 3rem 2.5rem to pull content up */
    border-radius: 2px;
    color: #a9c6b7;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

/* Legal text styling details */
.mode-document p {
    margin-bottom: 1.5rem;
    text-align: justify;
    text-justify: inter-word;
}

/* Sub-headers inside an official document look like article codes */
.mode-document h1, .mode-document h2, .mode-document h3 {
    font-family: "Courier New", Courier, monospace;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--accent-dim);
    padding-bottom: 0.3rem;
    letter-spacing: 1px;
}

/* Ordered/Unordered lists inside legal sheets */
.mode-document ul, .mode-document ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}
.mode-document li {
    margin-bottom: 0.5rem;
}

/* If you display structural tables in reports */
.mode-document table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9rem;
}
.mode-document th, .mode-document td {
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    text-align: left;
}
.mode-document th {
    background-color: rgba(0, 255, 102, 0.05);
    color: var(--accent-color);
}

/* --- CONSOLE LINK SHORTCUTS --- */
.wiki-link-console {
    display: inline-flex;
    align-items: center;
    color: var(--accent-color);
    text-decoration: none;
    background: rgba(0, 255, 102, 0.04);
    border: 1px solid rgba(0, 255, 102, 0.15);
    padding: 0.1rem 0.4rem;
    margin: 0 0.15rem;
    border-radius: 3px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.95rem;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}

/* Appends an interactive terminal tag shortcut look */
.wiki-link-console::after {
    content: attr(data-cmd);
    font-size: 0.65rem;
    background: var(--accent-dim);
    color: var(--bg-color);
    padding: 0.05rem 0.25rem;
    margin-left: 0.5rem;
    border-radius: 2px;
    font-weight: 900;
    letter-spacing: 0.5px;
    transition: all 0.2s ease-in-out;
}

/* Hover effects replicating an interactive directory system node */
.wiki-link-console:hover {
    background: rgba(0, 255, 102, 0.12);
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.2);
    color: #ffffff;
    cursor: pointer;
}

.wiki-link-console:hover::after {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 5px var(--accent-color);
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem;
    font-size: 0.8rem;
    font-family: "Courier New", Courier, monospace;
    border-top: 1px solid var(--border-color);
    color: #43544a;
    letter-spacing: 1px;
}

.obfuscated {
    font-family: monospace;
    color: var(--accent-color);
    background-color: rgba(6, 12, 12, 0.1);
    padding: 0 5px;
    border-radius: 1px;
}

/* --- TERMINAL BACK TO TOP BUTTON --- */
.terminal-totop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
    background-color: rgba(6, 9, 12, 0.9); /* Blends with --bg-color */
    color: var(--accent-color);
    border: 1px solid var(--accent-dim);
    font-family: "Courier New", Courier, monospace;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 1px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s, border-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(4px);
}

/* Button shows when active */
.terminal-totop.show {
    opacity: 1;
    visibility: visible;
}

/* Hover effects matching your wiki-links and enter-btn styles */
.terminal-totop:hover {
    border-color: var(--accent-color);
    background-color: rgba(0, 255, 102, 0.05);
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.3);
    color: #ffffff;
}

.terminal-totop:active {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.terminal-totop .arrow {
    font-size: 0.7rem;
    color: var(--accent-color);
    transition: transform 0.2s;
}

.terminal-totop:hover .arrow {
    transform: translateY(-2px);
    color: #ffffff;
}

/* --- YAML STATUS INDICATORS --- */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    border: 1px solid transparent;
    letter-spacing: 0.5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Variant Styles Utilizing Tokens */
.status-full {
    color: var(--status-full-color);
    background: var(--status-full-bg);
    border-color: var(--status-full-border);
}
.status-full .status-dot {
    background-color: var(--status-full-color);
    box-shadow: 0 0 6px var(--status-full-color);
}

.status-partial {
    color: var(--status-partial-color);
    background: var(--status-partial-bg);
    border-color: var(--status-partial-border);
}
.status-partial .status-dot {
    background-color: var(--status-partial-color);
    box-shadow: 0 0 6px var(--status-partial-color);
}

.status-encrypted {
    color: var(--status-encrypted-color);
    background: var(--status-encrypted-bg);
    border-color: var(--status-encrypted-border);
}
.status-encrypted .status-dot {
    background-color: var(--status-encrypted-color);
    box-shadow: 0 0 6px var(--status-encrypted-color);
}

.status-corrupted {
    color: var(--status-corrupted-color);
    background: var(--status-corrupted-bg);
    border-color: var(--status-corrupted-border);
}
.status-corrupted .status-dot {
    background-color: var(--status-corrupted-color);
    box-shadow: 0 0 6px var(--status-corrupted-color);
}

.text-alert-amber {
    color: var(--status-alert-color) !important;
}

.document-stream-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--accent-dim);
    font-family: "Courier New", Courier, monospace;
    font-size: 0.8rem;
    color: var(--accent-dim);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

button:focus-visible,
.enter-btn:focus-visible,
nav a:focus-visible,
.search-box:focus-visible,
.wiki-link-console:focus-visible,
.terminal-totop:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

@media (max-width: 800px) {
    body {
        background-size: 60px 60px;
    }

    .container {
        padding: 1rem 0.75rem; /* Much tighter side padding on small screens */
    }

    header {
        flex-direction: row; /* Keeps SCI-SEED and Archive on one line to save vertical block space */
        align-items: center;
        margin-bottom: 1rem;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    nav a {
        margin-left: 0;
    }

    .hero-section {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .system-status {
        position: static;
        width: 100%;
        justify-content: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .system-status span {
        font-size: 0.85rem;
    }

    .hero-title {
        font-size: 1.55rem;
    }

    .hero-meta-grid {
        grid-template-columns: 1fr;
        padding-top: 1rem;
        margin-top: 1.5rem;
    }

    .enter-btn {
        width: 100%;
        padding: 0.85rem 1rem;
        text-align: center;
    }

    .search-box {
        font-size: 1rem;
        padding: 1rem;
    }

    .chapter-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .chapter-item div {
        width: 100%;
    }

    .chapter-item span {
        align-self: flex-start;
    }

    .content-area {
        margin-top: 1rem; /* Reduced from 2rem */
    }

    .mode-chapter,
    .mode-document {
        padding: 1.25rem 1rem; /* Eliminates the massive inner padding gutters */
    }

    .mode-chapter {
        font-size: 1.05rem;
    }

    .mode-document {
        font-size: 0.98rem;
        padding: 2rem 1.5rem;
    }

    .status-indicator {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .wiki-link-console {
        width: 100%;
        justify-content: space-between;
        padding: 0.75rem 0.85rem;
    }

    .wiki-link-console::after {
        display: block;
        margin-top: 0.4rem;
    }

    .terminal-totop {
        right: 1rem;
        bottom: 1rem;
        padding: 0.8rem 1rem;
    }

    #doc-title {
        font-size: 1.5rem; /* Scales title text down on phones */
        margin-bottom: 1rem;
    }

    .reading-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .reading-header-right {
        align-items: flex-start;
        width: 100%;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.5rem;
    }

    .reading-header-meta {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex-wrap: wrap;
        width: 100%;
        justify-content: flex-start;
    }

    .directive-label {
        display: none;
    }

    .mobile-table-toggle {
        display: block;
        width: 100%;
        text-align: center;
        margin: 1rem 0 0;
        padding: 0.85rem 1rem;
    }

    .table-container table {
        display: none;
    }

    .table-expanded-mobile .table-container table {
        display: table;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .container {
        padding: 1rem 0.75rem;
    }

    .hero-title {
        font-size: 1.3rem;
    }

    .meta-item {
        font-size: 0.78rem;
    }

    .chapter-item {
        padding: 0.85rem;
    }

    .chapter-item a {
        font-size: 1rem;
    }

    .mode-chapter,
    .mode-document {
        border-radius: 0;
    }
}
