/* ============================================================
   VamusAI — premium workspace theme
   Palette is drawn directly from the app icon's teal→blue mark:
   a deep usable teal for everyday UI, with the icon's brighter
   teal/blue duo reserved for gradient accents on the moments
   that should feel like "the brand" — primary actions, avatars,
   the hero mark's glow.
   ============================================================ */

:root {
  --bg: #ffffff;
  --sidebar-bg: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #f2f3f6;
  --surface-3: #e9ebef;
  --border: #e7e8ec;
  --border-strong: #d7d9e0;

  --text: #17181c;
  --text-muted: #6b6f7b;
  --text-faint: #9a9ea9;

  --ink: #17181c;          /* dark neutral buttons */
  --ink-hover: #000000;

  --accent: #0aab8c;        /* deepened, usable version of the icon's teal */
  --accent-hover: #078f74;
  --accent-soft: #e2f9f3;

  --accent-teal: #10dcba;   /* icon's actual teal — gradients & brand moments only */
  --accent-blue: #0f83fd;   /* icon's actual blue */
  --accent-gradient: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  --accent-gradient-hover: linear-gradient(135deg, #0dc6a8, #0d72e0);
  --accent-glow: 0 8px 26px -6px rgba(15, 131, 253, 0.35), 0 6px 18px -8px rgba(16, 220, 186, 0.35);

  --danger: #d1453a;
  --danger-soft: #fceceb;

  --font-display: "Inter", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --sidebar-w: 264px;

  --shadow-sm: 0 1px 2px rgba(23, 24, 28, 0.05);
  --shadow-md: 0 4px 14px rgba(23, 24, 28, 0.07);
  --shadow-lg: 0 20px 55px rgba(23, 24, 28, 0.16);

  --radius: 14px;
  --radius-lg: 20px;
}

/* Dark theme variables, defined once and reused by both trigger conditions below. */
:root[data-theme="dark"] {
  --bg: #121316;
  --sidebar-bg: #18191d;
  --surface: #1c1d22;
  --surface-2: #26272d;
  --surface-3: #313239;
  --border: #34353c;
  --border-strong: #45464e;

  --text: #f1f2f4;
  --text-muted: #a8abb3;
  --text-faint: #74767e;

  --ink: #f1f2f4;
  --ink-hover: #ffffff;

  --accent: #1fd4ac;
  --accent-hover: #3ee0bd;
  --accent-soft: rgba(31, 212, 172, 0.16);

  --accent-teal: #17e6c2;
  --accent-blue: #3d93ff;
  --accent-gradient: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  --accent-gradient-hover: linear-gradient(135deg, #34ecca, #5aa4ff);
  --accent-glow: 0 8px 26px -6px rgba(61, 147, 255, 0.4), 0 6px 18px -8px rgba(23, 230, 194, 0.4);

  --danger: #ff6b60;
  --danger-soft: rgba(255, 107, 96, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 55px rgba(0, 0, 0, 0.5);
}

/* "System" (no explicit data-theme, or data-theme="system") follows the OS — same
   values as data-theme="dark" above, just gated by the media query instead of the attribute. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #121316;
    --sidebar-bg: #18191d;
    --surface: #1c1d22;
    --surface-2: #26272d;
    --surface-3: #313239;
    --border: #34353c;
    --border-strong: #45464e;

    --text: #f1f2f4;
    --text-muted: #a8abb3;
    --text-faint: #74767e;

    --ink: #f1f2f4;
    --ink-hover: #ffffff;

    --accent: #1fd4ac;
    --accent-hover: #3ee0bd;
    --accent-soft: rgba(31, 212, 172, 0.16);

    --accent-teal: #17e6c2;
    --accent-blue: #3d93ff;
    --accent-gradient: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
    --accent-gradient-hover: linear-gradient(135deg, #34ecca, #5aa4ff);
    --accent-glow: 0 8px 26px -6px rgba(61, 147, 255, 0.4), 0 6px 18px -8px rgba(23, 230, 194, 0.4);

    --danger: #ff6b60;
    --danger-soft: rgba(255, 107, 96, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 55px rgba(0, 0, 0, 0.5);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }

button, textarea { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* Thin, unobtrusive scrollbars everywhere instead of the chunky OS default — a small
   detail, but a stock scrollbar next to a designed interface is a dead giveaway. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }

/* ---------- shared motion ---------- */
:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-press: cubic-bezier(0.4, 0, 0.6, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- app shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
.app.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.75rem 1rem;
  overflow: hidden;
  min-width: 0;
}

.app.sidebar-collapsed .sidebar {
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
}

.sidebar-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.3rem 0.9rem 0.4rem;
}

.sidebar-topbar-icons {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.1s var(--ease-press);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }

.sidebar-expand-btn {
  position: fixed;
  top: 0.9rem;
  left: 1rem;
  z-index: 15;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.sidebar-expand-btn:hover { color: var(--text); }
.sidebar-expand-btn[hidden] { display: none; }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  margin: 0 0.05rem 0.7rem;
  color: var(--text-faint);
}
.sidebar-search[hidden] { display: none; }
.sidebar-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.82rem;
  color: var(--text);
  width: 100%;
}
.sidebar-search input::placeholder { color: var(--text-faint); }

.sidebar-top { margin-bottom: 1rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-mark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
}

.chat-list-item-row.is-search-hidden { display: none; }

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 10px;
  padding: 0.62rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.new-chat-btn:hover { background: var(--surface-2); border-color: var(--text-faint); }
.new-chat-btn:active { transform: scale(0.99); }
.new-chat-btn span { font-size: 1.05rem; line-height: 1; font-weight: 400; color: var(--accent); }

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  padding: 0.6rem 0.5rem 0.5rem;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.chat-list-item-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.12s ease;
}
.chat-list-item-row:hover,
.chat-list-item-row:focus-within { background: var(--surface-3); }
.chat-list-item-row.active { background: var(--accent-soft); }

