:root {
  --bg: #282c34;
  --bg2: #1e2228;
  --panel: #111;
  --panel2: #1e2228;
  --fg: #9cdef2;
  --heading: #9cdef2;
  --muted: #6b8a94;
  --border: #355a66;
  --accent: #e06c75;
  --accent2: #f0989e;
  --green: #50fa7b;
  --gold: #f0ad4e;
  --radius: 8px;
  --sidebar-w: 280px;
  --topbar-h: 54px;
  --input-area-h: 80px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  /* Lock the viewport: no pinch/double-tap zoom, no rubber-band overscroll. */
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  -ms-touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Fira Code', ui-monospace, monospace;
  /* Shared "OS" atmosphere: the same layered glow as the home screen, behind
     every view (the chat area is transparent, so it shows through here). */
  background-color: var(--bg2);
  background-image:
    radial-gradient(ellipse 85% 55% at 50% -10%, rgba(224,108,117,0.10), transparent 60%),
    radial-gradient(ellipse 70% 50% at 88% 108%, rgba(53,90,102,0.22), transparent 60%),
    radial-gradient(circle, rgba(156,222,242,0.05) 1px, transparent 1.4px);
  background-repeat: no-repeat, no-repeat, repeat;
  background-size: 100% 100%, 100% 100%, 24px 24px;
  background-attachment: fixed;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }

/* ── Offline banner ── */
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100000;
  background: var(--gold); color: #000;
  text-align: center; padding: 8px 12px;
  font-size: 13px; font-weight: 600;
  display: none;
}
#offline-banner.online-flash { background: var(--green); color: #000; transition: background 0.3s; }

/* ── Scrollbars ── hidden everywhere; scrolling still works ── */
* { scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { width: 0; height: 0; display: none; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
  z-index: 10;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand svg { color: var(--accent2); }

.btn-new-chat {
  margin: 12px 12px 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity .15s, transform .12s;
}
.btn-new-chat:hover { opacity: .9; transform: translateY(-1px); }
.btn-new-chat:active { transform: translateY(0); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  min-height: 0;
}

.conv-item {
  padding: 10px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  transition: background .12s;
  position: relative;
  margin-bottom: 2px;
  min-height: 44px;
}
.conv-item:hover { background: var(--bg2); }
.conv-item.active { background: rgba(224,108,117,0.12); border: 1px solid rgba(224,108,117,0.25); }
.conv-item .conv-info { flex: 1; min-width: 0; }
.conv-item .conv-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.conv-item .conv-meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.conv-item .conv-kebab {
  opacity: 0;
  background: none;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: opacity .15s, color .15s;
}
.conv-item:hover .conv-kebab { opacity: 1; }
.conv-item .conv-kebab:hover { color: var(--fg); }

/* ── Kebab dropdown ── */
.kebab-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 500;
  min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
  animation: modalIn .15s ease;
}
.kebab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--fg);
  cursor: pointer;
  transition: background .1s;
  background: none;
  width: 100%;
  text-align: left;
}
.kebab-item:hover { background: var(--bg2); }
.kebab-item.danger { color: var(--accent); }
.kebab-item .ki-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }

/* ── Folder sections ── */
.folder-section { margin-bottom: 4px; }
.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s, outline .12s;
  user-select: none;
}
.folder-header:hover { background: var(--bg2); }
.folder-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.folder-name { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; flex: 1; }
.folder-count { font-size: 10px; color: var(--muted); }
.folder-chevron { font-size: 11px; color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.folder-header.collapsed .folder-chevron { transform: rotate(-90deg); }
.folder-convs { padding-left: 8px; }
.folder-convs.hidden { display: none; }
.folder-del-btn {
  display: none;
  background: none;
  color: var(--muted);
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.folder-del-btn:hover { color: var(--accent); background: rgba(224,108,117,0.15); }
.folder-header:hover .folder-del-btn { display: block; }
.folder-section.drag-over .folder-header { background: rgba(224,108,117,0.15); outline: 1.5px dashed var(--accent); }
.conv-item[draggable="true"] { cursor: grab; }
.conv-item.dragging { opacity: 0.4; }
.uncat-drop-zone { min-height: 4px; border-radius: 6px; transition: background .12s, outline .12s; }
.uncat-drop-zone.drag-over { background: rgba(224,108,117,0.1); outline: 1.5px dashed var(--accent); min-height: 32px; }

.folder-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border-radius: 6px;
  width: 100%;
  text-align: left;
  transition: color .15s, background .15s;
  margin-bottom: 4px;
}
.folder-add-btn:hover { color: var(--fg); background: var(--bg2); }

.sidebar-nav {
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px;
  gap: 4px;
}

.nav-btn {
  flex: 1;
  padding: 10px 6px;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color .15s, background .15s;
  min-height: 44px;
}
.nav-btn:hover { color: var(--fg); background: var(--bg2); }
.nav-btn.active { color: var(--accent); background: rgba(224,108,117,0.1); }
.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Main area ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

/* ── Topbar ── */
#topbar {
  height: var(--topbar-h);
  background: rgba(17,17,17,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 5;
  flex-shrink: 0;
}

#hamburger {
  display: none;
  background: none;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  transition: color .15s;
  min-width: 36px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
}
#hamburger:hover { color: var(--fg); }

#topbar-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .12s;
}
#topbar-center:hover { background: var(--bg2); }

#conv-title-display {
  font-size: 14px;
  font-weight: 600;
  color: var(--heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#conv-title-display.empty { color: var(--muted); }

#model-badge {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  padding: 1px 5px;
  border-radius: 4px;
  transition: background .12s, color .12s;
}
#model-badge:hover { background: var(--bg2); color: var(--fg); }

/* ── Messages ── */
#messages-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  min-width: 0;
  animation: msgIn .2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg-wrap.user { align-self: flex-end; align-items: flex-end; }
.msg-wrap.assistant { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: var(--msg-font-size, 13.5px);
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: anywhere;
  /* min-width:0 — as a flex item, min-width:auto would let a long unbreakable
     code token force the bubble wider than the viewport (min beats max-width) */
  min-width: 0;
  /* Hard-cap against the viewport (not just 100% of an inflatable parent) so a
     wide table/code block can't stretch the bubble and stop prose from wrapping.
     64px ≈ messages-area padding + avatar + gap. */
  max-width: min(100%, calc(100vw - 64px));
}
.msg-bubble pre { max-width: min(100%, calc(100vw - 78px)); }
.msg-bubble img { max-width: min(100%, 520px); height: auto; border-radius: 6px; vertical-align: middle; display: block; margin: 4px 0; }

.msg-wrap.user .msg-bubble {
  background: rgba(224,108,117,0.15);
  border: 1px solid rgba(224,108,117,0.4);
  color: var(--fg);
  border-bottom-right-radius: 4px;
}

.msg-wrap.assistant .msg-bubble {
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--fg);
  border-bottom-left-radius: 4px;
}

.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4, .msg-bubble h5, .msg-bubble h6, .msg-bubble li { overflow-wrap: anywhere; word-break: break-word; }
.msg-bubble pre {
  background: var(--bg2) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px !important;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}
