/* ============================================================
   Haven – shared stylesheet
   All colors use CSS custom properties so the theme toggle
   can swap dark ↔ light by changing one data attribute.
   ============================================================ */

/* --- Theme variables ---------------------------------------- */

:root {
    /* Dark theme (default) */
    --bg-primary:    #0f1117;
    --bg-surface:    #1c1e26;
    --bg-hover:      #22242e;
    --border:        #2e3039;
    --border-hover:  #4f8ff7;

    --text-primary:  #e4e4e7;
    --text-heading:  #ffffff;
    --text-muted:    #a1a1aa;
    --text-faint:    #71717a;
    --text-subtle:   #52525b;
    --text-ghost:    #3f3f46;

    --accent:        #4ecdc4;
    --accent-hover:  #45b7af;
    --accent-glow:   #4ecdc418;

    --accent-warm:        #f59e0b;
    --accent-warm-bg:     #f59e0b18;
    --accent-warm-text:   #fbbf24;
    --accent-warm-hover:  #d97706;
    --accent-warm-border: #f59e0b40;

    --link:          #4f8ff7;
    --link-hover:    #93bbfc;

    /* Status colors */
    --status-green:       #22c55e;
    --status-green-text:  #4ade80;
    --status-green-bg:    #22c55e18;
    --status-green-border:#22c55e40;

    --status-yellow:       #eab308;
    --status-yellow-text:  #facc15;
    --status-yellow-bg:    #eab30818;
    --status-yellow-border:#eab30840;

    --status-red:       #ef4444;
    --status-red-text:  #f87171;
    --status-red-bg:    #ef444418;
    --status-red-border:#ef444440;

    --status-gray:       #71717a;
    --status-gray-text:  #a1a1aa;
    --status-gray-bg:    #71717a18;

    /* Button (wake) */
    --btn-border:    #ff6b6b;
    --btn-bg:        #ff6b6b15;
    --btn-text:      #ff8a8a;
    --btn-bg-hover:  #ff6b6b28;
    --btn-text-hover:#ffb3b3;

    /* Tag */
    --tag-bg:    #27272a;
    --tag-text:  #71717a;

    /* Nav */
    --nav-bg:        #0f1117;
    --nav-border:    #2e3039;
    --nav-link:      #a1a1aa;
    --nav-link-hover:#e4e4e7;
    --nav-active:    #4ecdc4;
}

[data-theme="light"] {
    --bg-primary:    #f4f4f5;
    --bg-surface:    #ffffff;
    --bg-hover:      #f0f0f2;
    --border:        #d4d4d8;
    --border-hover:  #4f8ff7;

    --text-primary:  #27272a;
    --text-heading:  #09090b;
    --text-muted:    #52525b;
    --text-faint:    #71717a;
    --text-subtle:   #a1a1aa;
    --text-ghost:    #d4d4d8;

    --accent:        #2ba89e;
    --accent-hover:  #24938a;
    --accent-glow:   #2ba89e18;

    --accent-warm:        #d97706;
    --accent-warm-bg:     #d9770615;
    --accent-warm-text:   #b45309;
    --accent-warm-hover:  #b45309;
    --accent-warm-border: #d9770640;

    --link:          #2563eb;
    --link-hover:    #1d4ed8;

    --status-green:       #16a34a;
    --status-green-text:  #15803d;
    --status-green-bg:    #16a34a15;
    --status-green-border:#16a34a40;

    --status-yellow:       #ca8a04;
    --status-yellow-text:  #a16207;
    --status-yellow-bg:    #ca8a0415;
    --status-yellow-border:#ca8a0440;

    --status-red:       #dc2626;
    --status-red-text:  #b91c1c;
    --status-red-bg:    #dc262615;
    --status-red-border:#dc262640;

    --status-gray:       #71717a;
    --status-gray-text:  #52525b;
    --status-gray-bg:    #71717a15;

    --btn-border:    #2563eb;
    --btn-bg:        #2563eb15;
    --btn-text:      #1d4ed8;
    --btn-bg-hover:  #2563eb25;
    --btn-text-hover:#1e40af;

    --tag-bg:    #e4e4e7;
    --tag-text:  #52525b;

    --nav-bg:        #ffffff;
    --nav-border:    #d4d4d8;
    --nav-link:      #52525b;
    --nav-link-hover:#09090b;
    --nav-active:    #2ba89e;
}

