/* Shared component tokens for both visual styles and both color themes. */
:root {
  --danger: #a3212e; --muted: #53675c; --line: #b8c9bf; --button-bg: #e3eee7; --button-ink: #173b2b;
  --button-border: #a0b8a9; --primary-bg: #245b40; --primary-ink: #fff;
  --focus: #226ba1; --radius: 12px;
}
body.dark {
  --danger: #ffb8b2; --bg: #101c18; --panel: #1a2d24; --ink: #eef7f0; --muted: #b5c9bb;
  --line: #52695b; --button-bg: #304b3b; --button-ink: #f0f9f2;
  --button-border: #779884; --primary-bg: #b8dea1; --primary-ink: #183321; --focus: #91c9ff;
}
button, .ghost, .secondary {
  color: var(--button-ink); background: var(--button-bg);
  border: 1px solid var(--button-border); border-radius: var(--radius);
  min-height: 40px; line-height: 1.35; font-weight: 600;
}
a.ghost {text-decoration: none; display: inline-flex; align-items: center; justify-content: center;}
button:hover, a.ghost:hover {filter: none; box-shadow: inset 0 0 0 1px var(--button-ink);}
button:disabled {opacity: 1; color: var(--muted); background: var(--soft); border-color: var(--line); box-shadow: none; cursor: not-allowed;}
button.primary {background: var(--primary-bg); color: var(--primary-ink); border-color: var(--primary-bg);}
button.icon-button, summary.icon-button {color: var(--ink); background: transparent; border: 1px solid transparent;}
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible {outline: 3px solid var(--focus); outline-offset: 2px;}
input, textarea, select {border-color: var(--line); color: var(--ink); background: var(--panel);}
select {max-width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius);}
input::placeholder, textarea::placeholder {color: var(--muted); opacity: 1;}
.account-tools button, #contact-settings-button, .social-tools button, .sidebar-foot button {font-size: 13px; padding: 9px 10px; white-space: normal; overflow-wrap: anywhere;}
.account-tools {gap: 8px;}
.tabs button {color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent;}
.tabs button.active {color: var(--green); border-bottom-color: var(--green);}
.tabs span {color: var(--ink);}
.message-meta {opacity: 1; font-size: 12px; color: var(--muted);}
.out .bubble .message-meta, .out .bubble .muted {color: #375025;}
.out .bubble .secondary {background: #f1f7e9; color: #173b2b; border-color: #749367;}
.tools-dialog label:has(input[type=checkbox]) {display: flex; align-items: center; gap: 10px; margin: 8px 0;}
.tools-dialog input[type=checkbox] {width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--green);}
.style-description {font-size: 13px; color: var(--muted); margin: 4px 0 12px;}

.brand-icon {background:var(--primary-bg); color:var(--primary-ink);}

/* Classic ICQ: squared controls, blue title bars, a restrained grey workspace. */
html[data-ui-style=classic] {font-family: Tahoma, "Segoe UI", sans-serif;}
html[data-ui-style=classic] body {
  --bg: #dfe7ef; --panel: #f7f9fc; --ink: #142c46; --muted: #455c74;
  --line: #a3b6ca; --green: #246129; --accent: #dbefc8; --soft: #e6edf5;
  --bubble: #fff; --button-bg: #e7edf4; --button-ink: #17314e; --button-border: #8aa1ba;
  --primary-bg: #245d95; --primary-ink: #fff; --radius: 3px;
  --shadow: 0 4px 16px #1d375526;
}
html[data-ui-style=classic] body.dark {
  --bg: #151d29; --panel: #202e40; --ink: #edf4ff; --muted: #b9cce2;
  --line: #627b96; --green: #b6dc91; --accent: #dbefc8; --soft: #2b3d52;
  --bubble: #293d54; --button-bg: #354d68; --button-ink: #f4f8ff; --button-border: #8aa4c2;
  --primary-bg: #b8d9fa; --primary-ink: #153658;
}
html[data-ui-style=classic] .topbar {background: #174c80; color: #fff; border-bottom: 2px solid #91b5d9;}
html[data-ui-style=classic] .topbar .brand, html[data-ui-style=classic] .topbar .brand-note,
html[data-ui-style=classic] .topbar #connection-status, html[data-ui-style=classic] .topbar .icon-button {color: #fff;}
html[data-ui-style=classic] .client-layout, html[data-ui-style=classic] .login-card,
html[data-ui-style=classic] dialog, html[data-ui-style=classic] .admin-section,
html[data-ui-style=classic] .stat, html[data-ui-style=classic] .admin-policy {border-radius: 4px;}
html[data-ui-style=classic] .sidebar-heading, html[data-ui-style=classic] .chat-header,
html[data-ui-style=classic] .dialog-header {background: var(--soft);}
html[data-ui-style=classic] .contact, html[data-ui-style=classic] .bubble,
html[data-ui-style=classic] input, html[data-ui-style=classic] textarea,
html[data-ui-style=classic] .search, html[data-ui-style=classic] .avatar {border-radius: 3px;}
html[data-ui-style=classic] .bubble {border: 1px solid var(--line); box-shadow: none;}
html[data-ui-style=classic] .out .bubble {border-color: #8da777;}
html[data-ui-style=classic] .brand-icon {background: #fff; color: #328327; border-radius: 3px;}
html[data-ui-style=classic] .contact.active {box-shadow: inset 3px 0 var(--green);}
@media(max-width:760px) {
  button, .ghost, .secondary {min-height: 44px;}
  .account-tools button, .social-tools button {font-size: 13px;}
  .tools-row button {font-size: 13px; min-height: 44px;}
}

/* Ocean: rounded blue controls and a cool, clean workspace. */
html[data-ui-style=ocean] body {
  --bg:#eaf1fa; --panel:#fff; --ink:#16314c; --muted:#455e76; --line:#b2c5db;
  --green:#215b95; --accent:#d5e9ff; --soft:#e7f0fc; --bubble:#eef4fc;
  --button-bg:#dfedfc; --button-ink:#173f69; --button-border:#8eaed0;
  --primary-bg:#215b95; --primary-ink:#fff; --radius:18px; --out-muted:#315273;
}
html[data-ui-style=ocean] body.dark {
  --bg:#101e30; --panel:#192f49; --ink:#ecf5ff; --muted:#b1c9e2; --line:#577697;
  --green:#a0d3ff; --accent:#d5e9ff; --soft:#243e5b; --bubble:#24405e;
  --button-bg:#2a4b6d; --button-ink:#f0f7ff; --button-border:#84afd5;
  --primary-bg:#add7ff; --primary-ink:#123454;
}
html[data-ui-style=ocean] .chat-header, html[data-ui-style=ocean] .self {background:var(--soft);}
html[data-ui-style=ocean] .client-layout {border-radius:22px;}
html[data-ui-style=ocean] .bubble {border-radius:18px 18px 18px 5px;}
html[data-ui-style=ocean] .out .bubble {border-radius:18px 18px 5px 18px;}
html[data-ui-style=ocean] .avatar {border-radius:50%;}

/* Graphite: neutral surfaces, straight lines, understated accents. */
html[data-ui-style=graphite] body {
  --bg:#e9ebef; --panel:#fff; --ink:#252932; --muted:#585e6b; --line:#b8bdc7;
  --green:#414d68; --accent:#e1e4ec; --soft:#eceef3; --bubble:#f2f3f6;
  --button-bg:#e7e9ee; --button-ink:#282f3d; --button-border:#a2a9b7;
  --primary-bg:#343c4d; --primary-ink:#fff; --radius:6px; --out-muted:#485165;
}
html[data-ui-style=graphite] body.dark {
  --bg:#16181e; --panel:#252830; --ink:#f0f1f6; --muted:#bec3cf; --line:#686e7c;
  --green:#c8d3ee; --accent:#e1e4ec; --soft:#343843; --bubble:#343843;
  --button-bg:#3c424f; --button-ink:#f2f4fa; --button-border:#8992a5;
  --primary-bg:#d6dbea; --primary-ink:#242b39;
}
html[data-ui-style=graphite] .client-layout, html[data-ui-style=graphite] dialog {border-radius:8px; box-shadow:none;}
html[data-ui-style=graphite] .contact, html[data-ui-style=graphite] .bubble {border-radius:6px;}
html[data-ui-style=graphite] .contact.active {box-shadow:inset 3px 0 var(--green);}
html[data-ui-style=graphite] .message-meta {font-family:Consolas, monospace;}

/* Warm: soft paper colors and terracotta actions. */
html[data-ui-style=warm] body {
  --bg:#f4ece2; --panel:#fffcf7; --ink:#422c25; --muted:#73574c; --line:#c8b0a0;
  --green:#8c432d; --accent:#f7dfc3; --soft:#f3e7da; --bubble:#f5eadf;
  --button-bg:#f3e2d2; --button-ink:#63321f; --button-border:#b58d72;
  --primary-bg:#89432f; --primary-ink:#fff; --radius:14px; --out-muted:#704f32;
}
html[data-ui-style=warm] body.dark {
  --bg:#231b18; --panel:#352720; --ink:#fff3e8; --muted:#d8beb0; --line:#8b7060;
  --green:#f1c39e; --accent:#f7dfc3; --soft:#4a362b; --bubble:#4a362b;
  --button-bg:#563c2e; --button-ink:#fff1e4; --button-border:#bb9479;
  --primary-bg:#f1c39e; --primary-ink:#4f2918;
}
html[data-ui-style=warm] .chat-header strong, html[data-ui-style=warm] .sidebar-heading h2 {font-family:Georgia, serif;}
html[data-ui-style=warm] .bubble {border:1px solid var(--line);}
html[data-ui-style=warm] .client-layout {box-shadow:0 8px 28px #6b3d211c;}
html[data-ui-style=ocean] .out .bubble, html[data-ui-style=graphite] .out .bubble,
html[data-ui-style=warm] .out .bubble {color:var(--button-ink);}
/* Outgoing bubbles always have a light surface, even in the dark themes. */
html[data-ui-style=ocean] .out .bubble {color:#173f69;}
html[data-ui-style=graphite] .out .bubble {color:#282f3d;}
html[data-ui-style=warm] .out .bubble {color:#63321f;}
.out .bubble .message-meta, .out .bubble .muted {color:var(--out-muted,#375025);}
html[data-ui-style=ocean] .out .bubble .secondary,
html[data-ui-style=graphite] .out .bubble .secondary,
html[data-ui-style=warm] .out .bubble .secondary {background:#fff; color:inherit; border-color:#8f99a3;}

/* Density is independent of style and message font size. */
html[data-ui-density=compact] .self {padding:12px 14px; gap:8px;}
html[data-ui-density=compact] .account-tools {padding:6px 12px 8px; gap:5px;}
html[data-ui-density=compact] .sidebar-heading {padding:12px 14px 0;}
html[data-ui-density=compact] .contact {padding:8px 10px; gap:8px;}
html[data-ui-density=compact] .avatar {width:34px; height:34px;}
html[data-ui-density=compact] .chat-header {padding:12px 18px; gap:10px;}
html[data-ui-density=compact] .bubble {padding:8px 12px;}
html[data-ui-density=compact] .message {margin-bottom:8px;}
html[data-ui-density=compact] .message-meta {margin-top:3px;}
html[data-ui-density=compact] .tabs {margin-top:6px;}
html[data-ui-density=compact] .tabs button {padding:9px 2px;}
html[data-ui-density=compact] .composer {padding:12px 16px; gap:8px;}
html[data-ui-density=compact] .tools-content {gap:8px;}
html[data-ui-density=compact] dialog {padding:20px;}
html[data-ui-density=compact] .admin-section,
html[data-ui-density=compact] .stat, html[data-ui-density=compact] .admin-policy {padding:16px;}
@media(min-width:761px) {
  html[data-ui-density=compact] .client-layout {grid-template-columns:280px minmax(0,1fr);}
  html[data-ui-density=compact] button, html[data-ui-density=compact] .ghost {min-height:34px; padding:7px 10px;}
  html[data-ui-density=compact] .icon-button {width:34px; padding:0;}
  html[data-ui-density=compact] input, html[data-ui-density=compact] textarea,
  html[data-ui-density=compact] select {padding:9px 10px;}
}
@media(max-width:760px) {
  html[data-ui-density=compact] .composer {padding:6px 10px max(6px,env(safe-area-inset-bottom));}
  html[data-ui-density=compact] .chat-header {padding:8px 10px;}
  html[data-ui-density=compact] button, html[data-ui-density=compact] .ghost,
  html[data-ui-density=compact] summary.icon-button {min-height:44px;}
}