code[class*="language-"], pre[class*="language-"] { background: none !important; text-shadow: none !important; font-size: 12px; }
.msg-bubble code {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.msg-bubble pre code { background: none; border: none; padding: 0; }
/* Markdown tables: become their own horizontally-scrollable box (width:max-content
   + max-width:100% + overflow-x:auto) so a wide table can NEVER drag the message
   or its headings off-screen — you swipe the table itself. All other text wraps. */
.msg-bubble table, .compacted-content table, .bve-preview table {
  display: block; max-width: min(100%, calc(100vw - 78px)); overflow-x: auto;
  -webkit-overflow-scrolling: touch; border-collapse: collapse; margin: 8px 0; font-size: 12px;
}
.msg-bubble th, .msg-bubble td,
.compacted-content th, .compacted-content td,
.bve-preview th, .bve-preview td {
  border: 1px solid var(--border); padding: 5px 9px; text-align: left; white-space: nowrap;
}
.msg-bubble th, .compacted-content th, .bve-preview th { background: var(--bg2); color: var(--heading); }

/* ══ ARES OS — home screen ═══════════════════════════════════════════════════ */
#os-home {
  position: fixed; inset: 0; z-index: 29;
  display: none; flex-direction: column;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(224,108,117,0.13), transparent),
    radial-gradient(ellipse 70% 45% at 85% 100%, rgba(53,90,102,0.25), transparent),
    var(--bg2);
  padding: max(18px, env(safe-area-inset-top)) 16px calc(76px + env(safe-area-inset-bottom));
}
#os-home.show { display: flex; }
.os-inner { width: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.os-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 8px; }
.os-clock { font-size: 52px; font-weight: 700; line-height: 1; color: var(--fg); letter-spacing: -2px; }
.os-clock .os-sec { font-size: 20px; color: var(--accent); font-weight: 400; }
.os-date { font-size: 12px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 1px; }
.os-greet { font-size: 14px; color: var(--accent2, var(--accent)); margin-top: 2px; }
.os-weather { text-align: right; font-size: 12px; color: var(--muted); max-width: 44%; line-height: 1.5; white-space: pre-line; }
.os-weather .ow-big { font-size: 21px; color: var(--fg); }
.os-ask { display: flex; gap: 8px; }
.os-ask input {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  color: var(--fg); font-family: inherit; font-size: 14px; padding: 13px 14px; outline: none;
}
.os-ask input:focus { border-color: var(--accent); }
.os-ask button {
  background: linear-gradient(135deg, var(--accent), #c4535e); color: #fff; border: none; border-radius: 12px;
  padding: 0 18px; font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.os-ask-models { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 8px; padding-bottom: 2px; scrollbar-width: none; }
.os-ask-models::-webkit-scrollbar { display: none; }
.os-ask-model { flex-shrink: 0; background: var(--panel); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.os-ask-model.on { border-color: var(--accent); color: var(--accent); background: rgba(224,108,117,0.12); }
.os-card { background: rgba(17,17,17,0.55); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.os-card-title { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.os-card-title .oct-link { color: var(--accent); cursor: pointer; letter-spacing: 0; text-transform: none; font-size: 11px; }
.os-task-tab { font-size: 10.5px; color: var(--muted); cursor: pointer; padding-bottom: 3px; border-bottom: 2px solid transparent; margin-right: 12px; user-select: none; -webkit-tap-highlight-color: transparent; letter-spacing: 1.5px; text-transform: uppercase; }
.os-task-tab.on { color: var(--fg); border-bottom-color: var(--accent); }
.os-task-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; border-top: 1px solid rgba(53,90,102,0.25); cursor: pointer; flex-wrap: wrap; }
.tp-edit-panel { width: 100%; flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 8px 28px; margin: 2px 0 4px; background: var(--bg2); border-radius: 8px; }
.tp-edit-panel input, .tp-edit-panel select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--fg); padding: 6px 8px; font-family: inherit; font-size: 13px; width: 100%; box-sizing: border-box; }
.tp-edit-panel select { cursor: pointer; }
.tp-edit-row { display: flex; gap: 8px; align-items: center; }
.tp-edit-row label { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 50px; text-align: right; flex-shrink: 0; }
/* Tasks modal tabs */
.tp-tabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tp-tab { flex: 1; text-align: center; padding: 8px 0; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; -webkit-tap-highlight-color: transparent; user-select: none; }
.tp-tab.on { color: var(--fg); border-bottom-color: var(--accent); }
/* Category pills */
.tp-cats { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tp-cat { padding: 4px 12px; font-size: 11px; border-radius: 999px; cursor: pointer; background: var(--bg2); border: 1px solid var(--border); color: var(--muted); -webkit-tap-highlight-color: transparent; user-select: none; }
.tp-cat.on { border-color: var(--accent); color: var(--accent); background: rgba(224,108,117,0.12); }
.tp-cat-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: middle; position: relative; top: -1px; }
.tp-cat-dot.books { background: #c678dd; }
.tp-cat-dot.movies { background: #e06c75; }
.tp-cat-dot.tv { background: #61afef; }
.tp-cat-dot.music { background: #e06c75; }
.tp-cat-dot.software { background: #56b6c2; }
.tp-cat-dot.general { background: #abb2bf; }
.tp-cat-dot.other { background: #98c379; }
.os-task-row:first-of-type { border-top: none; }
.os-task-check {
  width: 19px; height: 19px; flex-shrink: 0; border: 1.5px solid var(--muted); border-radius: 6px;
  background: none; cursor: pointer; color: transparent; font-size: 12px; line-height: 1; padding: 0;
}
.os-task-check:active { border-color: var(--green); color: var(--green); }
.os-task-label { flex: 1; min-width: 0; font-size: 13px; color: var(--fg); word-break: break-word; }
.os-task-due { font-size: 10.5px; color: var(--muted); flex-shrink: 0; }
.os-task-due.overdue { color: var(--accent); font-weight: 700; }
.os-conv-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-top: 1px solid rgba(53,90,102,0.25); cursor: pointer; }
.os-conv-row:first-of-type { border-top: none; }
.os-conv-title { flex: 1; min-width: 0; font-size: 13px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.os-conv-time { font-size: 10.5px; color: var(--muted); flex-shrink: 0; }
.os-empty { font-size: 12px; color: var(--muted); padding: 4px 0; }
.os-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.os-app {
  aspect-ratio: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  cursor: pointer; transition: border-color .15s, transform .1s; -webkit-tap-highlight-color: transparent;
}
.os-app:active { transform: scale(0.94); border-color: var(--accent); }
.os-app .oa-ico { font-size: 23px; line-height: 1; }
.os-app .oa-name { font-size: 9.5px; color: var(--muted); letter-spacing: .5px; }
@media (min-width: 701px) { #os-home { padding-bottom: 24px; } .os-grid { grid-template-columns: repeat(6, 1fr); } }
.os-version { text-align: center; font-size: 11px; color: var(--muted); opacity: .55; margin-top: 16px; padding-bottom: 6px; letter-spacing: .3px; user-select: none; -webkit-user-select: none; cursor: pointer; }
.os-version:active { opacity: 1; }

/* ── Changelog ── */
.cl-entry { padding: 12px 6px; border-bottom: 1px solid var(--border); }
.cl-entry:first-child { padding-top: 0; }
.cl-entry:last-child { border-bottom: none; }
.cl-entry h3, .cl-entry h4 { margin: 6px 0 4px; font-size: 12px; font-weight: 600; }
.cl-entry li { margin-bottom: 2px; }
.cl-more:hover { background: var(--accent); color: #fff !important; }

/* ── Super-app sections (Bloodvault / Discord) ── share os-home overlay mechanics ── */
.app-section {
  position: fixed; inset: 0; z-index: 29; display: none; flex-direction: column;
  background:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(224,108,117,0.10), transparent),
    var(--bg2);
}
.app-section.show { display: flex; animation: secIn .2s ease; }
#bv-editor.show { animation: secIn .2s ease; }
@keyframes secIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.as-head {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--border); background: rgba(17,17,17,0.35);
}
.as-title { font-size: 17px; font-weight: 700; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.as-title .as-ico { font-size: 19px; }
.as-head .as-spacer { flex: 1; }
.as-hbtn {
  background: var(--panel); border: 1px solid var(--border); color: var(--fg); border-radius: 10px;
  padding: 7px 11px; font-family: inherit; font-size: 13px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  white-space: nowrap; flex-shrink: 0;
}
.as-hbtn:active { transform: scale(0.95); border-color: var(--accent); }
.as-subtabs { display: flex; gap: 4px; flex-shrink: 0; padding: 8px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--border); }
.as-subtab {
  background: none; border: 1px solid transparent; color: var(--muted); border-radius: 999px;
  padding: 6px 14px; font-family: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.as-subtab.active { color: var(--fg); background: var(--panel); border-color: var(--accent); }
.as-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.as-inner { width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.as-loading { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; }
.as-skel { background: linear-gradient(90deg, var(--panel) 25%, rgba(255,255,255,0.05) 37%, var(--panel) 63%); background-size: 400% 100%; animation: asShimmer 1.3s ease infinite; border-radius: 10px; }
@keyframes asShimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (min-width: 701px) { .as-body { padding-bottom: 24px; } }

/* ── Hub: quick-launch service directory ── */
.hub-search { position: sticky; top: -14px; z-index: 2; margin: -2px 0 4px; padding: 8px 0; background: linear-gradient(var(--bg2) 70%, transparent); }
.hub-search input {
  width: 100%; box-sizing: border-box; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 14px; color: var(--fg); font-family: inherit; font-size: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.hub-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,108,117,0.12); }
.hub-search input::placeholder { color: var(--muted); }
#hub-grid { display: flex; flex-direction: column; gap: 18px; }
.hub-cat { animation: secIn .22s ease; }
.hub-cat-head {
  display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--muted); margin: 0 2px 9px;
}
.hub-cat-ico { font-size: 15px; }
.hub-cat-count {
  margin-left: auto; font-size: 10px; letter-spacing: 0; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 1px 7px;
}
.hub-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.hub-tile {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; min-height: 56px;
  background: rgba(17,17,17,0.55); border: 1px solid var(--border); border-radius: 13px;
  color: var(--fg); text-decoration: none; transition: transform .12s ease, border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.hub-tile:hover { background: var(--bg2); border-color: var(--accent2); }
.hub-tile:active { transform: scale(0.96); border-color: var(--accent); }
.hub-fav {
  position: relative; overflow: hidden;
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, hsl(var(--fav-h,210) 55% 46%), hsl(var(--fav-h,210) 60% 34%));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.hub-fav img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; border-radius: inherit; }
.hub-tile-name {
  font-size: 13.5px; font-weight: 600; line-height: 1.2; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.hub-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; }
@media (min-width: 560px) { .hub-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 760px) { .hub-tiles { grid-template-columns: repeat(4, 1fr); } }

/* Hub edit mode: single-column rows with inline controls */
.hub-editing .hub-tiles { grid-template-columns: 1fr !important; gap: 7px; }
.hub-cat-head.editing { text-transform: none; letter-spacing: 0; font-size: 13px; }
.hub-cat-editname { background: none; border: none; color: var(--fg); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 2px 4px; }
.hub-cat-editname:active { opacity: .6; }
.hub-row { display: flex; align-items: center; gap: 9px; padding: 8px 9px; background: rgba(17,17,17,0.55); border: 1px solid var(--border); border-radius: 12px; }
.hub-row-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hub-row-txt .hub-tile-name { font-size: 13px; }
.hub-row-url { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-mini { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
.hub-mini:active { transform: scale(0.9); }
.hub-mini.danger { color: var(--accent); }
.hub-add-link { width: 100%; margin-top: 8px; padding: 9px; background: none; border: 1px dashed var(--border); border-radius: 11px; color: var(--muted); font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.hub-add-link:active { transform: scale(0.98); border-color: var(--accent); color: var(--accent); }
.hub-edit-foot { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.bv-btn.danger { color: var(--accent); border-color: rgba(224,108,117,0.5); }
.bv-btn.arm { background: var(--accent); color: #fff; border-color: var(--accent); }
.hub-f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.hub-f input, .hub-f select { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--fg); font-family: inherit; font-size: 14px; outline: none; }
.hub-f input:focus, .hub-f select:focus { border-color: var(--accent); }
.hub-modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

/* Hub folder-first navigation */
.hub-folders { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
@media (min-width: 480px) { .hub-folders { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .hub-folders { grid-template-columns: repeat(4, 1fr); } }
.hub-folder {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px 12px; min-height: 108px; background: rgba(17,17,17,0.55);
  border: 1px solid var(--border); border-radius: 16px; color: var(--fg); cursor: pointer;
  transition: transform .12s ease, border-color .15s, background .15s; -webkit-tap-highlight-color: transparent;
}
.hub-folder:hover { background: var(--bg2); border-color: var(--accent2); }
.hub-folder:active { transform: scale(0.95); border-color: var(--accent); }
.hub-folder-ico { font-size: 34px; line-height: 1; }
.hub-folder-name { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.2; }
.hub-folder-count {
  position: absolute; top: 9px; right: 10px; min-width: 20px; height: 20px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
  color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
.hub-folder-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.hub-folder-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--fg); }
.hub-folder-title .hub-cat-ico { font-size: 20px; }
.hub-rows { display: flex; flex-direction: column; gap: 7px; }
.hub-row-ico { width: 30px; text-align: center; font-size: 18px; flex-shrink: 0; }

/* ── Bloodvault views ── */
.bv-chips { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.bv-chip { background: var(--panel); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bv-chip.active { color: var(--fg); border-color: var(--accent); background: rgba(224,108,117,0.12); }
.bv-tk-stats { display: flex; gap: 10px; }
.bv-tk-stat { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; }
.bv-tk-stat .n { font-size: 22px; font-weight: 700; color: var(--fg); line-height: 1; }
.bv-streak-value { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.bv-streak-flame { width: 21px; height: 21px; flex: 0 0 21px; color: var(--accent); overflow: visible; }
.bv-tk-stat .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 6px; }
.bv-goal-bar { height: 8px; border-radius: 999px; background: var(--bg2); overflow: hidden; margin-top: 8px; border: 1px solid var(--border); }
.bv-goal-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #c4535e); border-radius: 999px; }
.bv-goal-fill.done { background: linear-gradient(90deg, var(--green), #48b866); }
.bv-heat-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bv-act-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bv-btn { background: var(--panel); border: 1px solid var(--border); color: var(--fg); border-radius: 10px; padding: 9px 13px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bv-btn:active { transform: scale(0.96); }
.bv-btn.primary { background: linear-gradient(135deg, var(--accent), #c4535e); color: #fff; border: none; }
.bv-btn.on { border-color: var(--accent); color: var(--accent); }
.bv-del { background: none; border: none; color: var(--red); font-size: 15px; cursor: pointer; padding: 0 4px; }
/* Pages tree */
.bv-workspace { min-height: 100%; display: flex; flex-direction: column; }
#sec-bloodvault.bv-pages-mode .as-body { padding-top: 6px; }
#sec-bloodvault.bv-pages-mode .as-inner { max-width: 920px; }
.bv-workspace-head { position: sticky; top: -14px; z-index: 4; display: flex; gap: 7px; padding: 8px 0 10px; background: linear-gradient(var(--bg2) 82%, transparent); }
.bv-workspace-head .bv-search { flex: 1; min-width: 0; }
.bv-tree-root { flex: 1; min-height: 180px; padding-bottom: 20px; }
.bv-tree-row { position: relative; display: flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 8px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; -webkit-tap-highlight-color: transparent; user-select: none; }
.bv-tree-row:hover, .bv-tree-row:active { background: var(--panel); }
.bv-tree-row.selected { background: rgba(168,139,250,.14); border-color: rgba(168,139,250,.36); }
.bv-tree-row.drag-over { background: rgba(97,175,239,.12); border-color: #61afef; }
.bv-tree-row.drop-before::before, .bv-tree-row.drop-after::after { content:""; position:absolute; left:5px; right:5px; height:2px; background:#61afef; border-radius:2px; }
.bv-tree-row.drop-before::before { top:-2px; }
.bv-tree-row.drop-after::after { bottom:-2px; }
.bv-tree-row .tw { width: 16px; flex-shrink: 0; text-align: center; color: var(--muted); font-size: 15px; font-weight: 600; line-height: 1; transition: transform .15s; }
.bv-tree-row .tw.open { transform: rotate(90deg); }
.bv-tree-row .tf { width: 18px; flex-shrink: 0; text-align: center; color: var(--muted); font-size: 14px; }
.bv-tree-row .tl { flex: 1; min-width: 0; font-size: 14px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bv-tree-row .td { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bv-tree-row .bv-count { min-width: 20px; padding: 1px 5px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); font-size: 10px; text-align: center; }
.bv-tree-row.folder .tl { font-weight: 650; }
.bv-tree-row.virtual .tl { color: var(--muted); font-style: italic; }
.bv-tree-children { margin-left: 16px; border-left: 1px solid var(--border); padding-left: 3px; }
.bv-search { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); font-family: inherit; font-size: 14px; padding: 11px 13px; outline: none; }
.bv-search:focus { border-color: var(--accent); }
.bv-dim { opacity: .5; }
/* Editor overlay */
#bv-editor { position: fixed; inset: 0; z-index: 34; display: none; flex-direction: column; background: var(--bg2); }
#bv-editor.show { display: flex; }
.bve-shell { min-width: 0; min-height: 0; flex: 1; display: flex; overflow: hidden; }
.bve-main { min-width: 0; min-height: 0; flex: 1; display: flex; flex-direction: column; background: var(--bg2); }
.bve-explorer { width: 270px; flex-shrink: 0; display: flex; flex-direction: column; padding: 10px 8px; border-right: 1px solid var(--border); background: var(--bg); overflow: hidden; }
.bve-inspector { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--bg); overflow-y: auto; }
.bve-inspector.closed { display: none; }
.bvx-head { height: 38px; flex-shrink: 0; display: flex; align-items: center; gap: 5px; padding: 0 5px 8px; color: var(--fg); font-size: 13px; }
.bvx-head strong { flex: 1; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.bvx-icon { width: 29px; height: 29px; flex-shrink: 0; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--muted); font: 14px inherit; cursor: pointer; }
.bvx-icon:hover, .bvx-icon:active { color: var(--fg); background: var(--panel); border-color: var(--border); }
.bvx-search { flex-shrink: 0; margin-bottom: 8px; padding: 8px 10px; font-size: 12.5px; }
.bvx-tree { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.bve-inspector #bve-inspector-body { padding: 2px 12px 24px; }
.bvi-section { padding: 12px 0; border-bottom: 1px solid var(--border); }
.bvi-title { margin-bottom: 8px; color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.bvi-row { display: flex; align-items: center; gap: 8px; padding: 5px 2px; color: var(--fg); font-size: 12.5px; }
.bvi-row .k { width: 70px; flex-shrink: 0; color: var(--muted); }
.bvi-link { display: block; width: 100%; padding: 6px 7px; border: 0; border-radius: 7px; background: none; color: var(--fg); font: 12.5px inherit; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bvi-link:hover, .bvi-link:active { background: var(--panel); color: var(--accent); }
.bvi-link.broken { color: var(--red); }
.bvi-empty { color: var(--muted); font-size: 12px; padding: 3px 7px; }
#bv-editor .as-head { gap: 8px; }
.bve-title-row { padding: 10px 12px 0; }
.bve-title { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); font-family: inherit; font-size: 15px; font-weight: 600; padding: 10px 12px; outline: none; }
.bve-title:focus { border-color: var(--accent); }
.bve-toolbar { display: flex; gap: 3px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 7px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.bve-tb { background: var(--panel); border: 1px solid var(--border); color: var(--fg); border-radius: 8px; padding: 7px 10px; font-family: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; flex-shrink: 0; }
.bve-tb:active { transform: scale(0.93); }
.bve-body { position: relative; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.bve-textarea { flex: 1; width: 100%; background: var(--bg); border: none; color: var(--fg); font-family: 'SF Mono', ui-monospace, monospace; font-size: 15px; line-height: 1.6; padding: 14px; outline: none; resize: none; -webkit-overflow-scrolling: touch; }
.bve-preview { display: none; flex: 1; overflow-y: auto; padding: 18px max(18px, 4vw); color: var(--fg); line-height: 1.7; -webkit-overflow-scrolling: touch; background: var(--bg2); }
.bve-preview a[data-bv-page] { color: var(--obs); text-decoration: none; border-bottom: 1px dotted currentColor; }
.bve-preview a.bv-broken-link { color: var(--obs); opacity: .55; border-bottom: 1px dashed currentColor; }
.bve-foot { display: flex; flex-direction: column; gap: 7px; padding: 9px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex-shrink: 0; }
.bve-foot-line { display: flex; align-items: center; gap: 8px; }
.bve-foot .wc { font-size: 11px; color: var(--muted); }
.bve-goalwrap { display: flex; align-items: center; gap: 8px; }
.bve-goalbar { position: relative; flex: 1; height: 8px; border-radius: 5px; background: var(--panel); overflow: hidden; border: 1px solid var(--border); }
.bve-goalfill { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, var(--accent), #98c379); border-radius: 5px; transition: width .25s ease; }
.bve-goalfill.done { background: #98c379; }
.bve-goaltext { font-size: 10.5px; color: var(--muted); white-space: nowrap; min-width: 74px; text-align: right; }
/* Prominent save button in the editor header */
.as-hbtn.bve-save { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; padding-left: 16px; padding-right: 16px; box-shadow: 0 2px 10px rgba(224,108,117,0.35); }
.as-hbtn.bve-save:active { transform: scale(0.95); }
.as-hbtn.bve-save.saving { opacity: 0.7; }
.bvx-mobile-only, .bve-files-btn { display: none; }
@media (min-width: 901px) {
  .bve-body { flex-direction: row; }
  .bve-textarea { width: 50%; border-right: 1px solid var(--border); }
  .bve-preview { display: block; width: 50%; }
  .bve-body.preview-hidden .bve-preview { display: none; }
  .bve-body.preview-hidden .bve-textarea { width: 100%; border-right: 0; }
}
@media (max-width: 900px) {
  .bve-files-btn, .bvx-mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .bve-explorer { position: fixed; inset: 0 auto 0 0; z-index: 3; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 14px 0 35px rgba(0,0,0,.45); }
  .bve-explorer.open { transform: none; }
  .bve-inspector { display: flex; position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; width: 100%; max-height: 72vh; border: 1px solid var(--border); border-radius: 18px 18px 0 0; transform: translateY(103%); transition: transform .18s ease; box-shadow: 0 -16px 40px rgba(0,0,0,.48); }
  .bve-inspector.open { transform: none; }
  .bve-body.preview-mode .bve-textarea { display: none; }
  .bve-body.preview-mode .bve-preview { display: block; }
}
@media (max-width: 520px) {
  #bv-editor .as-head { gap: 5px; padding-left: 8px; padding-right: 8px; }
  #bv-editor .as-hbtn { padding: 7px 9px; }
  #bv-editor .as-hbtn.bve-save { padding-left: 11px; padding-right: 11px; }
  .bve-title-row { padding-left: 9px; padding-right: 9px; }
}
/* AI */
.bv-ai-msgs { display: flex; flex-direction: column; gap: 10px; }
.bv-ai-msg { padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.bv-ai-msg.u { background: rgba(224,108,117,0.14); border: 1px solid var(--accent); align-self: flex-end; max-width: 85%; }
.bv-ai-msg.a { background: var(--panel); border: 1px solid var(--border); border-left: 2px solid var(--accent); }
.bv-ai-input { display: flex; gap: 8px; position: sticky; bottom: 0; padding-top: 6px; }
.bv-ai-input textarea { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; color: var(--fg); font-family: inherit; font-size: 14px; padding: 11px 13px; outline: none; resize: none; max-height: 120px; }
.bv-ai-input textarea:focus { border-color: var(--accent); }
.bv-sheet-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }

/* ── Discord views ── */
#sec-discord {
  --dc-accent: #5865f2;
  --dc-hover: rgba(255,255,255,0.055);
  --dc-selected: rgba(88,101,242,0.18);
}
#sec-discord .as-head { gap: 7px; padding-bottom: 9px; }
#sec-discord .as-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sec-discord .as-title small { color: var(--muted); font-size: 10px; font-weight: 500; margin-left: 7px; }
#sec-discord .as-hbtn { border: 0; background: transparent; padding: 7px 8px; }
#sec-discord .as-hbtn:hover { background: var(--dc-hover); }
.dc-list-row { display: flex; align-items: center; gap: 11px; padding: 13px 12px; border-radius: 11px; cursor: pointer; -webkit-tap-highlight-color: transparent; border: 1px solid transparent; }
.dc-list-row:hover, .dc-list-row:active { background: var(--dc-hover); }
.dc-list-row .dc-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--panel); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; color: var(--muted); overflow: hidden; }
.dc-list-row .dc-ic img { width: 100%; height: 100%; object-fit: cover; }
.dc-list-row .dc-nm { flex: 1; min-width: 0; font-size: 14.5px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-list-row .dc-nm small { color: var(--muted); }
/* compact rows for channel lists */
.dc-list-row.sm { padding: 7px 12px; gap: 9px; border-radius: 8px; }
.dc-list-row.sm .dc-ic { width: 22px; height: 22px; border-radius: 6px; font-size: 13px; background: none; }
.dc-list-row.sm .dc-nm { font-size: 13.5px; }
.dc-cat { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin: 12px 4px 3px; font-weight: 700; }
.dc-msgs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 8px 6px; display: flex; flex-direction: column; gap: 0; scroll-behavior: smooth; }
.dc-msg { position: relative; display: flex; gap: 10px; padding: 3px 42px 3px 8px; border-radius: 4px; }
.dc-msg:hover { background: var(--dc-hover); }
.dc-msg.compact { padding-top: 1px; padding-bottom: 1px; }
.dc-msg.compact .dc-av { visibility: hidden; height: 20px; }
.dc-msg.compact .dc-mh { display: none; }
.dc-msg.flash { animation: dcReplyFlash 1.4s ease; }
@keyframes dcReplyFlash { 0%,35% { background: var(--dc-selected); } 100% { background: transparent; } }
.dc-msg .dc-av { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: var(--panel); object-fit: cover; margin-top: 2px; }
.dc-msg .dc-mc { flex: 1; min-width: 0; }
.dc-msg .dc-mh { display: flex; align-items: baseline; gap: 8px; }
.dc-msg .dc-au { font-size: 14px; font-weight: 650; color: var(--fg); }
.dc-msg .dc-au.has-profile { cursor: pointer; }
.dc-msg .dc-au.has-profile:hover { text-decoration: underline; }
.dc-msg .dc-au.bot::after { content: 'BOT'; font-size: 8px; background: var(--dc-accent); color: #fff; padding: 1px 4px; border-radius: 3px; margin-left: 5px; vertical-align: middle; font-weight: 700; }
.dc-msg .dc-tm { font-size: 10px; color: var(--muted); }
.dc-msg .dc-bd { font-size: 14px; color: var(--fg); line-height: 1.38; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.dc-msg .dc-reply { position: relative; font-size: 11.5px; color: var(--muted); margin: 0 0 3px -31px; padding-left: 31px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.dc-msg .dc-reply::before { content: ''; position: absolute; left: 8px; top: 8px; width: 16px; height: 8px; border-left: 2px solid var(--muted); border-top: 2px solid var(--muted); border-radius: 7px 0 0 0; opacity: .65; }
.dc-msg .dc-reply:hover { color: var(--fg); }
.dc-msg .dc-att img { max-width: 220px; max-height: 220px; border-radius: 8px; margin-top: 4px; display: block; cursor: zoom-in; }
.dc-embed .dc-e-img img { cursor: zoom-in; }
.dc-remoji { width: 16px; height: 16px; vertical-align: middle; object-fit: contain; }
.dc-msg .dc-att a { color: var(--accent); font-size: 12px; }
.dc-msg .dc-acts { opacity: 0; position: absolute; right: 7px; top: -13px; display: flex; gap: 2px; align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); border-radius: 7px; padding: 2px; box-shadow: 0 4px 10px rgba(0,0,0,.25); z-index: 2; }
.dc-msg:hover .dc-acts, .dc-msg.sel .dc-acts { opacity: 1; }
.dc-msg .dc-acts button { background: none; border: none; border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 14px; padding: 3px 5px; }
.dc-msg .dc-acts button:hover { color: var(--fg); background: var(--dc-hover); }
.dc-day { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 10px; font-weight: 650; margin: 13px 8px 9px; }
.dc-day::before, .dc-day::after { content: ''; height: 1px; background: var(--border); flex: 1; }
.dc-typing { font-size: 11px; color: var(--muted); padding: 1px 18px 3px; min-height: 18px; font-style: italic; }
.dc-compose { position: relative; border-top: 0; padding: 5px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg2); flex-shrink: 0; }
.dc-mention-pop { position: absolute; left: 10px; right: 10px; bottom: calc(100% - 2px); max-height: 210px; overflow-y: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 -6px 24px rgba(0,0,0,0.45); z-index: 5; padding: 4px; }
.dc-mrow { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.dc-mrow:active, .dc-mrow.on { background: rgba(224,108,117,0.14); }
.dc-mrow img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.dc-mrow .dc-mn { font-size: 14px; color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-mrow .dc-mu { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 400; }
.dc-mrow .dc-mbot { font-size: 9px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 4px; padding: 1px 5px; margin-left: auto; letter-spacing: .5px; }
.dc-mtext { flex: 1; min-width: 0; }
.dc-mtext .dc-mn { display: block; }
.dc-role-preview { color: var(--muted); font-size: 10px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dc-profile-head img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--panel); }
.dc-profile-name { font-size: 17px; font-weight: 700; color: var(--fg); }
.dc-profile-user { color: var(--muted); font-size: 11px; margin-top: 2px; }
.dc-role-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 15px; }
.dc-role-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; color: var(--fg); font-size: 11px; }
.dc-role-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dc-mdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dc-mdot.online { background: #43b581; } .dc-mdot.idle { background: #faa61a; } .dc-mdot.dnd { background: #f04747; } .dc-mdot.offline { background: #747f8d; }
.dc-mention { color: var(--accent); font-weight: 600; background: rgba(224,108,117,0.14); border-radius: 4px; padding: 0 3px; }
.dc-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.dc-react { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 2px 8px; font-size: 12px; color: var(--fg); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.dc-react:active { transform: scale(0.93); }
.dc-react .n { color: var(--muted); font-size: 11px; }
.dc-embed { margin-top: 6px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 6px; padding: 8px 10px; max-width: 100%; }
.dc-embed .dc-e-author { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.dc-embed .dc-e-title { font-weight: 700; font-size: 13.5px; color: var(--fg); margin-bottom: 3px; }
.dc-embed .dc-e-title a { color: var(--accent); text-decoration: none; }
.dc-embed .dc-e-desc { font-size: 13px; color: var(--fg); opacity: .92; white-space: pre-wrap; word-break: break-word; }
.dc-embed .dc-e-img { margin-top: 6px; }
.dc-embed .dc-e-img img { max-width: 100%; border-radius: 6px; display: block; }
.dc-embed .dc-e-field { margin-top: 5px; font-size: 12.5px; color: var(--fg); }
.dc-embed .dc-e-field b { display: block; }
.dc-embed .dc-e-foot { margin-top: 6px; font-size: 11px; color: var(--muted); }
.dc-load-earlier { text-align: center; padding: 6px 0 8px; }
.dc-load-earlier button { background: var(--panel); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 6px 16px; font-size: 12px; cursor: pointer; }
.dc-attach-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--accent); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--fg); margin-bottom: 6px; }
.dc-attach-chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.dc-compose-tools { display: flex; gap: 5px; margin: 0 0 5px; overflow-x: auto; }
.dc-tool { background: transparent; border: 0; color: var(--muted); border-radius: 6px; padding: 4px 8px; font-family: inherit; font-size: 11px; font-weight: 600; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.dc-tool:hover { background: var(--dc-hover); color: var(--fg); }
.dc-tool.on { color: var(--dc-accent); }
.dc-tool-icon { font-size: 16px; padding: 2px 7px; }
.dc-reply-bar { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 12px; background: var(--panel2); border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.dc-reply-bar .dc-reply-icon { color: var(--dc-accent); font-size: 15px; }
.dc-reply-bar .dc-reply-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-reply-bar .dc-reply-label b { color: var(--fg); }
.dc-reply-bar button { border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.dc-compose-row { display: flex; gap: 0; align-items: flex-end; background: var(--panel); border-radius: 10px; overflow: hidden; }
.dc-compose.replying .dc-compose-row { border-radius: 0 0 10px 10px; }
.dc-compose-row textarea { flex: 1; background: transparent; border: 0; color: var(--fg); font-family: inherit; font-size: 14px; padding: 11px 13px; outline: none; resize: none; max-height: 120px; }
.dc-compose-row textarea:focus { border: 0; }
.dc-compose-row .bv-btn.primary { align-self: stretch; border: 0; border-radius: 0; min-width: 46px; background: var(--dc-accent); }
#dc-live.off { color: var(--muted); opacity: .5; }
#dc-live.on { color: #23a55a; }
html.eink-mode #sec-discord { --dc-accent: #000; --dc-hover: #eee; --dc-selected: #ddd; }

/* OS panels (Notes / Tasks) share modal plumbing but go full-screen on mobile */
@media (max-width: 700px) {
  #notes-modal .modal-box, #tasks-modal .modal-box, #mail-modal .modal-box { max-width: 100%; width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; border: none; }
  #sec-discord .as-title small { display: none; }
  /* Discord chat view: lift the compose bar above the fixed mobile tabbar so the text box is visible */
  #dc-chat-view { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  /* Inline message action buttons never auto-show on touch (sticky :hover) — long-press opens a sheet instead */
  .dc-msg:hover .dc-acts { opacity: 0; }
  .dc-msg.sel { background: rgba(224,108,117,0.10); }
  .dc-msg { padding-right: 8px; }
  .dc-msg .dc-av { width: 38px; height: 38px; }
}
.osp-add { display: flex; gap: 6px; margin-bottom: 10px; }
.osp-add input { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); font-family: inherit; font-size: 13px; padding: 8px 10px; outline: none; }
.osp-add button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0 14px; font-family: inherit; font-weight: 700; cursor: pointer; }
.osp-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg2); }
.osp-item-head { display: flex; align-items: center; gap: 8px; }
.osp-item-title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--fg); word-break: break-word; }
.osp-item-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.osp-item-body { font-size: 12.5px; color: var(--muted); margin-top: 6px; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: hidden; }
.osp-item-body.expanded { max-height: none; }
.osp-mini { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; font-size: 11px; padding: 3px 8px; cursor: pointer; flex-shrink: 0; }
.osp-mini:active { color: var(--fg); border-color: var(--accent); }
/* OS system meters */
.os-sys-uptime { font-size: 10.5px; color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; }
.os-meter { margin: 9px 0; }
.os-meter-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11.5px; margin-bottom: 4px; }
.os-meter-label { color: var(--fg); }
.os-meter-val { color: var(--muted); font-size: 10.5px; }
.os-meter-bar { height: 6px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.os-meter-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width .4s ease; }
.os-meter-fill.warn { background: linear-gradient(90deg, var(--gold), var(--accent)); }
.os-meter-fill.crit { background: var(--accent); }
.os-sys-foot { display: flex; gap: 14px; font-size: 10.5px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
/* OS mail */
.os-mail-badge { display: inline-block; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 10px; padding: 1px 7px; letter-spacing: 0; text-transform: none; vertical-align: middle; }
.os-mail-actions { display: inline-flex; align-items: center; gap: 10px; }
.os-mail-read-all { display: inline; border: 0; padding: 0; background: none; color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 500; text-transform: none; letter-spacing: 0; cursor: pointer; }
.os-mail-read-all:hover, .os-mail-read-all:focus-visible { color: var(--fg); }
.os-mail-read-all:disabled { opacity: .55; cursor: wait; }
.os-mail-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid rgba(255,255,255,.05); cursor: pointer; }
.os-mail-row:last-child { border-bottom: none; }
.mail-row-del { flex-shrink: 0; background: none; border: none; color: var(--muted); font-size: 13px; opacity: .55; cursor: pointer; padding: 4px 6px; -webkit-tap-highlight-color: transparent; }
.mail-row-del:active { opacity: 1; transform: scale(0.9); }
.os-mail-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: transparent; }
.os-mail-row.unread .os-mail-dot { background: var(--accent); }
.os-mail-main { flex: 1; min-width: 0; }
.os-mail-from { font-size: 12.5px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-mail-row.unread .os-mail-from { font-weight: 700; }
.os-mail-subj { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-mail-star { color: var(--gold); font-size: 12px; flex-shrink: 0; }
.mail-iframe { width: 100%; border: none; background: #fff; border-radius: 8px; min-height: 140px; display: block; }
.mail-msg-subj { font-size: 15px; font-weight: 700; color: var(--heading); margin-bottom: 6px; word-break: break-word; }
.mail-msg-meta { font-size: 11.5px; color: var(--muted); }
.vip-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 3px 6px 3px 10px; font-size: 12px; color: var(--fg); margin: 3px 4px 0 0; }
.vip-chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 2px; }
/* OS writing progress: banner + heatmap + graph */
.os-writing-title { align-items: flex-start; gap: 8px; }
.os-writing-label { flex: 0 0 auto; }
.os-writing-metrics {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}
.os-writing-streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.os-writing-streak svg { width: 12px; height: 12px; flex: 0 0 12px; }
#os-writing-stats {
  min-width: 0;
  color: var(--fg);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
html.eink-mode .os-writing-streak {
  border: 2px solid #000;
  background: #fff;
  color: #000;
}
.os-banner { background: linear-gradient(90deg, rgba(240,173,78,0.18), rgba(224,108,117,0.14)); border: 1px solid var(--gold); color: var(--fg); border-radius: 12px; padding: 11px 14px; font-size: 13px; margin-bottom: 14px; text-align: center; }
.os-heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-auto-columns: 12px; gap: 3px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; justify-content: start; }
.os-heat-cell { width: 12px; height: 12px; border-radius: 2px; background: var(--bg2); }
.os-heat-cell[data-date] { cursor: pointer; transition: transform .08s; }
.os-heat-cell[data-date]:hover { transform: scale(1.35); }
/* Keep perceived brightness strictly ordered from least to most activity. */
.os-heat-cell.l1 { background: #0b3d20; } .os-heat-cell.l2 { background: #0d5c2d; }
.os-heat-cell.l3 { background: #0f7a3a; } .os-heat-cell.l4 { background: #10a34a; }
.os-heat-cell.l5 { background: #14cc5b; } .os-heat-cell.l6 { background: #20f273; }
.os-heat-cell.today { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.os-heat-cell.sel { outline: 1.5px solid var(--gold); outline-offset: 1px; }
/* Heatmap day-detail popover */
.os-heat-detail { margin-top: 12px; border: 1px solid var(--border); background: var(--bg2); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.os-heat-detail .hd-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.os-heat-detail .hd-date { font-weight: 600; color: var(--fg); }
.os-heat-detail .hd-total { color: var(--green); font-size: 12px; white-space: nowrap; }
.os-heat-detail .hd-close { cursor: pointer; color: var(--muted); background: none; border: none; font-size: 16px; line-height: 1; padding: 0 2px; }
.os-heat-detail .hd-close:hover { color: var(--fg); }
.os-heat-detail .hd-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid rgba(255,255,255,0.05); }
.os-heat-detail .hd-row:first-of-type { border-top: none; }
.os-heat-detail .hd-name { color: var(--fg); }
.os-heat-detail .hd-name small { color: var(--muted); font-weight: 400; }
.os-heat-detail .hd-val { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.os-heat-detail .hd-sec { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 2px; }
.os-heat-detail .hd-note { color: var(--muted); font-size: 12px; font-style: italic; padding: 3px 0; }
.os-heat-detail .hd-empty { color: var(--muted); text-align: center; padding: 6px 0; }
.os-heat-legend { display: flex; align-items: center; gap: 5px; justify-content: flex-end; font-size: 10px; color: var(--muted); margin-top: 8px; }
.os-heat-legend .os-heat-cell { width: 10px; height: 10px; }
.os-graph { display: flex; align-items: flex-end; gap: 3px; height: 54px; margin-top: 14px; }
.os-graph-bar { flex: 1; min-width: 3px; background: linear-gradient(180deg, var(--accent), rgba(224,108,117,0.35)); border-radius: 2px 2px 0 0; min-height: 2px; transition: height .3s; }
.os-graph-bar.zero { background: var(--bg2); }
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 { color: var(--heading); margin: 10px 0 6px; }
.msg-bubble ul,.msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble blockquote { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--muted); margin: 8px 0; }

.msg-time { font-size: 10px; color: var(--muted); margin-top: 4px; padding: 0 2px; }

.msg-bubble-row { display: flex; align-items: flex-end; gap: 4px; }
.msg-wrap.user .msg-bubble-row { flex-direction: row; }
.msg-wrap.assistant .msg-bubble-row { flex-direction: row; }
.msg-kebab-btn {
  display: none; /* hidden on desktop — shown only on mobile */
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 5px;
  transition: color .12s, background .12s;
}
.msg-kebab-btn:hover { color: var(--fg); background: var(--bg2); }

.msg-actions { display: none; gap: 3px; margin-top: 5px; flex-direction: row; }
.msg-wrap:hover .msg-actions { display: flex; }
.discord-ch-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 11px;
}
.discord-ch-divider::before, .discord-ch-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.discord-ch-divider span {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  font-family: var(--mono, monospace);
}
.discord-ch-badge {
  font-size: 10px;
  color: var(--muted);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 6px;
  margin-right: 5px;
  font-family: var(--mono, monospace);
  vertical-align: middle;
}
#scroll-btn {
  position: absolute;
  bottom: 80px;
  right: 20px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  transition: color .15s, border-color .15s, opacity .2s;
  line-height: 1;
}
#scroll-btn:hover { color: var(--fg); border-color: var(--accent); }

/* ── Notifications ── */
#notif-bell { position: relative; background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 18px; line-height: 1; transition: color .15s; flex-shrink: 0; }
#notif-bell:hover { color: var(--fg); }
#notif-badge { position: absolute; top: -2px; right: -2px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; text-align: center; padding: 0 4px; display: none; }
#notif-panel { position: fixed; top: 10px; right: 8px; width: 360px; max-width: calc(100vw - 16px); max-height: 80vh; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); z-index: 99999; display: none; flex-direction: column; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,.5); }
#notif-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; flex-shrink: 0; }
#notif-panel-header button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; font-family: inherit; padding: 2px 6px; border-radius: 4px; }
#notif-panel-header button:hover { background: var(--bg2); }
#notif-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid rgba(53,90,102,0.3); cursor: pointer; transition: background .15s; }
.notif-item:hover { background: var(--bg2); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item .ni-type { font-size: 10px; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.notif-item .ni-title { font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 2px; }
.notif-item .ni-body { font-size: 11px; color: var(--muted); max-height: 3.6em; overflow: hidden; word-break: break-word; }
.notif-item .ni-body a { color: var(--accent); text-decoration: underline; word-break: break-all; }
.notif-item.expanded .ni-body { max-height: none; }
.notif-item .ni-expand-hint { font-size: 10px; color: var(--accent); opacity: .7; margin-top: 2px; }
.notif-item.expanded .ni-expand-hint { display: none; }
.notif-item .ni-actions { display: none; gap: 6px; margin-top: 6px; }
.notif-item.expanded .ni-actions { display: flex; }
.notif-item .ni-act-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--fg); cursor: pointer; font-size: 11px; font-family: inherit; padding: 4px 8px; border-radius: 4px; }
.notif-item .ni-act-btn:hover { background: var(--accent); color: #fff; }
.notif-item .ni-time { font-size: 10px; color: var(--muted); margin-top: 4px; }
.notif-item .ni-files { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.notif-item .ni-file { background: var(--bg2); border: 1px solid var(--border); color: var(--fg); cursor: pointer; font-size: 11px; font-family: inherit; padding: 3px 8px; border-radius: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item .ni-file:hover { border-color: var(--accent); color: var(--accent); }
.notif-item .ni-file:disabled { opacity: .6; cursor: default; }
.notif-item .ni-file-size { color: var(--muted); font-size: 10px; }
.notif-item .ni-del { float: right; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; opacity: 0; transition: opacity .15s; }
.notif-item:hover .ni-del { opacity: 1; }
.notif-item .ni-del:hover { color: var(--accent); }
#notif-empty { padding: 30px 14px; text-align: center; color: var(--muted); font-size: 13px; }
@media(max-width:500px){#notif-panel{right:4px;width:calc(100vw - 8px);}}
.tool-call-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  margin: 3px 0;
  border-radius: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono, monospace);
  transition: border-color .15s, color .15s;
  user-select: none;
  max-width: 100%;
  overflow: hidden;
}
.tool-call-pill:hover { border-color: var(--accent); color: var(--fg); }
.tool-call-pill .tc-icon { font-size: 10px; flex-shrink: 0; }
.tool-call-pill .tc-name { color: var(--accent); font-weight: 600; flex-shrink: 0; }
.tool-call-pill .tc-summary { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; max-width: 280px; }
@media(max-width:500px){.tool-call-pill .tc-summary{max-width:120px;}}
.tool-call-pill .tc-chevron { margin-left: 2px; flex-shrink: 0; transition: transform .15s; }
.tool-call-pill.open .tc-chevron { transform: rotate(90deg); }
.tool-call-args {
  display: none;
  margin: 0 0 4px 8px;
  padding: 6px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--mono, monospace);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow-y: auto;
}
.tool-call-args.open { display: block; }
.tool-calls-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin-bottom: 4px; }
.msg-action-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.5;
  transition: color .12s, border-color .12s, background .12s;
}
.msg-action-btn:hover { color: var(--fg); border-color: var(--fg); background: var(--panel); }
.msg-action-btn.regen:hover { color: var(--green); border-color: var(--green); }

/* ── Summary card (compacted) ── */
.summary-card {
  margin: 0 auto 8px;
  max-width: 700px;
  width: 100%;
  background: linear-gradient(135deg, rgba(53,90,102,.18) 0%, rgba(30,34,40,.95) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
}
.summary-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.summary-icon { font-size: 14px; }
.summary-label { color: var(--accent); font-weight: 700; }
.summary-hint { color: var(--muted); }
.summary-body { color: var(--fg); line-height: 1.65; }
.summary-body p { margin: 0 0 6px; }
.summary-body p:last-child { margin-bottom: 0; }

/* ── Compacted history ── */
.compacted-history {
  margin: 0 auto 4px;
  max-width: 700px;
  width: 100%;
}
.compacted-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.compacted-toggle:hover { background: var(--bg2); color: var(--fg); }
.compacted-toggle-icon { font-size: 11px; }
.compacted-count {
  margin-left: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 10px;
}
.compacted-messages {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: rgba(0,0,0,.18);
}
.compacted-msg {
  display: flex;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(53,90,102,.3);
  font-size: 12px;
  opacity: .75;
}
.compacted-msg:last-child { border-bottom: none; }
.compacted-role { color: var(--accent); font-weight: 600; flex-shrink: 0; min-width: 24px; font-size: 10px; text-transform: uppercase; padding-top: 2px; }
.compacted-content { color: var(--muted); line-height: 1.5; }

/* ── Archive ── */
.archive-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  transition: background .12s;
}
.archive-item:hover { background: var(--bg2); }
.archive-item-info { flex: 1; cursor: pointer; min-width: 0; }
.archive-item-title { font-size: 13px; color: var(--fg); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.archive-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.archive-item-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* ── Integration cards ── */
.intg-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.intg-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; user-select: none; }
.intg-header:hover { background: var(--bg2); }
.intg-icon { font-size: 16px; flex-shrink: 0; }
.intg-name { font-size: 13px; font-weight: 600; color: var(--fg); flex: 1; }
.intg-status { font-size: 10px; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.intg-status.on { background: rgba(80,250,123,.15); color: var(--green); }
.intg-status.off { background: rgba(107,138,148,.15); color: var(--muted); }
.intg-status.uncfg { background: var(--bg2); color: var(--muted); }
.intg-chevron { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.intg-body { padding: 4px 12px 12px; border-top: 1px solid var(--border); background: var(--bg2); }

.conv-pin-dot { font-size: 10px; margin-right: 2px; }

/* ── Sidebar search ── */
.sidebar-search { margin: 6px 12px 2px; position: relative; }
.sidebar-search input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px 6px 28px;
  font-size: 12px; color: var(--fg); transition: border-color .15s;
}
.sidebar-search input::placeholder { color: var(--muted); }
.sidebar-search input:focus { border-color: var(--accent); outline: none; }
.sidebar-search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }

/* ── Tag chips ── */
.tag-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 99px; font-size: 10px;
  font-weight: 600; line-height: 1.7; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12); white-space: nowrap;
  transition: opacity .12s, outline .12s;
}
.tag-chip:hover { opacity: .85; }
.tag-chip.active-filter { outline: 2px solid var(--fg); outline-offset: 1px; }
.tag-strip { display: flex; gap: 4px; padding: 4px 12px 2px; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.tag-strip::-webkit-scrollbar { display: none; }
.conv-tags { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px; }

/* ── Bulk mode ── */
.bulk-bar {
  display: none; padding: 8px 10px; border-top: 1px solid var(--border);
  background: var(--bg2); gap: 5px; flex-wrap: wrap; align-items: center;
}
.bulk-bar.visible { display: flex; }
.btn-bulk { padding: 5px 10px; font-size: 11px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-family: inherit; cursor: pointer; transition: color .12s, border-color .12s; }
.btn-bulk:hover { color: var(--fg); border-color: var(--fg); }
.btn-bulk.danger:hover { color: var(--accent); border-color: var(--accent); }
.btn-bulk.cancel { margin-left: auto; }
.conv-item .bulk-chk { display: none; width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.bulk-active .conv-item .bulk-chk { display: block; }
.conv-item.bulk-selected { background: rgba(224,108,117,0.1); }
.bulk-count { font-size: 11px; color: var(--muted); }

/* ── Pinned messages banner ── */
#pinned-banner {
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 0; overflow: hidden; flex-shrink: 0;
}
#pinned-banner.open { padding: 8px 14px 10px; }
.pinned-header {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px;
  cursor: pointer; user-select: none; font-size: 11.5px; color: var(--muted);
  transition: color .12s;
}
.pinned-header:hover { color: var(--fg); }
.pinned-items { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.pinned-item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; color: var(--fg); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color .12s;
}
.pinned-item:hover { border-color: var(--accent); }
.msg-pinned-dot { font-size: 10px; margin-right: 3px; color: var(--gold); }

/* ── Usage stats ── */
.usage-grid { display: flex; flex-direction: column; gap: 0; }
.usage-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.usage-row:last-child { border-bottom: none; }
.usage-label { color: var(--muted); }
.usage-value { color: var(--fg); font-weight: 600; }
.usage-provider-section { margin-top: 12px; }
.usage-provider-header { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }

/* ── Stop button ── */
#send-btn.stop-mode { background: var(--accent) !important; }

/* ── Tag modal ── */
.tag-color-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: border-color .12s, transform .12s; flex-shrink: 0; }
.tag-color-swatch.selected { border-color: var(--fg); transform: scale(1.15); }
.tag-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.tag-row:last-child { border-bottom: none; }

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink .8s steps(1) infinite;
}
@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:0 } }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}
.empty-state .es-icon { font-size: 48px; opacity: .3; }
.empty-state h3 { font-size: 16px; color: var(--heading); font-weight: 600; }
.empty-state p { font-size: 13px; max-width: 280px; }

/* ── Terminal floating controls ── */
#term-voice-btn {
  position: absolute;
  right: 106px;
  bottom: 18px;
  z-index: 10;
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #68717c;
  border-radius: 50%;
  background: transparent;
  color: #f4f6f8;
  cursor: pointer;
}
.term-voice-icon {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000);
}
#term-joystick {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  width: 76px;
  height: 76px;
  border: 2px solid #68717c;
  border-radius: 50%;
  background: transparent;
  color: #f4f6f8;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#term-joystick-nub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: #78838f;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .55);
  transition: transform .15s ease;
}
.term-joy-arrow {
  position: absolute;
  color: currentColor;
  font-size: 9px;
  line-height: 1;
  opacity: .95;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
  pointer-events: none;
}
.term-joy-up { top: 6px; left: 50%; transform: translateX(-50%); }
.term-joy-right { right: 6px; top: 50%; transform: translateY(-50%); }
.term-joy-down { bottom: 6px; left: 50%; transform: translateX(-50%); }
.term-joy-left { left: 6px; top: 50%; transform: translateY(-50%); }

/* ── Input area ── */
#input-area {
  position: relative;
  border-top: 1px solid var(--border);
  background: rgba(17,17,17,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

#msg-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  font-size: 13.5px;
  padding: 10px 12px;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color .15s;
  line-height: 1.5;
}
#msg-input::placeholder { color: var(--muted); }
#msg-input:focus { border-color: var(--accent); }

.input-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .12s;
}
.input-btn:hover { transform: translateY(-1px); }
.input-btn:active { transform: none; }

#send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
#send-btn:disabled { opacity: .4; transform: none; cursor: not-allowed; }

#mem-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
#mem-btn:hover { color: var(--gold); border-color: var(--gold); }

/* ── Overlay / Drawer ── */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
  backdrop-filter: blur(2px);
}
#overlay.show { display: block; }

/* ── Modal base ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.show { display: flex; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: modalIn .2s ease;
  position: relative;
  z-index: 51;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:none; } }

.modal-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--heading); }
.modal-close {
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color .15s;
}
.modal-close:hover { color: var(--fg); }
.modal-body { padding: 20px; }

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 8px 14px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Forms ── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; letter-spacing: 0.04em; text-transform: uppercase; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 13px;
  padding: 9px 11px;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field select option { background: var(--panel); }
.field textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }

.auth-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: -2px 0 14px;
}
.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px !important;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.security-code-card {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  text-align: center;
}
.security-code-label {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.security-code {
  margin: 8px 0 10px;
  color: var(--heading);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(19px, 5vw, 25px);
  font-weight: 800;
  letter-spacing: .08em;
  overflow-wrap: anywhere;
  user-select: all;
}
.security-code-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.security-code-expiry {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 8px;
}

.btn-primary {
  width: 100%;
  padding: 11px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  transition: opacity .15s, transform .12s;
  margin-top: 4px;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; transform: none; cursor: not-allowed; }

.btn-secondary {
  padding: 9px 16px;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(224,108,117,0.07); }

.btn-danger {
  padding: 7px 13px;
  border-radius: 6px;
  background: none;
  border: 1px solid rgba(224,108,117,0.3);
  color: var(--accent);
  font-size: 12px;
  transition: background .15s, border-color .15s;
}
.btn-danger:hover { background: rgba(224,108,117,0.12); border-color: var(--accent); }

/* ── API Key list ── */
.key-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.key-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.key-card .key-info { flex: 1; min-width: 0; }
.key-card .key-label { font-size: 12.5px; font-weight: 600; color: var(--fg); }
.key-card .key-provider { font-size: 11px; color: var(--muted); }
.key-card .key-actions { display: flex; gap: 4px; flex-shrink: 0; }
.btn-star { background: none; padding: 5px; border-radius: 4px; font-size: 14px; color: var(--muted); transition: color .15s; line-height: 1; }
.btn-star:hover { color: var(--gold); }
.btn-star.active { color: var(--gold); }
.btn-icon-sm { background: none; padding: 5px; border-radius: 4px; font-size: 13px; color: var(--muted); transition: color .15s; line-height: 1; }
.btn-icon-sm:hover { color: var(--accent); }

.section-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  margin-top: 4px;
}

.provider-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.provider-openrouter { background: rgba(80,250,123,0.12); color: var(--green); border: 1px solid rgba(80,250,123,0.3); }
.provider-anthropic { background: rgba(224,108,117,0.12); color: var(--accent); border: 1px solid rgba(224,108,117,0.3); }
.provider-openai { background: rgba(156,222,242,0.1); color: var(--fg); border: 1px solid var(--border); }
.provider-venice { background: rgba(100,200,255,0.12); color: #64c8ff; border: 1px solid rgba(100,200,255,0.3); }

/* ── Provider radio cards ── */
.provider-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.provider-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.provider-card:hover { border-color: var(--muted); }
.provider-card.selected { border-color: var(--accent); background: rgba(224,108,117,0.1); }
.provider-card .pc-icon { font-size: 22px; }
.provider-card .pc-name { font-size: 11px; font-weight: 600; color: var(--fg); }

/* ── Memory cards ── */
.mem-grid { display: flex; flex-direction: column; gap: 8px; }
.mem-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: border-color .15s;
}
.mem-card:hover { border-color: var(--muted); }
.mem-card.disabled { opacity: .5; }
.mem-card .mem-body { flex: 1; min-width: 0; }
.mem-card .mem-title { font-size: 13px; font-weight: 600; color: var(--heading); margin-bottom: 4px; }
.mem-card .mem-content { font-size: 12px; color: var(--muted); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mem-card .mem-actions { display: flex; gap: 4px; flex-shrink: 0; padding-top: 2px; }

/* ── Toggle ── */
.toggle {
  position: relative;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  display: block;
  width: 34px;
  height: 18px;
  border-radius: 99px;
  background: var(--border);
  cursor: pointer;
  transition: background .2s;
  position: relative;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 90px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  background: var(--panel2);
  border: 1px solid var(--border);
  color: var(--fg);
  animation: toastIn .2s ease, toastOut .2s ease 2.8s forwards;
  max-width: 280px;
}
.toast.error { border-color: var(--accent); color: var(--accent); }
.toast.success { border-color: var(--green); color: var(--green); }
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }
@keyframes toastOut { to { opacity:0; transform:translateX(20px); } }

/* ── Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, var(--panel2) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Terminal ── */
html:not(.eink-mode) #sec-terminal { background: #0a0a0a; }
html:not(.eink-mode) #sec-terminal .as-head { background: #111; }
#sec-terminal .as-body { padding: 4px 6px !important; background: #0a0a0a; }
#term-toolbar { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
#term-toolbar button:active { background: #0c0 !important; color: #000 !important; border-color: #0c0 !important; }
#term-tabbar .term-tab.active { background: #1a1a1a; color: #c0c0c0; border-color: #333; }
@media (min-width: 701px) {
  #term-toolbar { padding-bottom: 4px; }
}
@media (max-width: 400px) {
  #term-toolbar button { padding: 3px 5px; font-size: 10px; min-width: 24px; }
}

/* ── Mobile bottom tab bar ── */
#mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  background: rgba(17,17,17,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 30;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px;
  background: none;
  color: var(--muted);
  font-size: 10px;
  min-height: 44px;
  transition: color .15s;
}
.mobile-tab svg { width: 20px; height: 20px; }
.mobile-tab.active { color: var(--accent); }

/* ── Inline editing ── */
#title-edit {
  display: none;
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
}

/* ── No conversation state ── */
#no-conv {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}
#no-conv h2 { font-size: 22px; color: var(--accent); font-weight: 700; }
#no-conv p { font-size: 13px; max-width: 300px; line-height: 1.6; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ── Info row ── */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row .ir-label { font-size: 11.5px; color: var(--muted); }
.info-row .ir-value { font-size: 13px; color: var(--fg); font-weight: 500; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 45;
    transform: translateX(-100%);
    width: 88vw;
    min-width: 0;
    pointer-events: none;
  }
  #sidebar.open { transform: translateX(0); pointer-events: auto; }
  #hamburger { display: flex; }
  #__TABMENU__ { display: none; }
  #mobile-tabbar { display: flex; }
  #main { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  #messages-area { padding-bottom: 12px; }
  #input-area { padding: 6px 10px; gap: 5px; }
  #continue-btn { height: 34px; border-radius: 8px; }
  .modal-box { max-height: 85dvh; }
  body { overflow: hidden; }
  :root { --topbar-h: 60px; }
  .input-btn { width: 34px; height: 34px; border-radius: 8px; }
  #msg-input { padding: 7px 10px; min-height: 34px; font-size: 13px; }
  .tag-chip { font-size: 11px; padding: 1px 5px; }
  .sidebar-search input { font-size: 11px; }
}

@media (min-width: 701px) {
  .sidebar-nav { display: flex; }
}

@media (max-width: 700px) {
  #input-tools-desktop { display: none; }
  #input-expand-btn { display: flex !important; }
  .msg-wrap { max-width: 96%; }
  .msg-img { max-width: 100%; max-height: 260px; }
  .msg-bubble img { max-width: 100%; }
  #topbar-center { padding: 2px 4px; }
  .bulk-bar { padding: 6px 8px; gap: 4px; }
  .btn-bulk { padding: 4px 7px; font-size: 10px; }
  /* On mobile: show kebab buttons, suppress hover-only actions */
  .msg-kebab-btn { display: block; }
  .msg-wrap:hover .msg-actions { display: none; }
}

/* ── Memory modal full-width ── */
#memories-modal .modal-box { max-width: 560px; }
#settings-modal .modal-box { max-width: 720px; max-height: 90dvh; }
#settings-modal .modal-body { padding: 14px; }
#settings-modal .settings-legacy-tabs { display: none; }
.settings-accordion { display: flex; flex-direction: column; gap: 8px; }
.settings-shelf {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--fg);
  text-align: left;
}
.settings-shelf:hover { border-color: var(--accent); }
.settings-shelf-icon { width: 25px; font-size: 18px; text-align: center; flex-shrink: 0; }
.settings-shelf-text { flex: 1; min-width: 0; }
.settings-shelf-title { display: block; color: var(--heading); font-size: 13.5px; font-weight: 700; }
.settings-shelf-summary { display: block; margin-top: 2px; color: var(--muted); font-size: 10.5px; font-weight: 400; }
.settings-shelf-chevron { color: var(--muted); font-size: 17px; transition: transform .15s ease; }
.settings-shelf[aria-expanded="true"] {
  border-color: var(--accent);
  border-radius: 10px 10px 0 0;
}
.settings-shelf[aria-expanded="true"] .settings-shelf-chevron { transform: rotate(90deg); }
.settings-pane {
  display: none;
  margin-top: -8px;
  padding: 16px 14px 18px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--panel);
  background: color-mix(in srgb, var(--panel) 85%, var(--bg2));
}
.settings-pane.open { display: block; }
.settings-pane > .tab-panel { display: block !important; }
.settings-intro {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}
.setting-row {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
}
.setting-row > div:first-child { min-width: 0; }
.setting-row strong { display: block; color: var(--fg); font-size: 12.5px; }
.setting-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.setting-font-row { align-items: center; }
.font-stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.font-stepper button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--fg);
  font-size: 16px;
  font-weight: 700;
}
.font-stepper span { min-width: 42px; color: var(--fg); font-size: 12px; text-align: center; }
.settings-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.settings-action-row button { width: 100%; font-size: 11.5px; }

/* Local display preferences */
html.ui-reduce-motion *, html.eink-mode * {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: .001ms !important;
}
html.ui-wide-messages .msg-wrap { max-width: 100%; width: 100%; }
html.ui-wide-messages .msg-bubble { max-width: 100%; }
html.ui-compact #messages-area { padding-top: 6px; padding-bottom: 6px; }
html.ui-compact .msg-wrap { margin-bottom: 5px; }
html.ui-compact .msg-bubble { padding: 7px 9px; line-height: 1.45; }
html.ui-compact .conv-item { padding-top: 5px; padding-bottom: 5px; }
html.ui-compact .os-card { padding: 10px; }
html.ui-large-controls button, html.ui-large-controls .mobile-tab,
html.ui-large-controls input, html.ui-large-controls select {
  min-height: 46px;
}

html.eink-mode {
  --bg: #fff;
  --bg2: #f4f4f4;
  --panel: #fff;
  --panel2: #f4f4f4;
  --fg: #000;
  --heading: #000;
  --muted: #444;
  --border: #000;
  --accent: #000;
  --accent2: #222;
  --green: #000;
  --gold: #222;
}
html.eink-mode body {
  background: #fff !important;
  color: #000;
  -webkit-font-smoothing: none;
}
html.eink-mode #os-home,
html.eink-mode #sec-bloodvault {
  filter: grayscale(1);
}
html.eink-mode body, html.eink-mode #sidebar, html.eink-mode #mobile-tabbar,
html.eink-mode .modal-box, html.eink-mode .app-section, html.eink-mode #os-home {
  background-image: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.eink-mode #mobile-tabbar {
  background: #fff !important;
  border-top: 3px solid #000 !important;
}
html.eink-mode #topbar,
html.eink-mode .as-head {
  background: #fff !important;
  color: #000 !important;
  border-bottom: 3px solid #000 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.eink-mode #topbar button,
html.eink-mode #topbar svg,
html.eink-mode .as-head button,
html.eink-mode .as-head svg,
html.eink-mode .as-title {
  color: #000 !important;
  stroke: #000 !important;
}
html.eink-mode .mobile-tab {
  color: #000 !important;
  opacity: 1 !important;
}
html.eink-mode .mobile-tab svg {
  color: #000 !important;
  stroke: #000 !important;
  stroke-width: 2.7px;
}
html.eink-mode img, html.eink-mode video, html.eink-mode canvas { filter: grayscale(1) contrast(1.12); }
html.eink-mode button, html.eink-mode input, html.eink-mode textarea,
html.eink-mode select, html.eink-mode .msg-bubble, html.eink-mode .os-card {
  box-shadow: none !important;
  text-shadow: none !important;
}
html.eink-mode .settings-shelf,
html.eink-mode .settings-pane,
html.eink-mode .security-code-card,
html.eink-mode .os-card,
html.eink-mode .msg-bubble,
html.eink-mode .conv-item,
html.eink-mode .field input,
html.eink-mode .field textarea,
html.eink-mode .field select,
html.eink-mode .btn-primary,
html.eink-mode .btn-secondary,
html.eink-mode .btn-danger {
  border-width: 2px !important;
}
html.eink-mode .os-card,
html.eink-mode .os-app,
html.eink-mode .hub-tile,
html.eink-mode .hub-row,
html.eink-mode .hub-folder,
html.eink-mode .bv-tk-stat {
  background: #fff !important;
}
html.eink-mode .os-ask button,
html.eink-mode .bv-btn.primary,
html.eink-mode .bv-goal-fill,
html.eink-mode .bv-goal-fill.done {
  background: #000 !important;
  color: #fff !important;
}
html.eink-mode .os-ask-model.on,
html.eink-mode .bv-chip.active,
html.eink-mode .as-subtab.active {
  background: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
}
html.eink-mode .bv-streak-flame { color: #000 !important; }
html.eink-mode .os-heatmap {
  grid-template-rows: repeat(7, 14px);
  grid-auto-columns: 14px;
  gap: 4px;
}
html.eink-mode .os-heat-cell {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  border-radius: 2px;
  background: #fff;
  border: 1px solid #b8b8b8;
}
html.eink-mode .os-heat-cell.l1 { background: #dedede; border-color: #dedede; }
html.eink-mode .os-heat-cell.l2 { background: #b8b8b8; border-color: #b8b8b8; }
html.eink-mode .os-heat-cell.l3 { background: #909090; border-color: #909090; }
html.eink-mode .os-heat-cell.l4 { background: #686868; border-color: #686868; }
html.eink-mode .os-heat-cell.l5 { background: #383838; border-color: #383838; }
html.eink-mode .os-heat-cell.l6 { background: #000; border-color: #000; }
html.eink-mode .os-heat-cell.today,
html.eink-mode .os-heat-cell.sel {
  outline: none;
  box-shadow: inset 0 0 0 3px #000 !important;
}
html.eink-mode .os-heat-legend {
  flex-wrap: nowrap;
  white-space: nowrap;
}
html.eink-mode .setting-row,
html.eink-mode .info-row,
html.eink-mode .pref-row {
  border-bottom-width: 2px !important;
}
html.eink-mode .settings-shelf[aria-expanded="true"] { border-bottom-width: 2px !important; }
html.eink-mode .settings-pane { border-top-width: 0 !important; }
html.eink-mode .btn-primary, html.eink-mode #send-btn {
  background: #000 !important;
  color: #fff !important;
}
html.eink-mode pre, html.eink-mode code {
  background: #f1f1f1 !important;
  color: #000 !important;
  text-shadow: none !important;
}
html.eink-mode .settings-pane { background: #fff; }
html.eink-mode #sec-terminal,
html.eink-mode #sec-terminal .as-body,
html.eink-mode #term-body,
html.eink-mode #term-tabbar,
html.eink-mode #term-toolbar,
html.eink-mode .xterm,
html.eink-mode .xterm-viewport,
html.eink-mode .xterm-screen,
html.eink-mode .term-scrollback-snapshot {
  background: #fff !important;
  color: #000 !important;
}
html.eink-mode #term-tabbar {
  border-bottom: 2px solid #000 !important;
}
html.eink-mode #term-toolbar {
  border-top: 2px solid #000 !important;
}
html.eink-mode #term-toolbar button,
html.eink-mode #term-more-menu button,
html.eink-mode #term-tabbar .term-tab {
  background: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
  border-width: 2px !important;
}
html.eink-mode #term-tabbar .term-tab.active {
  background: #000 !important;
  color: #fff !important;
}
html.eink-mode #term-voice-btn,
html.eink-mode #term-joystick {
  background: transparent !important;
  color: #000 !important;
  border-color: #000 !important;
  border-width: 3px !important;
}
html.eink-mode .term-voice-icon {
  filter: none;
  stroke-width: 3;
}
html.eink-mode #term-joystick-nub { background: #000 !important; }
html.eink-mode #term-joystick-nub {
  border-color: #000 !important;
  box-shadow: none !important;
}
html.eink-mode .term-joy-arrow {
  color: #000 !important;
  opacity: 1 !important;
  font-size: 10px;
}
html.eink-mode .mobile-tab.active {
  color: #000;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
html.eink-mode .skeleton { background: #ddd !important; }

@media (max-width: 700px) {
  body.settings-open #mobile-tabbar { z-index: 60; }
  #settings-modal {
    padding: 0;
    bottom: calc(56px + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  #settings-modal .modal-box {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  #settings-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
    padding: 14px 16px;
  }
  #settings-modal .modal-body { padding: 10px; }
  .settings-pane { padding: 14px 12px 16px; }
  .settings-action-row { grid-template-columns: 1fr; }
}

.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 12px; line-height: 1.5; }
.pref-row:last-child { border-bottom: none; }
.pref-row:hover { background: rgba(255,255,255,.02); }
.pref-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }

/* ── Mem edit form ── */
.mem-edit-form {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}

/* ── Framework cards ── */
.framework-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}
.framework-card {
  flex-shrink: 0;
  width: 88px;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
}
.framework-card:hover { border-color: var(--muted); }
.framework-card.selected { border-color: var(--accent); background: rgba(224,108,117,0.1); }
.framework-card .fw-icon { font-size: 20px; line-height: 1; }
.framework-card .fw-name { font-size: 10px; font-weight: 600; color: var(--fg); line-height: 1.3; }
.framework-card .fw-del {
  display: none;
  position: absolute;
  top: -6px; right: -6px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 11px;
  align-items: center; justify-content: center;
  line-height: 1;
}
.framework-card:hover .fw-del { display: flex; }

/* ── Custom model picker ── */
.model-picker { position: relative; }
.model-picker-box {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 13px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  cursor: text;
  transition: border-color .15s;
}
.model-picker-box.focused { border-color: var(--accent); }
.model-search {
  flex: 1;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.model-search::placeholder { color: var(--muted); }
.model-picker-arrow { color: var(--muted); font-size: 10px; flex-shrink: 0; }

.model-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.model-dropdown.open { display: block; }

.mdrop-section {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 10px 3px;
  background: var(--panel);
  position: sticky;
  top: 0;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background .1s;
}
.model-option:hover { background: var(--bg2); }
.model-option.is-selected { background: rgba(224,108,117,0.1); }
.model-option .mo-name {
  font-size: 12.5px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-option .mo-id {
  display: block;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-option .mo-alias {
  font-size: 10.5px;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}
.model-option .mo-info {
  flex: 1;
  min-width: 0;
}
.mo-star-btn {
  background: none;
  font-size: 20px;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
  transition: color .15s;
  flex-shrink: 0;
  color: var(--muted);
}
.mo-star-btn:hover { color: var(--gold); }
.mo-star-btn.starred { color: var(--gold); }
.mo-rename-btn {
  background: none;
  font-size: 18px;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
  transition: color .15s;
  flex-shrink: 0;
}
.mo-rename-btn:hover { color: var(--fg); }

.mo-rename-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--fg);
  font-size: 12px;
  padding: 2px 7px;
  font-family: inherit;
  outline: none;
}

/* ── Loading dots ── */
.loading-dots { display: inline-flex; gap: 4px; }
.loading-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: ldot .9s ease infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes ldot { 0%,80%,100% { opacity:.2; transform:scale(.8); } 40% { opacity:1; transform:scale(1); } }
@keyframes voicePulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Image attachments ── */
.img-preview-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 14px 0; }
.img-preview-item { position: relative; }
.img-preview-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.img-preview-remove { position: absolute; top: -5px; right: -5px; background: var(--accent); color: #fff; border: none; border-radius: 50%; width: 17px; height: 17px; font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.msg-images { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.msg-img { max-width: 240px; max-height: 200px; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; object-fit: contain; }
.img-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9999; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.img-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }
#img-upload-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--muted); transition: color .15s, border-color .15s; }
#img-upload-btn:hover { color: var(--gold); border-color: var(--gold); }
#piwigo-upload-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--muted); transition: color .15s, border-color .15s; }
#piwigo-upload-btn:hover { color: #e06c75; border-color: #e06c75; }
#piwigo-upload-btn.has-piwigo { color: #e06c75; border-color: #e06c75; }

/* Piwigo upload modal */
.piwigo-drop-zone { border:2px dashed var(--border); border-radius:8px; padding:24px 16px; text-align:center; color:var(--muted); font-size:13px; cursor:pointer; transition:border-color .2s, background .2s; }
.piwigo-drop-zone:hover, .piwigo-drop-zone.drag-over { border-color:var(--accent); background:rgba(224,108,117,.07); color:var(--fg); }
.piwigo-drop-zone .drop-icon { font-size:24px; margin-bottom:6px; }
.piwigo-queue { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:8px; max-height:50vh; overflow-y:auto; }
.piwigo-queue-item { display:flex; flex-direction:column; background:var(--bg2); border-radius:8px; overflow:hidden; font-size:12px; cursor:pointer; border:2px solid transparent; transition:border-color .15s, background .15s; padding:0; gap:0; align-items:stretch; }
.piwigo-queue-item.selected { border-color:var(--accent); background:rgba(224,108,117,.08); }
.piwigo-queue-item.uploading { opacity:.6; cursor:default; }
.piwigo-queue-item img { width:100%; height:120px; object-fit:cover; flex-shrink:0; display:block; }
.piwigo-queue-item .q-info { flex:1; min-width:0; display:flex; flex-direction:column; gap:3px; padding:7px 8px; }
.piwigo-queue-item .q-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--fg); }
.piwigo-queue-item .q-tags { display:flex; flex-wrap:wrap; gap:3px; }
.q-tag-chip { background:rgba(224,108,117,.18); color:var(--accent); border-radius:3px; padding:1px 5px; font-size:10px; display:flex; align-items:center; gap:3px; }
.q-tag-chip button { background:none; border:none; color:inherit; cursor:pointer; font-size:10px; padding:0; line-height:1; opacity:.7; }
.q-tag-chip button:hover { opacity:1; }
.piwigo-queue-item .q-status { font-size:13px; }
.piwigo-queue-item .q-remove { position:absolute; top:6px; right:6px; background:rgba(0,0,0,.55); border:none; color:#fff; cursor:pointer; font-size:14px; padding:2px 5px; border-radius:4px; line-height:1; }
.piwigo-queue-item .q-remove:hover { background:rgba(224,108,117,.85); color:#fff; }
.piwigo-queue-item { position:relative; }
.piwigo-queue-item .q-remove:hover { color:var(--accent); }
.piwigo-queue-selbar { display:flex; align-items:center; gap:8px; font-size:11px; color:var(--muted); padding:0 2px; }
.piwigo-queue-selbar button { background:none; border:none; color:var(--muted); cursor:pointer; font-size:11px; padding:0; text-decoration:underline; }
.piwigo-queue-selbar button:hover { color:var(--fg); }
.piwigo-tag-bar { display:flex; gap:6px; align-items:center; }
.piwigo-tag-bar input { flex:1; background:var(--bg2); border:1px solid var(--border); border-radius:6px; color:var(--fg); font-family:inherit; font-size:13px; padding:7px 10px; }
.piwigo-tag-bar input:focus { outline:none; border-color:var(--accent); }
.piwigo-tag-bar button { flex-shrink:0; }
.piwigo-tag-suggestions { display:flex; flex-wrap:wrap; gap:4px; margin-top:5px; max-height:260px; overflow-y:auto; }
.piwigo-tag-sug { background:var(--bg2); border:1px solid var(--border); border-radius:4px; padding:2px 8px; font-size:11px; color:var(--muted); cursor:pointer; transition:color .12s, border-color .12s; white-space:nowrap; }
.piwigo-tag-sug:hover { color:var(--fg); border-color:var(--accent); }
.piwigo-tag-sug.used { opacity:.5; border-color:var(--accent); color:var(--accent); }
.piwigo-upload-results { font-size:12px; display:flex; flex-direction:column; gap:4px; }
.piwigo-upload-results .res-ok { color:var(--green); }
.piwigo-upload-results .res-err { color:var(--accent); }

/* ── Inline message edit ── */
.msg-edit-wrap { width: 100%; max-width: 500px; }
.msg-edit-textarea { width: 100%; background: var(--bg2); border: 1px solid var(--accent); border-radius: 10px; color: var(--fg); font-family: inherit; font-size: 13.5px; padding: 10px 12px; resize: vertical; min-height: 70px; line-height: 1.5; box-sizing: border-box; }
.msg-edit-actions { display: flex; gap: 8px; margin-top: 6px; }
.btn-sm { font-family: inherit; font-size: 12px; font-weight: 600; padding: 5px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); background: var(--bg2); color: var(--fg); transition: opacity .15s; }
.btn-sm.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.btn-sm:hover { opacity: .8; }

/* ── Content search panel ── */
.search-results { flex: 1; overflow-y: auto; padding: 4px 0; }
.search-result-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.search-result-item:hover { background: var(--bg2); }
.search-result-conv { font-size: 10px; color: var(--muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .04em; }
.search-result-snippet { font-size: 12px; color: var(--fg); line-height: 1.4; }
.search-result-snippet mark { background: rgba(224,108,117,.25); color: var(--accent); border-radius: 2px; padding: 0 1px; }
.search-result-role { font-size: 10px; color: var(--muted); margin-right: 4px; }
.search-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }
#content-search-btn.active { color: var(--accent) !important; border-color: var(--accent) !important; }

/* ── Code block actions ── */
.code-block-wrap { position: relative; }
.code-block-bar { display: flex; gap: 4px; align-items: center; justify-content: flex-end; padding: 4px 8px; background: rgba(0,0,0,.25); border-bottom: 1px solid rgba(255,255,255,.05); flex-wrap: wrap; }
.code-block-lang { flex: 1; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.code-block-btn { font-family: inherit; font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 2px 7px; border-radius: 4px; transition: color .12s, background .12s; white-space: nowrap; }
.code-block-btn:hover { color: var(--fg); background: rgba(255,255,255,.08); }
.code-block-btn.preview-btn { color: var(--green); }
.code-block-btn.preview-btn:hover { background: rgba(80,250,123,.12); }

/* ── Doc / URL chips ── */
.doc-chip-strip { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 14px 0; }
.doc-chip { display: flex; align-items: center; gap: 5px; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 11px; color: var(--fg); max-width: 220px; }
.doc-chip-icon { flex-shrink: 0; font-size: 13px; }
.doc-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.doc-chip-remove { cursor: pointer; color: var(--muted); background: none; border: none; padding: 0 0 0 4px; font-size: 12px; flex-shrink: 0; }
.doc-chip-remove:hover { color: var(--accent); }

/* ── Inline doc context in message ── */
.msg-doc-chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(53,90,102,.25); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 11px; color: var(--muted); margin-bottom: 8px; cursor: pointer; }
.msg-doc-chip:hover { color: var(--fg); border-color: var(--fg); }
.msg-doc-context-text { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 11px; color: var(--muted); white-space: pre-wrap; max-height: 180px; overflow-y: auto; margin-bottom: 8px; line-height: 1.5; }

/* ── Token / cost display ── */
.msg-usage { font-size: 10px; color: var(--muted); margin-top: 3px; opacity: .6; }

/* ── URL reader input ── */
#url-reader-bar { display: none; align-items: center; gap: 6px; padding: 6px 14px 0; }
#url-reader-input { flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); font-family: inherit; font-size: 13px; padding: 6px 10px; outline: none; }
#url-reader-input:focus { border-color: var(--accent); }
#doc-upload-btn, #url-fetch-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--muted); transition: color .15s, border-color .15s; }
#doc-upload-btn:hover { color: var(--gold); border-color: var(--gold); }
#url-fetch-btn { background: var(--bg2); border: 1px solid var(--border); color: var(--muted); transition: color .15s, border-color .15s; }
#url-fetch-btn:hover, #url-fetch-btn.active { color: var(--green); border-color: var(--green); }

/* ── Slash commands ── */
.slash-item { display:flex; align-items:center; gap:10px; padding:10px 14px; cursor:pointer; font-size:13px; transition:background .1s; border-bottom:1px solid var(--border); }
.slash-item:last-child { border-bottom:none; }
.slash-item:hover, .slash-item.active { background:var(--bg2); }
.slash-item .slash-name { color:var(--fg); font-weight:600; font-family:'Fira Code',monospace; }
.slash-item .slash-desc { color:var(--muted); font-size:12px; margin-left:auto; }

/* ── Arena ── */
.arena-col { background:var(--bg2); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
@media (max-width:700px) { #arena-results { grid-template-columns: 1fr !important; } .arena-col-body { max-height:300px; } }
.arena-col-header { padding:8px 12px; font-size:12px; font-weight:600; color:var(--muted); border-bottom:1px solid var(--border); display:flex; align-items:center; gap:6px; }
.arena-col-body { padding:12px; font-size:13px; line-height:1.6; max-height:400px; overflow-y:auto; }
.arena-picker { display:flex; gap:6px; align-items:center; background:var(--bg2); border:1px solid var(--border); border-radius:8px; padding:6px 10px; font-size:12px; }
.arena-picker select { background:transparent; border:none; color:var(--fg); font-family:inherit; font-size:12px; outline:none; }
.arena-picker .rm-btn { color:var(--accent); cursor:pointer; font-size:16px; line-height:1; }

/* ── Context bar ── */
#context-bar { display:flex; }

/* ── Cost badge ── */
.msg-cost { font-size:10px; color:var(--muted); margin-top:2px; opacity:.7; }

/* ── Branch button on messages ── */
.msg-branch-btn { opacity:0; transition:opacity .15s; font-size:11px; color:var(--muted); background:none; border:1px solid var(--border); border-radius:5px; padding:1px 6px; cursor:pointer; font-family:inherit; }
.msg-bubble:hover .msg-branch-btn { opacity:1; }
.msg-branch-btn:hover { color:var(--fg); border-color:var(--fg); }

/* ── Thread panel ── */
#thread-panel { position:fixed; right:0; top:0; bottom:0; width:380px; background:var(--panel); border-left:1px solid var(--border); display:flex; flex-direction:column; z-index:120; transform:translateX(100%); transition:transform .25s cubic-bezier(.4,0,.2,1); }
#thread-panel.open { transform:translateX(0); }
#thread-header { display:flex; align-items:center; gap:8px; padding:10px 14px; border-bottom:1px solid var(--border); flex-shrink:0; }
#thread-header-title { flex:1; font-size:13px; color:var(--fg); font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#thread-close-btn { background:none; border:none; color:var(--muted); cursor:pointer; font-size:18px; padding:2px 6px; border-radius:5px; line-height:1; }
#thread-close-btn:hover { color:var(--fg); background:rgba(255,255,255,.06); }
#thread-parent-msg { padding:10px 14px; background:var(--bg2); border-bottom:1px solid var(--border); font-size:12px; color:var(--muted); flex-shrink:0; max-height:100px; overflow:hidden; }
#thread-parent-msg .tpm-label { font-size:10px; color:var(--muted); margin-bottom:4px; text-transform:uppercase; letter-spacing:.05em; }
#thread-parent-msg .tpm-content { color:var(--fg); font-size:12px; line-height:1.5; overflow:hidden; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; }
#thread-messages { flex:1; overflow-y:auto; padding:10px 12px; display:flex; flex-direction:column; gap:10px; }
#thread-messages .msg-wrap { max-width:100%; }
#thread-input-area { display:flex; gap:6px; padding:10px 12px; border-top:1px solid var(--border); flex-shrink:0; }
#thread-input { flex:1; background:var(--bg2); border:1px solid var(--border); border-radius:8px; color:var(--fg); font-family:inherit; font-size:13px; padding:8px 10px; resize:none; min-height:36px; max-height:120px; outline:none; }
#thread-input:focus { border-color:var(--accent); }
#thread-send-btn { background:var(--accent); border:none; color:#fff; border-radius:8px; padding:8px 12px; cursor:pointer; font-size:14px; flex-shrink:0; }
#thread-send-btn:hover { background:var(--accent2); }
.msg-thread-btn { font-size:11px; color:var(--muted); background:none; border:1px solid var(--border); border-radius:5px; padding:1px 6px; cursor:pointer; font-family:inherit; }
.msg-thread-btn:hover { color:var(--fg); border-color:var(--fg); }
.msg-thread-badge { display:inline-flex; align-items:center; gap:3px; font-size:11px; color:var(--accent); background:rgba(224,108,117,.12); border:1px solid rgba(224,108,117,.25); border-radius:10px; padding:1px 7px; cursor:pointer; margin-top:4px; }
.msg-thread-badge:hover { background:rgba(224,108,117,.2); }
@media (max-width:768px) { #thread-panel { width:100%; } }

/* ── Imggen result ── */
#imggen-result img { width:100%; border-radius:8px; margin-top:8px; }
.imggen-meta { font-size:11px; color:var(--muted); margin-top:6px; line-height:1.5; }

/* ── New-chat mode tabs ── */
.nc-mode-tabs { display:flex; gap:6px; margin-bottom:18px; background:var(--bg2); border-radius:8px; padding:4px; }
.nc-mode-tab { flex:1; padding:7px 12px; border-radius:6px; background:none; border:none; color:var(--muted); font-family:inherit; font-size:13px; font-weight:500; cursor:pointer; transition:background .15s,color .15s; }
.nc-mode-tab.active { background:var(--panel); color:var(--fg); }
.nc-mode-tab:hover:not(.active) { color:var(--fg); }

/* ── Arena model picker row (new-chat inline) ── */
.nc-arena-row { display:flex; align-items:center; gap:8px; background:var(--bg2); border:1px solid var(--border); border-radius:8px; padding:7px 10px; }
.nc-arena-row select { background:transparent; border:none; color:var(--muted); font-family:inherit; font-size:11px; outline:none; flex-shrink:0; }
.nc-arena-row input[type=text] { flex:1; background:transparent; border:none; color:var(--fg); font-family:inherit; font-size:12px; outline:none; min-width:0; }
.nc-arena-row .rm-btn { color:var(--accent); cursor:pointer; font-size:16px; line-height:1; flex-shrink:0; }

/* Desktop tool row — hidden on mobile via max-width:700px above */
@media (min-width: 701px) {
  #input-tools-desktop { display: flex; gap: 0; align-items: center; }

  /* Piwigo upload modal — nearly full-screen on desktop */
  #piwigo-upload-modal { padding: 24px; }
  #piwigo-upload-modal .modal-box { max-width: min(92vw, 1400px); width: 100%; }
  .piwigo-drop-zone { padding: 40px 24px; font-size: 15px; }
  .piwigo-drop-zone .drop-icon { font-size: 36px; margin-bottom: 10px; }
  .piwigo-queue { max-height: 60vh; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .piwigo-queue-item img { height: 220px; }
  .piwigo-tag-suggestions { max-height: 180px; }
}

/* Input tools popup (mobile) */
#input-tools-popup {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin: 0 0 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  z-index:499;
  box-shadow: 0 -4px 20px rgba(0,0,0,.5);
}
#input-tools-popup .tool-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
#input-tools-popup .tool-row:last-child { border-bottom: none; }
#input-tools-popup .tool-row:active { background: var(--bg2); }

/* ── Notepad ── */
.np-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.np-folder {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 10px; cursor: pointer; transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  position: relative;
}
.np-folder:active { border-color: var(--accent); transform: scale(0.96); }
.np-folder .np-folder-ico { font-size: 28px; line-height: 1; }
.np-folder:hover .np-folder-del { display: block !important; }
.np-folder .np-folder-del:hover { background: var(--accent) !important; color: #fff !important; }
.np-folder .np-folder-name { font-size: 12px; font-weight: 600; color: var(--fg); word-break: break-word; }
.np-folder .np-folder-count { font-size: 10px; color: var(--muted); }
.np-note-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; transition: border-color .15s;
  display: flex; flex-direction: column; gap: 5px; position: relative;
}
.np-note-card:active { border-color: var(--accent); }
.np-note-card .np-note-title { font-size: 13px; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-note-card .np-note-preview { font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; }
.np-note-card .np-note-meta { font-size: 10px; color: var(--muted); display: flex; justify-content: space-between; }
.np-note-card.secure .np-note-title::before { content: '🔒 '; }
.np-note-card .np-menu-btn { position: absolute; top: 6px; right: 6px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; line-height: 1; border-radius: 4px; z-index: 2; }
.np-note-card .np-menu-btn:hover { background: var(--bg2); color: var(--fg); }
.np-note-card.archived { opacity: 0.55; }
.np-editor { display: flex; flex-direction: column; gap: 8px; }
.np-editor input { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); font-family: inherit; font-size: 14px; padding: 9px 11px; outline: none; }
.np-editor input:focus { border-color: var(--accent); }
.np-editor textarea { flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); font-family: inherit; font-size: 14px; padding: 10px 12px; outline: none; resize: none; min-height: 200px; line-height: 1.55; }
.np-editor textarea:focus { border-color: var(--accent); }
.np-editor-row { display: flex; gap: 8px; }
.np-editor-row button { flex: 1; }
.np-editor-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); padding: 0 2px; }
.np-editor-meta #np-editor-status { color: var(--accent); transition: opacity .3s; }
.np-editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.np-editor-actions .np-ea-btn { flex: 1; min-width: 90px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); font-family: inherit; font-size: 12px; padding: 8px 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.np-editor-actions .np-ea-btn:hover { border-color: var(--accent); }
.np-editor-actions .np-ea-btn:active { background: var(--accent); color: #fff; }
/* Focus / distraction-free writing mode */
#np-editor-view.np-focus .np-editor-actions, #np-editor-view.np-focus #np-editor-folder-row, #np-editor-view.np-focus #np-editor-title { display: none !important; }
#np-editor-view.np-focus .np-editor textarea { min-height: 70vh; font-size: 16px; }
/* Notepad list toolbar (search + sort) */
.np-toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.np-toolbar input, .np-toolbar select { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); font-family: inherit; font-size: 13px; padding: 8px 10px; outline: none; }
.np-toolbar input { flex: 1; min-width: 0; }
.np-toolbar input:focus, .np-toolbar select:focus { border-color: var(--accent); }
@media (max-width: 700px) {
  .np-grid { grid-template-columns: repeat(3, 1fr); }
  .np-folder { padding: 12px 8px; }
  .np-folder .np-folder-ico { font-size: 22px; }
}

/* ══ Obsidian-style vault extras (quick switcher, [[ suggester, graph) ══ */
:root { --obs: #a88bfa; }
.bv-tree-children { margin-left: 12px; border-left: 1px solid rgba(140,150,170,.2); padding-left: 4px; }

/* quick switcher */
.bvqs-back { position: fixed; inset: 0; z-index: 70; display: none; background: rgba(0,0,0,.55); padding: max(8vh, 40px) 14px 0; }
.bvqs-back.show { display: flex; justify-content: center; align-items: flex-start; }
.bvqs { width: 100%; max-width: 560px; background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 22px 60px rgba(0,0,0,.55); overflow: hidden; display: flex; flex-direction: column; max-height: min(64vh, 520px); }
.bvqs-input { padding: 14px 16px; background: transparent; border: 0; border-bottom: 1px solid var(--border); color: var(--fg); font: 15px inherit; outline: none; }
.bvqs-list { overflow-y: auto; padding: 6px; }
.bvqs-item { display: flex; align-items: baseline; gap: 10px; padding: 9px 11px; border-radius: 8px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bvqs-item .t { color: var(--fg); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bvqs-item .s { margin-left: auto; color: var(--muted); font-size: 11.5px; flex-shrink: 0; }
.bvqs-item.sel, .bvqs-item:hover { background: rgba(168,139,250,.14); }
.bvqs-item.create { color: var(--obs); font-size: 13.5px; }
.bvqs-empty { padding: 16px; color: var(--muted); font-size: 13px; text-align: center; }

/* [[ link suggester */
.bvac { position: absolute; top: 8px; left: 10px; right: 10px; z-index: 5; max-width: 420px; margin: 0 auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.5); overflow: hidden; }
.bvac-head { padding: 7px 12px 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.bvac-item { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 12px; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; }
.bvac-item .t { color: var(--obs); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bvac-item .s { margin-left: auto; color: var(--muted); font-size: 11px; flex-shrink: 0; }
.bvac-item:hover, .bvac-item:active { background: rgba(168,139,250,.14); }
.bvac-empty { padding: 8px 12px 10px; color: var(--muted); font-size: 12.5px; }

/* graph view */
.bv-graph-wrap { position: relative; height: calc(100dvh - 230px); min-height: 320px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: radial-gradient(circle at 50% 40%, rgba(168,139,250,.06), transparent 70%), var(--bg); }
.bv-graph-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.bv-graph-hud { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 8px; }
.bvg-stats { color: var(--muted); font-size: 11px; background: rgba(0,0,0,.35); padding: 4px 9px; border-radius: 999px; }
.bv-graph-tip { position: absolute; left: 0; right: 0; bottom: 7px; text-align: center; color: var(--muted); font-size: 10.5px; pointer-events: none; opacity: .75; }