.chat-list-item {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.55rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s ease;
}
.chat-list-item-row:hover .chat-list-item { color: var(--text); }
.chat-list-item-row.active .chat-list-item { color: var(--accent-hover); font-weight: 600; }

.chat-list-share-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-right: 0.35rem;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.chat-list-item-row:hover .chat-list-share-btn,
.chat-list-item-row:focus-within .chat-list-share-btn { opacity: 1; }
.chat-list-share-btn:hover { background: var(--surface-2); color: var(--text); }

.chat-list-menu {
  position: absolute;
  top: calc(100% + 0.2rem);
  right: 0;
  z-index: 20;
  width: 150px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 0.3rem;
  animation: dropIn 0.12s var(--ease-out);
}
.chat-list-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}
.chat-list-menu-item:hover { background: var(--surface-3); }
.chat-list-menu-item.is-danger { color: var(--danger); }
.chat-list-menu-item.is-danger:hover { background: var(--danger-soft); }

.chat-list-rename-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.chat-list-empty {
  color: var(--text-faint);
  font-size: 0.8rem;
  padding: 0.6rem;
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
  margin-top: 0.6rem;
}

/* ---------- main column ---------- */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  background:
    radial-gradient(640px circle at 12% -8%, rgba(16, 220, 186, 0.11), transparent 60%),
    radial-gradient(640px circle at 92% 8%, rgba(15, 131, 253, 0.09), transparent 55%),
    var(--bg);
}
:root[data-theme="dark"] .main {
  background:
    radial-gradient(640px circle at 12% -8%, rgba(23, 230, 194, 0.14), transparent 60%),
    radial-gradient(640px circle at 92% 8%, rgba(61, 147, 255, 0.12), transparent 55%),
    var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .main {
    background:
      radial-gradient(640px circle at 12% -8%, rgba(23, 230, 194, 0.14), transparent 60%),
      radial-gradient(640px circle at 92% 8%, rgba(61, 147, 255, 0.12), transparent 55%),
      var(--bg);
  }
}

.main-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1.4rem 0;
  flex-shrink: 0;
}

.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.1s var(--ease-press);
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.topbar-icon-btn:active { transform: scale(0.92); }

.upgrade-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-gradient);
  box-shadow: var(--accent-glow);
  border: none;
  color: #ffffff;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.upgrade-btn:hover { background: var(--accent-gradient-hover); transform: translateY(-1px); }