/* --- Reset -------------------------------------------------- */

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

/* --- Base --------------------------------------------------- */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* --- Nav bar ------------------------------------------------ */

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-logo {
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

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

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--nav-link);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover { color: var(--nav-link-hover); }
.nav-links a.active { color: var(--nav-active); }

/* --- Theme toggle ------------------------------------------- */

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}

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

/* --- Main content ------------------------------------------- */

.content {
    flex: 1;
    padding: 2rem;
}

/* --- Footer ------------------------------------------------- */

.footer {
    text-align: center;
    padding: 2rem;
    font-size: 0.75rem;
    color: var(--text-ghost);
}

.footer a {
    color: var(--text-subtle);
    text-decoration: none;
}

.footer a:hover { color: var(--text-muted); }

/* --- Cards (shared by home + servers) ----------------------- */

.card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, background 0.2s;
}

a.card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--text-heading);
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-faint);
}

/* --- Home glow background ----------------------------------- */

.home-glow {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: glow-pulse 6s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.4; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.7; transform: translateX(-50%) scale(1.1); }
}

.home-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 8rem);
    text-align: center;
}

.home-title {
    font-size: 3.5rem;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

.home-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
    position: relative;
    z-index: 1;
}

.home-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 480px;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* --- Card icons --------------------------------------------- */

.card-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}

/* Responsive: single column on small screens */
@media (max-width: 520px) {
    .home-links {
        grid-template-columns: 1fr;
    }

    .home-title {
        font-size: 2.5rem;
    }
}

.home-links .card {
    min-width: 200px;
    padding: 1.5rem 2rem;
}

/* --- Server status page ------------------------------------- */

.servers-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.servers-header h1 {
    font-size: 2rem;
    color: var(--text-heading);
    margin-bottom: 0.3rem;
}

.servers-header .subtitle {
    font-size: 0.95rem;
    color: var(--text-faint);
}

.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    max-width: 1000px;
    margin: 0 auto;
}

.server-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.server-card.state-running,
.server-card.state-idle {
    border-color: var(--status-green-border);
}

.server-card.state-starting,
.server-card.state-stopping {
    border-color: var(--status-yellow-border);
}

.server-card.state-sleeping,
.server-card.state-unknown {
    border-color: var(--border);
}

.server-card.state-node_offline {
    border-color: var(--status-red-border);
}

.server-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
}

.server-domain {
    font-size: 0.8rem;
    color: var(--text-subtle);
    font-family: monospace;
    margin-bottom: 1rem;
}

.server-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
}

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

.badge-running .status-dot,
.badge-idle .status-dot { background: var(--status-green); }
.badge-running, .badge-idle {
    background: var(--status-green-bg);
    color: var(--status-green-text);
}

.badge-starting .status-dot,
.badge-stopping .status-dot { background: var(--status-yellow); }
.badge-starting, .badge-stopping {
    background: var(--status-yellow-bg);
    color: var(--status-yellow-text);
}

.badge-sleeping .status-dot,
.badge-unknown .status-dot { background: var(--status-gray); }
.badge-sleeping, .badge-unknown {
    background: var(--status-gray-bg);
    color: var(--status-gray-text);
}

.badge-node_offline .status-dot { background: var(--status-red); }
.badge-node_offline {
    background: var(--status-red-bg);
    color: var(--status-red-text);
}

.badge-starting .status-dot {
    animation: pulse 1.5s ease-in-out infinite;
}

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

