/* Dark theme. Everything here applies only when <html data-theme="dark"> (see core::partials.theme). The tokens are redefined, then the few
   places that use a fixed light colour are overridden. Charts, QR codes and the article editor's paper stay light on purpose. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1322;
    --surface: #151d30;
    --surface-2: #1a2438;
    --title: #f1f4fb;
    --text: #e4e9f4;
    --muted: #97a5bf;
    --line: #26324b;
    --line-strong: #34435f;
    --primary: #5b8cff;
    --primary-dark: #9db8ff;
    --primary-soft: rgba(91, 140, 255, .16);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, .13);
    --danger: #ff7a80;
    --danger-soft: rgba(255, 107, 112, .13);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .13);
    --nav: #0a101f;
    --nav-hover: #172240;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .5);
    --track: #26324b;
    --bar: #6f8dff;
    --ink-danger: #ff8a90;
    --ink-warn: #fbbf24;
    --hl-today: rgba(251, 191, 36, .12);
    --hl-small: rgba(255, 107, 112, .14);
    --gap-a: rgba(255, 255, 255, .10);
    --gap-b: rgba(255, 107, 112, .18);
    --gap-c: rgba(236, 72, 153, .22);
}
:root[data-theme="dark"] .tone-amber { --tone-ink: #fbbf24; } :root[data-theme="dark"] .tone-blue { --tone-ink: #8ab4ff; } :root[data-theme="dark"] .tone-green { --tone-ink: #4ade80; }
:root[data-theme="dark"] .tone-violet { --tone-ink: #c4b5fd; } :root[data-theme="dark"] .tone-teal { --tone-ink: #67e8f9; } :root[data-theme="dark"] .tone-rose { --tone-ink: #f9a8d4; }

/* Surfaces that used a fixed white or near-white */
[data-theme="dark"] .input, [data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
[data-theme="dark"] input::placeholder, [data-theme="dark"] textarea::placeholder { color: #6f7f9c; }
[data-theme="dark"] .card-foot, [data-theme="dark"] details.more, [data-theme="dark"] .picture-preview, [data-theme="dark"] .version-body, [data-theme="dark"] .table tr.is-off td { background: var(--surface-2); }
[data-theme="dark"] .table th { background: var(--surface-2); }
[data-theme="dark"] { --zebra: rgba(255, 255, 255, .045); --zebra-hover: rgba(250, 204, 21, .14); }
[data-theme="dark"] .table tbody tr:hover { background: var(--zebra-hover); }
[data-theme="dark"] #stories-table tr.zebra td.cell-actions { background: #1f2630; }
[data-theme="dark"] #stories-table tr:hover td.cell-actions { background: #2f3020; }
[data-theme="dark"] .label { color: var(--text); }
[data-theme="dark"] .auth-card { background: var(--surface); color: var(--text); }
[data-theme="dark"] .assignment, [data-theme="dark"] .chip { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
[data-theme="dark"] .chip { color: var(--primary-dark); }
[data-theme="dark"] .ai-panel { background: linear-gradient(180deg, rgba(91, 140, 255, .12), var(--surface)); border-color: var(--line-strong); }
[data-theme="dark"] .action-bar { background: rgba(21, 29, 48, .96); }
[data-theme="dark"] .thumb { background: var(--surface-2); }
[data-theme="dark"] .assignment-scope { background: var(--surface-2); }
[data-theme="dark"] .assignment-scope.is-limited, [data-theme="dark"] .matrix .is-all { background: var(--primary-soft); color: var(--primary-dark); }
[data-theme="dark"] .in-chip, [data-theme="dark"] .in-white { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] #stories-table th:last-child, [data-theme="dark"] #stories-table td.cell-actions { box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .6); }
[data-theme="dark"] #stories-table tr.is-busy td.cell-actions, [data-theme="dark"] .table td.is-open { background: rgba(251, 191, 36, .12); }
[data-theme="dark"] .table td.hours-ok, [data-theme="dark"] .table td.adj-pos { background: rgba(52, 211, 153, .14); }
[data-theme="dark"] .table td.adj-neg { background: rgba(255, 107, 112, .14); }
[data-theme="dark"] .day-separator-cell { background: rgba(138, 169, 255, .14); color: #ffb4b4; }
[data-theme="dark"] .diff ins { background: rgba(52, 211, 153, .22); } [data-theme="dark"] .diff del { background: rgba(255, 107, 112, .22); }

/* Messages and badges */
:root[data-theme="dark"] .badge-violet { background: rgba(196, 181, 253, .14); color: #c4b5fd; }
[data-theme="dark"] .alert-success { border-color: rgba(52, 211, 153, .35); color: #6ee7b7; }
[data-theme="dark"] .alert-error { border-color: rgba(255, 107, 112, .4); color: #ffa3a7; }
[data-theme="dark"] .alert-warning { border-color: rgba(251, 191, 36, .4); color: #fcd34d; }
[data-theme="dark"] .alert-info { border-color: rgba(91, 140, 255, .4); color: #aac3ff; }
[data-theme="dark"] .btn-danger { border-color: rgba(255, 107, 112, .5); }
[data-theme="dark"] .status-live, [data-theme="dark"] .tag-suggest-chips .chip.is-used { border-color: rgba(52, 211, 153, .4); }
[data-theme="dark"] .status-unpublished { background: var(--surface-2); }
[data-theme="dark"] .status-unlisted { border-color: rgba(251, 191, 36, .4); }
[data-theme="dark"] .kpi.is-alert { border-color: rgba(255, 107, 112, .45); }
[data-theme="dark"] .final-edit, [data-theme="dark"] .in-green { background: rgba(52, 211, 153, .2); color: #6ee7b7; }
[data-theme="dark"] .in-orange { background: rgba(251, 146, 60, .22); color: #fdba74; }
[data-theme="dark"] .in-red { background: rgba(255, 107, 112, .22); color: #ffa3a7; }
[data-theme="dark"] .id-chip.views-top, [data-theme="dark"] .id-chip.views-high, [data-theme="dark"] .id-chip.views-good { color: #0b3d22; }
[data-theme="dark"] .id-chip.views-low, [data-theme="dark"] .id-chip.views-poor { color: #5c1010; }

/* Charts */
[data-theme="dark"] .bars i { background: rgba(138, 169, 255, .38); }
[data-theme="dark"] .bars i.is-day { background: var(--primary); }
[data-theme="dark"] .ai-report { border-color: var(--line-strong); }

/* Scorecards: the number pills keep dark text on their tint */
[data-theme="dark"] .sc-cell { color: var(--text); }

/* Ask AI and chat */
[data-theme="dark"] .ai-thread:hover, [data-theme="dark"] .ai-thread button:hover { background: var(--surface-2); }
[data-theme="dark"] .ai-chip, [data-theme="dark"] .ai-bubble :not(pre) > code { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .ai-bubble.is-error { border-color: rgba(255, 107, 112, .4); }
[data-theme="dark"] .chat-avatar { background: rgba(91, 140, 255, .22); }
[data-theme="dark"] .chat-avatar.is-group { background: rgba(52, 211, 153, .18); }
[data-theme="dark"] .chat-day { background: var(--surface-2); }
[data-theme="dark"] .is-mine .chat-bubble { border-color: rgba(91, 140, 255, .4); }
[data-theme="dark"] .cw-dock { background: var(--surface); color: var(--text); }
[data-theme="dark"] .cw-warn { background: var(--warn-soft); color: var(--warn); }
[data-theme="dark"] .chat-suggest { background: rgba(124, 58, 237, .14); border-color: rgba(167, 139, 250, .35); }
[data-theme="dark"] .chat-suggest-label { color: #c4b5fd; }
[data-theme="dark"] .chat-suggest-text { background: var(--surface-2); border-color: rgba(167, 139, 250, .35); }
[data-theme="dark"] .chat-tag { background: rgba(91, 140, 255, .2); color: var(--primary-dark); }
[data-theme="dark"] .chat-tag.is-me { background: rgba(251, 191, 36, .2); color: #fcd34d; }
[data-theme="dark"] .chat-bubble.is-tagged-me { box-shadow: 0 0 0 2px rgba(251, 191, 36, .3); }

/* Pictures are never dimmed or inverted; the article editor and the QR code keep their white paper. */
[data-theme="dark"] .fr-box, [data-theme="dark"] .fr-wrapper, [data-theme="dark"] #qr { color-scheme: light; }