.upgrade-btn:active { transform: scale(0.98); }

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem 1rem;
}

.empty-state {
  max-width: 900px;
  margin: 9vh auto 0;
  text-align: center;
  animation: riseIn 0.4s var(--ease-out);
}
.empty-state-hero {
  max-width: 580px;
  margin: 0 auto 2.6rem;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 0 auto 1.3rem;
  filter: drop-shadow(0 8px 20px rgba(15, 131, 253, 0.3)) drop-shadow(0 4px 10px rgba(16, 220, 186, 0.3));
}
.empty-state h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.9rem;
  color: var(--text);
}
.empty-state p {
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.65;
  margin: 0;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- messages ---------- */
.msg {
  max-width: 740px;
  margin: 0 auto 2.25rem;
  animation: riseIn 0.3s var(--ease-out);
}

.msg-user { display: flex; justify-content: flex-end; margin-bottom: 1.15rem; }
.msg-user-bubble {
  background: var(--surface-2);
  border-radius: 18px 18px 6px 18px;
  padding: 0.7rem 1.05rem;
  max-width: 80%;
  font-size: 0.94rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.msg-assistant { font-size: 0.96rem; line-height: 1.7; color: var(--text); }

.is-streaming > *:last-child::after {
  content: "▍";
  display: inline-block;
  color: var(--accent);
  animation: blink 1s step-start infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- routing indicator ---------- */
.routing-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  padding: 0.3rem 0.1rem;
  margin-bottom: 0.4rem;
}
.routing-indicator[hidden] { display: none; }

.routing-dots { display: inline-flex; gap: 0.2rem; margin-left: 0.15rem; }
.routing-dots i {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: routingDotPulse 1.1s ease-in-out infinite;
}
.routing-dots i:nth-child(1) { animation-delay: 0s; }
.routing-dots i:nth-child(2) { animation-delay: 0.15s; }
.routing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes routingDotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.routing-indicator::before {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  flex-shrink: 0;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- thinking block ---------- */
.thinking-block {
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}
.thinking-block[hidden] { display: none; }
.thinking-block:not([hidden]) { animation: fadeIn 0.2s ease; }

.thinking-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  text-align: left;
  font-size: 0.83rem;
  transition: background 0.12s ease;
}
.thinking-toggle:hover { background: var(--surface-3); }

.thinking-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
}
.thinking-spinner.is-active {
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.thinking-label {
  flex: 1;
  font-style: italic;
  color: var(--text-muted);
}

.thinking-chevron {
  color: var(--text-faint);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.thinking-block.is-open .thinking-chevron { transform: rotate(180deg); }

.thinking-body {
  padding: 0 0.9rem 0.85rem 2.05rem;
  font-size: 0.83rem;
  line-height: 1.6;
  color: var(--text-muted);
  font-style: italic;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.thinking-body[hidden] { display: none; }
.thinking-body:not([hidden]) { animation: fadeIn 0.18s ease; }

/* ---------- token usage ---------- */
.token-usage {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-left: 0.6rem;
}
.token-usage svg { opacity: 0.7; }

/* ---------- final answer ---------- */
.answer { color: var(--text); }
.answer p { margin: 0 0 0.9rem; }
.answer ul, .answer ol { margin: 0 0 0.9rem; padding-left: 1.35rem; }
.answer li { margin-bottom: 0.35rem; }
.answer h3, .answer h4 {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 1.4rem 0 0.55rem;
}
.answer strong { font-weight: 600; }
.answer code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
  font-size: 0.84em;
}
.answer .code-file {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1.1rem 0 0.4rem;
}
.code-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 0.9rem;
  box-shadow: var(--shadow-sm);
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.5rem 0.45rem 0.8rem;
}
.code-block-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.code-block-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.code-block-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 0.32rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.1s var(--ease-press);
}
.code-block-btn:hover { background: var(--surface-3); color: var(--text); }
.code-block-btn:active { transform: scale(0.94); }
.code-block-btn.is-confirmed { color: var(--accent); }

.answer pre {
  background: var(--surface-2);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0;
}
.answer pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
}

