/* Shared finishing layer. Keep page structure and selected themes intact. */
:root {
    --ui-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ui-focus: #5eead4;
}
body { -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
:is(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--ui-focus);
    outline-offset: 3px;
}
button:disabled { cursor: not-allowed; }
[data-theme="vintage"] { --ui-focus: var(--accent); }
.pn-search-row input:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 3px; }

/* Entry and account screens */
.auth-shell, .profile-shell {
    --ui-surface: var(--panel, #101823);
    --ui-ink: var(--text, #e8eef4);
    --ui-secondary: color-mix(in srgb, var(--text) 68%, var(--bg));
    --ui-link: var(--accent);
    --ui-button-ink: #fff;
    min-height: 100svh;
    padding: 48px 24px;
    font-family: var(--ui-font);
}
[data-theme="bioluminescence"] :is(.auth-shell, .profile-shell) {
    --ui-surface: #101923;
    --ui-ink: #e8eef4;
    --ui-secondary: #a4b3c3;
    --ui-link: #5eead4;
    --ui-button-ink: #06241e;
}
[data-theme="radioactive"] :is(.auth-shell, .profile-shell) { --ui-button-ink: #101900; }
[data-theme="sunset"] :is(.auth-shell, .profile-shell),
[data-theme="monochrome"] :is(.auth-shell, .profile-shell) { --ui-button-ink: #2a0a10; }
[data-theme="vintage"] .auth-form input::placeholder { color: #756553 !important; opacity: 1; }
.auth-card, .profile-card {
    max-width: 460px;
    padding: 36px;
    background: var(--ui-surface);
    color: var(--ui-ink);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 70px rgba(0,0,0,.16), 0 1px 0 rgba(255,255,255,.025) inset;
}
.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 28px;
    color: var(--ui-ink);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.025em;
    text-decoration: none;
}
.auth-brand::before {
    content: "+";
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--ui-link) 12%, transparent);
    color: var(--ui-link);
    font-size: 22px;
    font-weight: 500;
}
.auth-card h1, .profile-card h1 {
    margin: 0 0 10px;
    font-size: clamp(25px, 3vw, 30px);
    line-height: 1.22;
    letter-spacing: -.035em;
    color: var(--ui-ink);
    overflow-wrap: anywhere;
}
.auth-description {
    margin: 0 0 26px;
    color: var(--ui-secondary);
    font-size: 14px;
    line-height: 1.65;
}
.auth-form { margin-top: 24px; gap: 10px; }
.auth-form > label {
    margin: 8px 0 0;
    color: var(--ui-ink);
    font-size: 13px;
    font-weight: 550;
}
.auth-form input:not([type="checkbox"]):not([type="hidden"]) {
    min-width: 0;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--ui-ink);
    font-size: 15px;
    transition: border-color .16s, box-shadow .16s;
}
.auth-form input::placeholder { color: var(--ui-secondary); opacity: .75; }
.auth-form input:focus { border-color: var(--ui-link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-link) 10%, transparent); }
.auth-form input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    padding: 0;
    accent-color: var(--ui-link);
}
.auth-form .checkbox-label { color: var(--ui-secondary) !important; line-height: 1.55; }
.auth-form button, .profile-card .primary-link {
    min-height: 46px;
    margin-top: 10px;
    border-radius: 10px;
    padding: 12px 16px;
    background: var(--ui-link);
    color: var(--ui-button-ink);
    font-size: 14px;
    font-weight: 650;
    transition: filter .16s, box-shadow .16s;
}
.auth-form button:hover, .profile-card .primary-link:hover { filter: brightness(1.08); box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.auth-link-row { font-size: 13px; line-height: 1.65; margin: 20px 0 0; color: var(--ui-secondary); }
.auth-card a:not(.auth-brand) { color: var(--ui-link); text-decoration: none; text-underline-offset: 3px; }
.auth-card a:not(.auth-brand):hover { text-decoration: underline; }
.auth-error { font-size: 14px; line-height: 1.6; border-radius: 10px; }
.auth-notice { background: color-mix(in srgb, var(--ui-link) 8%, transparent); border-color: color-mix(in srgb, var(--ui-link) 28%, transparent); color: var(--ui-link); }
.profile-row { display: flex; justify-content: space-between; gap: 20px; padding: 15px 0; margin: 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; font-size: 14px; }
.profile-row strong { color: var(--ui-secondary); font-weight: 500; }
.profile-card .primary-link { margin: 0; }
.profile-card .secondary-link { font-size: 14px; border-radius: 10px; }

/* Legal content has the same contrast in every theme and one page scrollbar. */
.auth-card.legal-card { max-width: 820px; text-align: left; }
.legal-card h1 { font-size: clamp(24px, 3vw, 32px); }
.legal-content { margin: 28px 0; color: var(--ui-ink); font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.legal-content h2 { margin: 30px 0 12px; font-size: 18px; line-height: 1.4; letter-spacing: -.015em; }
.legal-content p { margin: 0 0 14px; }
.legal-content ul { padding-left: 22px; }
.legal-content li { margin-bottom: 8px; }
.legal-footer { border-top: 1px solid var(--border); padding-top: 4px; }
.legal-meta { font-size: 12px; color: var(--ui-secondary); margin-top: 16px; line-height: 1.65; }

/* Common library, reports and help shell */
.pn-app { font-family: var(--ui-font); }
.pn-main { min-width: 0; padding-top: 40px; }
.pn-page-head { margin-bottom: 28px; }
.pn-page-head h1 { font-size: clamp(24px, 2.5vw, 30px); letter-spacing: -.03em; line-height: 1.25; }
.pn-page-sub { line-height: 1.7; margin-top: 10px; max-width: 76ch; color: #a2b2c4; }
.pn-card { border-color: #233141; box-shadow: 0 4px 20px rgba(0,0,0,.07); }
.pn-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; border-radius: 9px; line-height: 1.4; }
.pn-search-row { min-width: 0; align-items: center; }
.pn-search-row input { min-width: 0; width: 0; min-height: 42px; }
.pn-search-row .pn-btn { flex-shrink: 0; min-height: 42px; }
.pn-search-row input::placeholder { color: #899db2; }
.pn-muted, .pn-doc-chunks, .research-date, .pn-reader-footer { color: #95a7bc; }
.pn-stat { margin-left: 0; margin-right: 12px; line-height: 1.6; }
.research-list { grid-template-columns: repeat(auto-fill,minmax(min(100%,300px),1fr)); }
.research-card-top { flex-wrap: wrap; row-gap: 6px; }
.research-title, .pn-doc-name, .lib-doc-title { overflow-wrap: anywhere; }
.pn-empty { max-width: 620px; margin: 7vh auto 0; padding: 28px 12px; }
.pn-empty h2 { color: #e8eef4; letter-spacing: -.025em; font-size: 23px; }
.pn-empty p { line-height: 1.7; }
.pn-reader-content { line-height: 1.8; overflow-wrap: anywhere; }
.pn-reader-content h2 { font-size: 21px; margin-top: 1.8em; }
.pn-reader-content h3 { font-size: 17px; margin-top: 1.6em; }
.pn-reader-content a { color: #5eead4; text-underline-offset: 3px; }
.pn-reader-content table { display: block; max-width: 100%; overflow-x: auto; }
.pn-reader-content :is(th,td) { min-width: 140px; overflow-wrap: normal; word-break: normal; }
.pn-reader-content pre { max-width: 100%; overflow-x: auto; }
.pn-help .pn-card { scroll-margin-top: 24px; }
.pn-help .pn-card h2 { font-size: 20px; letter-spacing: -.02em; line-height: 1.4; }
.pn-help .tool-meta { color: #95a7bc; }
.pn-help table { display: block; max-width: 100%; overflow-x: auto; line-height: 1.65; }
.pn-help .help-toc { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,245px),1fr)); gap: 8px 18px; font-size: 13.5px; line-height: 1.7; }
.pn-help .help-toc a { text-decoration: none; border-radius: 6px; padding: 3px 0; }
.pn-help .help-toc a:hover { text-decoration: underline; text-underline-offset: 3px; }
.pn-rail { width: 76px; padding-inline: 4px; }
.pn-rail-item { width: 66px; min-height: 58px; justify-content: center; gap: 7px; }
.pn-rail-label { max-width: 100%; font-size: 10px; line-height: 1.3; overflow-wrap: anywhere; text-align: center; }
.pn-app { padding-left: 76px; }
.pn-rail-icon svg { width: 20px; height: 20px; display: block; }
.pn-rail-item[aria-current="page"] { font-weight: 600; }
.rail-research .pn-rail-label { font-size: 9px; letter-spacing: -.15px; }
.pn-toast-wrap { max-width: calc(100vw - 32px); }
.pn-cmdk-item .k { color: #9aadc1; }
.pn-app .lib-docs { grid-template-columns: repeat(auto-fill,minmax(min(100%,340px),1fr)); }
.pn-app .lib-doc-item { min-width: 0; }
.pn-app .lib-doc-frag, .pn-app .lib-topic-count { color: #94a7bc; }
.profile-row span { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 768px) {
    .pn-main { padding: 26px 16px 76px; }
    .pn-rail { width: 60px; }
    .pn-rail-item { width: 52px; min-height: 56px; }
    .pn-rail-label { font-size: 9px; }
    .rail-research .pn-rail-label { font-size: 8px; letter-spacing: -.3px; }
    .pn-app { padding-left: 60px; }
    .pn-card { padding: 18px 16px; border-radius: 13px; }
    .pn-page-head h1 { font-size: 24px; }
    .pn-card-head { align-items: flex-start; }
    .pn-reader { padding: 22px 18px; }
    .pn-help .tool-sub { padding: 14px; }
    .pn-help .pn-card h2 { font-size: 18px; }
    .pn-help table { font-size: 12px !important; }
    .pn-help th, .pn-help td { min-width: 95px; }
    .pn-empty { margin-top: 24px; padding: 16px 0; }
    .theme-switcher { right: 14px; bottom: 14px; }
    .pn-app .lib-doc-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
    .pn-app .lib-doc-kind { width: fit-content; }
    .pn-app .lib-doc-title { grid-column: 1 / -1; grid-row: 2; }
    .pn-app .lib-doc-frag { grid-column: 2; grid-row: 1; }
    .pn-stat-row { display: flex; flex-wrap: wrap; gap: 5px; }
    .pn-search-row:has(#pn-cat-filter) { flex-wrap: wrap; }
    #pn-cat-filter { flex: 1 1 100%; width: 100%; }
    #pn-cat-count { font-size: 11px; }
}
@media (max-width: 480px) {
    .auth-shell, .profile-shell { padding: 28px 18px 80px; }
    .auth-card, .profile-card { padding: 28px 24px; border-radius: 16px; }
    .auth-brand { margin-bottom: 24px; }
    .auth-form input:not([type="checkbox"]):not([type="hidden"]) { font-size: 16px; }
    .auth-card.legal-card { padding: 26px 22px; }
    .legal-content { font-size: 14px; }
    .profile-row { flex-wrap: wrap; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
    .pn-rail, .theme-switcher, .pn-reader-actions, .auth-brand { display: none !important; }
    .pn-app { padding: 0; background: white; }
    .pn-main, .pn-reader { max-width: none; padding: 0; border: 0; box-shadow: none; }
    .pn-reader, .pn-reader-content, .pn-reader-content h1, .pn-reader-content h2, .pn-reader-content h3, .legal-content { background: white; color: black; }
}
