/* ClinikAgents — 3 thèmes (Medical Pro, Dark Clinical, Warm Practice) × clair / foncé.
   Charte : navy #0A1628, bleu #4A9EFF, teal #00D4AA. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 290px;
  --navy: #0A1628;
  --blue: #4A9EFF;
  --teal: #00D4AA;
  color-scheme: light;
}

/* ---------- Medical Pro ---------- */
:root,
[data-theme="medical"][data-mode="light"] {
  --bg: #F3F6FB; --surface: #FFFFFF; --surface-2: #EAF0F8; --border: #D5DFEC;
  --text: #0A1628; --muted: #56677F;
  --primary: #4A9EFF; --on-primary: #0A1628; --primary-strong: #1A64C2; --focus: #4A9EFF;
  --accent: #00D4AA; --accent-text: #007A63;
  --user-bubble: #0A1628; --on-user-bubble: #F3F6FB; --assistant-bubble: #FFFFFF;
  --topbar: #0A1628; --on-topbar: #EAF1FB; --topbar-muted: #9FB3CF;
  --danger: #C93838; --warn: #B37400; --ok: #00A884;
  --shadow: 0 1px 2px rgba(10, 22, 40, .06), 0 10px 30px rgba(10, 22, 40, .07);
}
[data-theme="medical"][data-mode="dark"] {
  --bg: #0A1628; --surface: #101F37; --surface-2: #162A48; --border: #223A5E;
  --text: #E7EEF8; --muted: #94A6C0;
  --primary: #4A9EFF; --on-primary: #0A1628; --primary-strong: #86C0FF; --focus: #86C0FF;
  --accent: #00D4AA; --accent-text: #3EE6C3;
  --user-bubble: #4A9EFF; --on-user-bubble: #0A1628; --assistant-bubble: #101F37;
  --topbar: #07101F; --on-topbar: #E7EEF8; --topbar-muted: #8EA2BF;
  --danger: #FF6B6B; --warn: #F2B544; --ok: #2FE0B8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ---------- Dark Clinical ---------- */
[data-theme="clinical"][data-mode="dark"] {
  --bg: #060D18; --surface: #0C1626; --surface-2: #122036; --border: #1C2E48;
  --text: #DCE7F3; --muted: #8597AF;
  --primary: #00D4AA; --on-primary: #04221C; --primary-strong: #4BE8C8; --focus: #4BE8C8;
  --accent: #4A9EFF; --accent-text: #86C0FF;
  --user-bubble: #00D4AA; --on-user-bubble: #04221C; --assistant-bubble: #0C1626;
  --topbar: #040A13; --on-topbar: #DCE7F3; --topbar-muted: #7F91AA;
  --danger: #FF6B6B; --warn: #F2B544; --ok: #2FE0B8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
[data-theme="clinical"][data-mode="light"] {
  --bg: #EDF2F5; --surface: #FFFFFF; --surface-2: #E1E9EF; --border: #C9D5DF;
  --text: #0B1A2C; --muted: #536375;
  --primary: #00B892; --on-primary: #0A1628; --primary-strong: #00785F; --focus: #00B892;
  --accent: #4A9EFF; --accent-text: #1A64C2;
  --user-bubble: #0B1A2C; --on-user-bubble: #EDF2F5; --assistant-bubble: #FFFFFF;
  --topbar: #0B1A2C; --on-topbar: #E3ECF3; --topbar-muted: #93A6B9;
  --danger: #C93838; --warn: #B37400; --ok: #00896C;
  --shadow: 0 1px 2px rgba(11, 26, 44, .07), 0 10px 28px rgba(11, 26, 44, .08);
}

/* ---------- Warm Practice ---------- */
[data-theme="warm"][data-mode="light"] {
  --bg: #F8F4EE; --surface: #FFFDF9; --surface-2: #F1EADF; --border: #E3D8C9;
  --text: #2A2420; --muted: #74675B;
  --primary: #4A9EFF; --on-primary: #0A1628; --primary-strong: #1F67C4; --focus: #4A9EFF;
  --accent: #00B894; --accent-text: #00775F;
  --user-bubble: #24324A; --on-user-bubble: #FFF8EF; --assistant-bubble: #FFFDF9;
  --topbar: #24324A; --on-topbar: #FBF4EA; --topbar-muted: #B9C0CC;
  --danger: #B93A2E; --warn: #A86B00; --ok: #00896C;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 10px 30px rgba(60, 40, 20, .08);
}
[data-theme="warm"][data-mode="dark"] {
  --bg: #1B1713; --surface: #25201B; --surface-2: #2F2923; --border: #3E362D;
  --text: #F2EADF; --muted: #B3A594;
  --primary: #6FB2FF; --on-primary: #1B1713; --primary-strong: #A3CDFF; --focus: #A3CDFF;
  --accent: #2FD9B5; --accent-text: #5FE6C9;
  --user-bubble: #6FB2FF; --on-user-bubble: #1B1713; --assistant-bubble: #25201B;
  --topbar: #14110E; --on-topbar: #F2EADF; --topbar-muted: #A99A88;
  --danger: #FF7A6B; --warn: #F2B544; --ok: #2FD9B5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.danger { color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer; color: inherit;
}
.icon-btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; border: 0; padding: 0; margin: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); font-weight: 400;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 0; }
.radio, .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px 0; cursor: pointer; }
.radio input, .check input { margin-top: 4px; accent-color: var(--primary); width: 18px; height: 18px; }
.stack { display: grid; gap: 14px; }
.form-error { color: var(--danger); font-weight: 600; margin: 0; }