.answer-actions { margin-top: 0.6rem; display: flex; align-items: center; }
.copy-btn {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, transform 0.1s var(--ease-press);
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.copy-btn:active { transform: scale(0.96); }

.error-msg {
  color: var(--danger);
  font-size: 0.86rem;
  margin: 0 0 0.55rem;
}
.retry-btn {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.12s ease;
}
.retry-btn:hover { border-color: var(--danger); }

/* ---------- composer ---------- */
.composer-wrap {
  padding: 0.5rem 1.5rem 1.4rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--bg) 45%);
}
/* Inline mode: sitting in normal flow right after the hero (empty-state), not pinned to
   the viewport bottom with content fading in behind it — there's nothing behind it yet. */
.composer-wrap.is-inline {
  padding: 0;
  background: none;
  animation: riseIn 0.4s var(--ease-out) 0.05s backwards;
}

.composer {
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0.85rem 0.85rem 0.7rem;
  box-shadow: var(--shadow-lg);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}

.composer-input {
  width: 100%;
  resize: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.55;
  padding: 0.15rem 0.1rem;
  max-height: 200px;
}
.composer-input::placeholder { color: var(--text-faint); }
.composer-input:focus { outline: none; }

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.send-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.send-btn:hover:not(:disabled) { background: var(--accent-gradient-hover); transform: translateY(-1px); box-shadow: var(--accent-glow); }
.send-btn:disabled { opacity: 0.35; cursor: default; }
.send-btn.is-stop { background: var(--ink); }
.send-btn.is-stop:hover { background: var(--ink-hover); box-shadow: none; }

/* ---------- inline model picker (composer) ---------- */
.model-picker {
  position: relative;
  flex-shrink: 0;
}

.model-picker-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.5rem 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.model-picker-btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.model-picker-btn svg { flex-shrink: 0; transition: transform 0.15s ease; opacity: 0.6; }
.model-picker.is-open .model-picker-btn svg { transform: rotate(180deg); }

.model-picker-btn-effort {
  color: var(--text-faint);
  font-weight: 500;
  padding-left: 0.4rem;
  border-left: 1px solid var(--border-strong);
}

.model-picker-menu {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  z-index: 20;
  overflow: hidden;
  animation: dropIn 0.15s var(--ease-out);
  transform-origin: bottom right;
}
.model-picker-menu[hidden] { display: none; }

.model-picker-panel[hidden] { display: none; }
.model-picker-panel:not([hidden]) { animation: fadeIn 0.15s ease; }

/* ---------- provider / model two-pane picker ---------- */
.provider-picker {
  display: flex;
  height: 210px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.provider-list {
  width: 136px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
}

.provider-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 0.5rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.provider-item:hover { background: var(--surface-3); color: var(--text); }
.provider-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.provider-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #ffffff;
}
.provider-icon-zai { background: #6c5ce7; }
.provider-icon-deepseek { background: #2f6fed; }
.provider-icon-anthropic { background: #c96442; }
.provider-icon-openai { background: #10a37f; }

.provider-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-3);
  border-radius: 5px;
  padding: 0.14rem 0.32rem;
}
.provider-badge-live { color: var(--accent-hover); background: var(--accent-soft); }

.provider-models {
  flex: 1;
  min-width: 0;
  padding: 0.35rem;
  overflow-y: auto;
}

.provider-model-group[hidden] { display: none; }
.provider-model-group:not([hidden]) { animation: fadeIn 0.15s ease; }

.provider-models-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 1rem;
}
.provider-models-empty svg { opacity: 0.6; }

.model-picker-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
.model-picker-option:hover:not(.is-disabled) { background: var(--surface-2); }
.model-picker-option.is-disabled { opacity: 0.4; cursor: not-allowed; }

.model-picker-option-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  min-width: 0;
}
.model-picker-option-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.model-picker-option-sub {
  font-size: 0.72rem;
  color: var(--text-faint);
}
.model-picker-option-badge {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface-3);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
  text-transform: none;
}

.model-picker-check {
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0;
}
.model-picker-option.is-selected .model-picker-check { opacity: 1; }

.model-picker-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.4rem;
}

