/* Theme overrides are loaded after workspace styles. All values come from validated presets. */

/* Shared defaults also cover controls created after startup. Keep component geometry intact. */
:root[data-theme]{background:var(--bg);color:var(--text);--scroll-thumb:color-mix(in srgb,var(--muted) 65%,var(--panel));--scroll-hover:var(--muted)}
:root[data-theme] *{scrollbar-color:var(--scroll-thumb) var(--panel);scrollbar-width:thin}
:root[data-theme] ::-webkit-scrollbar{width:10px;height:10px}
:root[data-theme] ::-webkit-scrollbar-track,:root[data-theme] ::-webkit-scrollbar-corner{background:var(--panel)}
:root[data-theme] ::-webkit-scrollbar-thumb{background:var(--scroll-thumb);border:2px solid var(--panel);border-radius:8px}
:root[data-theme] ::-webkit-scrollbar-thumb:hover{background:var(--scroll-hover)}
:root[data-theme] ::-webkit-scrollbar-button{display:none}
:root[data-theme] :is(button,input,select,textarea){color-scheme:inherit;accent-color:var(--accent)}
:root[data-theme] button:not(.radar-blip),:root[data-theme] :is(input,select,textarea){background-color:var(--surface);color:var(--text);border-color:var(--edge)}
:root[data-theme] select option{background:var(--surface);color:var(--text)}
:root[data-theme] :is(input,textarea)::placeholder{color:var(--muted);opacity:1}
:root[data-theme] button:not(.radar-blip):not(:disabled):hover{border-color:var(--accent)}
:root[data-theme] button:disabled{opacity:.5}
:root[data-theme] ::selection{background:var(--accent);color:var(--accent-text)}
:root[data-theme] #show-all-pairs{padding:3px 6px;border:1px solid var(--edge);border-radius:4px;font:10px Arial;white-space:nowrap;cursor:pointer}