.player-count {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.player-count strong {
    color: var(--accent-warm-text);
}

/* --- Action buttons (unified: wake, map, transition) -------- */

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.action-btn.wake-btn {
    border-color: var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-text);
}

.action-btn.wake-btn:hover {
    background: var(--btn-bg-hover);
    color: var(--btn-text-hover);
}

.action-btn.wake-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.action-btn.wake-btn.waking {
    border-color: var(--status-yellow);
    background: var(--status-yellow-bg);
    color: var(--status-yellow-text);
    cursor: wait;
}

.action-btn.map-btn {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
    gap: 0.4rem;
}

.action-btn.map-btn:hover {
    background: var(--accent);
    color: #0f1117;
}

.action-btn.transition-btn {
    border-color: var(--status-yellow-border);
    background: var(--status-yellow-bg);
    color: var(--status-yellow-text);
    cursor: default;
}

.action-btn.transition-btn .status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-yellow);
    margin-right: 0.4rem;
    animation: pulse 1.5s ease-in-out infinite;
}

.wake-result {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    min-height: 1.2em;
}

.wake-result.success { color: var(--status-green-text); }
.wake-result.error { color: var(--status-red-text); }

.no-sleep-tag {
    font-size: 0.65rem;
    color: var(--accent-warm-text);
    background: var(--accent-warm-bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

/* --- Documentation page ------------------------------------- */

.docs-layout {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.docs-sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 4rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
}

.docs-sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.docs-nav {
    list-style: none;
}

.docs-nav li a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.docs-nav li a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.docs-nav li a.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 500;
}

.docs-content {
    flex: 1;
    min-width: 0;
}

/* --- Markdown rendered content ------------------------------ */

.markdown-body h1 {
    font-size: 2rem;
    color: var(--text-heading);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
    font-size: 1.5rem;
    color: var(--text-heading);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.markdown-body h3 {
    font-size: 1.25rem;
    color: var(--text-heading);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    color: var(--text-heading);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.markdown-body p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.markdown-body a {
    color: var(--link);
}

.markdown-body a:hover {
    color: var(--link-hover);
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.35rem;
    line-height: 1.6;
}

.markdown-body li > ul, .markdown-body li > ol {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

.markdown-body code {
    font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
    font-size: 0.85em;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15em 0.35em;
}

.markdown-body pre {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    margin: 0 0 1rem 0;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-radius: 0 8px 8px 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.markdown-body th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-heading);
    font-weight: 600;
}

.markdown-body td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

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

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.markdown-body strong {
    color: var(--text-heading);
}

/* Responsive: stack sidebar on narrow screens */
@media (max-width: 768px) {
    .docs-layout {
        flex-direction: column;
    }

    .docs-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .docs-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

/* --- Guide pages -------------------------------------------- */

.guide-index {
    max-width: 800px;
    margin: 0 auto;
}

.guide-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.guide-header h1 {
    font-size: 2rem;
    color: var(--text-heading);
    margin-bottom: 0.3rem;
}

.guide-subtitle {
    font-size: 0.95rem;
    color: var(--text-faint);
}

.guide-server-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.guide-server-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    gap: 1.5rem;
}

.guide-server-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.guide-server-emoji {
    font-size: 2rem;
    line-height: 1;
}

.guide-server-icon {
    width: 2rem;
    height: 2rem;
    max-width: 2rem;
    max-height: 2rem;
    object-fit: contain;
    flex-shrink: 0;
}

.guide-server-domain {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-subtle);
    margin-top: 0.2rem;
}

.guide-server-links {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.guide-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-text);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.guide-link:hover {
    background: var(--btn-bg-hover);
    color: var(--btn-text-hover);
}

.guide-link-secondary {
    border-color: var(--border);
    background: transparent;
    color: var(--text-muted);
}

.guide-link-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.guide-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-faint);
}

/* --- Guide detail layout ------------------------------------ */

.guide-layout {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.guide-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 4rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
}