.model-picker-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
  transition: background 0.12s ease;
}
.model-picker-row:hover { background: var(--surface-2); }
.model-picker-row-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  text-align: left;
}
.model-picker-row-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-faint);
}
.model-picker-row-value {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.model-picker-row-value svg { opacity: 0.6; }

.toggle-switch {
  flex-shrink: 0;
  position: relative;
  width: 32px;
  height: 19px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.model-picker-row[aria-pressed="true"] .toggle-switch { background: var(--accent); }
.model-picker-row[aria-pressed="true"] .toggle-knob { transform: translateX(13px); }

.model-picker-back {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.5rem 0.55rem 0.4rem;
  cursor: pointer;
}
.model-picker-back:hover { color: var(--accent); }

/* ---------- effort gauge (segmented signal-strength style selector) ---------- */
.effort-gauge {
  position: relative;
  display: flex;
  gap: 0.2rem;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.3rem;
  margin: 0.3rem 0.4rem 0.7rem;
}

.effort-gauge-thumb {
  position: absolute;
  top: 0.3rem;
  bottom: 0.3rem;
  left: 0;
  width: 0;
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.effort-gauge-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  border-radius: 9px;
  padding: 0.55rem 0.2rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s ease, transform 0.1s var(--ease-press);
}
.effort-gauge-btn:hover { color: var(--text-muted); }
.effort-gauge-btn.is-active { color: var(--text); }
.effort-gauge-btn:active { transform: scale(0.95); }

.effort-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.15rem;
  height: 13px;
}
.effort-bars i {
  display: block;
  width: 3px;
  border-radius: 1px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}
.effort-bars i:nth-child(1) { height: 5px; }
.effort-bars i:nth-child(2) { height: 7px; }
.effort-bars i:nth-child(3) { height: 9px; }
.effort-bars i:nth-child(4) { height: 11px; }
.effort-bars i:nth-child(5) { height: 13px; }

.effort-bars[data-level="1"] i:nth-child(-n+1),
.effort-bars[data-level="2"] i:nth-child(-n+2),
.effort-bars[data-level="3"] i:nth-child(-n+3),
.effort-bars[data-level="4"] i:nth-child(-n+4),
.effort-bars[data-level="5"] i:nth-child(-n+5) {
  background: var(--text-faint);
}
.effort-gauge-btn.is-active .effort-bars[data-level="1"] i:nth-child(-n+1),
.effort-gauge-btn.is-active .effort-bars[data-level="2"] i:nth-child(-n+2),
.effort-gauge-btn.is-active .effort-bars[data-level="3"] i:nth-child(-n+3),
.effort-gauge-btn.is-active .effort-bars[data-level="4"] i:nth-child(-n+4),
.effort-gauge-btn.is-active .effort-bars[data-level="5"] i:nth-child(-n+5) {
  background: var(--accent);
}

.model-picker-effort-desc {
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--text-faint);
  padding: 0 0.6rem 0.5rem;
  min-height: 2.2em;
}

.composer-hint {
  max-width: 740px;
  margin: 0.6rem auto 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.suggestion-chips {
  max-width: 740px;
  margin: 0.9rem auto 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.suggestion-chips[hidden] { display: none; }

.suggestion-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.15s var(--ease-out);
  animation: riseIn 0.35s var(--ease-out) backwards;
}
.suggestion-chip:nth-child(1) { animation-delay: 0.03s; }
.suggestion-chip:nth-child(2) { animation-delay: 0.07s; }
.suggestion-chip:nth-child(3) { animation-delay: 0.11s; }
.suggestion-chip:nth-child(4) { animation-delay: 0.15s; }
.suggestion-chip:nth-child(5) { animation-delay: 0.19s; }
.suggestion-chip:nth-child(6) { animation-delay: 0.23s; }
.suggestion-chip:nth-child(7) { animation-delay: 0.27s; }
.suggestion-chip:nth-child(8) { animation-delay: 0.31s; }
.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.suggestion-chip:active { transform: translateY(0) scale(0.97); }
.suggestion-chip svg { flex-shrink: 0; opacity: 0.75; }

/* ---------- prompt gallery (empty-state browse section) ---------- */
.prompt-gallery {
  margin-top: 3rem;
  text-align: left;
}
.prompt-gallery[hidden] { display: none; }

.gallery-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.6rem;
}
.gallery-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 0.1rem 0.75rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.gallery-tab:hover { color: var(--text-muted); }
.gallery-tab.is-active { color: var(--text); font-weight: 700; border-color: var(--accent); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.85rem;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s var(--ease-out);
  animation: riseIn 0.35s var(--ease-out) backwards;
}
.gallery-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.gallery-card:active { transform: translateY(0) scale(0.99); }
.gallery-card:nth-child(1) { animation-delay: 0.02s; }
.gallery-card:nth-child(2) { animation-delay: 0.05s; }
.gallery-card:nth-child(3) { animation-delay: 0.08s; }
.gallery-card:nth-child(4) { animation-delay: 0.11s; }
.gallery-card:nth-child(5) { animation-delay: 0.14s; }
.gallery-card:nth-child(6) { animation-delay: 0.17s; }
.gallery-card:nth-child(7) { animation-delay: 0.20s; }
.gallery-card:nth-child(8) { animation-delay: 0.23s; }
.gallery-card:nth-child(9) { animation-delay: 0.26s; }

