/* Hanken Grotesk — self-hosted (woff2 in ./fonts), four weights × four ranges. */
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url("./fonts/hanken-cyrillic-ext.woff2") format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url("./fonts/hanken-vietnamese.woff2") format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url("./fonts/hanken-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url("./fonts/hanken-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url("./fonts/hanken-cyrillic-ext.woff2") format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url("./fonts/hanken-vietnamese.woff2") format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url("./fonts/hanken-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url("./fonts/hanken-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url("./fonts/hanken-cyrillic-ext.woff2") format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url("./fonts/hanken-vietnamese.woff2") format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url("./fonts/hanken-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url("./fonts/hanken-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url("./fonts/hanken-cyrillic-ext.woff2") format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url("./fonts/hanken-vietnamese.woff2") format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url("./fonts/hanken-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url("./fonts/hanken-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ===========================================================================
   OpenClaw chat — calm & minimal design system
   Light theme by default; [data-theme="dark"] overrides on <html>.
   =========================================================================== */

:root {
  /* tweakable */
  --accent: #1f2937;          /* slate-800 primary */
  --accent-strong: #111827;   /* hover */
  --accent-fg: #ffffff;       /* text on accent */
  --radius-bubble: 18px;
  --density: 1;               /* multiplier for vertical rhythm */

  /* neutral palette (cool, soft) */
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-sidebar: #f7f7f8;
  --bg-elev: #ffffff;
  --bg-hover: #f2f3f5;
  --bg-active: #eceef1;
  --bubble-user: #f1f2f4;

  --text: #1c1e22;
  --text-2: #5b616e;
  --text-3: #9298a3;

  --border: #ececee;
  --border-strong: #e0e1e4;
  --ring: rgba(31, 41, 55, 0.16);

  --good: #16855c;
  --shadow-sm: 0 1px 2px rgba(20, 22, 28, 0.04), 0 1px 3px rgba(20, 22, 28, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 22, 28, 0.08), 0 1px 4px rgba(20, 22, 28, 0.06);
  --shadow-lg: 0 18px 48px rgba(20, 22, 28, 0.18);

  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 276px;
  --col-max: 760px;
}

[data-theme="dark"] {
  --accent: #f2f3f5;
  --accent-strong: #ffffff;
  --accent-fg: #16181d;

  --bg: #0f1115;
  --bg-subtle: #131620;
  --bg-sidebar: #0c0e12;
  --bg-elev: #16181f;
  --bg-hover: #1b1e26;
  --bg-active: #21252e;
  --bubble-user: #1c2029;

  --text: #e7e8ea;
  --text-2: #a0a5b0;
  --text-3: #6c7280;

  --border: #23262e;
  --border-strong: #2c303a;
  --ring: rgba(242, 243, 245, 0.18);

  --good: #4ec08a;
  --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 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* The app owns its own scroll regions (the thread). Stop the whole page
     from scrolling, which would drag the composer along with the messages. */
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

button { font-family: inherit; cursor: pointer; }
::selection { background: var(--ring); }

/* tidy scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

/* ============================ App shell ================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  /* minmax(0, 1fr) pins the row to the viewport height so a tall thread
     can't grow the row and push the composer off-screen. */
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  transition: grid-template-columns 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.app.sidebar-collapsed { grid-template-columns: 0px 1fr; }

/* ============================ Sidebar =================================== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.sidebar-header {
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px;
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid; place-items: center;
  flex: none;
  position: relative;
}
.brand-mark::before {
  content: "";
  width: 10px; height: 10px;
  border: 2px solid var(--accent-fg);
  border-radius: 50%;
  border-right-color: transparent;
  border-bottom-color: transparent;
  transform: rotate(45deg);
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-name small { display: block; font-weight: 400; font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; }

.new-chat-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.new-chat-btn:hover { background: var(--bg-hover); border-color: var(--text-3); }
.new-chat-btn:active { transform: translateY(1px); }

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; min-height: 0; }
.conv-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); padding: 12px 8px 6px;
}
.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.conv-item:hover { background: var(--bg-hover); color: var(--text); }
.conv-item.active { background: var(--bg-active); color: var(--text); }
.conv-item .conv-title {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item .conv-del {
  opacity: 0; flex: none;
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  background: transparent; border: none; color: var(--text-3);
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-item .conv-del:hover { background: var(--bg-active); color: var(--text); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  display: flex;
  gap: 6px;
}
.sidebar-footer .ghost-btn-label { flex: 1; justify-content: flex-start; }
.sidebar-footer .ghost-btn-icon { flex: 0 0 auto; width: 38px; padding: 8px; justify-content: center; }

.ghost-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
}
.ghost-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ============================ Main ===================================== */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--bg); position: relative; }

.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.topbar-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }

.conn-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-2);
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  white-space: nowrap;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.conn-status.live .conn-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.conn-status.demo .conn-dot { background: #d08b2c; box-shadow: 0 0 0 3px rgba(208,139,44,0.22); }

.google-integration { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.google-connect-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.google-connect-btn:hover { background: var(--bg-hover); }
.google-pill {
  display: inline-flex; align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11.5px;
  white-space: nowrap;
}
.google-pill.connected {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 34%, var(--border));
  background: color-mix(in srgb, var(--good) 9%, transparent);
}

/* ============================ Thread =================================== */
.thread { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.thread-inner {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: calc(28px * var(--density)) 24px calc(40px * var(--density));
  display: flex;
  flex-direction: column;
  gap: calc(22px * var(--density));
}

.msg-row { display: flex; gap: 12px; }
.msg-row.user { flex-direction: row-reverse; }
.msg-row.assistant { align-items: flex-start; }

.avatar {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  margin-top: 2px;
}
.avatar.assistant { background: var(--accent); color: var(--accent-fg); position: relative; }
.avatar.assistant::before {
  content: ""; width: 11px; height: 11px;
  border: 2px solid var(--accent-fg); border-radius: 50%;
  border-right-color: transparent; border-bottom-color: transparent;
  transform: rotate(45deg);
}
.avatar.user { background: var(--bubble-user); color: var(--text-2); border: 1px solid var(--border); }

.msg-col { min-width: 0; max-width: 100%; display: flex; flex-direction: column; gap: 8px; }
.msg-row.user .msg-col { align-items: flex-end; }
.msg-row.assistant .msg-col { flex: 1; }

.bubble {
  background: var(--bubble-user);
  border-radius: var(--radius-bubble);
  border-top-right-radius: 6px;
  padding: 11px 15px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}
.assistant-content {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  max-width: 100%;
  word-break: break-word;
}

/* attached images on user message */
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-row.user .msg-images { justify-content: flex-end; }
.msg-thumb {
  width: 132px; height: 132px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: zoom-in;
  background: var(--bg-subtle);
}
.msg-audio-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--bubble-user); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-2);
}

