/* Palettes follow apps/dashboard/dashboard_theme.py in the read-only reference.
   Layout and verified client artwork stay the same in every theme. */
:root[data-theme] {
    --accent-fill: #2563eb;
    --input-bg: #0d1117;
    --green: #4ade80; --amber: #facc15; --red: #f87171;
    --green-bg: #0f2a20; --amber-bg: #2d230d; --red-bg: #321515;
    --grey-bg: #1e293b;
    --row-shielded: #0f1f19; --row-unshielded: #1f1a0e;
    --disabled-bg: var(--surface-2);
    --disabled-text: var(--muted);
    --control-border: #64748b;
    color-scheme: dark;
}
:root[data-theme=dark] {
    --bg: #090b10; --surface: #12141a; --surface-2: #181b23;
    --border: #1e222d; --text: #f1f5f9; --muted: #bac6d8;
    --accent: #60a5fa;
}
:root[data-theme=midnight] {
    --bg: #080f1f; --surface: #111c32; --surface-2: #182740;
    --border: #304360; --text: #edf4ff; --muted: #c6d3e7; --control-border: #6f88ad;
    --accent: #60a5fa; --input-bg: #0b1527; --grey-bg: #1b2d49;
}
:root[data-theme=slate] {
    --bg: #1b2028; --surface: #252d38; --surface-2: #303b49;
    --border: #46566c; --text: #f4f7fb; --muted: #d0dae8; --control-border: #7c92ad;
    --accent: #93c5fd; --input-bg: #1e2733; --grey-bg: #344255;
    --red: #ff9b9b;
}
:root[data-theme=ocean] {
    --bg: #071a20; --surface: #102d36; --surface-2: #193c47;
    --border: #365d68; --text: #edfafc; --muted: #c7e4e9; --control-border: #709da8;
    --accent: #67d4e7; --accent-fill: #0e7490; --input-bg: #0b232b; --grey-bg: #1c4652;
    --red: #ff9b9b;
}
:root[data-theme=light], :root[data-theme=warm_light] {
    --green: #116b33; --amber: #854d0e; --red: #b91c1c;
    --green-bg: #e7f5ec; --amber-bg: #fff4d6; --red-bg: #fce8e8;
    --grey-bg: #e8edf4; --row-shielded: #edf8f0; --row-unshielded: #fff8e8;
    --accent: #1d4ed8; --accent-fill: #2563eb;
    --input-bg: #ffffff; --shadow: 0 1px 3px rgb(15 23 42 / 8%);
    color-scheme: light;
}
:root[data-theme=light] {
    --bg: #f6f8fb; --surface: #ffffff; --surface-2: #eef2f7;
    --border: #cbd5e1; --text: #111827; --muted: #3e4b5e;
}
:root[data-theme=warm_light] {
    --bg: #f7f3eb; --surface: #fffdfa; --surface-2: #f0e9dc;
    --border: #c8bda9; --text: #29261f; --muted: #554b3d; --grey-bg: #eee7da; --control-border: #8a7960;
}

/* Accent fills are darker than link accents to keep white button text readable. */
:root[data-theme] :is(.btn.primary, .btn-primary, .tb.start, .topnav a.cta, a.cta) {
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: #ffffff;
}
:root[data-theme] .btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
:root[data-theme] :is(input, select, textarea) { accent-color: var(--accent-fill); }
:root[data-theme] .form-grid :is(input:not([type=checkbox]):not([type=radio]), select),
:root[data-theme] :is(.form-control, .bank-amounts input, textarea) { background: var(--input-bg); color: var(--text); }
:root[data-theme] .form-grid :is(input:not([type=checkbox]):not([type=radio]), select),
:root[data-theme] :is(.form-control, .theme-picker select, .bank-amounts input, textarea) { border-color: var(--control-border); }

/* Inactive controls stay readable. Their neutral fill and native disabled
   behavior distinguish them; fading the whole section also faded its labels. */
:root[data-theme] :is(.global-fields:disabled, .card.soon) { opacity: 1; }
:root[data-theme] :is(.btn, .tb, .tile, .method, .btn-primary):disabled {
    opacity: 1;
    color: var(--disabled-text);
    background: var(--disabled-bg);
    border-color: var(--control-border);
    cursor: not-allowed;
    filter: none;
}
:root[data-theme] :is(input, select, textarea):disabled {
    opacity: 1;
    -webkit-text-fill-color: var(--disabled-text);
    cursor: not-allowed;
}
:root[data-theme] .form-grid :is(input:not([type=checkbox]):not([type=radio]), select):disabled,
:root[data-theme] .form-control:disabled {
    color: var(--disabled-text);
    background: var(--disabled-bg);
    border-color: var(--control-border);
}
:root[data-theme] :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme] .form-floating > .form-control::placeholder { color: transparent; }