.gallery-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gallery-card-title {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.gallery-card-desc {
  font-size: 0.78rem;
  color: var(--text-faint);
  line-height: 1.5;
  margin-top: -0.3rem;
}

/* ---------- settings ---------- */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.32);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1.5rem;
  animation: fadeIn 0.15s ease;
}
.settings-overlay[hidden] { display: none; }

.settings-panel {
  animation: scaleIn 0.2s var(--ease-out);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.settings-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.settings-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.settings-close:hover { background: var(--surface-2); color: var(--text); }

.settings-body { padding: 1.3rem 1.4rem 1.6rem; }

.settings-section + .settings-section {
  margin-top: 1.7rem;
  padding-top: 1.7rem;
  border-top: 1px solid var(--border);
}

.settings-section h3 {
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}
.settings-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0 0 1rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.settings-field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.settings-input,
.settings-textarea {
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.6rem 0.75rem;
  font-size: 0.87rem;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.12s ease;
}
.settings-input:focus,
.settings-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.settings-textarea { resize: vertical; min-height: 5.5em; line-height: 1.5; }

.settings-field-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 0.2rem;
}
.settings-save-status {
  font-size: 0.78rem;
  color: var(--accent-hover);
}
.settings-save-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s var(--ease-press), opacity 0.12s ease;
}
.settings-save-btn:hover:not(:disabled) { background: var(--accent-hover); }
.settings-save-btn:active:not(:disabled) { transform: scale(0.97); }
.settings-save-btn:disabled { opacity: 0.6; cursor: default; }

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}
.theme-btn:hover { border-color: var(--border-strong); }
.theme-btn.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
.theme-swatch {
  width: 100%;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
}
.theme-swatch-light { background: #ffffff; }
.theme-swatch-dark { background: #1c1d22; }
.theme-swatch-system { background: linear-gradient(135deg, #ffffff 50%, #1c1d22 50%); }

.settings-toggle-row { margin-bottom: 0.4rem; }
.settings-toggle-row:last-child { margin-bottom: 0; }

.settings-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.settings-data-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.settings-data-btn:hover { background: var(--surface-2); }
.settings-data-btn.is-danger { color: var(--danger); border-color: var(--danger-soft); }
.settings-data-btn.is-danger:hover { background: var(--danger-soft); }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .thread { padding: 1.5rem 1rem 1rem; }
  .composer-wrap { padding: 0.5rem 1rem 1.1rem; }
  .empty-state { margin-top: 10vh; }
  .main-topbar { padding: 0.75rem 1rem 0; }
  .model-picker-btn { padding: 0.4rem 0.45rem 0.4rem 0.55rem; font-size: 0.72rem; }
  .model-picker-btn span[data-role="modelPickerLabel"] { max-width: 52px; overflow: hidden; display: inline-block; text-overflow: ellipsis; white-space: nowrap; }
  .model-picker-btn-effort { display: none; }
  .model-picker-menu { width: 230px; }
}

/* ---------- toast notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- file attachments ---------- */
.attach-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.attach-btn:hover { background: var(--surface-2); color: var(--text); }

.file-tray {
  max-width: 740px;
  margin: 0 auto 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.file-tray[hidden] { display: none; }

.file-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  box-shadow: var(--shadow-sm);
  max-width: 220px;
}

.file-msg-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  max-width: 240px;
  margin-bottom: 0.4rem;
}

.file-chip-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  overflow: hidden;
}
.file-chip-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-chip-info { min-width: 0; flex: 1; }
.file-chip-name {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip-meta {
  font-size: 0.68rem;
  color: var(--text-faint);
}

.file-chip-remove {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-chip-remove:hover { background: var(--surface-3); color: var(--text); }

.msg-user-files {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}
.msg-user-files[hidden] { display: none; }

/* ---------- drag & drop overlay ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 22, 26, 0.06);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }

.drop-overlay-inner {
  background: var(--surface);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.drop-overlay-inner p {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- sidebar account row / profile popover ---------- */
.account-row {
  margin-top: 0.5rem;
  position: relative;
}

.account-login-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.account-login-btn:hover { background: var(--surface-3); border-color: var(--text-faint); }

.account-signed-in { position: relative; }
.account-signed-in[hidden] { display: none; }

.account-profile-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: none;
  padding: 0.4rem 0.35rem;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.account-profile-btn:hover { background: var(--surface-3); }

.account-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.account-profile-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.account-email {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-plan {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.account-chevron {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}
.account-profile-btn[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }

.account-popover {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.7rem;
  z-index: 20;
  animation: dropIn 0.15s var(--ease-out);
  transform-origin: bottom left;
}
.account-popover[hidden] { display: none; }

.account-popover-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.2rem 0.4rem 0.6rem;
}

.account-credits-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.55rem;
}
.account-credits-row span:first-child {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
}

.account-upgrade-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  border: none;
  color: #ffffff;
  border-radius: 9px;
  padding: 0.55rem;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.6rem;
  transition: background 0.12s ease;
}
.account-upgrade-btn:hover { background: var(--accent-hover); }

.account-popover-divider {
  height: 1px;
  background: var(--border);
  margin: 0.2rem 0 0.5rem;
}

.account-popover-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: none;
  color: var(--text);
  padding: 0.5rem 0.4rem;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.account-popover-item:hover { background: var(--surface-3); }
.account-popover-item.is-danger { color: var(--danger); }
.account-popover-item.is-danger:hover { background: var(--danger-soft); }

/* ---------- auth modal ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.32);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  padding: 1.5rem;
  animation: fadeIn 0.15s ease;
}
.auth-overlay[hidden] { display: none; }

.auth-panel {
  animation: scaleIn 0.2s var(--ease-out);
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem 1.75rem;
}

.auth-panel .settings-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
}

.auth-view[hidden] { display: none; }
.auth-view:not([hidden]) { animation: fadeIn 0.18s ease; }

.auth-heading {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.25rem;
  text-align: center;
  color: var(--text);
}
.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1.4rem;
}
.auth-sub strong { color: var(--text); font-weight: 600; }

.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.65rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.google-btn:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1.1rem 0;
  color: var(--text-faint);
  font-size: 0.75rem;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.auth-field span:first-child {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}
.auth-field input {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.88rem;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.12s ease;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-field-hint {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.auth-error {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.8rem;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  margin: 0;
}
.auth-error[hidden] { display: none; }

.auth-submit {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.68rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.12s ease, transform 0.1s var(--ease-press), box-shadow 0.15s ease;
}
.auth-submit:hover:not(:disabled) { background: var(--accent-gradient-hover); box-shadow: var(--accent-glow); }
.auth-submit:active:not(:disabled) { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

.auth-switch {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 1.2rem 0 0;
}
.auth-switch button {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
}
.auth-switch button:hover { text-decoration: underline; }

#verifyCode {
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 0.4em;
  font-weight: 600;
  padding-left: 0.3em;
}

.chat-loading {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 3rem;
}

/* ---------- pricing / checkout ---------- */
.pricing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.32);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  padding: 1.5rem;
  animation: fadeIn 0.15s ease;
}
.pricing-overlay[hidden] { display: none; }

