:root {
  /* Dark (default) */
  --bg: #0b0c10;
  --surface: #14161d;
  --surface-2: #1c1f2a;
  --line: #262a37;
  --line-2: #353a4a;
  --text: #ecedf1;
  --text-dim: #9aa0b2;
  --text-faint: #5b6276;
  --accent: #7aa2ff;
  --accent-2: #b9d0ff;
  --warn: #f0b86e;
  --good: #7fd1a3;
  --bad: #e58a82;
  --scrollbar: rgba(255, 255, 255, 0.10);
  --scrollbar-hover: rgba(255, 255, 255, 0.22);

  --font-mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.42s;
}

body[data-theme="light"] {
  --bg: #fafbfc;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --line: #e3e6ee;
  --line-2: #c8cdda;
  --text: #1a1d27;
  --text-dim: #4f566f;
  --text-faint: #8a90a3;
  --accent: #3563dc;
  --accent-2: #214bb8;
  --warn: #b46a16;
  --good: #2c8c5a;
  --bad: #c44a40;
  --scrollbar: rgba(0, 0, 0, 0.10);
  --scrollbar-hover: rgba(0, 0, 0, 0.25);
}

/* Theme transition */
body, .composer input, .tile, .tile-status, .msg.user .msg-body, .tile-callout, .theme-toggle, .brand {
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- Hidden scrollbars (scroll still works with wheel/touchpad/keys) ---- */
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

/* ---- Floating brand + theme toggle ---- */

.brand {
  position: fixed;
  top: 14px;
  left: 18px;
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 1.2px;
  font-weight: 600;
  user-select: none;
  z-index: 10;
  display: flex;
  align-items: baseline;
  /* Soft floating-pill backdrop so the header reads as overlaid on the canvas
   * the same way the composer/selection bars do. Subtle so it doesn't compete
   * with chat content scrolling underneath. */
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
}
/* Two colors chosen for contrast against both dark and light backgrounds */
.brand-auto { color: #f08a4b; }  /* warm orange */
.brand-vec  { color: #5d8fd9; }  /* steel blue */
/* Light mode keeps the same hues but slightly deeper for contrast */
body[data-theme="light"] .brand-auto { color: #d2691e; }
body[data-theme="light"] .brand-vec  { color: #3563dc; }

.topright {
  position: fixed;
  top: 14px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  padding: 4px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
}
.theme-toggle, .auth-badge {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-faint);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  cursor: pointer;
}
.theme-toggle:hover, .auth-badge:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: var(--surface);
}
.auth-badge.signed-in {
  border-color: rgba(122, 162, 255, 0.35);
  color: var(--accent);
  background: rgba(122, 162, 255, 0.07);
}
body[data-theme="light"] .auth-badge.signed-in {
  border-color: rgba(53, 99, 220, 0.30);
  color: var(--accent);
  background: rgba(53, 99, 220, 0.05);
}

/* ---- MODAL (auth) ---- */
.modal-overlay[hidden] { display: none !important; }
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: overlayIn 0.2s var(--ease);
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
body[data-theme="light"] .modal-overlay { background: rgba(0, 0, 0, 0.35); }

.modal-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: cardIn 0.25s var(--ease);
}

/* Watches/sessions modal: cap height to viewport and let the two lists
 * scroll independently within the remaining vertical space. Scoped via
 * #watches-modal so the auth modal isn't affected. */
#watches-modal .modal-card {
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
#watches-modal .modal-head { flex-shrink: 0; }
#watches-modal .modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 6px;
}
#watches-modal .modal-section-label { flex-shrink: 0; }
#watches-modal .watches-list,
#watches-modal .sessions-list {
  flex: 1 1 0;
  min-height: 60px;
  overflow-y: auto;
  margin-bottom: 8px;
  padding-right: 4px;
}
#watches-modal .watches-footer { flex-shrink: 0; margin-top: 6px; }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 14px; color: var(--text); letter-spacing: 0.2px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; }
.modal-prose { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin: 0 0 14px; }
.modal-body form { display: flex; gap: 8px; }
.modal-body input[type="email"] {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
}
.modal-body input[type="email"]:focus { border-color: var(--line-2); background: var(--surface-2); }
.modal-body button[type="submit"] {
  background: var(--accent);
  color: #0a0e1c;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.8px;
  cursor: pointer;
  font-weight: 600;
}
.modal-body button[type="submit"]:hover { background: var(--accent-2); }
.modal-body button[type="submit"]:disabled { opacity: 0.6; cursor: not-allowed; }
body[data-theme="light"] .modal-body button[type="submit"] { color: #ffffff; }
.modal-status {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  min-height: 18px;
}
.modal-status.ok { color: var(--good); }
.modal-status.err { color: var(--bad); }

/* ---- PROPOSE-WATCH ACTION (rendered in Vector messages) ---- */
.watch-propose {
  margin: 10px 0 6px;
  padding: 12px 14px;
  background: rgba(122, 162, 255, 0.06);
  border: 1px solid rgba(122, 162, 255, 0.25);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body[data-theme="light"] .watch-propose {
  background: rgba(53, 99, 220, 0.06);
  border-color: rgba(53, 99, 220, 0.25);
}
.watch-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.watch-summary {
  font-size: 13px;
  color: var(--text-dim);
}
.watch-button, .review-button {
  align-self: flex-start;
  background: var(--accent);
  color: #0a0e1c;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  cursor: pointer;
  font-weight: 600;
}
.watch-button:hover, .review-button:hover { background: var(--accent-2); }
.watch-button:disabled, .review-button:disabled { opacity: 0.6; cursor: not-allowed; }
body[data-theme="light"] .watch-button, body[data-theme="light"] .review-button { color: #ffffff; }

/* Review-request card has a slightly different accent tone to distinguish it from watch */
.review-propose {
  margin: 10px 0 6px;
  padding: 12px 14px;
  background: rgba(240, 138, 75, 0.08);
  border: 1px solid rgba(240, 138, 75, 0.30);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body[data-theme="light"] .review-propose {
  background: rgba(210, 105, 30, 0.07);
  border-color: rgba(210, 105, 30, 0.28);
}
.review-button { background: #f08a4b; }
.review-button:hover { background: #ffa56b; }
body[data-theme="light"] .review-button { background: #d2691e; }
body[data-theme="light"] .review-button:hover { background: #c0571d; }
.watch-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.watch-status.ok { color: var(--good); }
.watch-status.err { color: var(--bad); }

/* ---- Layout ---- */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 24px;
  min-height: 0;
}

/* ---- INITIAL STATE ---- */
body[data-state="initial"] main { justify-content: center; align-items: stretch; }
body[data-state="initial"] .chat { display: none; }
body[data-state="initial"] .composer { padding: 0; }
body[data-state="initial"] .composer input { font-size: 18px; padding: 18px 22px; }
body[data-state="initial"] .hint { margin-top: 18px; text-align: left; }

/* ---- Read-only mode (viewing a shared session as a non-owner) ---- */
body[data-readonly] .composer { display: none !important; }
body[data-readonly] .hint { display: none !important; }
body[data-readonly] .watch-propose,
body[data-readonly] .review-propose { display: none !important; }
body[data-readonly] .new-search-btn { display: none !important; }

/* ---- Session strip (above the composer) — borderless, inline ---- */
.session-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  margin: 0 0 6px 0;
  font-size: 12px;
  color: var(--text-dim);
}
.session-strip[hidden] { display: none !important; }
.session-strip-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
}
.session-strip-title {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-strip-actions { display: flex; gap: 4px; flex-shrink: 0; }
.session-strip-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 0 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.session-strip-btn:hover { color: var(--accent); border-color: var(--accent); }
.session-strip-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.session-strip-readonly-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bad, #c0392b);
  border: 1px solid currentColor;
  padding: 1px 6px;
  border-radius: 3px;
}

/* Hide the legacy floating session banner — replaced by the inline strip */
.session-banner { display: none !important; }
.session-banner-readonly {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bad, #c0392b);
  border: 1px solid currentColor;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 4px;
}

/* Hero headline (shown only in initial state) */
.hero-headline {
  display: none;
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin: 0 0 28px;
  color: var(--text);
}
body[data-state="initial"] .hero-headline { display: block; }

/* Color-sweep effect using the two brand hues */
.hero-headline.sweep {
  background: linear-gradient(
    90deg,
    var(--text) 0%,
    var(--text) 20%,
    #f08a4b 38%,
    #5d8fd9 62%,
    var(--text) 80%,
    var(--text) 100%
  );
  background-size: 250% 100%;
  background-position: 100% 50%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  animation: heroSweep 1s linear forwards;
}
body[data-theme="light"] .hero-headline.sweep {
  background: linear-gradient(
    90deg,
    var(--text) 0%,
    var(--text) 20%,
    #d2691e 38%,
    #3563dc 62%,
    var(--text) 80%,
    var(--text) 100%
  );
  background-size: 250% 100%;
  background-position: 100% 50%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}
@keyframes heroSweep {
  /* Sweep moves left-to-right: gradient starts off-screen right, ends off-screen left */
  0%   { background-position: 150% 50%; }
  100% { background-position: -50% 50%; }
}

/* ---- ACTIVE STATE ---- */
body[data-state="active"] main { justify-content: flex-end; }
body[data-state="active"] .chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 24px;
  padding-top: 56px;
  min-height: 0;
}
body[data-state="active"] .hint { display: none; }

/* ---- CONTEXT CHIP (shown above composer when a tile is selected) ---- */
.selection-bar[hidden] { display: none !important; }
.selection-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(122, 162, 255, 0.06);
  border: 1px solid rgba(122, 162, 255, 0.20);
  border-radius: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
body[data-theme="light"] .selection-bar {
  background: rgba(53, 99, 220, 0.05);
  border-color: rgba(53, 99, 220, 0.18);
}
.selection-bar-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.selection-chips {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}
.selection-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 4px;
  background: rgba(122, 162, 255, 0.15);
  border: 1px solid rgba(122, 162, 255, 0.40);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  max-width: 220px;
  animation: chipIn 0.18s var(--ease);
}
body[data-theme="light"] .selection-chip {
  background: rgba(53, 99, 220, 0.10);
  border-color: rgba(53, 99, 220, 0.32);
}
.selection-chip img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}
.selection-chip .no-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  flex-shrink: 0;
}
.selection-chip-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.selection-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}
.selection-chip-remove:hover { color: var(--text); }
.selection-clear-all {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-faint);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}
.selection-clear-all:hover { color: var(--text); border-color: var(--line-2); }
@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chip-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.chip-value {
  color: var(--accent);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 460px;
}
.chip-clear {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  margin-left: 2px;
}
.chip-clear:hover { color: var(--text); }