/* Labels are instructions, not secondary metadata. Keep their type and
   contrast strong in every palette, including scoped bank/editor styles. */
:root[data-theme] label,
:root[data-theme] :is(.panel, .global-settings) label,
:root[data-theme] .form-label {
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}
:root[data-theme] :is(legend, .rally-type-options legend) { color: var(--text); font-size: 13px; font-weight: 500; }
:root[data-theme] :is(.tabs button, .subtabs button) { font-weight: 500; }
:root:is([data-theme=light], [data-theme=warm_light]) .chip.violet { color: #6d28d9; background: #ede9fe; }
:root:is([data-theme=light], [data-theme=warm_light]) .modal { box-shadow: 0 16px 48px rgb(15 23 42 / 20%); }

.theme-picker { position: relative; }
.theme-trigger { display:inline-flex; align-items:center; gap:8px; min-height:36px; padding:5px 9px; border:1px solid var(--border); border-radius:8px; background:var(--surface-2); color:var(--text); cursor:pointer; list-style:none; }
.theme-trigger::-webkit-details-marker { display:none; }
.theme-chevron { width:6px; height:6px; border:solid currentColor; border-width:0 1px 1px 0; transform:rotate(45deg); margin:0 2px 3px; }
.theme-menu { position:absolute; top:calc(100% + 8px); inset-inline-end:0; z-index:30; width:min(254px, calc(100vw - 24px)); padding:8px; border-radius:10px; border:1px solid var(--control-border); background:var(--surface); color:var(--text); box-shadow:0 8px 28px #0004; }
.theme-options { display:grid; grid-template-columns:1fr 1fr; gap:4px; }
.theme-options button { display:flex; align-items:center; gap:7px; min-height:40px; padding:6px 7px; text-align:start; border:1px solid transparent; border-radius:6px; background:var(--surface-2); color:var(--text); font:inherit; cursor:pointer; }
.theme-options button:hover, .theme-options button[aria-pressed=true] { border-color:var(--accent); }
.theme-options button[aria-pressed=true] { font-weight:700; }
.theme-trigger:focus-visible, .theme-options button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.theme-swatch { width:17px; height:17px; flex:none; border-radius:50%; border:1px solid var(--control-border); background:linear-gradient(135deg,var(--sample) 58%,var(--sample-accent) 59%); }
.theme-swatch[data-palette=dark] { --sample:#12141a; --sample-accent:#60a5fa; }
.theme-swatch[data-palette=midnight] { --sample:#111c32; --sample-accent:#8ab5ff; }
.theme-swatch[data-palette=slate] { --sample:#283347; --sample-accent:#b5ccf0; }
.theme-swatch[data-palette=ocean] { --sample:#11323e; --sample-accent:#67e8f9; }
.theme-swatch[data-palette=light] { --sample:#f8fafc; --sample-accent:#2563eb; }
.theme-swatch[data-palette=warm_light] { --sample:#fff7ed; --sample-accent:#b45309; }
.theme-status { display:block; padding:5px 3px 0; color:var(--muted); font-size:13px; }
.theme-status:empty { padding:0; }
.theme-status[data-error] { color:var(--red); }
@media (max-width: 760px) {
    .topbar { flex-wrap: wrap; gap: 8px; }
    .topbar .topnav { width: 100%; justify-content: flex-start; }
    .theme-menu { inset-inline-start:0; inset-inline-end:auto; }
    .topnav :is(a, .linklike) { padding: 6px 8px; font-size: 13px; }
}

/* Public pages (landing, sign-in, sign-up, recovery) act in ink like the Brahmastra logo; inside the app the theme accent stays. */
:root[data-theme] :is(.landing .actions a.cta, .topnav a.cta, .page-body:has(.form-floating) .btn-primary) {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}
:root[data-theme] :is(.landing .actions a.cta, .topnav a.cta, .page-body:has(.form-floating) .btn-primary):hover { filter: none; opacity: .88; }
