/* =====================================================================
   Hello Chat AI — styles.css
   All styling + theming via CSS variables. Light + dark supported.
   ===================================================================== */

/* ---------- Design tokens (light is the base) ---------- */
:root {
  --bg: #f7f6f3;
  --bg-grad-1: #f9f2ee;
  --bg-grad-2: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --surface-3: #e9e8e3;
  --text: #201e1b;
  --text-muted: #6c6a64;
  --text-faint: #9a978f;
  --border: rgba(20, 18, 15, 0.10);
  --border-strong: rgba(20, 18, 15, 0.16);

  --accent: #d97757;
  --accent-hover: #c15f3f;
  --accent-press: #ac4f31;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(217, 119, 87, 0.12);
  --accent-ring: rgba(217, 119, 87, 0.35);

  --user-bubble: linear-gradient(135deg, #e2825f 0%, #d0623f 100%);
  --user-bubble-text: #ffffff;
  --assistant-bubble: var(--surface);

  --danger: #c0392b;
  --danger-hover: #a93226;
  --danger-soft: rgba(192, 57, 43, 0.10);

  --shadow-sm: 0 1px 2px rgba(20, 18, 15, 0.06), 0 1px 3px rgba(20, 18, 15, 0.05);
  --shadow-md: 0 4px 14px rgba(20, 18, 15, 0.09);
  --shadow-lg: 0 18px 50px rgba(20, 18, 15, 0.22);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --header-h: 60px;
  --sidebar-w: 300px;

  --font-ui: "Inter", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 180ms;
}

/* ---------- Dark theme ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191714; --bg-grad-1: #221c18; --bg-grad-2: #17150f;
    --surface: #232019; --surface-2: #2b2721; --surface-3: #35302a;
    --text: #efece5; --text-muted: #a8a49b; --text-faint: #78746c;
    --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18);
    --accent: #e2895f; --accent-hover: #ed9873; --accent-press: #f0a789;
    --accent-contrast: #221a14; --accent-soft: rgba(226, 137, 95, 0.16); --accent-ring: rgba(226, 137, 95, 0.40);
    --user-bubble: linear-gradient(135deg, #e2895f 0%, #cd6b45 100%); --user-bubble-text: #201812;
    --assistant-bubble: var(--surface-2);
    --danger: #ef8a7f; --danger-hover: #f39c92; --danger-soft: rgba(239, 138, 127, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #191714; --bg-grad-1: #221c18; --bg-grad-2: #17150f;
  --surface: #232019; --surface-2: #2b2721; --surface-3: #35302a;
  --text: #efece5; --text-muted: #a8a49b; --text-faint: #78746c;
  --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #e2895f; --accent-hover: #ed9873; --accent-press: #f0a789;
  --accent-contrast: #221a14; --accent-soft: rgba(226, 137, 95, 0.16); --accent-ring: rgba(226, 137, 95, 0.40);
  --user-bubble: linear-gradient(135deg, #e2895f 0%, #cd6b45 100%); --user-bubble-text: #201812;
  --assistant-bubble: var(--surface-2);
  --danger: #ef8a7f; --danger-hover: #f39c92; --danger-soft: rgba(239, 138, 127, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* [hidden] must always win over display rules */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:lang(bn) { line-height: 1.7; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-hover); }
img { display: block; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100dvh; }
.main-col {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 900px; margin: 0 auto; height: var(--header-h);
  padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { filter: drop-shadow(0 2px 6px var(--accent-soft)); }
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-controls { display: flex; align-items: center; gap: 6px; }

/* ---------- Buttons / controls ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; min-width: 38px; padding: 0 9px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.text-btn { font-size: 13.5px; font-weight: 600; }

.model-select { position: relative; display: inline-flex; align-items: center; }
.model-select select {
  appearance: none; -webkit-appearance: none;
  height: 38px; padding: 0 30px 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease);
}
.model-select::after {
  content: ""; position: absolute; right: 11px; width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px); pointer-events: none;
}
.model-select select:hover { border-color: var(--border-strong); }

.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
}

.history-toggle { display: none; }   /* only on mobile */

/* ---------- Chat area ---------- */
.chat { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.messages { max-width: 820px; margin: 0 auto; padding: 24px 16px 8px; display: flex; flex-direction: column; gap: 22px; }

.empty-state {
  max-width: 820px; margin: 0 auto;
  padding: clamp(40px, 12vh, 110px) 24px 40px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-mark { margin-bottom: 10px; animation: floaty 6s var(--ease) infinite; filter: drop-shadow(0 6px 16px var(--accent-soft)); }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-7px) rotate(6deg); } }