.pricing-panel {
  animation: scaleIn 0.2s var(--ease-out);
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.1rem 2rem 1.8rem;
}
.pricing-panel .settings-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
}

.pricing-view[hidden] { display: none; }
.pricing-view:not([hidden]) { animation: fadeIn 0.2s ease; }

.pricing-heading {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.3rem;
  text-align: center;
  color: var(--text);
}
.pricing-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.87rem;
  margin: 0 0 1.4rem;
}

.billing-toggle {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.25rem;
  width: fit-content;
  margin: 0 auto 1.6rem;
}
.billing-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.billing-toggle-btn:hover { color: var(--text); }
.billing-toggle-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.billing-save-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
}

.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 560px) {
  .plan-cards { grid-template-columns: 1fr; }
}

.plan-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.2rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s ease;
}
.plan-card:hover { transform: translateY(-2px); }
.plan-card.is-featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.plan-card.is-featured:hover { box-shadow: 0 0 0 1px var(--accent), var(--shadow-md); }
.plan-card-badge {
  position: absolute;
  top: -10px;
  left: 1.2rem;
  background: var(--accent-gradient);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
}
.plan-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.plan-card-price {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  margin-bottom: 0.15rem;
}
.plan-price-amount {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.plan-price-period {
  font-size: 0.82rem;
  color: var(--text-faint);
  font-weight: 500;
}
.plan-price-note {
  font-size: 0.74rem;
  color: var(--text-faint);
  margin-bottom: 0.9rem;
}
.plan-card-price + .plan-features { margin-top: 0.9rem; }

.plan-features {
  list-style: none;
  margin: 0 0 1.2rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}
.plan-features li {
  font-size: 0.83rem;
  color: var(--text-muted);
  padding-left: 1.3rem;
  position: relative;
  line-height: 1.4;
}
.plan-features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 9px;
  height: 6px;
  border-left: 1.6px solid var(--accent);
  border-bottom: 1.6px solid var(--accent);
  transform: rotate(-45deg);
}