/* ---- Watches list (modal) ---- */
.watches-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.watch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.watch-row-label { color: var(--text); font-size: 14px; }
.watch-row-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.watch-row-delete {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
}
.watch-row-delete:hover { color: var(--bad); border-color: var(--bad); }

/* ---- Sessions list (modal) ---- */
.modal-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.sessions-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.session-row-main { min-width: 0; flex: 1; }
.session-row-title {
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-row-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.session-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.session-row-open, .session-row-share {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
}
.session-row-open:hover { color: var(--accent); border-color: var(--accent); }
.session-row-share:hover { color: var(--text); border-color: var(--text); }

/* ---- Signin summary (chat block shown after magic-link verify) ---- */
.signin-summary-body { padding-left: 12px; }
.signin-summary-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin: 10px 0 6px;
}
.signin-summary-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.signin-summary-empty {
  color: var(--text-dim);
  font-size: 13px;
  margin: 8px 0;
}
.signin-watch-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.signin-watch-row { font-size: 13px; color: var(--text); }
.signin-session-list { display: flex; flex-direction: column; gap: 6px; }
.signin-session-row {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.signin-session-row:hover { border-color: var(--accent); }
.signin-session-title { color: var(--accent); font-size: 13px; }
.signin-session-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.signin-session-active {
  color: #2c8c5a;
  font-family: var(--font-mono);
  font-size: 10px;
  margin-left: 4px;
}

/* ---- New-search button (in topright) ---- */
.new-search-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  margin-right: 6px;
}
.new-search-btn:hover { color: var(--accent); border-color: var(--accent); }
.new-search-btn[hidden] { display: none !important; }