/* ---------- Connexion ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--teal) 22%, transparent), transparent 60%),
    radial-gradient(800px 600px at -10% 110%, color-mix(in srgb, var(--blue) 25%, transparent), transparent 60%),
    var(--navy);
}
.login-card {
  width: min(400px, 100%); display: grid; gap: 14px; padding: 32px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
}
.login-logo { width: 84px; height: 84px; border-radius: 20px; justify-self: center; }
.login-title { text-align: center; font-size: 26px; letter-spacing: -.01em; }
.login-card > p { text-align: center; margin: -6px 0 6px; }
.login-foot { display: flex; justify-content: center; gap: 10px; font-size: 14px; color: var(--muted); }

/* ---------- Coque de l'application ---------- */
.shell {
  height: 100dvh; display: grid;
  grid-template: "top top" auto "side main" 1fr / var(--sidebar-w) 1fr;
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--topbar); color: var(--on-topbar);
}
.topbar .btn-ghost { border-color: color-mix(in srgb, var(--on-topbar) 30%, transparent); color: var(--on-topbar); }
.topbar .btn-ghost:hover { background: color-mix(in srgb, var(--on-topbar) 12%, transparent); }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; }
.brand { display: grid; line-height: 1.2; min-width: 0; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand span { font-size: 12.5px; color: var(--topbar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--on-topbar) 12%, transparent); color: var(--on-topbar);
  font-variant-numeric: tabular-nums;
}
.pill.warn { background: color-mix(in srgb, var(--warn) 30%, transparent); }
.pill.full { background: var(--danger); color: #fff; }

.sidebar {
  grid-area: side; display: flex; flex-direction: column; gap: 14px; padding: 16px 12px;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; min-height: 0;
}
.note { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; background: color-mix(in srgb, var(--warn) 14%, transparent); }
.conv-nav { display: grid; gap: 6px; }
.side-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 10px 6px 2px; }
.conv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.conv-item {
  width: 100%; text-align: left; display: grid; gap: 1px; padding: 9px 10px; border-radius: var(--radius-sm);
  border: 0; background: transparent; cursor: pointer;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.conv-item .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .m { font-size: 12px; color: var(--muted); }
.conv-list .empty { padding: 6px 10px; font-size: 13px; color: var(--muted); }
.side-foot { margin-top: auto; font-size: 12px; padding: 0 6px; }
.backdrop { display: none; }

/* ---------- Chat ---------- */
.chat { grid-area: main; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.chat-head h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chat-head .muted { font-size: 13px; }
.chat-actions { margin-left: auto; display: flex; gap: 8px; }
.messages { flex: 1; overflow-y: auto; padding: 24px 20px; scroll-behavior: smooth; }
.messages > * { max-width: 820px; margin-inline: auto; }

.welcome { text-align: center; padding: 6vh 8px 24px; display: grid; gap: 10px; justify-items: center; }
.welcome img { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); }
.welcome h2 { font-size: 22px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.suggestion {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 14px;
  cursor: pointer; font-size: 14px; text-align: left;
}
.suggestion:hover { border-color: var(--primary); }

.msg { display: flex; gap: 10px; margin-bottom: 18px; }
.msg-user { justify-content: flex-end; }
.msg .avatar { width: 30px; height: 30px; border-radius: 8px; flex: none; margin-top: 2px; }
.msg-body { display: grid; justify-items: start; min-width: 0; max-width: min(720px, 88%); }
.msg-user .msg-body { justify-items: end; }
.bubble { padding: 11px 15px; border-radius: var(--radius); max-width: 100%; overflow-wrap: anywhere; }
.msg-user .bubble { background: var(--user-bubble); color: var(--on-user-bubble); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg-assistant .bubble { background: var(--assistant-bubble); border: 1px solid var(--border); border-top-left-radius: 4px; box-shadow: var(--shadow); }
.msg-meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg-meta .agent-tag { font-weight: 700; color: var(--accent-text); }
.msg-meta .status { color: var(--warn); font-weight: 600; }
.msg-error .bubble { border-color: var(--danger); }
.msg-error .err { color: var(--danger); font-weight: 600; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Contenu Markdown des réponses */
.bubble p { margin: 0 0 .7em; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 .7em; padding-left: 1.3em; }
.bubble h3, .bubble h4, .bubble h5, .bubble h6 { font-size: 15px; margin: .8em 0 .4em; }
.bubble code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.bubble pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; margin: 0 0 .7em; }
.bubble pre code { background: none; padding: 0; }
.bubble blockquote { margin: 0 0 .7em; padding-left: 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.bubble .table-wrap { margin: 0 0 .7em; }
.bubble table { border-collapse: collapse; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; }

.banner { margin: 0 20px 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; font-size: 14px; }

.composer { padding: 10px 20px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.composer > * { max-width: 820px; margin-inline: auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.composer-box:focus-within { border-color: var(--primary); }
.composer textarea {
  flex: 1; border: 0; background: transparent; resize: none; outline: none;
  max-height: 200px; min-height: 26px; padding: 6px 0; line-height: 1.5;
}
.send-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 12px;
  background: var(--primary); color: var(--on-primary); cursor: pointer;
}
.send-btn:disabled { opacity: .45; cursor: not-allowed; }
.composer-bar { display: flex; align-items: center; gap: 12px; padding: 6px 4px 0; min-height: 30px; }
.hint { font-size: 12px; margin-left: auto; }

/* Choix d'agent discret */
.agent-picker { position: relative; }
.agent-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer;
}
.agent-chip:hover, .agent-chip[aria-expanded="true"] { border-color: var(--border); background: var(--surface); }
.agent-chip svg { width: 14px; height: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }
.agent-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.agent-menu button {
  width: 100%; display: grid; grid-template-columns: 12px 1fr; gap: 2px 10px; align-items: center; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; cursor: pointer;
}
.agent-menu button:hover, .agent-menu button[aria-checked="true"] { background: var(--surface-2); }
.agent-menu small { grid-column: 2; color: var(--muted); font-size: 12px; }

/* ---------- Dialogues ---------- */
.dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0;
  border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog-wide { width: min(980px, calc(100% - 24px)); }
.dialog::backdrop { background: rgba(5, 12, 24, .55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--border); margin: 0; }
.dialog-head h2 { font-size: 18px; }
.dialog-body { padding: 18px 20px 22px; overflow-y: auto; display: grid; gap: 22px; align-content: start; }
.dialog-body section { display: grid; gap: 10px; }
.dialog-body h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.row-2 { display: grid !important; grid-template-columns: 1fr 1fr; gap: 18px !important; }
.row-2 > div { display: grid; gap: 10px; align-content: start; }

.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-card {
  display: grid; gap: 8px; padding: 10px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13.5px; text-align: center;
}
.theme-card[aria-pressed="true"] { border-color: var(--primary); }
.swatch { display: flex; height: 38px; border-radius: 8px; overflow: hidden; }
.swatch i { flex: 1; }
.swatch-medical i:nth-child(1) { background: #0A1628; } .swatch-medical i:nth-child(2) { background: #4A9EFF; } .swatch-medical i:nth-child(3) { background: #F3F6FB; }
.swatch-clinical i:nth-child(1) { background: #060D18; } .swatch-clinical i:nth-child(2) { background: #00D4AA; } .swatch-clinical i:nth-child(3) { background: #122036; }
.swatch-warm i:nth-child(1) { background: #24324A; } .swatch-warm i:nth-child(2) { background: #4A9EFF; } .swatch-warm i:nth-child(3) { background: #F8F4EE; }

.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.tabs { display: flex; gap: 4px; padding: 8px 14px 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: transparent; padding: 9px 12px; cursor: pointer; font-weight: 600; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head p { margin: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table-compact td, .table-compact th { padding: 6px 10px; font-size: 13px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); }
.tag.off { color: var(--danger); }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.meter.warn > i { background: var(--warn); }
.meter.full > i { background: var(--danger); }
.conv-list-wide .conv-item { border: 1px solid var(--border); margin-bottom: 6px; }

.toast {
  position: fixed; inset: auto; margin: 0; border: 0;
  left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
}

/* ---------- Mobile ---------- */
.only-mobile { display: none; }
@media (max-width: 860px) {
  .shell { grid-template: "top" auto "main" 1fr / 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(310px, 86vw);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .shell.sidebar-open .sidebar { transform: none; }
  .shell.sidebar-open .backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(5, 12, 24, .45); }
  .brand span, .hint { display: none; }
  .messages { padding: 16px 12px; }
  .composer { padding-inline: 10px; }
  .chat-head { padding: 10px 14px; }
  .bubble { max-width: 92%; }
  .theme-grid { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .dialog-body { padding: 16px; }
}
@media (max-width: 420px) {
  #admin-btn { padding: 0 8px; }
  .msg .avatar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