/* ============== Markdown rendered content ============================== */
.assistant-content > *:first-child { margin-top: 0; }
.assistant-content > *:last-child { margin-bottom: 0; }
.assistant-content p { margin: 0 0 12px; }
.assistant-content h1, .assistant-content h2, .assistant-content h3 {
  margin: 22px 0 10px; line-height: 1.3; letter-spacing: -0.01em; font-weight: 650;
}
.assistant-content h1 { font-size: 22px; }
.assistant-content h2 { font-size: 19px; }
.assistant-content h3 { font-size: 16.5px; }
.assistant-content ul, .assistant-content ol { margin: 0 0 12px; padding-left: 22px; }
.assistant-content li { margin: 4px 0; }
.assistant-content li::marker { color: var(--text-3); }
.assistant-content a { color: var(--accent); text-underline-offset: 2px; text-decoration-color: var(--ring); }
[data-theme="dark"] .assistant-content a { color: #8ab4ff; }
.assistant-content strong { font-weight: 650; }
.assistant-content blockquote {
  margin: 0 0 12px; padding: 4px 14px;
  border-left: 3px solid var(--border-strong); color: var(--text-2);
}
.assistant-content code.inline {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--bg-hover); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 5px;
}
.assistant-content pre {
  margin: 0 0 14px; padding: 14px 16px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 12px; overflow-x: auto;
}
.assistant-content pre code { font-family: var(--mono); font-size: 13px; line-height: 1.55; color: var(--text); }
.assistant-content hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* image card from markdown */
.img-card {
  margin: 4px 0 14px;
  display: inline-block;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  position: relative;
  line-height: 0;
}
.img-card img { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; }
.img-card .img-caption {
  line-height: 1.4; font-size: 12px; color: var(--text-3);
  padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg-elev);
}
.img-card .img-zoom {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; color: var(--text);
  opacity: 0; transition: opacity 0.15s; border: 1px solid var(--border);
}
.img-card:hover .img-zoom { opacity: 1; }

/* inline audio player */
.audio-card {
  margin: 4px 0 14px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 14px; max-width: 420px;
}
.audio-card .audio-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.audio-card audio { width: 100%; height: 36px; }