/* ---- Session banner (shown when in a hydrated session) ---- */
.session-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  z-index: 50;
  max-width: 90vw;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.session-banner[hidden] { display: none !important; }
.session-banner-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
}
.session-banner-title {
  font-weight: 500;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-banner-close {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
}
.session-banner-close:hover { color: var(--bad); border-color: var(--bad); }

.watches-empty {
  color: var(--text-faint);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}
.watches-footer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  justify-content: flex-end;
}
.modal-secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
}
.modal-secondary:hover { color: var(--text); border-color: var(--text-dim); }

/* ---- COMPOSER ---- */
.composer { display: flex; padding-top: 10px; }
.composer input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 18px;
  font-family: var(--font-sans);
  font-size: 15px;
  outline: none;
}
.composer input::placeholder { color: var(--text-faint); }
.composer input:focus { border-color: var(--line-2); background: var(--surface-2); }

.hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  padding-top: 12px;
  letter-spacing: 0.3px;
}

/* ---- CHAT MESSAGES ---- */
.msg { display: flex; flex-direction: column; gap: 6px; animation: fadeUp 0.3s var(--ease); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.msg.user .msg-body {
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  align-self: flex-start;
  max-width: 75%;
  color: var(--text);
}
.msg.vector .msg-body { background: transparent; padding: 0; color: var(--text); line-height: 1.55; }
.msg.vector .msg-body p { margin: 0 0 10px 0; }
.msg.vector .msg-body p:last-child { margin-bottom: 0; }
.msg.vector .msg-body .say-list { margin: 6px 0 10px 4px; padding-left: 18px; }
.msg.vector .msg-body .say-list li { margin: 0 0 4px 0; }
.msg.vector .msg-body strong { color: var(--text); font-weight: 600; }
.msg.error .msg-body { color: var(--bad); }
.msg-thinking {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.5px;
}
.msg-thinking::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--text-faint);
  border-radius: 50%;
  margin-left: 6px;
  animation: pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

