/* Theme controls stay compact alongside the existing header navigation. */
html{color-scheme:light}
.theme-controls{display:inline-flex;align-items:center;gap:2px;flex:0 0 auto;padding:3px;border:1px solid #dfe5ee;border-radius:20px;background:#f4f6fa}
.theme-button{display:grid;place-items:center;width:32px;height:32px;padding:6px;border:0;border-radius:50%;background:transparent;color:#607995;cursor:pointer}
.theme-button svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.theme-button:hover{background:#e4ebf5;color:#1769cf}
.theme-button[aria-pressed=true]{background:#fff;color:#1769cf;box-shadow:0 1px 4px #1d3b5b22}
.theme-button:focus-visible{outline:2px solid #1769cf;outline-offset:2px}

html[data-theme=dark]{color-scheme:dark;--bg:#111827;--ink:#dce5f2;--muted:#a3b2c7;--line:#344155;--blue:#246bfe;--link:#80b5ff;--white:#1c2636;--navy:#131d2c;--theme-panel:#1c2636;--theme-soft:#243247;--theme-active:#2b4160}
html[data-theme=dark] body{background:var(--bg);color:var(--ink)}
html[data-theme=dark] .theme-controls{background:#111c2c;border-color:var(--line)}
html[data-theme=dark] .theme-button{color:#a9bad0}
html[data-theme=dark] .theme-button:hover{background:var(--theme-soft);color:#c8ddff}
html[data-theme=dark] .theme-button[aria-pressed=true]{background:#344c6d;color:#f0d89a}
html[data-theme=dark] .theme-button:focus-visible{outline-color:#80b5ff}

/* Public documentation, header, menus and member forms. */
html[data-theme=dark] :is(.topbar,.content,.home-card,.profile-card,.account-dropdown,.login-required-dialog){background:var(--theme-panel);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] :is(.brand,.article h1,.home-panel h1,.category-article b,.profile-card h1,.profile-card h2){color:#e9f0fb}
html[data-theme=dark] :is(.topnav a,.tree-article,.home-card,.category-article,.profile-form label,.login-required-dialog p){color:#b7cee9}
html[data-theme=dark] .ticket-readonly-notice{background:#152031;color:#a3b2c7;border-color:var(--line)}
html[data-theme=dark] :is(.doc-layout,.sidebar,.category-count,.category-article,.profile-card hr){border-color:var(--line)}
html[data-theme=dark] :is(.side-title,.content-meta,.home-intro,.category-count,.category-article span,.tree-search-status,.tree-empty,.member-summary,.profile-avatar small){color:var(--muted)}
html[data-theme=dark] :is(.tree-row em,.member-divider){color:#a3b2c7}
html[data-theme=dark] :is(.member-summary b,.folder-link:hover,.topnav a:hover){color:var(--link)}
html[data-theme=dark] :is(.tree-row:hover,.tree-article:hover,.home-card:hover,.category-article:hover){background:var(--theme-soft);color:#b9d7ff}
html[data-theme=dark] .tree-article.active{background:var(--theme-active);color:#b9d7ff}
html[data-theme=dark] .tree-toggle{color:#e0bc67}
html[data-theme=dark] .article-body{color:var(--ink)}
html[data-theme=dark] .article-body :is(td,th){border-color:var(--line)}
html[data-theme=dark] .article-body pre{background:#111c2c;color:var(--ink)}
html[data-theme=dark] .article-body a{color:var(--link)}
html[data-theme=dark] .empty{background:#342d20;border-color:#6f5a32;color:#eddcb6}
html[data-theme=dark] .account-dropdown a{color:var(--ink)!important}
html[data-theme=dark] .account-dropdown a:hover{background:var(--theme-soft)}
html[data-theme=dark] .account-dropdown .account-username{color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(.search input,.profile-form input,.panel input,.panel select,.panel textarea,.auth-box input,.editor-link-dialog input,.editor-link-dialog select){background:#131f30;color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(input,textarea)::placeholder{color:#93a5bd;opacity:1}
html[data-theme=dark] :is(.login-required-actions button,.link-dialog-actions button){background:var(--theme-soft);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(.login-required-actions button:hover,.link-dialog-actions button:hover){background:var(--theme-active)}
html[data-theme=dark] :is(.login-required-dialog,.editor-link-dialog)::backdrop{background:#050b16aa}

/* Keep authored color charts on their original paper, including swatch values.
   Ordinary black legacy text inherits the reading color; images are never filtered. */
html[data-theme=dark] .article-body [data-theme-plain-text]{color:var(--ink)!important}
html[data-theme=dark] .article-body table:not([bgcolor]):not([style*="background" i]):has([bgcolor]){background:#fff;color:#202a39;color-scheme:light}
html[data-theme=dark] .article-body table:has([bgcolor]) :is(td,th){border-color:#dbe2eb}

/* Administration shell. The editing canvas retains publication colors. */
html[data-theme=dark] :is(.panel,.auth-box,.admin-stats div,.editor-link-dialog){background:var(--theme-panel);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] .auth{background:linear-gradient(135deg,#0e1828,#25364d)}
html[data-theme=dark] :is(.category-line>a,.admin-category.depth-1 .category-line>a,.category-articles a,.ticket-admin-list b,.install-box h3){color:#b7cee9}
html[data-theme=dark] :is(.admin-category,.category-children,.member-list>div,.article-admin-list>div,.ticket-admin-list>a,.cats li){border-color:var(--line)}
html[data-theme=dark] :is(.category-line small,.category-line button,.editor-tools label,.category-move-actions label){color:var(--muted)}
html[data-theme=dark] :is(.editor-tools button,.category-actions button,.category-move-actions button){background:var(--theme-soft);color:#b9d7ff;border-color:var(--line)}
html[data-theme=dark] .editor-upload{background:var(--theme-soft);color:#b9d7ff!important}
html[data-theme=dark] :is(.category-actions .danger,.actions button){background:#382a31;color:#ffaaaa;border-color:#70434b}
html[data-theme=dark] .visual-editor{background:#fff;color:#243246;color-scheme:light}
html[data-theme=dark] :is(.auth-box button,.link-dialog-actions button[type=submit]){background:#2567d5;color:#fff}
html[data-theme=dark] :is(.auth-box a,.panel-title a,.actions a,.category-actions .category-publish,.category-line .add-child-category,.admin-stats b){color:var(--link)}
html[data-theme=dark] :is(.notice,.ticket-notice,.profile-card .ticket-notice){background:#203b58;color:#b0d4ff;border-color:#395e87}
html[data-theme=dark] :is(.error,.ticket-notice.error,.profile-card .ticket-notice.error){background:#3c2831;color:#ffb0b0;border-color:#70434b}
html[data-theme=dark] :is(.editor-upload-status.is-error,.link-error,.category-articles button){color:#ffaaaa}
html[data-theme=dark] .editor-upload-status{color:#93d9b5}
html[data-theme=dark] .category-articles .article-move-trigger{color:var(--link)}

/* Ticket windows, conversation bubbles and upload/emoji controls. */
html[data-theme=dark] :is(.ticket-grid,.chat-shell,.chat-title,.chat-compose,.emoji-picker,.ticket-close){background:var(--theme-panel);border-color:var(--line);color:var(--ink)}
html[data-theme=dark] :is(.ticket-head h1,.new-ticket h2,.chat-title b){color:#e9f0fb}
html[data-theme=dark] :is(.ticket-list,.chat-messages){background:#152031;border-color:var(--line)}
html[data-theme=dark] .ticket-item{color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(.admin-link,.back-tickets,.eyebrow){color:var(--link)}
html[data-theme=dark] :is(.ticket-item:hover,.ticket-item.selected,.emoji-picker button:hover,.ticket-close:hover){background:var(--theme-active)}
html[data-theme=dark] :is(.list-title,.new-ticket label){color:#b7cee9}
html[data-theme=dark] :is(.new-ticket input,.new-ticket textarea,.chat-compose textarea){background:#131f30;color:var(--ink);border-color:var(--line)}
html[data-theme=dark] .chat-compose textarea{background:transparent}
html[data-theme=dark] .bubble{background:#2b3a4f;color:#e4edf9}
html[data-theme=dark] .from-user .bubble{background:#26496d;color:#e4edf9}
html[data-theme=dark] .from-admin .message-meta b{color:#ff7d87}
html[data-theme=dark] .status-open{color:#f1b565}
html[data-theme=dark] .status-answered{color:#79d9a5}
html[data-theme=dark] .emoji-picker button{background:var(--theme-panel)}
html[data-theme=dark] :is(.compose-tools .image-button,.ticket-state-button){background:var(--theme-soft);color:#b9d7ff!important;border-color:#465c78}
html[data-theme=dark] .ticket-delete{background:#382a31;color:#ffaaaa;border-color:#70434b}
html[data-theme=dark] .ticket-delete:hover{background:#51323c}
html[data-theme=dark] .ticket-closed-notice{background:#342d20;color:#eddcb6;border-color:#6f5a32}
html[data-theme=dark] .popup-mode{background:#050b16aa}

@media(max-width:560px){.theme-button{width:30px;height:30px}.theme-controls{padding:2px}.topnav{flex-wrap:wrap;justify-content:flex-end}}