/* placeholder shown while a data: image is still streaming in */
.md-img-pending { display: inline-block; color: var(--text-2); font-size: 13px; font-style: italic; opacity: 0.8; }
.md-bigmedia { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 4px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, rgba(0,0,0,0.03)); font-size: 13px; }
.md-bigmedia-meta { color: var(--text-2); font-variant-numeric: tabular-nums; }
.md-bigmedia-label { color: var(--text-1); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============== Tool / agent activity ================================== */
.tool-activity {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
  max-width: 100%;
}
.tool-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.tool-head .tool-caret { margin-left: auto; transition: transform 0.18s; color: var(--text-3); }
.tool-activity.open .tool-caret { transform: rotate(90deg); }
.tool-head .spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--text-2);
  animation: spin 0.7s linear infinite; flex: none;
}
.tool-head .done-check { color: var(--good); flex: none; display: grid; place-items: center; }
.tool-body { padding: 2px 12px 10px 12px; display: none; flex-direction: column; gap: 0; }
.tool-activity.open .tool-body { display: flex; }
.tool-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0; color: var(--text-2);
  position: relative; padding-left: 20px;
}
.tool-step::before {
  content: ""; position: absolute; left: 4px; top: 12px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
}
.tool-step.running::before { background: var(--accent); }
.tool-step .step-skill { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
@keyframes spin { to { transform: rotate(360deg); } }

/* typing dots */
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; align-items: center; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-3);
  animation: blink 1.3s infinite ease-in-out;
}
.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.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* per-message footer */
.msg-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 22px; }
.msg-row.user .msg-footer { justify-content: flex-end; }
.timestamp { font-size: 11.5px; color: var(--text-3); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-family: var(--mono);
  color: var(--text-2);
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev);
}
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text-3);
  background: transparent; border: none; padding: 3px 6px; border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.mini-btn:hover { background: var(--bg-hover); color: var(--text); }
.msg-footer { opacity: 0; transition: opacity 0.15s; }
.msg-row:hover .msg-footer, .msg-row.streaming .msg-footer { opacity: 1; }

/* ============== Empty state =========================================== */
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; gap: 8px;
}
.empty-mark {
  width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; margin-bottom: 14px; position: relative; box-shadow: var(--shadow-md);
}
.empty-mark::before {
  content: ""; width: 22px; height: 22px; border: 2.5px solid var(--accent-fg); border-radius: 50%;
  border-right-color: transparent; border-bottom-color: transparent; transform: rotate(45deg);
}
.empty-state h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.empty-state p { margin: 0; color: var(--text-2); max-width: 440px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; max-width: 540px; }
.suggestion {
  text-align: left;
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); font-size: 13.5px; max-width: 250px;
  box-shadow: var(--shadow-sm); transition: border-color 0.15s, transform 0.06s, background 0.15s;
}
.suggestion:hover { border-color: var(--text-3); background: var(--bg-hover); }
.suggestion:active { transform: translateY(1px); }
.suggestion b { display: block; font-weight: 600; margin-bottom: 2px; }
.suggestion span { color: var(--text-3); font-size: 12.5px; }

/* ============== Assistant overview ==================================== */
.overview-panel {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.overview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.overview-title { font-size: 14px; font-weight: 650; color: var(--text); }
.overview-sub { font-size: 12px; color: var(--text-3); }
.overview-empty {
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  color: var(--text-3);
  font-size: 13px;
}
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.assistant-card {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}
.assistant-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.assistant-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.assistant-id b { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-id span { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-pill {
  flex: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}
.live-pill.on {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 34%, var(--border));
  background: color-mix(in srgb, var(--good) 9%, transparent);
}
.assistant-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--bg-subtle);
}
.metric span { display: block; color: var(--text-3); font-size: 11px; }
.metric b { display: block; color: var(--text); font-size: 14px; font-weight: 650; }
.integration-pills, .peer-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.integration-pill, .peer-list span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--text-3);
  background: var(--bg-subtle);
  font-size: 11px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.integration-pill.connected {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 34%, var(--border));
  background: color-mix(in srgb, var(--good) 9%, transparent);
}
.peer-list em, .hop-empty { color: var(--text-3); font-size: 12px; font-style: normal; }
.hop-list { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hop-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  min-width: 0;
  color: var(--text-2);
  font-size: 11.5px;
}
.hop-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hop-row small { color: var(--text-3); font-size: 11px; }
.hop-dir {
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--text-3);
  background: var(--bg-hover);
  font-weight: 650;
}
.hop-dir.out { color: var(--accent); }
.hop-dir.in { color: var(--good); }

/* ============== Composer ============================================== */
.composer-wrap { flex: none; padding: 8px 24px 22px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer-inner { max-width: var(--col-max); margin: 0 auto; }
.composer {
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
  padding: 8px 8px 8px 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.composer:focus-within { border-color: var(--text-3); box-shadow: var(--shadow-md), 0 0 0 4px var(--ring); }
.composer.dragover { border-color: var(--accent); border-style: dashed; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 6px 8px; }
.attachment {
  position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-subtle); flex: none;
}
.attachment img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment.audio { width: auto; padding: 0 12px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.attachment.loading { display: grid; place-items: center; }
.attachment .att-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text-2); animation: spin 0.7s linear infinite; }
.attachment .remove {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.62); color: #fff; border: none;
  display: grid; place-items: center; font-size: 11px; line-height: 1;
}
.attachment .remove:hover { background: rgba(0,0,0,0.82); }

