body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fcfcfc;
    margin: 0;
    padding: 0;
}

.toolbar {
    background-color: #fcfcfc;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
}

.hamburger {
    background: none;
    border: none;
    color: #333333dd;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    margin-right: 12px;
}

.toolbar-logo {
    display: block;
    height: 28px;
    width: auto;
    margin-right: 16px;
    object-fit: contain;
}

.toolbar-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

.text-btn {
    background: transparent;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: #333;
    margin-right: 12px;
}

.text-btn:hover {
    background-color: #e1e4e8;
}

.muted-prompt {
    color: #656d76;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-dialog {
    width: min(560px, 100%);
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    padding: 14px 18px;
}

.modal-header {
    justify-content: space-between;
    border-bottom: 1px solid #d0d7de;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #656d76;
}

.modal-body {
    padding: 16px 18px 8px;
}

.modal-help {
    margin: 0 0 14px;
    color: #656d76;
    font-size: 0.95rem;
}

.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #656d76;
    margin-bottom: 6px;
}

.modal-text-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.modal-status {
    min-height: 1.25em;
    margin-top: 10px;
    font-size: 0.9rem;
    color: #656d76;
}

.modal-status.is-error {
    color: #cf222e;
}

.modal-footer {
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #d0d7de;
}

.btn-primary,
.btn-secondary {
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    border: 1px solid #003865;
    background: #003865;
    color: #fff;
}

.btn-primary:hover {
    background: #002545;
}

.btn-secondary {
    border: 1px solid #d0d7de;
    background: #fff;
    color: #24292f;
}

.btn-secondary:hover {
    background: #f6f8fa;
}

body.dark-theme .text-btn {
    border-color: #30363d;
    color: #c9d1d9;
}

body.dark-theme .text-btn:hover {
    background-color: #21262d;
}

body.dark-theme .muted-prompt {
    color: #8b949e;
}

body.dark-theme .modal-dialog {
    background: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
}

body.dark-theme .modal-header,
body.dark-theme .modal-footer {
    border-color: #30363d;
}

body.dark-theme .modal-help,
body.dark-theme .modal-label,
body.dark-theme .modal-status,
body.dark-theme .modal-close {
    color: #8b949e;
}

body.dark-theme .modal-text-input {
    background: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}

body.dark-theme .modal-status.is-error {
    color: #f85149;
}

body.dark-theme .btn-secondary {
    background: #21262d;
    border-color: #30363d;
    color: #c9d1d9;
}

body.dark-theme .btn-secondary:hover {
    background: #30363d;
}

.font-controls {
    display: flex;
    gap: 8px;
}

.font-btn {
    background: transparent;
    border: 1px solid #d1d5da;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: #333;
    transition: background-color 0.2s;
}

.font-btn:hover {
    background-color: #e1e4e8;
}

.theme-controls {
    margin-right: 12px;
}

#export-docx-btn,
#export-pdf-btn {
    margin-right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#export-docx-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Dark Theme Variables / Overrides */
body.dark-theme {
    background-color: #0d1117;
    color: #c9d1d9;
}

body.dark-theme .container {
    background: #161b22;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

body.dark-theme .container a {
    color: #4493f8;
}

body.dark-theme .toolbar {
    background-color: #161b22;
    color: #c9d1d9;
    border-bottom: 1px solid #30363d;
}

body.dark-theme .hamburger {
    color: #c9d1d9;
}

body.dark-theme .side-menu {
    background-color: #161b22;
    box-shadow: 2px 0 8px rgba(0,0,0,0.5);
}

body.dark-theme .menu-header {
    background-color: #0d1117;
    border-bottom: 1px solid #30363d;
}

body.dark-theme .close-btn {
    color: #c9d1d9;
}

body.dark-theme #toc-list li a {
    color: #58a6ff;
    border-bottom: 1px solid #30363d;
}

body.dark-theme #toc-list li a:hover {
    background-color: #30363d;
}

body.dark-theme pre {
    background-color: #0d1117;
}

body.dark-theme .copy-btn {
    background: #21262d;
    border-color: #30363d;
    color: #c9d1d9;
}

body.dark-theme .copy-btn:hover, body.dark-theme .copy-btn:focus {
    background: #30363d;
}

body.dark-theme table th, body.dark-theme table td {
    border-color: #30363d;
}