:root[data-theme] body{background:var(--bg);color:var(--text)}
:root[data-theme] :is(body>header,#main-navigation,.chart-toolbar,.table-card,.table-head,.table-card th,.chart-panel,.chart-studio .chart-panel,.chart-panel:hover,.chart-panel footer,.grid-workspace,.trade-checklist-content,.radar-dialog,#radar-panel,.radar-top,.radar-filters,.radar-sizing){background:var(--panel);color:var(--text);border-color:var(--edge)}
:root[data-theme] :is(.header-button,.controls button,.controls input,.controls select,.coin-list-toolbar button,.coin-list-toolbar select,.filter-range input,.filter-actions button,.radar-dialog button,.radar-dialog input,.radar-dialog select,.timeframes button,.chart-tool-icon,.studio-timeframe,.studio-list-dock,.layout-buttons button,.chart-engine-select,#toggle-market-filters,#toggle-main-navigation,#coin-list-dialog,#coin-list-dialog input,#coin-list-dialog select,#coin-list-dialog button){background:var(--surface);color:var(--text);border-color:var(--edge);color-scheme:inherit}
:root[data-theme] :is(.status,.updated,.dialog-note,.radar-dialog label,.chart-panel header b small,.chart-panel header em,.chart-panel footer,#account-save-status,.chart-feed-status,.table-card th,.filter-actions details,.theme-card-description){color:var(--muted)}
:root[data-theme] :is(.chart-panel header b,.contract,.brand,.radar-dialog h2,.radar-dialog h3){color:var(--text)}
:root[data-theme] :is(.table-card td,.table-card tr,.coin-list-toolbar,.chart-panel header,.chart-panel footer,.radar-dialog li){border-color:var(--edge)}
:root[data-theme] .table-card tbody tr:hover{background:var(--surface)}
:root[data-theme] :is(.pos,.change.pos){color:var(--green)}
:root[data-theme] :is(.neg,.change.neg){color:var(--red)}
:root[data-theme] :is(.timeframes button.active,.app-tabs button[aria-selected="true"],.radar-dialog [role="tab"][aria-selected="true"],.layout-buttons button.active){background:var(--accent)!important;border-color:var(--accent)!important;color:var(--accent-text)!important}
:root[data-theme] .radar-dialog [role="tab"][aria-selected="false"]{background:var(--surface);border-color:var(--edge);color:var(--muted)}
:root[data-theme] :is(button,a,input,select):focus-visible{outline:2px solid var(--accent);outline-offset:3px}
#settings-dialog{width:min(760px,calc(100vw - 30px));max-height:calc(100dvh - 36px)}
#settings-dialog>[role="tablist"]{display:flex;gap:6px;padding-bottom:16px;border-bottom:1px solid var(--edge);margin-bottom:18px}
#settings-dialog>[role="tablist"] button{padding:8px 18px}
.theme-heading{font-size:19px;margin:0 0 8px;letter-spacing:-.4px}
.theme-section-heading{display:flex;align-items:center;justify-content:space-between;margin:20px 0 10px;color:var(--text);font:600 12px Arial}
.theme-section-heading span{color:var(--muted);font:10px Arial}
.theme-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
#settings-dialog .theme-card{display:flex;flex-direction:column;gap:8px;min-width:0;padding:10px;border-radius:9px;text-align:left;border:1px solid var(--edge);background:var(--surface);color:var(--text);cursor:pointer}
#settings-dialog .theme-card:hover{border-color:var(--accent)}
#settings-dialog .theme-card[aria-pressed="true"]{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.theme-preview{height:76px;display:flex;position:relative;overflow:hidden;background:var(--preview-bg);border:1px solid var(--preview-edge);border-radius:5px;gap:8px;padding:8px}
.theme-preview-sidebar{width:20%;background:var(--preview-panel);border-right:1px solid var(--preview-edge)}
.theme-preview-chart{flex:1;display:flex;align-items:center;justify-content:center;gap:9px;background:linear-gradient(var(--preview-edge) 1px,transparent 1px) 0 0/100% 18px}
.theme-preview-chart i{width:6px;height:22px;background:var(--preview-bull);position:relative;transform:translateY(8px)}
.theme-preview-chart i:before{content:'';position:absolute;top:-7px;bottom:-7px;left:2px;width:1px;background:inherit}
.theme-preview-chart i:nth-child(2){height:30px;transform:translateY(0)}
.theme-preview-chart i:nth-child(3){height:15px;background:var(--preview-bear);transform:translateY(-5px)}
.theme-preview-chart i:nth-child(4){height:24px;transform:translateY(-9px)}
.theme-preview-chart i:nth-child(5){height:12px;background:var(--preview-bear);transform:translateY(-17px)}
.theme-preview-dot{position:absolute;right:5px;top:5px;width:5px;height:5px;border-radius:50%;background:var(--preview-accent)}
.theme-card-name{display:flex;justify-content:space-between;align-items:center;font-size:12px;font-weight:600}
.theme-card-description{font-size:10px;line-height:1.5;min-height:15px}
.theme-card-check{visibility:hidden;color:var(--accent)}
.theme-card[aria-pressed="true"] .theme-card-check{visibility:visible}
#theme-selection-status{margin:16px 0 0}
@media(max-width:380px){.theme-grid{grid-template-columns:1fr}.theme-preview{height:64px}}

:root[data-theme] :is(.radar-controls,.radar-filters) :is(input,select,button),:root[data-theme] #radar-nearest button{background:var(--surface);color:var(--text);border-color:var(--edge)}
:root[data-theme] :is(.radar-info h2,#radar-level-details){color:var(--text)}
:root[data-theme] #radar-volume{color:var(--text)!important}
:root[data-theme] .radar-disc{background:radial-gradient(circle,var(--surface),var(--panel) 65%,transparent 72%)}
:root[data-theme-mode="light"] .brand-logo{filter:brightness(.18)}
:root[data-theme] .chart-panel header :is(button,a){color:var(--muted)}
:root[data-theme] :is(.trade-checklist>summary,#studio-layouts){background:var(--surface);color:var(--text);border-color:var(--edge)}

/* Secondary surfaces share the same palette as the workspace. */
:root[data-theme] :is(#chart-visibility-menu,#book-details,#radar-settings-drawer,#radar-level-tooltip,.radar-chart-popup,.radar-coin-window,.trade-checklist,.auth-card,#admin-summary div){background:var(--panel);color:var(--text);border-color:var(--edge)}
:root[data-theme] #main-navigation .trade-checklist-content{background:var(--panel);color:var(--text);border-color:var(--edge)}
:root[data-theme] :is(#book-details header,#book-details strong,.trade-checklist h3,.trade-checklist-intro,#radar-settings-drawer>header,.radar-coin-window>header){color:var(--text)}
:root[data-theme] :is(#book-details p,#chart-visibility-menu strong,.trade-checklist-hint,.radar-sizing p,.radar-dialog li small,.auth-card p,.auth-card label,.auth-help,.auth-footer,.auth-back){color:var(--muted)}
:root[data-theme] :is(#book-details button,#radar-settings-drawer button,#radar-nearest button,.radar-settings-toggle,.radar-chart-popup button){background:var(--surface);color:var(--text);border-color:var(--edge)}
:root[data-theme] :is(.book-detail-row,.radar-info,td,th){border-color:var(--edge)}
:root[data-theme] #chart-visibility-menu label:hover,:root[data-theme] #chart-visibility-menu label:focus-within{background:var(--surface)}
:root[data-theme] :is(.radar-dialog input[type=range],#market-columns-dialog .column-choices input,#market-column-options input,#chart-visibility-menu input){accent-color:var(--accent)}
:root[data-theme] :is(.chart-tool-icon,.ruler-toggle,#line-tool,#alerts-only-filter,#toggle-market-filters)[aria-pressed="true"],:root[data-theme] .ruler-toggle.active,:root[data-theme] #chart-visibility[aria-expanded="true"]{background:var(--accent)!important;color:var(--accent-text)!important;border-color:var(--accent)!important}
:root[data-theme] #pro-dialog{background:var(--panel);color:var(--text);border-color:var(--edge)}
:root[data-theme] #alert-toast{background:var(--panel);color:var(--text);border-color:var(--accent)}
:root[data-theme] .radar-dialog li.unread{background:var(--surface);border-left-color:var(--accent)}
:root[data-theme] :is(.dialog-error,.auth-message.error){color:var(--red)}
:root[data-theme] .auth-message.success{color:var(--green)}
:root[data-theme] :is(.auth-nav,a.auth-back){background:var(--bg)}
:root[data-theme] .auth-nav a{color:var(--muted)}
:root[data-theme] :is(.auth-nav a[aria-current=page],.auth-card button,.auth-primary){background:var(--accent);color:var(--accent-text);border-color:var(--accent)}
:root[data-theme] :is(.auth-card a:not(.auth-primary):not([aria-current]),body>header>a){color:var(--accent)}
:root[data-theme] :is(.auth-card input,input:focus){outline-color:var(--accent)}
:root[data-theme] :is(.trade-checklist>summary,.trade-checklist-sections>li)::marker{color:var(--accent)}
@media(forced-colors:active){:root[data-theme] *{scrollbar-color:auto}}

/* Popup controls and inline header actions use the same restrained palette. */
:root[data-theme] :is(.market-filters,#studio-add-dialog,#studio-link-dialog,#symbol-copy-toast,.widget-snap-palette){background:var(--panel);color:var(--text);border-color:var(--edge)}
:root[data-theme] :is(.studio-timeframes button,.studio-timeframe,.chart-engine-select){background:var(--surface);color:var(--muted);border-color:var(--edge);color-scheme:inherit}
:root[data-theme] .studio-timeframes button.active{background:var(--accent);color:var(--accent-text);border-color:var(--accent)}
:root[data-theme] .chart-panel.studio-active{border-color:var(--accent)}
:root[data-theme] .chart-panel header button[aria-pressed="true"]{color:var(--accent-text)}
:root[data-theme] :is(.chart-context-menu button,.studio-panel-controls button){background:transparent}
:root[data-theme] .chart-context-menu button:hover{background:var(--surface)}
:root[data-theme] .book-status{background:var(--surface);color:var(--muted);border-color:var(--edge)}
:root[data-theme] .candle-timer{color:var(--muted)}
:root[data-theme-mode="light"] .radar-dialog::backdrop{background:#20304455}
@media(max-width:620px){.theme-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.theme-card-description{min-height:30px}}