.guide-sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.guide-sidebar-meta {
    margin-top: 1.5rem;
    padding: 0 0.5rem;
}

.guide-sidebar-domain {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-subtle);
    margin-bottom: 0.5rem;
}

.guide-back-link {
    font-size: 0.8rem;
    color: var(--text-faint);
    text-decoration: none;
}

.guide-back-link:hover {
    color: var(--text-primary);
}

/* --- Download button (rendered into markdown) --------------- */

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: #0f1117;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
    margin: 0.5rem 0 1rem 0;
}

.download-btn:hover {
    background: var(--accent-hover);
    color: #0f1117;
}

.download-btn-size {
    font-weight: 400;
    font-size: 0.8rem;
    opacity: 0.7;
}

/* --- Guide responsive --------------------------------------- */

@media (max-width: 768px) {
    .guide-server-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .guide-server-links {
        width: 100%;
    }

    .guide-link {
        flex: 1;
        justify-content: center;
    }

    .guide-layout {
        flex-direction: column;
    }

    .guide-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }
}

/* --- Wave Divider ------------------------------------------- */

.wave-divider {
    width: 100%;
    line-height: 0;
    margin-top: -1px; /* close the gap with nav border */
}

.wave-divider svg {
    width: 100%;
    height: 40px;
    display: block;
}

/* --- Card Lift Effect --------------------------------------- */

.card {
    transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
}

a.card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(78, 205, 196, 0.08);
}

/* --- Accent Bar on Active Nav Link -------------------------- */

.nav-links a {
    position: relative;
    padding-bottom: 0.25rem;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

/* --- LIVE tag (warm pulse) ---------------------------------- */

.live-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--accent-warm-text);
    background: var(--accent-warm-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.live-tag::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-warm);
    animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-warm-bg); }
    50% { opacity: 0.6; box-shadow: 0 0 0 4px var(--accent-warm-bg); }
}

/* --- Error pages -------------------------------------------- */

.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 8rem);
    text-align: center;
    padding: 2rem;
}

.error-code {
    font-size: 8rem;
    font-weight: 800;
    line-height: 1;
    color: var(--border);
    letter-spacing: -0.05em;
    user-select: none;
}

.error-icon {
    font-size: 3rem;
    margin: -1rem 0 1rem 0;
    animation: sway 3s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.error-title {
    font-size: 1.5rem;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.error-message {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 440px;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.error-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.error-btn:hover {
    transform: translateY(-1px);
}

.error-btn-primary {
    background: var(--accent);
    color: #0f1117;
}

.error-btn-primary:hover {
    background: var(--accent-hover);
    color: #0f1117;
}

.error-btn-secondary {
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
}

.error-btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.error-hint {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

@media (max-width: 520px) {
    .error-code {
        font-size: 5rem;
    }

    .error-actions {
        flex-direction: column;
        width: 100%;
    }

    .error-btn {
        justify-content: center;
    }
}

/* ── Docs Index ────────────────────────────────────────────── */

.docs-index-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.docs-index-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.docs-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.docs-card {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.docs-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.docs-card h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    color: var(--accent);
}

.docs-card p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (min-width: 600px) {
    .docs-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- View-as banner (owner role switcher) ------------------- */

.view-as-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.4rem 1rem;
    background: var(--accent-warm-bg);
    border-bottom: 1px solid var(--accent-warm-border);
    color: var(--accent-warm-text);
    font-size: 0.8rem;
    font-weight: 500;
}

.view-as-exit {
    color: var(--accent-warm-text);
    text-decoration: none;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.view-as-exit:hover {
    background: var(--accent-warm-border);
    color: var(--accent-warm-hover);
}

/* --- Role switcher dropdown --------------------------------- */

.role-switcher {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;

    /* Custom dropdown arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23a1a1aa' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.75rem;
}

.role-switcher:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.role-switcher:focus {
    outline: none;
    border-color: var(--accent);
}