/* ---- TILES (inline in vector messages) ---- */
.tile-rationale {
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-mono);
  margin: 6px 0 14px;
  letter-spacing: 0.2px;
  font-style: italic;
}
.tiles {
  margin: 6px 0 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  animation: tileIn 0.4s var(--ease) backwards;
}
@keyframes tileIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tile:nth-child(1) { animation-delay: 0.00s; }
.tile:nth-child(2) { animation-delay: 0.04s; }
.tile:nth-child(3) { animation-delay: 0.08s; }
.tile:nth-child(4) { animation-delay: 0.12s; }
.tile:nth-child(5) { animation-delay: 0.16s; }
.tile:nth-child(6) { animation-delay: 0.20s; }
.tile:nth-child(7) { animation-delay: 0.24s; }
.tile:nth-child(8) { animation-delay: 0.28s; }
.tile:nth-child(9) { animation-delay: 0.32s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--surface-2); }
.tile.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 16px rgba(122, 162, 255, 0.18);
}
body[data-theme="light"] .tile.selected {
  box-shadow: 0 0 0 1px var(--accent), 0 6px 16px rgba(53, 99, 220, 0.15);
}

/* External-source icon in tile corner */
.tile-external {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 14px;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
  z-index: 2;
}
.tile:hover .tile-external,
.tile.selected .tile-external {
  opacity: 1;
  transform: scale(1);
}
.tile-external:hover { background: var(--accent); color: #fff; }
.tile { position: relative; }

.tile-thumb-wrap { width: 100%; aspect-ratio: 4/3; background: var(--surface-2); overflow: hidden; }
.tile-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-noimg {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.5px;
}
.tile-body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.tile-title { font-size: 13.5px; line-height: 1.35; color: var(--text); font-weight: 500; }
.tile-row { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.tile-price { color: var(--accent); font-weight: 600; font-size: 13px; }
.tile-status {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.tile-status.sold { background: rgba(127, 209, 163, 0.13); color: var(--good); }
.tile-status.live { background: rgba(122, 162, 255, 0.13); color: var(--accent); }
.tile-status.no-sale { background: rgba(240, 184, 110, 0.13); color: var(--warn); }
.tile-status.unknown,
.tile-status.ended,
.tile-status.withdrawn { background: rgba(155, 160, 178, 0.10); color: var(--text-dim); }
.tile-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.2px; }
