/* ECP theme tokens. Black retains the existing neutral surfaces.
   Green follows Inventory, light follows AHKETA; destructive states stay red. */
:root, html[data-theme="dark"] {
  --bg-dark:#2f2f2f; --bg-darker:#262626; --bg-sidebar:#2f2f2f; --bg-chat:#212121;
  --bg-hover:rgba(255,255,255,.05); --bg-active:#3d3d3d;
  --bg-bubble:rgba(255,255,255,.06); --bg-input:rgba(255,255,255,.07);
  --text:#ececec; --text-sec:#a0a0a0; --text-muted:#969696;
  --border:rgba(255,255,255,.08); --gradient-out:linear-gradient(135deg,#3a3a3a,#484848);
  --accent:#4ade80 !important; --accent2:#15803d; --accent-rgb:34,197,94;
  --action:#15803d; --action-hover:#166534; --on-action:#fff;
  --brand:#15803d !important; --brand-grad:linear-gradient(135deg,#15803d,#166534) !important;
  --accent-soft:rgba(34,197,94,.12); --shadow-msg:0 1px 3px rgba(0,0,0,.3);
  --green:#4ade80; --red:#f06060; --orange:#f0b050;
  --bg:var(--bg-chat); --card:var(--bg-sidebar); --card2:var(--bg-active); --input-bg:var(--bg-input);
}
html[data-theme="green"] {
  --bg-dark:#222b1f; --bg-darker:#161c14; --bg-sidebar:#1f2a1b; --bg-chat:#161c14;
  --bg-hover:rgba(111,160,85,.12); --bg-active:#33482a;
  --bg-bubble:#222b1f; --bg-input:#222b1f; --text:#e8ede4;
  --text-sec:#b0bea7; --text-muted:#9aab90; --border:#33402d;
  --accent:#8aaf6a !important; --accent2:#3d5a2d; --accent-rgb:111,160,85;
  --action:#3d5a2d; --action-hover:#324b24; --green:#8aaf6a;
  --brand:#3d5a2d !important; --brand-grad:linear-gradient(135deg,#3d5a2d,#304723) !important;
  --accent-soft:rgba(111,160,85,.15); --gold:#d4b554;
  --gradient-out:linear-gradient(135deg,#304326,#3d5230);
}
html[data-theme="green"] .sidebar-header,
html[data-theme="green"] .chat-header,
html[data-theme="green"] .profile-header { background:#1d2a14; border-bottom-color:rgba(212,181,84,.55); }
html[data-theme="green"] .folder-tab.active { color:var(--gold); }
html[data-theme="green"] .ecp-theme-heading h2 { color:var(--gold); }
html[data-theme="light"] {
  --bg-dark:#f3f4f6; --bg-darker:#f3f4f6; --bg-sidebar:#fff; --bg-chat:#f3f4f6;
  --bg-hover:rgba(15,118,110,.05); --bg-active:#d7eee2; --bg-bubble:#fff; --bg-input:#f9fafb;
  --text:#111827; --text-sec:#59616e; --text-muted:#6b7280; --border:rgba(17,24,39,.12);
  --accent:#0f766e !important; --accent2:#166534; --accent-rgb:15,118,110;
  --action:#15803d; --action-hover:#166534; --green:#15803d; --red:#dc2626;
  --accent-soft:rgba(15,118,110,.10); --gradient-out:linear-gradient(135deg,#d9f0e3,#c9e9d8);
  --shadow-msg:0 1px 4px rgba(0,0,0,.06);
}
/* Chat avatars retain the identity color supplied by the channel renderer. */
.logo-pill:not(.impersonating), .logo-icon, .submit-btn, .btn-install {
  background:var(--brand-grad) !important; color:var(--on-action);
  box-shadow:0 2px 8px rgba(var(--accent-rgb),.2);
}
.voice-send-btn, .voice-send-btn.is-send, .m-btn-primary, .new-chat-btn,
.folder-manage-btn, .folders-modal .fm-btn.primary, .folders-modal .fm-add-icon,
.unread-badge, .sg-tab.active, .sg-gif-upload, .msg-contact-btn, .btn-primary {
  background:var(--action); color:var(--on-action);
}
html .folder-tab.active, html .folders-modal .fm-add-row, .user-pick-item.selected,
.selected-tag, .reaction-chip.mine, .profile-version-badge, .session-card.session-current {
  background:var(--accent-soft); color:var(--accent);
}
html .folders-modal .fm-input:focus, .search-box input:focus { box-shadow:0 0 0 3px rgba(var(--accent-rgb),.18); }
html #update-banner { background:var(--brand-grad); box-shadow:0 12px 34px rgba(var(--accent-rgb),.25); }
@keyframes searchJumpHighlight {
  0%,100% { box-shadow:var(--shadow-msg); }
  25%,70% { box-shadow:0 0 0 3px rgba(var(--accent-rgb),.72),0 5px 18px rgba(0,0,0,.28); }
}
.ecp-theme-dialog {
  margin:auto; padding:20px; width:min(440px,calc(100vw - 24px)); max-height:calc(100dvh - 32px);
  overflow:auto; border:1px solid var(--border); border-radius:18px;
  background:var(--bg-sidebar); color:var(--text); box-shadow:0 20px 70px rgba(0,0,0,.4);
  font-family:inherit; text-align:left;
}
.ecp-theme-dialog::backdrop { background:rgba(0,0,0,.6); }
.ecp-theme-heading { display:flex; align-items:center; gap:8px; margin-bottom:12px; }
.ecp-theme-heading h2 { flex:1; margin:0; font-size:20px; }
.ecp-theme-close { width:44px; height:44px; flex-shrink:0; border:0; border-radius:50%; background:var(--bg-hover); color:var(--text); font-size:28px; cursor:pointer; }
.ecp-theme-dialog fieldset { border:0; margin:0; padding:0; display:grid; gap:10px; }
.ecp-theme-option { display:flex; align-items:center; gap:12px; min-height:84px; padding:10px; border:2px solid var(--border); border-radius:12px; cursor:pointer; }
.ecp-theme-option:has(input:checked) { border-color:var(--accent); background:var(--accent-soft); }
.ecp-theme-option:has(input:focus-visible) { outline:2px solid var(--accent); outline-offset:3px; }
.ecp-theme-option input { width:20px; height:20px; flex-shrink:0; accent-color:var(--action); margin-left:auto; }
.ecp-theme-copy { min-width:0; }
.ecp-theme-copy strong { display:block; font-size:16px; }
.ecp-theme-copy small { display:block; margin-top:4px; font-size:12px; line-height:1.4; color:var(--text-sec); }
.ecp-theme-preview { width:54px; height:58px; flex-shrink:0; border-radius:8px; border:1px solid rgba(128,128,128,.3); padding:9px 6px; background:#212121; }
.ecp-theme-preview span { display:block; height:12px; width:30px; border-radius:5px; background:#454545; }
.ecp-theme-preview span + span { margin:6px 0 0 auto; background:#15803d; }
.ecp-preview-green { background:#161c14; border-color:#6fa055; }
.ecp-preview-green span { background:#222b1f; }
.ecp-preview-green span + span { background:#3d5a2d; }
.ecp-preview-light { background:#f3f4f6; }
.ecp-preview-light span { background:#fff; border:1px solid #ddd; }
.ecp-preview-light span + span { background:#c9e9d8; }
.ecp-theme-dialog [role="status"] { color:var(--text-sec); font-size:12px; line-height:1.5; margin:14px 0 0; }
.ecp-sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.ecp-install { background:var(--bg-chat); color:var(--text); }
.ecp-install .install-header { background:var(--bg-sidebar); border-color:var(--border); }
.ecp-install .instructions { background:var(--bg-sidebar); }
.ecp-install .icon { background:var(--brand-grad); box-shadow:0 8px 32px rgba(var(--accent-rgb),.25); }
.ecp-install .btn-back, .ecp-install .instructions h3 { color:var(--accent); }
.ecp-install .btn-back:hover { background:var(--accent-soft); }
.ecp-install .btn-back:focus-visible { outline-color:var(--accent); }
.ecp-install .btn-open { color:var(--text); border-color:var(--border); }
.ecp-install .btn-open:hover { border-color:var(--accent); }
.ecp-install .step-num { background:var(--action); }
.ecp-install .sub, .ecp-install .device-label { color:var(--text-sec); }
.ecp-install .device-label { border-color:var(--border); }
.ecp-install .step-text { color:var(--text-sec); }
.ecp-install .step-text b { color:var(--text); }
/* Keep text readable on the pale active row and outgoing light bubbles. */
html[data-theme="light"] .contact-item.active .contact-name,
html[data-theme="light"] .contact-item.active .preview-author { color:var(--text); }
html[data-theme="light"] .contact-item.active .contact-preview,
html[data-theme="light"] .contact-item.active .contact-time { color:var(--text-sec); }
html[data-theme="light"] .contact-item.active .contact-unread { background:var(--action); color:#fff; }
html[data-theme="light"] .msg-out { background:var(--gradient-out); color:var(--text); }
html[data-theme="light"] .msg-out .msg-author,
html[data-theme="light"] .msg-out .msg-forward,
html[data-theme="light"] .msg-out .msg-reply-author,
html[data-theme="light"] .msg-out .msg-check.read { color:var(--accent); }
.contact-unread, .scroll-down-btn .badge, .sd-period-btn.active, .paste-send,
.voice-play-btn, .feed-comment-send, .session-current-badge { background:var(--action); color:#fff; }
.theme-btn { min-width:44px; min-height:44px; }