.empty-title { font-size: clamp(22px, 4vw, 30px); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.empty-sub { color: var(--text-muted); margin: 0; font-size: 15px; }

/* ---------- Messages ---------- */
.msg { display: flex; gap: 12px; align-items: flex-start; animation: msg-in 360ms var(--ease) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg.user { flex-direction: row-reverse; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 13px; font-weight: 700; box-shadow: var(--shadow-sm); user-select: none; overflow: hidden; }
.avatar.assistant { background: var(--accent); color: var(--accent-contrast); }
.avatar.assistant img { width: 22px; height: 22px; }
.avatar.user { background: var(--surface-3); color: var(--text); }
.bubble-col { min-width: 0; max-width: min(660px, 82%); display: flex; flex-direction: column; gap: 6px; }
.msg.user .bubble-col { align-items: flex-end; }
.bubble { position: relative; padding: 11px 15px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user-bubble); color: var(--user-bubble-text); border-bottom-right-radius: 6px; }
.msg.assistant .bubble { background: var(--assistant-bubble); border: 1px solid var(--border); border-bottom-left-radius: 6px; }

/* Attachments shown inside a message bubble */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-attachments:empty { display: none; }
.att-thumb { width: 132px; max-width: 60vw; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.att-thumb img, .att-thumb video { width: 100%; height: auto; display: block; max-height: 180px; object-fit: cover; }
.att-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  font-size: 12.5px; color: var(--text); max-width: 240px;
}
.msg.user .att-file { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.25); color: inherit; }
.att-file .att-icon { flex: none; opacity: 0.8; }
.att-file .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .att-size { color: var(--text-faint); flex: none; }
.msg.user .att-file .att-size { color: rgba(255,255,255,0.7); }

/* Thinking / reasoning */
.thinking { border: 1px dashed var(--border-strong); background: var(--surface-2); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.thinking > summary { list-style: none; cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 7px; user-select: none; }
.thinking > summary::-webkit-details-marker { display: none; }
.thinking > summary::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.thinking[open] > summary { border-bottom: 1px dashed var(--border); }
.thinking .thinking-body { padding: 4px 14px 12px; font-size: 13px; color: var(--text-muted); white-space: pre-wrap; line-height: 1.6; }

.msg-actions { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.copy-btn { height: 30px; padding: 0 9px; font-size: 12px; font-weight: 600; color: var(--text-muted); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); display: inline-flex; align-items: center; gap: 5px; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.copy-btn:hover { background: var(--surface-2); color: var(--text); }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); animation: blink 1.3s var(--ease) infinite; }
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.bubble.error { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); font-size: 14px; }

/* ---------- Markdown ---------- */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.md h1 { font-size: 1.4em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 1.4em; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--text-faint); }
.md a { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
.msg.user .md a { color: inherit; }
.md blockquote { margin: 0 0 10px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--text-muted); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md code { font-family: var(--font-mono); font-size: 0.88em; background: var(--surface-3); padding: 0.12em 0.4em; border-radius: 6px; }
.msg.user .md code { background: rgba(255,255,255,0.22); }
.md pre { margin: 0 0 10px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 0.86em; line-height: 1.55; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 10px; font-size: 0.92em; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md img { max-width: 100%; border-radius: var(--radius-sm); }

/* ---------- Composer ---------- */
.composer-wrap { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 55%, transparent); padding: 10px 16px calc(8px + env(safe-area-inset-bottom)); }
.attachments { max-width: 820px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.att-chip { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 6px 30px 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); font-size: 12.5px; max-width: 220px; }
.att-chip .chip-thumb { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; flex: none; background: var(--surface-3); }
.att-chip .chip-ico { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-hover); flex: none; }
.att-chip .chip-meta { min-width: 0; }
.att-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-chip .chip-sub { color: var(--text-faint); font-size: 11px; }
.att-chip .chip-remove { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border: none; border-radius: 50%; background: var(--surface-3); color: var(--text-muted); display: grid; place-items: center; }
.att-chip .chip-remove:hover { background: var(--danger-soft); color: var(--danger); }

.composer { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 8px; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-ring); }
.composer.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input-shell { flex: 1 1 auto; display: flex; align-items: center; min-width: 0; }
#composer-input { width: 100%; border: none; outline: none; background: transparent; resize: none; max-height: 200px; padding: 8px 6px; line-height: 1.5; }
#composer-input::placeholder { color: var(--text-faint); }
.send-btn { flex: none; width: 40px; height: 40px; border: none; border-radius: var(--radius); background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; box-shadow: var(--shadow-sm); transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), opacity var(--dur) var(--ease); }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-stop { display: none; }
.send-btn.streaming { background: var(--surface-3); color: var(--text); }
.send-btn.streaming .icon-send { display: none; }
.send-btn.streaming .icon-stop { display: block; }

