/* Shared switch; the existing light palette is unchanged. */
.app-header.public-site-header { flex-direction: row; align-items: center; }
.app-header .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 62px;
    gap: 8px;
    width: 62px;
    height: 30px;
    min-height: 30px;
    margin-left: auto;
    padding: 4px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #ccc;
    box-shadow: none;
}
.app-header .theme-toggle[hidden] { display: none; }
.theme-toggle > i { width: 14px; font-size: 13px; text-align: center; }
.theme-switch-track { position: relative; width: 30px; height: 18px; border: 1px solid #666; border-radius: 10px; background: #333; }
.theme-switch-track::before { content: ''; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #ddd; }
.theme-toggle[aria-checked="true"] .theme-switch-track { background: var(--amber); border-color: var(--amber); }
.theme-toggle[aria-checked="true"] .theme-switch-track::before { left: 14px; background: #161616; }
.app-header .theme-toggle:hover { background: #292929; color: var(--amber); }
.app-header .theme-toggle:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e4e4e4;
    --muted: #b0b0b0;
    --soft: #252525;
    --paper: #111;
    --panel: #1d1d1d;
    --line: #404040;
    --teal-dark: #ffb65b;
    --theme-base: #151515;
    --theme-panel: #1d1d1d;
    --theme-raised: #262626;
    --theme-hover: #323232;
    --theme-border: #444;
    --theme-icon: #a3a3a3;
    --theme-green: #8bc99b;
    --theme-red: #f08f87;
}
html[data-theme="dark"] body { color: var(--ink); }
html[data-theme="dark"] :is(input, textarea, select) { color: var(--ink); background: #141414; border-color: var(--theme-border); caret-color: var(--ink); }
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #929292; opacity: 1; }
html[data-theme="dark"] :is(input, textarea, select):focus { border-color: var(--amber); }
html[data-theme="dark"] :is(input[type="checkbox"], input[type="radio"], progress) { accent-color: var(--amber); }
html[data-theme="dark"] :is(.panel-section, .panel-card, .package-card, .form-panel, .setup-card, .account-summary, .auth-card, .login-gateway, .home-packages .package-card) {
    background: var(--theme-panel); color: var(--ink); border-color: var(--theme-border);
}
html[data-theme="dark"] :is(.free-flow, .gateway-forms, .login-band, .hosted-preview-shell) { background: var(--theme-base); }
html[data-theme="dark"] :is(.control-card, .table-list div, .file-row, .pill-row span) { background: var(--theme-panel); color: var(--ink); }
html[data-theme="dark"] :is(.auth-card, .login-gateway, .package-card, .form-panel, .setup-card) :is(h2, h3, label, strong) { color: var(--ink); }
html[data-theme="dark"] :is(.auth-card, .login-gateway, .package-card) :is(.muted, .field-subtitle) { color: var(--muted); }
html[data-theme="dark"] :is(.login-gateway, .auth-card, .panel-card, .package-card) a:not(.button):hover { color: #ffc47d !important; }
html[data-theme="dark"] :is(.review-badge, .card-heading span) { background: #342819; color: #ffc47d; }
html[data-theme="dark"] .signup-form button:disabled { background: #333; border-color: #444; color: #aaa; opacity: 1; }
html[data-theme="dark"] .setup-page .auth-card .signup-status.is-good { color: var(--theme-green) !important; }
html[data-theme="dark"] .setup-page .auth-card .signup-status.is-bad { color: var(--theme-red) !important; }
html[data-theme="dark"] .setup-page .auth-card .signup-status.is-checking { color: #ffc47d !important; }

/* Sidebar and tool surfaces retain their light-mode geometry. */
html[data-theme="dark"] .folder-tree { background: #202020; border-color: var(--theme-border); }
html[data-theme="dark"] .control-panel-page .folder-tree a { color: #c5c5c5; }
html[data-theme="dark"] .control-panel-page .folder-tree a:is(:hover, .active) { color: #f1f1f1; background: var(--theme-hover); border-color: #505050; }
html[data-theme="dark"] .control-panel-page .folder-tree a > i { color: var(--theme-icon); }
html[data-theme="dark"] .control-panel-page .folder-tree a > span { color: inherit; }
html[data-theme="dark"] .control-panel-page .folder-tree .sidebar-account p { color: var(--muted); }
html[data-theme="dark"] .control-panel-page .sidebar-site-list [data-site-status="online"] > .sidebar-site-state { color: var(--theme-green); }
html[data-theme="dark"] .control-panel-page .sidebar-site-list [data-site-status="private"] > .sidebar-site-state { color: #b8b8b8; }
html[data-theme="dark"] .control-panel-page .sidebar-site-list [data-site-status="offline"] > .sidebar-site-state { color: var(--theme-red); }
html[data-theme="dark"] .folder-tree a::before,
html[data-theme="dark"] .folder-tree a::after { background: #555; }
html[data-theme="dark"] .control-panel-page .workspace-pane { background: var(--theme-base); }
html[data-theme="dark"] .control-panel-page .workspace-pane::before { filter: none; opacity: .12; }
html[data-theme="dark"] .control-panel-page .workspace-pane-title h1 { color: #ccc; }
html[data-theme="dark"] .control-panel-page .workspace-pane-title h1 i { color: var(--theme-icon); }
html[data-theme="dark"] .control-panel-page .control-workspace :is(.panel-card, .site-overview, .file-explorer) {
    background: var(--theme-panel); color: var(--ink); border-color: var(--theme-border);
}
html[data-theme="dark"] .control-panel-page .workspace-pane :is(h3, label, strong, dt, dd) { color: #d5d5d5; }
html[data-theme="dark"] .control-panel-page .workspace-pane .table-list strong { color: #d5d5d5; }
html[data-theme="dark"] .control-panel-page .workspace-pane :is(p, span, small, .muted, legend) { color: var(--muted); }
html[data-theme="dark"] .control-panel-page .workspace-pane :is(.overview-metric-heading h3, .database-form-heading h3) { color: #d5d5d5; }
html[data-theme="dark"] .control-panel-page .workspace-pane :is(.overview-metric-heading i, .site-admin-member > i) { color: var(--theme-icon); }
html[data-theme="dark"] .control-panel-page .workspace-pane :is(.overview-identity a, .overview-metric-heading a, .settings-links a, .database-name-link) { color: #bcbcbc; }
html[data-theme="dark"] .control-panel-page .workspace-pane :is(.overview-header, .overview-metric, .visibility-options, .overview-visibility label, .site-admin-controls, .domain-controls, .settings-controls, .database-form-heading) { border-color: var(--theme-border); }
html[data-theme="dark"] :is(.site-admin-heading, .domain-heading, .settings-heading, .database-window .db-access-heading, .database-window .db-heading-actions) { background: var(--theme-raised); border-color: var(--theme-border); }
html[data-theme="dark"] .database-window .database-access-layout { background: #1a1a1a; }
html[data-theme="dark"] .database-window .db-window-statusbar { background: var(--theme-raised); color: var(--muted); }
html[data-theme="dark"] .database-window .database-user-divider { background: var(--theme-border); }
html[data-theme="dark"] .control-panel-page .workspace-pane .access-ready { color: var(--theme-green) !important; }
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions a,
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions a i { color: #d5d5d5; }
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions .database-action-tab:is(:hover, .active),
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions .database-action-tab:is(:hover, .active) :is(i, span) { color: var(--amber) !important; }
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions .phpmyadmin-button,
html[data-theme="dark"] .control-panel-page .workspace-pane form:not(.fe-inline-form) > :is(button.primary, button[type="submit"]),
html[data-theme="dark"] .control-panel-page .workspace-pane .panel-navigation-message button {
    background: #333; color: #e0e0e0; border-color: #555;
}
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions .phpmyadmin-button:hover,
html[data-theme="dark"] .control-panel-page .workspace-pane form:not(.fe-inline-form) > :is(button.primary, button[type="submit"]):hover {
    background: var(--amber); color: #111; border-color: var(--amber);
}
html[data-theme="dark"] .control-panel-page .database-window .db-heading-actions .phpmyadmin-button:hover i { color: #111; }
html[data-theme="dark"] .control-panel-page .workspace-pane form:not(.fe-inline-form) :is(input, textarea, select),
html[data-theme="dark"] .control-panel-page .workspace-pane form:not(.fe-inline-form) :is(input, textarea, select):is(:hover, :focus) {
    background: #141414; color: var(--ink); border-color: var(--theme-border); caret-color: var(--ink);
}
html[data-theme="dark"] .control-panel-page .workspace-pane .site-create-card button:disabled { background: #2a2a2a; border-color: #404040; color: #929292; }
html[data-theme="dark"] .control-panel-page .workspace-pane [data-new-site-status][data-state="available"] { color: var(--theme-green); }
html[data-theme="dark"] .control-panel-page .workspace-pane [data-new-site-status]:is([data-state="unavailable"], [data-state="error"]),
html[data-theme="dark"] .control-panel-page .workspace-pane .site-create-card [data-site-create-error] { color: var(--theme-red); }
html[data-theme="dark"] .control-panel-page .overview-visibility label span { background: #262626; color: #c5c5c5; }
html[data-theme="dark"] .control-panel-page .overview-visibility input:checked + span { background: #484848; color: #fff; }
html[data-theme="dark"] .control-panel-page .workspace-pane .site-admin-member button { background: transparent; color: #bbb; border-color: transparent; }
html[data-theme="dark"] .control-panel-page .workspace-pane .site-admin-member button:hover { background: #333; color: #fff; border-color: #555; }
html[data-theme="dark"] :is(.overview-storage-meter, .control-panel-page .panel-card:not(.database-window) .storage-bar) { background: #393939; }
html[data-theme="dark"] .overview-storage-meter::-webkit-meter-bar { background: #393939; }

/* Keep masked input glyphs transparent; only dots and the last typed character are visible. */
html[data-theme="dark"] .control-panel-page .workspace-pane .database-window .database-login-form input.password-mask-enhanced,
html[data-theme="dark"] .control-panel-page .database-window .password-mask-glyph { color: transparent; }
html[data-theme="dark"] .control-panel-page .database-window input.password-mask-enhanced::selection { background: #494949; color: transparent; }
html[data-theme="dark"] .database-window .password-mask-glyph::after,
html[data-theme="dark"] .control-panel-page .database-window .password-mask-glyph.is-revealed { color: var(--ink); }

/* File explorer, including transient rename, drag/drop and confirmation states. */
html[data-theme="dark"] .file-explorer :is(.fe-pathbar, .fe-toolbar, .fe-statusbar) { background: var(--theme-raised); border-color: var(--theme-border); color: var(--muted); }
html[data-theme="dark"] .file-explorer :is(.fe-breadcrumbs a, .fe-file-name, .fe-table, .fe-table th a) { color: #d0d0d0; }
html[data-theme="dark"] .file-explorer :is(.fe-breadcrumbs a, .fe-file-name, .fe-table th a):hover { color: var(--amber); }
html[data-theme="dark"] .file-explorer button.fe-file-name { background: transparent; }
html[data-theme="dark"] .file-explorer .fe-table :is(td, th) { border-color: #333; }
html[data-theme="dark"] .file-explorer :is(.fe-table th, .fe-upload-status, .fe-new-folder) { background: #202020; color: #c5c5c5; border-color: var(--theme-border); }
html[data-theme="dark"] .file-explorer .fe-table tbody tr:hover { background: #292929; }
html[data-theme="dark"] .file-explorer .fe-table tr.is-selected { background: #353535; }
html[data-theme="dark"] .file-explorer :is(.fe-icon-button, .fe-table td:nth-child(n+3), .fe-search, .fe-empty, .fe-selection-count) { color: var(--muted); }
html[data-theme="dark"] .file-explorer .fe-icon-button:hover { background: #393939; color: #eee; border-color: #555; }
html[data-theme="dark"] .file-explorer .fe-toolbar .fe-icon-button { background: #303030; border-color: #505050; color: #ccc; }
html[data-theme="dark"] .file-explorer .fe-toolbar .fe-icon-button:is(:hover, :focus-visible):not(:disabled) { background: #3c3c3c; border-color: #707070; color: #eee; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-crumb { color: #d0d0d0; }
html[data-theme="dark"] .file-explorer .fe-breadcrumbs a.fe-crumb:hover { color: #eee; }
html[data-theme="dark"] .file-explorer .fe-breadcrumbs .fe-crumb-separator { color: #aaa; }
html[data-theme="dark"] .file-explorer :is(.fe-search, .fe-inline-form, .fe-new-folder) input { background: #141414; color: var(--ink); border-color: #555; }
html[data-theme="dark"] .file-explorer input[type="checkbox"] { accent-color: var(--amber); }
html[data-theme="dark"] .file-explorer .fe-drop-hint { color: var(--muted); border-color: #555; }
html[data-theme="dark"] .file-explorer .fe-drop-hint.is-dragging { border-color: var(--amber); background: #30261b; }
html[data-theme="dark"] .file-explorer :is(.fe-file-name > i, .fe-inline-form > i, .fe-drop-hint i) { color: #aaa; }
html[data-theme="dark"] .file-explorer :is(.fe-file-name > i.fa-folder, .fe-inline-form > i.fa-folder) { color: #d9a15d; }
html[data-theme="dark"] .file-explorer .fe-delete-dialog { background: #242424; border-color: #555; color: var(--ink); }
html[data-theme="dark"] .file-explorer .fe-delete-dialog::backdrop { background: rgba(0, 0, 0, .7); }
html[data-theme="dark"] .file-explorer .fe-window { background: #242424; border-color: #555; color: #ddd; }
html[data-theme="dark"] .file-explorer .fe-window-title { background: #303030; border-color: #555; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-window :is(.fe-window-title h3, p, .fe-trash-name strong, .fe-trash-row label) { color: #ddd; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-window :is(.fe-trash-name small, .fe-window-footer) { color: #bbb; }
html[data-theme="dark"] .file-explorer :is(.fe-window-footer, .fe-trash-row, .fe-destination-list) { border-color: #4b4b4b; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-window :is(.fe-dialog-button:not(.is-primary), .fe-folder-choice), html[data-theme="dark"] .control-panel-page .workspace-pane .fe-trash-tools button { background: #303030; border-color: #555; color: #ddd; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-window :is(.fe-dialog-button:not(.is-primary), .fe-folder-choice):hover, html[data-theme="dark"] .control-panel-page .workspace-pane .fe-trash-tools button:hover { background: #404040; color: #fff; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-window .fe-dialog-button.is-primary { color: #171717; }
html[data-theme="dark"] .file-explorer .fe-image-canvas { background: #191919; }
html[data-theme="dark"] .control-panel-page .workspace-pane .fe-image-canvas pre { color: #ddd; }
html[data-theme="dark"] .file-explorer .fe-upload-status :is(ul, a) { color: #ffc47d; }

html[data-theme="dark"] :is(.success, .control-panel-page .workspace-pane > .success) { background: #202d24; color: #b8e1c3; border-color: #455d4c; }
html[data-theme="dark"] .errors { background: #342520; color: #ffbf9c; border-color: #74513e; }
html[data-theme="dark"] .control-panel-page .workspace-pane :is(.success, .errors) :is(p, span, strong, li),
html[data-theme="dark"] .setup-page .auth-card :is(.success, .errors) p { color: inherit !important; }