.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer-row > .icon-btn { width: 38px; height: 38px; }
.ta {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 15px; line-height: 1.5; color: var(--text);
  padding: 9px 6px 9px 10px; max-height: 220px; min-height: 24px;
}
.ta::placeholder { color: var(--text-3); }
.composer-actions { display: flex; align-items: center; gap: 2px; }
.composer-actions .icon-btn { width: 38px; height: 38px; }
.icon-btn.recording { color: #d14343; background: color-mix(in srgb, #d14343 12%, transparent); }
.icon-btn.recording::after { content: ""; position: absolute; }
.send-btn {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent); color: var(--accent-fg);
  border: none; display: grid; place-items: center; flex: none;
  transition: background 0.15s, transform 0.06s, opacity 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-strong); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn.stop { background: var(--bg-active); color: var(--text); }

.composer-hint { text-align: center; font-size: 11.5px; color: var(--text-3); margin-top: 8px; }
.composer-hint kbd {
  font-family: var(--mono); font-size: 10.5px; background: var(--bg-hover);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 4px;
}
.rec-indicator { display: inline-flex; align-items: center; gap: 7px; color: #d14343; font-weight: 500; }
.rec-indicator .rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #d14343; animation: blink 1s infinite; }

/* drop overlay over whole main */
.drop-overlay {
  position: absolute; inset: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  pointer-events: none;
}
.drop-overlay .drop-box {
  border: 2px dashed var(--accent); border-radius: 20px;
  padding: 40px 56px; background: var(--bg-elev); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text); font-weight: 600;
}

/* ============== Modal / Settings ====================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 17, 21, 0.45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field input[type="text"], .field input[type="password"] {
  font-family: var(--mono); font-size: 13px;
  padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--bg-subtle); color: var(--text); outline: none;
}
.field input:focus { border-color: var(--text-3); box-shadow: 0 0 0 3px var(--ring); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.toggle-row .toggle-text b { display: block; font-size: 13.5px; }
.toggle-row .toggle-text span { font-size: 12px; color: var(--text-3); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong);
  transition: background 0.18s;
}
.switch .track::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.18s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(18px); }
[data-theme="dark"] .switch .track::before { background: #d8dade; }

.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 20px 20px; }
.btn {
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.secondary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn.secondary:hover { background: var(--bg-hover); }

/* ============== Lightbox ============================================== */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 9, 12, 0.85); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 40px; cursor: zoom-out;
  animation: fade 0.16s ease;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: var(--shadow-lg); cursor: default; }
.lightbox .lb-close {
  position: absolute; top: 20px; right: 24px; width: 40px; height: 40px;
  border-radius: 10px; background: rgba(255,255,255,0.1); color: #fff; border: none;
  display: grid; place-items: center; backdrop-filter: blur(4px);
}
.lightbox .lb-close:hover { background: rgba(255,255,255,0.2); }

/* toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 300; background: var(--accent); color: var(--accent-fg);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastin 0.2s ease;
}
@keyframes toastin { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ============== Responsive ============================================ */
.scrim { display: none; }
@media (max-width: 820px) {
  /* The sidebar is taken out of flow (position: fixed) and overlaid as a
     drawer, so the grid only needs a single full-width column for .main.
     A two-column track would leave .main in the empty 0px column. */
  .app, .app.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(var(--sidebar-w), 86vw); z-index: 60;
    transform: translateX(-100%); transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .app.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,0.35); }
  .thread-inner { padding-left: 16px; padding-right: 16px; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .composer-inner { padding-left: 0; padding-right: 0; }
  .topbar { padding: 0 12px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  /* 16px text on the input keeps iOS from auto-zooming when it gains focus. */
  .ta { font-size: 16px; }
  /* Shrink the keyboard hint to its essentials so it never wraps awkwardly. */
  .composer-hint { font-size: 11px; }
  .empty-state { padding: 24px 18px; }
  .msg-thumb { width: 108px; height: 108px; }
}

@media (max-width: 640px) {
  .google-pill { display: none; }
  .google-connect-btn { width: 34px; padding: 0; justify-content: center; font-size: 0; }
}

/* Very small phones: drop the verbose composer hint entirely. */
@media (max-width: 420px) {
  .composer-hint { display: none; }
  .composer-wrap { padding-top: 6px; }
}

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