.drop-hint { max-width: 820px; margin: 6px auto 0; text-align: center; font-size: 12.5px; color: var(--accent-hover); font-weight: 600; }

.app-footer { max-width: 820px; margin: 6px auto 0; text-align: center; font-size: 11.5px; color: var(--text-faint); display: flex; gap: 7px; justify-content: center; align-items: center; }
.app-footer .powered { font-weight: 600; }

/* ---------- Sidebar (history) ---------- */
.sidebar {
  flex: none; width: var(--sidebar-w); height: 100dvh;
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  display: flex; flex-direction: column;
  position: sticky; top: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); padding: 0 16px; border-bottom: 1px solid var(--border); }
.sidebar-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.new-chat-btn { margin: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-sm); transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.new-chat-btn:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }
.new-chat-btn:active { transform: scale(0.98); }

.history-list { flex: 1 1 auto; overflow-y: auto; padding: 4px 10px 10px; }
.history-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); padding: 12px 8px 6px; }
.history-item { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 9px 34px 9px 12px; border-radius: 10px; cursor: pointer; transition: background var(--dur) var(--ease); }
.history-item:hover { background: var(--surface-2); }
.history-item.active { background: var(--accent-soft); }
.history-item.active .history-item-title { color: var(--accent-hover); }
.history-item-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item-time { font-size: 11px; color: var(--text-faint); }
.history-del { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border: none; border-radius: 7px; background: transparent; color: var(--text-faint); display: grid; place-items: center; opacity: 0; transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease); }
.history-item:hover .history-del { opacity: 1; }
.history-del:hover { background: var(--danger-soft); color: var(--danger); }

.history-empty { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; color: var(--text-faint); font-size: 13px; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
.retention-note { margin: 0 0 8px; font-size: 11px; color: var(--text-faint); text-align: center; }
.clear-all-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; height: 38px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.clear-all-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Scrim (mobile drawer) ---------- */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(15,12,9,0.45); backdrop-filter: blur(2px); animation: fade-in var(--dur) var(--ease); }

/* ---------- Modals ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 12, 9, 0.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px; animation: fade-in var(--dur) var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { position: relative; width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 26px 24px 22px; text-align: center; animation: pop-in 260ms var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal-mark { margin: 0 auto 12px; }
.modal h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.modal-desc { margin: 0 0 18px; color: var(--text-muted); font-size: 14px; }
.modal.confirm { max-width: 380px; }

.field { position: relative; display: flex; align-items: center; }
#key-input { width: 100%; height: 46px; padding: 0 44px 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); font-family: var(--font-mono); font-size: 14px; letter-spacing: 0.02em; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
#key-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.reveal-btn { position: absolute; right: 5px; height: 36px; min-width: 36px; }

.modal-error { margin: 10px 0 0; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; text-align: left; }
.modal-reassure { display: flex; align-items: flex-start; gap: 7px; margin: 14px 0 0; color: var(--text-muted); font-size: 12.5px; text-align: left; line-height: 1.5; }
.modal-reassure svg { flex: none; margin-top: 2px; color: var(--accent); }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn-primary, .btn-secondary, .btn-danger { flex: 1; height: 44px; border-radius: var(--radius); font-weight: 600; font-size: 14.5px; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease); border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger:active { transform: scale(0.98); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); z-index: 60; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive: sidebar becomes a right drawer ---------- */
@media (max-width: 900px) {
  .history-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; right: 0; z-index: 40;
    width: min(320px, 86vw);
    transform: translateX(100%);
    transition: transform 240ms var(--ease);
    box-shadow: var(--shadow-lg);
    background: color-mix(in srgb, var(--surface) 88%, var(--bg));
  }
  .sidebar.open { transform: translateX(0); }
}
@media (min-width: 901px) {
  #sidebar-close { display: none; }
  .scrim { display: none !important; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .brand-name { font-size: 15px; }
  .model-select select { max-width: 118px; text-overflow: ellipsis; }
  .header-controls { gap: 3px; }
  .icon-btn { padding: 0 7px; min-width: 36px; height: 36px; }
  .bubble-col { max-width: 88%; }
  .messages { gap: 18px; padding-top: 16px; }
}
@media (max-width: 400px) {
  .header-inner { padding: 0 10px; }
  .brand-name { display: none; }
  .model-select select { max-width: 100px; padding-left: 10px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .chat { scroll-behavior: auto; }
}