body.dark-theme table tr:nth-child(2n) {
    background-color: #0d1117;
}

body.dark-theme blockquote {
    color: #8b949e;
    border-left-color: #30363d;
}

/* GitHub Alert Dark Mode Overrides */
body.dark-theme .markdown-alert-note { border-left-color: #2f81f7; }
body.dark-theme .markdown-alert-note .markdown-alert-title { color: #2f81f7; }

body.dark-theme .markdown-alert-tip { border-left-color: #3fb950; }
body.dark-theme .markdown-alert-tip .markdown-alert-title { color: #3fb950; }

body.dark-theme .markdown-alert-important { border-left-color: #a371f7; }
body.dark-theme .markdown-alert-important .markdown-alert-title { color: #a371f7; }

body.dark-theme .markdown-alert-warning { border-left-color: #d29922; }
body.dark-theme .markdown-alert-warning .markdown-alert-title { color: #d29922; }

body.dark-theme .markdown-alert-caution { border-left-color: #f85149; }
body.dark-theme .markdown-alert-caution .markdown-alert-title { color: #f85149; }

body.dark-theme .font-btn {
    color: #c9d1d9;
    border-color: #30363d;
}

body.dark-theme .font-btn:hover {
    background-color: #30363d;
}

body.dark-theme .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background-color: #fff;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    transition: left 0.3s ease;
    overflow-y: auto;
    z-index: 1000;
}

.side-menu.open {
    left: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e1e4e8;
    background-color: #f6f8fa;
}

.menu-header h2 {
    margin: 0;
    font-size: 16px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #586069;
}

#toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    margin-bottom: 20px;
}

#toc-list li a {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: #0366d6;
    border-bottom: 1px solid #f6f8fa;
    font-size: 14px;
}

#toc-list li a:hover {
    background-color: #f6f8fa;
    text-decoration: underline;
}

.container {
    max-width: 800px;
    margin: 30px auto;
    background: #fff;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.container a {
    color: #0969da;
    text-decoration: none;
}

.container a:hover {
    text-decoration: underline;
}

.lab-image-wrap {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 50%;
    margin: 1.25em 0;
}

.lab-image-wrap img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    margin: 0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-sizing: border-box;
}

.lab-image-wrap.is-expanded {
    width: 100%;
    max-width: 100%;
}

.lab-image-wrap.is-expanded img {
    width: 100%;
}

body.dark-theme .lab-image-wrap img {
    border-color: #6e7681;
}

.lab-image-zoom-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    color: rgba(15, 23, 42, 0.72);
    opacity: 0.42;
    cursor: pointer;
    box-shadow: none;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.lab-image-wrap.is-expanded .lab-image-zoom-btn {
    opacity: 0.7;
}

.lab-image-zoom-btn:hover,
.lab-image-zoom-btn:focus-visible {
    opacity: 0.95;
    background: rgba(255, 255, 255, 0.92);
    outline: none;
}

body.dark-theme .lab-image-zoom-btn {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.45);
    color: rgba(248, 250, 252, 0.85);
}

body.dark-theme .lab-image-zoom-btn:hover,
body.dark-theme .lab-image-zoom-btn:focus-visible {
    background: rgba(15, 23, 42, 0.8);
}

@media print {
    @page {
        size: letter;
        margin: 0.5in;
    }

    html,
    body,
    body.dark-theme {
        background-color: #ffffff !important;
        color: #333333 !important;
        font-size: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .toolbar,
    .side-menu,
    .modal-overlay,
    .copy-btn,
    .lab-image-zoom-btn {
        display: none !important;
    }

    #content.container,
    body.dark-theme #content.container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #333333 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
    }

    #content.container a,
    body.dark-theme #content.container a {
        color: #0969da !important;
    }

    pre,
    body.dark-theme pre {
        background-color: #f6f8fa !important;
        color: #24292f !important;
        border: 1px solid #d0d7de !important;
        padding: 14px 16px !important;
        white-space: pre-wrap !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        overflow-x: hidden !important;
        font-variant-ligatures: none !important;
        font-feature-settings: "liga" 0, "calt" 0 !important;
        break-inside: avoid;
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    code,
    pre code,
    pre code.hljs {
        font-variant-ligatures: none !important;
        font-feature-settings: "liga" 0, "calt" 0 !important;
    }

    pre code,
    pre code.hljs {
        white-space: pre-wrap !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        overflow-x: visible !important;
    }

    table,
    blockquote,
    .markdown-alert,
    .lab-image-wrap,
    img {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    h1, h2, h3, h4, h5, h6 {
        break-after: avoid;
        page-break-after: avoid;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    p,
    li {
        orphans: 3;
        widows: 3;
    }

    table th,
    table td,
    body.dark-theme table th,
    body.dark-theme table td {
        border-color: #d0d7de !important;
        color: #333333 !important;
    }

    table tr:nth-child(2n),
    body.dark-theme table tr:nth-child(2n) {
        background-color: #f6f8fa !important;
    }

    blockquote,
    body.dark-theme blockquote {
        color: #57606a !important;
        border-left-color: #d0d7de !important;
    }

    body.dark-theme .markdown-alert {
        color: #333333 !important;
    }
    body.dark-theme .markdown-alert-note { border-left-color: #0969da !important; }
    body.dark-theme .markdown-alert-note .markdown-alert-title { color: #0969da !important; }
    body.dark-theme .markdown-alert-tip { border-left-color: #1a7f37 !important; }
    body.dark-theme .markdown-alert-tip .markdown-alert-title { color: #1a7f37 !important; }
    body.dark-theme .markdown-alert-important { border-left-color: #8250df !important; }
    body.dark-theme .markdown-alert-important .markdown-alert-title { color: #8250df !important; }
    body.dark-theme .markdown-alert-warning { border-left-color: #9a6700 !important; }
    body.dark-theme .markdown-alert-warning .markdown-alert-title { color: #9a6700 !important; }
    body.dark-theme .markdown-alert-caution { border-left-color: #cf222e !important; }
    body.dark-theme .markdown-alert-caution .markdown-alert-title { color: #cf222e !important; }

    .lab-image-wrap img,
    body.dark-theme .lab-image-wrap img {
        border-color: #e0e0e0 !important;
        background-color: #ffffff !important;
        box-shadow: none !important;
    }
}

pre {
    background-color: #f6f8fa;
    padding: 16px;
    padding-top: 36px; /* Extra space for the copy button */
    border-radius: 6px;
    overflow-x: hidden;
    position: relative;
    white-space: pre-wrap; /* Wraps the code */
    overflow-wrap: break-word;
    word-break: normal;
}

pre code,
pre code.hljs {
    white-space: pre-wrap !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    overflow-x: visible !important;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #e1e4e8;
    border: 1px solid #d1d5da;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #24292e;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

pre:hover .copy-btn, .copy-btn:focus {
    opacity: 1;
}

.copy-btn:active {
    background-color: #d1d5da;
}

code {
    font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
    font-size: 85%;
}

blockquote {
    padding: 0 1em;
    color: #57606a;
    border-left: .25em solid #d0d7de;
    margin: 0;
    margin-bottom: 16px;
}

/* GitHub Alerts */
.markdown-alert {
    padding: 8px 16px;
    margin-bottom: 16px;
    color: inherit;
    border-left: .25em solid #d0d7de;
    background: transparent;
}
.markdown-alert-title {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}
.octicon {
    display: inline-block;
    overflow: visible !important;
    vertical-align: text-bottom;
    fill: currentColor;
    margin-right: 8px;
}

.markdown-alert-note { border-left-color: #0969da; }
.markdown-alert-note .markdown-alert-title { color: #0969da; }

.markdown-alert-tip { border-left-color: #1a7f37; }
.markdown-alert-tip .markdown-alert-title { color: #1a7f37; }

.markdown-alert-important { border-left-color: #8250df; }
.markdown-alert-important .markdown-alert-title { color: #8250df; }

.markdown-alert-warning { border-left-color: #9a6700; }
.markdown-alert-warning .markdown-alert-title { color: #9a6700; }

.markdown-alert-caution { border-left-color: #cf222e; }
.markdown-alert-caution .markdown-alert-title { color: #cf222e; }

h1, h2, h3, h4, h5, h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 16px;
}

table th, table td {
    padding: 6px 13px;
    border: 1px solid #d0d7de;
}

table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.error {
    color: #cf222e;
    background-color: #ffebe9;
    padding: 16px;
    border: 1px solid rgba(255,129,130,0.4);
    border-radius: 6px;
}
