/* Base styles */
body {
    font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 10.5pt;
    line-height: 1.5;
    color: #111;
    background: white;
    margin: 1.5cm;
    hyphens: none;
}

/* Headings */
h1, h2, h3 {
    font-weight: 600;
    color: #222;
    margin-top: 1em;
    margin-bottom: 0.3em;
    line-height: 1.2;
}

h1 {
    font-size: 22pt;
    border-bottom: 2px solid #ccc;
    padding-bottom: 0.3em;
}

h2 {
    font-size: 14pt;
    color: #444;
    line-height: 1.3;
}

h3 {
    font-size: 12pt;
    color: #555;
    line-height: 1.3;
}

/* Paragraphs */
p {
    margin: 0.5em 0;
}

/* Lists */
ul, ol {
    margin-top: 0.3em;
    margin-bottom: 0.6em;
    padding-left: 1.4em;
    list-style-position: outside;
}

li {
    margin-bottom: 0.25em;
    text-indent: 0;
}

/* Links */
a {
    color: #0366d6;
    text-decoration: none;
    white-space: nowrap;
    overflow-wrap: anywhere;
}

a:hover {
    text-decoration: underline;
}

@media screen {
    a::after {
        content: none;
    }
}

@media print {
    a {
        color: inherit;
    }
    a::after {
        content: " (" attr(href) ")";
        font-size: 8pt;
        color: #555;
    }

}

/* Horizontal rules */
hr {
    border: 0;
    border-top: 1px solid #ccc;
    margin: 2em 0;
}

/* Code blocks and inline code */
pre, code {
    font-family: Menlo, Monaco, Consolas, monospace;
    font-size: 10pt;
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

pre {
    padding: 1em;
    overflow-x: auto;
}

@media print {
    code, pre {
        background: transparent;
        border: 1px solid #999;
    }
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

th, td {
    border: 1px solid #ccc;
    padding: 0.4em 0.6em;
    font-size: 10pt;
    text-align: left;
    vertical-align: top;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
}

th {
    background: #f0f0f0;
}

/* Page breaks (for WeasyPrint) */
@page {
    margin: 2cm;
}

h1, h2, h3 {
    page-break-after: avoid;
}

p, ul, ol, table {
    page-break-inside: avoid;
}

/* Optional: Prevent orphans/widows */
p, li, a {
    orphans: 2;
    widows: 2;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #1e1e1e;
        color: #ddd;
    }

    h1, h2, h3 {
        color: #f0f0f0;
    }

    h1 {
        border-bottom: 2px solid #444;
    }

    h2 {
        color: #ccc;
    }

    h3 {
        color: #bbb;
    }

    a {
        color: #66aaff;
    }

    a:hover {
        text-decoration: underline;
    }

    hr {
        border-top: 1px solid #444;
    }

    code, pre {
        background: #2b2b2b;
        color: #f8f8f2;
    }

    @media print {
        code, pre {
            background: transparent;
            color: #000;
        }
    }

    table {
        background: #2a2a2a;
        border-color: #444;
    }

    th, td {
        border: 1px solid #444;
        color: #ddd;
    }

    th {
        background: #333;
    }

    tr:nth-child(even) td {
        background: #2e2e2e;
    }
}