/* Print Daemon docs portal. Plain CSS, no inline styles anywhere (strict CSP).
   Theming follows the shared contract (labelviewer docs/styling.md): public --pd-* tokens with the shared base names, light
   defaults and dark defaults (prefers-color-scheme). Colours appear only inside the token blocks; docs/build.mjs fails the build
   on a colour literal anywhere else. */
/* tokens:start */
:root {
    color-scheme: light dark;
    --pd-accent: #1f5fd6;
    --pd-accent-hover: #194fb3;
    --pd-accent-soft: #eaf1fd;
    --pd-accent-text: #ffffff;
    --pd-bg: #f7f8fa;
    --pd-surface: #ffffff;
    --pd-text: #1b2330;
    --pd-muted: #5b6676;
    --pd-border: #e1e5ea;
    --pd-border-strong: #cdd3db;
    --pd-danger: #c4282d;
    --pd-ok: #18794e;
    --pd-warn: #915b00;
    --pd-warn-soft: #fdf3e1;
    --pd-code-bg: #f2f4f7;
    --pd-radius: 8px;
    --pd-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --pd-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --pd-accent: #6ea0ff;
        --pd-accent-hover: #8fb5ff;
        --pd-accent-soft: #1d2b45;
        --pd-accent-text: #0d1117;
        --pd-bg: #11151c;
        --pd-surface: #181d26;
        --pd-text: #e4e8ee;
        --pd-muted: #9aa5b4;
        --pd-border: #2a313d;
        --pd-border-strong: #3a4352;
        --pd-danger: #ff7b7b;
        --pd-ok: #4cc38a;
        --pd-warn: #e5a83b;
        --pd-warn-soft: #2e2617;
        --pd-code-bg: #1f2530;
    }
}
/* tokens:end */

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-padding-top: 64px;
}

body {
    margin: 0;
    font-family: var(--pd-font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--pd-text);
    background: var(--pd-surface);
}

a {
    color: var(--pd-accent);
}

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

:focus-visible {
    outline: 2px solid var(--pd-accent);
    outline-offset: 2px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 24px;
    background: var(--pd-surface);
    border-bottom: 1px solid var(--pd-border);
}

.brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--pd-text);
    text-decoration: none;
}

.version {
    font-size: 12px;
    color: var(--pd-muted);
}

.layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    max-width: 1280px;
    margin: 0 auto;
}

.sidebar {
    position: sticky;
    top: 49px;
    align-self: start;
    max-height: calc(100vh - 49px);
    overflow-y: auto;
    padding: 20px 16px 20px 24px;
    font-size: 14px;
    border-right: 1px solid var(--pd-border);
}

.sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pages > li {
    margin-bottom: 6px;
}

.pages > li > a {
    display: block;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--pd-text);
    font-weight: 600;
    text-decoration: none;
}

.pages > li > a:hover {
    background: var(--pd-bg);
}

.pages > li > a[aria-current=page] {
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
}

.toc {
    margin: 4px 0 8px 8px;
    border-left: 2px solid var(--pd-border);
}

.toc a {
    display: block;
    padding: 1px 0 1px 10px;
    color: var(--pd-muted);
    text-decoration: none;
}

.toc a:hover {
    color: var(--pd-accent);
}

.content {
    padding: 24px 40px 48px;
    max-width: 960px;
}

h1, h2, h3, h4 {
    line-height: 1.25;
    scroll-margin-top: 64px;
}

h1 {
    font-size: 30px;
    margin: 8px 0 16px;
}

h2 {
    font-size: 22px;
    margin: 36px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--pd-border);
}

h3 {
    font-size: 17px;
    margin: 28px 0 8px;
}

h4 {
    font-size: 15px;
    margin: 20px 0 6px;
}

.anchor {
    margin-left: 8px;
    color: var(--pd-border-strong);
    text-decoration: none;
    font-weight: 400;
}

h2:hover .anchor, h3:hover .anchor, h4:hover .anchor {
    color: var(--pd-muted);
}

code {
    font-family: var(--pd-mono);
    font-size: 0.88em;
    padding: 1px 4px;
    background: var(--pd-code-bg);
    border-radius: 4px;
    overflow-wrap: anywhere;
}

.code-block {
    position: relative;
    margin: 12px 0 16px;
}

.code-block pre {
    margin: 0;
    padding: 32px 16px 14px;
    overflow-x: auto;
    background: var(--pd-code-bg);
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    line-height: 1.45;
    tab-size: 4;
}

.code-block pre code {
    padding: 0;
    background: none;
    font-size: 13px;
    overflow-wrap: normal;
}

.code-block .lang {
    position: absolute;
    top: 6px;
    right: 84px;
    font-size: 11px;
    color: var(--pd-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    pointer-events: none;
}

.copy {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 1;
    min-width: 62px;
    padding: 2px 10px;
    font: 600 12px var(--pd-font);
    color: var(--pd-text);
    background: var(--pd-surface);
    border: 1px solid var(--pd-border);
    border-radius: 6px;
    cursor: pointer;
}

.copy:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

.copy[data-state=copied] {
    color: var(--pd-ok);
    border-color: var(--pd-ok);
}

.copy[data-state=failed] {
    color: var(--pd-danger);
    border-color: var(--pd-danger);
}

table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 12px 0 16px;
    font-size: 14px;
}

th, td {
    padding: 6px 10px;
    border: 1px solid var(--pd-border);
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--pd-bg);
}

/* Field and command names in the first column stay on one line. */
td:first-child code {
    white-space: nowrap;
    overflow-wrap: normal;
}

blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    color: var(--pd-text);
    background: var(--pd-warn-soft);
    border-left: 4px solid var(--pd-warn);
    border-radius: 0 6px 6px 0;
}

blockquote p {
    margin: 4px 0;
}

/* The Status page (status.md, status.js). */
.notice {
    margin: 12px 0 16px;
    padding: 12px 16px;
    background: var(--pd-accent-soft);
    border-left: 4px solid var(--pd-accent);
    border-radius: 0 6px 6px 0;
}

.notice p {
    margin: 0;
}

table.status th {
    white-space: nowrap;
}

table.status td[data-state=ok] {
    color: var(--pd-ok);
    font-weight: 600;
}

table.status td[data-state=warn] {
    color: var(--pd-warn);
    font-weight: 600;
}

table.status td[data-state=error] {
    color: var(--pd-danger);
    font-weight: 600;
}

.refresh {
    font: inherit;
    font-size: 14px;
    padding: 4px 12px;
    border: 1px solid var(--pd-border-strong);
    border-radius: 6px;
    background: var(--pd-bg);
    color: var(--pd-text);
    cursor: pointer;
}

.refresh:hover {
    border-color: var(--pd-accent);
}

.refresh:disabled {
    cursor: progress;
    opacity: 0.6;
}

.footer {
    padding: 16px 24px;
    font-size: 12px;
    color: var(--pd-muted);
    border-top: 1px solid var(--pd-border);
}

@media (max-width: 860px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: static;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--pd-border);
    }

    .content {
        padding: 16px 20px 40px;
    }
}
