* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #F1F5F9;
    color: #1E293B;
    line-height: 1.6;
}
sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    background: #FFFFFF;
    border-right: 1px solid #DDE2E8;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-header {
    padding: 20px 16px 14px;
    text-align: center;
    border-bottom: 1px solid #E2E8F0;
}
.sidebar-header img {
    width: 100%;
    max-width: 185px;
    height: auto;
    display: block;
    margin: 0 auto 8px;
}
.sidebar-header p {
    margin: 0;
    font-size: 0.78em;
    color: #475569;
    font-weight: 600;
}
.nav-toggle, .nav-toggle-label { display: none; }
.nav-links {
    list-style: none;
    margin: 12px 0;
    padding: 0;
}
.nav-links a {
    display: block;
    padding: 11px 20px;
    color: #0D4373;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95em;
    border-left: 4px solid transparent;
}
.nav-links a:hover, .nav-links a.active {
    background: #EFF6FF;
    border-left-color: #F39221;
    color: #0D4373;
}
.sidebar-tools {
    padding: 12px 14px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.sidebar-group-label {
    font-size: 0.72em;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #F39221;
    margin-bottom: 2px;
}
.tool-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 11px;
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    border-left: 3px solid #0D4373;
    border-radius: 6px;
    color: #0D4373;
    text-decoration: none;
    font-size: 0.82em;
    font-weight: 700;
}
.tool-pill:hover { background: #EFF6FF; }
.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid #E2E8F0;
}
.patreon-btn {
    display: block;
    text-align: center;
    background: #F39221;
    color: #FFFFFF !important;
    text-decoration: none;
    font-weight: 800;
    padding: 10px 14px;
    border-radius: 22px;
    font-size: 0.9em;
}
main {
    margin-left: 250px;
    padding: 28px 34px;
    max-width: 1040px;
}
main .card {
    background: #FFFFFF;
    border: 1px solid #DDE2E8;
    border-radius: 12px;
    padding: 26px 30px;
    margin-bottom: 24px;
    box-shadow: 0 2px 6px rgba(15,23,42,0.04);
}
main h2 {
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 3px solid #F39221;
    display: inline-block;
    color: #0D4373;
    font-size: 1.75em;
}
main h2 span { color: #F39221; }
details.info-card {
    background: #FFFFFF;
    border: 1px solid #DDE2E8;
    border-left: 5px solid #0D4373;
    border-radius: 8px;
    margin-bottom: 14px;
    overflow: hidden;
}
details.info-card.orange { border-left-color: #F39221; }
details.info-card.red { border-left-color: #DC2626; }
details.info-card summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    font-weight: 800;
    color: #0D4373;
    font-size: 1.05em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
details.info-card summary::-webkit-details-marker { display: none; }
details.info-card[open] .card-caret { transform: rotate(90deg); display: inline-block; }
.card-caret { display: inline-block; margin-right: 8px; color: #F39221; transition: transform 0.15s; }
.card-body {
    padding: 14px 18px 16px;
    border-top: 1px solid #E2E8F0;
}
@media (max-width: 820px) {
    sidebar { position: relative; width: 100%; border-right: none; border-bottom: 1px solid #DDE2E8; }
    main { margin-left: 0; padding: 18px; }
    .nav-toggle-label { display: inline-block; margin-top: 10px; padding: 7px 14px; background: #0D4373; color: #FFF; border-radius: 6px; font-weight: 700; cursor: pointer; }
    .nav-links, .sidebar-tools, .sidebar-footer { display: none; }
    sidebar:has(.nav-toggle:checked) .nav-links,
    sidebar:has(.nav-toggle:checked) .sidebar-tools,
    sidebar:has(.nav-toggle:checked) .sidebar-footer,
    sidebar.menu-open .nav-links,
    sidebar.menu-open .sidebar-tools,
    sidebar.menu-open .sidebar-footer { display: flex !important; flex-direction: column; }
}

/* Site-Wide Dark Mode */
#theme-toggle {
    position: fixed;
    top: 14px;
    right: 18px;
    z-index: 9999;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    color: #0D4373;
    border: 1px solid #CBD5E1;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.14);
}
html.dark #theme-toggle { background: #1E293B; color: #FBBF24; border-color: #475569; }
html.dark, html.dark body { background: #0B1120 !important; color: #E2E8F0 !important; }
html.dark sidebar { background: #111827 !important; border-right-color: #1E293B !important; }
html.dark .sidebar-header { border-bottom-color: #1E293B !important; }
html.dark .sidebar-header p, html.dark .sidebar-group-label { color: #94A3B8 !important; }
html.dark .nav-links a { color: #CBD5E1 !important; }
html.dark .nav-links a:hover, html.dark .nav-links a.active { background: #1E293B !important; color: #60A5FA !important; }
html.dark .sidebar-tools, html.dark .sidebar-footer { background: #111827 !important; border-top-color: #1E293B !important; }
html.dark .tool-pill { background: #1E293B !important; color: #E2E8F0 !important; border-color: #334155 !important; }
html.dark main .card { background: #111827 !important; border-color: #1E293B !important; color: #E2E8F0 !important; }
html.dark main h2, html.dark main h3, html.dark summary { color: #93C5FD !important; }
html.dark main h2 span { color: #F39221 !important; }
html.dark main p, html.dark main li, html.dark main div, html.dark main span { color: #E2E8F0 !important; }
html.dark main a:not(.patreon-btn) { color: #60A5FA !important; }
html.dark details.info-card { background: #1E293B !important; border-color: #334155 !important; }
html.dark .card-body { border-top-color: #334155 !important; }
html.dark code { background: #334155 !important; color: #FDE68A !important; padding: 2px 5px; border-radius: 4px; }
html.dark main [style*="background:#"], html.dark main [style*="background: #"] {
    background-color: #1E293B !important;
    border-color: #334155 !important;
    color: #E2E8F0 !important;
}
html.dark main [style*="background:#0D4373"], html.dark main [style*="background: #0D4373"],
html.dark main [style*="background:#F39221"], html.dark main [style*="background: #F39221"],
html.dark main [style*="background:#DC2626"], html.dark main [style*="background: #DC2626"] {
    color: #FFFFFF !important;
}

/* Printable Guide Links & Digest Box */
.pdf-link {
    display: flex;
    align-items: center;
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    border-left: 5px solid #0D4373;
    border-radius: 8px;
    padding: 13px 16px;
    margin: 10px 0;
    color: #0D4373;
    text-decoration: none;
    font-weight: 700;
    transition: background 0.15s;
}
.pdf-link:hover { background: #EFF6FF; }
.digest-box {
    background: #FFF7ED;
    border: 1px solid #FDBA74;
    border-left: 5px solid #F39221;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 10px 0;
}
html.dark .pdf-link, html.dark .digest-box {
    background: #1E293B !important;
    border-color: #334155 !important;
    color: #E2E8F0 !important;
}
html.dark main [style*="background:#007AFF"],
html.dark main [style*="background:#34C759"],
html.dark main [style*="background:#166534"] {
    color: #FFFFFF !important;
}
@media print {
    #theme-toggle, sidebar { display: none !important; }
    main { margin-left: 0 !important; padding: 0 !important; }
}


/* Unified Mobile Caret Accordion Menu */
@media (max-width: 820px) {
    .sidebar-header {
        padding: 16px 14px 12px !important;
        border-bottom: none !important;
    }
    .nav-toggle-label {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-top: 12px !important;
        padding: 13px 16px !important;
        background: #F8FAFC !important;
        color: #0D4373 !important;
        border: 1px solid #CBD5E1 !important;
        border-left: 5px solid #F39221 !important;
        border-radius: 8px !important;
        font-weight: 800 !important;
        font-size: 1.0em !important;
        cursor: pointer;
        text-align: left;
        box-shadow: 0 1px 3px rgba(15,23,42,0.05);
    }
    html.dark .nav-toggle-label {
        background: #1E293B !important;
        color: #93C5FD !important;
        border-color: #334155 !important;
        border-left-color: #F39221 !important;
    }
    .nav-toggle-label .menu-caret {
        display: inline-block;
        color: #F39221 !important;
        margin-right: 8px;
        transition: transform 0.15s ease;
    }
    sidebar.menu-open .nav-toggle-label,
    sidebar:has(.nav-toggle:checked) .nav-toggle-label {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }
    sidebar.menu-open .nav-toggle-label .menu-caret,
    sidebar:has(.nav-toggle:checked) .nav-toggle-label .menu-caret {
        transform: rotate(90deg);
    }
    sidebar.menu-open .nav-links,
    sidebar:has(.nav-toggle:checked) .nav-links {
        display: flex !important;
        flex-direction: column;
        margin: -12px 14px 0 14px !important;
        background: #FFFFFF;
        border: 1px solid #CBD5E1;
        border-top: none;
        border-left: 5px solid #F39221;
    }
    html.dark sidebar.menu-open .nav-links,
    html.dark sidebar:has(.nav-toggle:checked) .nav-links {
        background: #1E293B !important;
        border-color: #334155 !important;
        border-left-color: #F39221 !important;
    }
    sidebar.menu-open .sidebar-tools,
    sidebar:has(.nav-toggle:checked) .sidebar-tools,
    sidebar.menu-open .sidebar-footer,
    sidebar:has(.nav-toggle:checked) .sidebar-footer {
        display: flex !important;
        flex-direction: column;
        margin: 0 14px;
        border-left: 5px solid #0D4373;
    }
}
