/* Semantic dark palette. Light fallbacks live beside the original component rules. */
:root {
  --tone-text-strong:#263e52; --tone-text:#435e73; --tone-text-muted:#566d81;
  --tone-blue-text:#146c9b; --tone-green-text:#287359; --tone-amber-text:#89611e;
  --tone-violet-text:#7850a9; --tone-red-text:#ad435d;
  --ui-text:#263e52; --ui-secondary:#526b80; --ui-muted:#566d81;
  --ui-surface:#fff; --ui-subtle:#f3f7fa; --ui-line:#dce6ee; --ui-accent:#087ebd;
  --ui-hover:#eaf4fc; --ui-danger:#b54658; --ui-danger-bg:#fff2f4;
}
:root[data-theme="dark"] {
  color-scheme:dark; color:#d8e3ee; background:#101923;
  --bg:#101923; --panel:#182431; --line:#304254; --muted:#a1b4c7;
  --dark:#111b27; --accent:#359fdd; --accent-hover:#51afe5; --green:#68d2ad;
  --tone-text-strong:#eef4fa; --tone-text:#d0ddeb; --tone-text-muted:#a1b4c7;
  --tone-surface-deep:#101923; --tone-surface-1:#182431; --tone-surface-2:#1d2c3b;
  --tone-surface-3:#243647; --tone-line:#304254; --tone-wire:#65849b;
  --tone-shadow:#00000059; --tone-shadow-soft:#0000001f; --tone-overlay:#060d17bb;
  --tone-focus:#65bcf5;
  --tone-blue-text:#78c5f4; --tone-blue-soft:#1d364b; --tone-blue-solid:#247bb2; --tone-blue-line:#3574a0;
  --tone-green-text:#7cdbb7; --tone-green-soft:#1b3a36; --tone-green-solid:#24715c; --tone-green-line:#34755f;
  --tone-violet-text:#c2a8f5; --tone-violet-soft:#302a46; --tone-violet-solid:#7054b3; --tone-violet-line:#7154a0;
  --tone-amber-text:#e7c380; --tone-amber-soft:#3b3224; --tone-amber-solid:#826126; --tone-amber-line:#826337;
  --tone-red-text:#f0a1b2; --tone-red-soft:#422b37; --tone-red-solid:#a64c66; --tone-red-line:#8e5063;
  --ui-text:#e1eaf3; --ui-secondary:#c0d0e0; --ui-muted:#a1b4c7;
  --ui-surface:#182431; --ui-subtle:#1d2c3b; --ui-line:#304254; --ui-accent:#78c5f4;
  --ui-hover:#243b50; --ui-danger:#f0a1b2; --ui-danger-bg:#422b37;
}
.theme-toggle,.theme-close {
  display:inline-grid;place-items:center;flex:none;width:38px;height:38px;padding:0;
  border:1px solid var(--ui-line);border-radius:9px;color:var(--ui-secondary);
  background:var(--ui-surface);font:24px/1 system-ui;cursor:pointer;
}
.theme-toggle:hover,.theme-close:hover{background:var(--ui-hover);color:var(--ui-accent)}
.theme-floating,.theme-auth{position:fixed;right:22px;top:18px;z-index:90}
body:has(#auth[hidden]) .theme-auth{display:none}
.theme-dialog{width:460px;max-width:calc(100vw - 28px);padding:24px;border:1px solid var(--ui-line);border-radius:16px;background:var(--ui-surface);color:var(--ui-text);box-shadow:0 22px 100px #0005}
.theme-dialog::backdrop{background:#060d178c;backdrop-filter:blur(4px)}
.theme-dialog-heading{display:flex;align-items:flex-start;gap:16px;justify-content:space-between}
.theme-dialog h2{font:600 23px/1.4 system-ui;color:var(--ui-text);margin:0 0 6px}
.theme-dialog p{font:13px/1.65 system-ui;color:var(--ui-muted);margin:0}
.theme-options{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;border:0;padding:0;margin:24px 0 18px;min-width:0}
.theme-option{position:relative;cursor:pointer;border:2px solid var(--ui-line);padding:9px;border-radius:10px;min-width:0;color:var(--ui-secondary)}
.theme-option:has(input:checked){border-color:var(--ui-accent);background:var(--ui-hover);color:var(--ui-accent)}
.theme-option:has(input:focus-visible){outline:3px solid var(--ui-accent);outline-offset:3px}
.theme-option input{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden}
.theme-option strong{font:500 12px/1.4 system-ui;display:block;margin-top:9px;text-align:center}
.theme-swatch{display:block;height:65px;border-radius:5px;position:relative;overflow:hidden;border:1px solid #cedbe6;background:#eef3f8}
.theme-swatch i{position:absolute;inset:0 auto 0 0;width:26%;background:#fff;border-right:1px solid #d9e4ed}
.theme-swatch b,.theme-swatch em{position:absolute;left:35%;right:10%;height:12px;border-radius:3px;top:16px;background:#bddef3}
.theme-swatch em{top:36px;background:#fff;height:18px}
.theme-swatch.dark{background:#101923;border-color:#38516a}.theme-swatch.dark i{background:#1d2c3b;border-color:#38516a}
.theme-swatch.dark b{background:#3778a0}.theme-swatch.dark em{background:#243b50}
.theme-swatch.system{background:linear-gradient(90deg,#eef3f8 50%,#101923 50%)}
.theme-swatch.system b{background:linear-gradient(90deg,#bddef3 30%,#3778a0 30%)}
.theme-swatch.system em{background:linear-gradient(90deg,#fff 30%,#243b50 30%)}
.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
/* Intentional component semantics where hue alone does not describe a role. */
[data-theme="dark"] dialog{background:var(--ui-surface)}
[data-theme="dark"] .topbar{background:#111b27f2}
[data-theme="dark"] .sidebar,[data-theme="dark"] .sidebar-bottom{background:#131f2b}
[data-theme="dark"] .brand-icon{color:#fff;background:#168acd}
[data-theme="dark"] .board{background-color:#101c29;background-image:radial-gradient(#3d5267 .85px,transparent .85px)}
[data-theme="dark"] .board-node{background:#1e2e3f}
[data-theme="dark"] .board-node.selected{border-color:#64bdf3;box-shadow:0 0 0 2px #349ddb55}
[data-theme="dark"] .board-node-head{border-bottom-color:#304457}
[data-theme="dark"] .board-minimap{background:#172838ee}
[data-theme="dark"] .board-minimap rect{fill:#516f87}
[data-theme="dark"] .board-minimap rect:last-child{fill:#269fdb22;stroke:#78c5f4}
[data-theme="dark"] .board-fullscreen{box-shadow:0 0 0 30px #080f18e6}
[data-theme="dark"] .omni-person.active,[data-theme="dark"] .exp-ticket.selected{background:#28597e;color:#fff}
[data-theme="dark"] .omni-person.active :is(small,.chat-person-preview,.chat-person-time),[data-theme="dark"] .exp-ticket.selected :is(p,small,strong){color:#daebf8}
[data-theme="dark"] :is(.omni-messages,.messenger-conversation,.chat-compose-wrap,.telegram-preview,.exp-ticket-detail,#desk-detail>.section-note){background-color:#10262c}
[data-theme="dark"] .omni-message{background:#213b44;color:#e1eff3;box-shadow:0 1px 2px #0003}
[data-theme="dark"] .omni-message.out{background:#255146}
[data-theme="dark"] .message-text{color:#e4eff0}
[data-theme="dark"] .message-author{color:#86c8e6}
[data-theme="dark"] .omni-message.out .message-author{color:#9ce2bc}
[data-theme="dark"] .message-author>span,[data-theme="dark"] .omni-message.out .message-author>span{color:#b3cacb}
[data-theme="dark"] .message-meta,[data-theme="dark"] .omni-message.out .message-meta{color:#b3cbbe}
[data-theme="dark"] .message-button{background:#ffffff0d;border-color:#ffffff1c;color:#c2dcd3}
[data-theme="dark"] .message-button.primary{background:#1e4456;color:#9ad5f3}
[data-theme="dark"] .message-button.positive{background:#21543f;color:#a0e5bf}
[data-theme="dark"] .message-button.negative{background:#583640;color:#ffb4c0}
[data-theme="dark"] .chat-date{background:#2e484dd9;color:#d1e0e3}
[data-theme="dark"] .chat-livebar{background:#213b36;color:#afd4c4;border-bottom-color:#365147}
[data-theme="dark"] .telegram-composer{background:#1d3540}
[data-theme="dark"] .telegram-composer>textarea{color:#e4eff3}
[data-theme="dark"] .chat-compose-top select{color:#b7d9c9}
[data-theme="dark"] .chat-compose-top small{color:#a0bcaf}
[data-theme="dark"] .chat-empty :is(strong,p),[data-theme="dark"] .chat-empty{color:#a5c4c8}
[data-theme="dark"] .toast{background:#255a77;color:#f4fbff;border-color:#4887a6}
[data-theme="dark"] .toast.error{background:#783347;color:#fff1f4;border-color:#bc6982}
[data-theme="dark"] .btn.primary{background:#227ab3;border-color:#329ad8;color:#fff}
[data-theme="dark"] .btn.primary:hover{background:#2878a8}
[data-theme="dark"] input,[data-theme="dark"] select,[data-theme="dark"] textarea{color-scheme:dark}
[data-theme="dark"] input::placeholder,[data-theme="dark"] textarea::placeholder{color:#94aabc}
[data-theme="dark"] option{background:#1d2c3b;color:#e1eaf3}
[data-theme="dark"] ::selection{background:#306b91;color:#fff}
/* Documentation shares the preference with the workspace. */
[data-theme="dark"] .manual-article,[data-theme="dark"] body>aside{background:var(--ui-surface)}
[data-theme="dark"] body>aside input{background:var(--ui-subtle);color:var(--ui-text)}
body:has(.manual-article) .theme-toggle{position:static;margin-top:18px}
@media(max-width:600px){.theme-toggle{width:36px;height:36px}.theme-dialog{padding:20px}.theme-option{padding:7px}.theme-option strong{font-size:11px}.theme-floating{top:12px;right:14px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;transition-duration:.01ms!important}}
@media print{.theme-toggle,.theme-dialog{display:none!important}}
[data-theme=dark] body:has(.cards){background:#101923;color:var(--ui-text)}
[data-theme=dark] body:has(.cards) :is(header a,.cards h2){color:var(--ui-text)}
[data-theme=dark] body:has(.cards) :is(.lead,.hint,.cards p,header>span,footer){color:var(--ui-muted)}
[data-theme=dark] body:has(.cards) .cards article{background:var(--ui-surface);border-color:var(--ui-line)}
[data-theme=dark] body:has(.cards) header{border-color:var(--ui-line)}
[data-theme=dark] body:has(.cards) :is(.eyebrow,.cards b,header a span){color:var(--ui-accent)}

[data-theme="dark"] .board-minimap rect.map-selected{fill:#78c5f4}

.toast{color:#f5fbff}.toast.error{color:#fff5f6}
.omni-person.active :is(small,.chat-person-preview,.chat-person-time),.exp-ticket.selected :is(p,small,strong){color:#e8f5ff}

:root[data-theme=light] .btn.primary{background:#087bb5;border-color:#087bb5}
:root[data-theme=light] .btn.primary:hover{background:#076b9f}
.beta{color:var(--ui-secondary);font-size:9px}