.plan-card-btn {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 9px;
  padding: 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: default;
}
.plan-card-btn:disabled { opacity: 0.7; cursor: default; }
.plan-card-btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s var(--ease-press), box-shadow 0.15s ease;
}
.plan-card-btn-primary:hover { background: var(--accent-gradient-hover); box-shadow: var(--accent-glow); }
.plan-card-btn-primary:active { transform: scale(0.98); }

.pricing-footnote {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.74rem;
  margin: 1.3rem 0 0;
}

.pricing-back {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0;
  margin-bottom: 1rem;
  cursor: pointer;
}
.pricing-back:hover { color: var(--text); }

.order-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.1rem;
}
.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
  color: var(--text-muted);
  padding: 0.4rem 0;
}
.order-row-total {
  border-top: 1px solid var(--border);
  margin-top: 0.3rem;
  padding-top: 0.7rem;
  font-weight: 700;
  color: var(--text);
  font-size: 0.92rem;
}

.checkout-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 1.1rem;
}
.checkout-notice svg { flex-shrink: 0; margin-top: 0.1rem; }

.pricing-pay-btn {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-faint);
  border-radius: 9px;
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: not-allowed;
}

/* ---------- share modal (create link) ---------- */
.share-link-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.55rem 0.6rem;
  margin: 0.9rem 0 0.3rem;
}
.share-link-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
}
.share-copy-link-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 7px;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s var(--ease-press);
}
.share-copy-link-btn:hover { background: var(--accent-hover); }
.share-copy-link-btn:active { transform: scale(0.96); }
.share-modal-note {
  font-size: 0.76rem;
  color: var(--text-faint);
  margin: 0;
}

/* ---------- share.html (public read-only viewer) ---------- */
.share-body { overflow: auto; }
.share-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem 5rem;
}
.share-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 2rem;
}
.share-topbar .brand {
  text-decoration: none;
}
.share-loading {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.9rem;
  margin-top: 4rem;
}
.share-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 1rem;
}
.share-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1.6rem;
  color: var(--text);
}

.share-thread .msg { max-width: none; }
.share-script .code-block { margin: 0; }
