/* eSumit Console — single stylesheet, dark default + light theme. */

:root,
:root[data-theme='dark'] {
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #202c33;
  --panel-3: #2a3942;
  --hover: #202c33;
  --active: #2a3942;
  --border: #222d34;
  --text: #e9edef;
  --text-2: #d1d7db;
  --muted: #8696a0;
  --accent: #00a884;
  --accent-strong: #06cf9c;
  --accent-contrast: #111b21;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-text: #e9edef;
  --meta: rgba(233, 237, 239, 0.6);
  --wallpaper: #0b141a;
  --wallpaper-dot: rgba(255, 255, 255, 0.025);
  --ok: #25d366;
  --warn: #f2b84b;
  --bad: #f15c6d;
  --info: #53bdeb;
  --code-bg: rgba(0, 0, 0, 0.28);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --chart-in: #53bdeb;
  --chart-out: #00a884;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --panel-3: #e9edef;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --border: #e9edef;
  --text: #111b21;
  --text-2: #3b4a54;
  --muted: #667781;
  --accent: #008069;
  --accent-strong: #00a884;
  --accent-contrast: #ffffff;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-text: #111b21;
  --meta: #667781;
  --wallpaper: #efeae2;
  --wallpaper-dot: rgba(0, 0, 0, 0.035);
  --ok: #1fa855;
  --warn: #c98a00;
  --bad: #ea0038;
  --info: #027eb5;
  --code-bg: rgba(0, 0, 0, 0.06);
  --shadow: 0 6px 24px rgba(11, 20, 26, 0.12);
  --chart-in: #027eb5;
  --chart-out: #008069;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', 'Noto Sans Devanagari', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
:root[data-theme='light'] a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 500; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
code, pre, kbd, .mono { font-family: ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo, Consolas, monospace; }
kbd { font-size: 0.7rem; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.18); }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: 6px; }
svg { flex-shrink: 0; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid transparent; border-radius: 20px; padding: 8px 16px;
  font: inherit; font-weight: 500; cursor: pointer; transition: background 0.15s, opacity 0.15s;
  color: var(--text); background: var(--panel-2); white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:not(:disabled):hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--panel-3); color: var(--accent-strong); }
:root[data-theme='light'] .btn-ghost { color: var(--accent); }
.btn-ghost:not(:disabled):hover { background: var(--hover); }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:not(:disabled):hover { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.btn-sm { padding: 5px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; }
.icon-btn.is-on.ok { color: var(--ok); }
.icon-btn.is-on.warn { color: var(--warn); }
.icon-btn.is-on.bad { color: var(--bad); }
.icon-btn.danger:hover { color: var(--bad); }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid transparent; border-radius: 8px; padding: 9px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type='range'] { padding: 0; accent-color: var(--accent); background: transparent; }
input[type='radio'] { accent-color: var(--accent); width: auto; }
.select { width: auto; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { font-size: 0.8rem; color: var(--muted); padding: 0; }
.form-error { color: var(--bad); margin: 0; font-size: 0.9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }

/* Switch */
.switch {
  appearance: none; -webkit-appearance: none; width: 36px; height: 20px; padding: 0; border-radius: 20px;
  background: var(--panel-3); position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.15s; border: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-cell { display: inline-flex; }
.toggles { display: flex; flex-direction: column; gap: 12px; }

/* Badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; font-weight: 600;
  padding: 2px 7px; border-radius: 10px; background: var(--panel-3); color: var(--text-2); white-space: nowrap;
}
.badge-ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge-warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge-bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.tier-fast { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }
.tier-balanced { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.tier-quality { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--panel-3); background: transparent; color: var(--text-2); font: inherit; font-size: 0.85rem;
  padding: 5px 12px; border-radius: 16px; cursor: pointer;
}
.chip.active { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: transparent; color: var(--accent-strong); }
:root[data-theme='light'] .chip.active { color: var(--accent); }

/* Spinner */
.spinner {
  width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--panel-3);
  border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot, .view-loading { display: grid; place-items: center; height: 100%; min-height: 120px; }

/* ---------- app shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }
.rail {
  width: 68px; flex-shrink: 0; background: var(--panel-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 6px;
}
.rail-brand { color: var(--accent); padding: 6px 0 12px; }
.rail-brand svg { width: 30px; height: 30px; }
.rail-items, .rail-bottom { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.rail-items { flex: 1; }
.rail-item {
  position: relative; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%;
  color: var(--muted); background: transparent; border: 0; cursor: pointer; text-decoration: none !important;
}
.rail-item:hover { background: var(--hover); color: var(--text); }
:root[data-theme='light'] .rail-item:hover { background: var(--panel-3); }
.rail-item.active { background: var(--active); color: var(--text); }
:root[data-theme='light'] .rail-item.active { background: #d9dbdf; }
.rail-label { display: none; }
.status-dot {
  position: absolute; top: 9px; right: 9px; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--panel-2); background: var(--bad);
}
.status-dot[data-tone='ok'] { background: var(--ok); }
.status-dot[data-tone='warn'] { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; overflow: auto; outline: none; }
.view[data-view='chats'] { overflow: hidden; }
.qr-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px;
  background: color-mix(in srgb, var(--warn) 18%, var(--panel)); color: var(--text); font-size: 0.9rem;
}
.qr-banner span { display: inline-flex; align-items: center; gap: 8px; }
.qr-banner svg { width: 18px; height: 18px; }

/* ---------- pages & cards ---------- */
.page { padding: 24px; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.page-full { max-width: none; height: 100%; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-header p { margin: 4px 0 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; min-width: 0; }
.card-title { margin-bottom: 14px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-title-row .card-title { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.list-empty { padding: 28px 16px; text-align: center; color: var(--muted); list-style: none; }
.empty-state { padding: 48px; text-align: center; }

/* ---------- split panes (chats) ---------- */
.split { display: flex; height: 100%; }
.pane { display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.list-pane { width: 32%; min-width: 300px; max-width: 460px; border-right: 1px solid var(--border); }
.conversation-pane { flex: 1; background: var(--panel-2); }
.pane-header {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 16px;
  background: var(--panel-2); border-bottom: 1px solid var(--border);
}
.list-pane .pane-header { background: var(--panel); justify-content: space-between; border: 0; }
.list-pane .pane-header h2 { font-size: 1.35rem; font-weight: 600; }
.search-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 0 12px;
  background: var(--panel-2); border-radius: 8px; color: var(--muted);
}
.search-bar svg { width: 18px; height: 18px; }
.search-bar input { background: transparent; padding: 8px 0; border: 0; }
.search-bar.compact { margin: 0; min-width: 200px; flex: 1; max-width: 320px; }

.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 0 0 0 14px; color: var(--text) !important;
  text-decoration: none !important; cursor: pointer;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item-body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); padding: 12px 14px 12px 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item-top, .chat-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-item-name { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.chat-item-preview { color: var(--muted); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-badges { display: flex; gap: 4px; flex-shrink: 0; }
.tick { color: var(--info); font-size: 0.78rem; letter-spacing: -3px; margin-left: 2px; }
.typing-text { color: var(--accent-strong); font-weight: 500; }
:root[data-theme='light'] .typing-text { color: var(--accent); }

.avatar {
  --h: 160;
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 600; font-size: 1rem; color: #fff; background: hsl(var(--h) 38% 42%);
}
.avatar-sm { width: 34px; height: 34px; font-size: 0.8rem; }

.conv-header .avatar { width: 40px; height: 40px; }
.conv-title { flex: 1; min-width: 0; }
.conv-name { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-sub { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-actions { display: flex; gap: 2px; }
.back-btn { display: none; }

.wallpaper {
  background-color: var(--wallpaper);
  background-image: radial-gradient(var(--wallpaper-dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.messages { flex: 1; overflow-y: auto; padding: 12px 6% 16px; display: flex; flex-direction: column; overscroll-behavior: contain; }
#message-list { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
.load-older { display: grid; place-items: center; padding: 8px; }
.day-sep { display: flex; justify-content: center; margin: 10px 0; }
.day-sep span {
  background: var(--panel-2); color: var(--muted); font-size: 0.75rem; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); text-transform: uppercase; letter-spacing: 0.02em;
}
:root[data-theme='light'] .day-sep span { background: #fff; }
.msg-row { display: flex; margin: 1px 0; }
.msg-row.out { justify-content: flex-end; }
.msg-row.in + .msg-row.out, .msg-row.out + .msg-row.in { margin-top: 8px; }
.bubble {
  max-width: min(65%, 620px); padding: 6px 9px 7px; border-radius: 8px; color: var(--bubble-text);
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13); word-wrap: break-word; overflow-wrap: anywhere; position: relative;
}
.bubble-in { background: var(--bubble-in); border-top-left-radius: 0; }
.bubble-out { background: var(--bubble-out); border-top-right-radius: 0; }
.msg-body { white-space: normal; font-size: 0.93rem; }
.msg-type { font-size: 0.72rem; color: var(--meta); text-transform: uppercase; margin-bottom: 2px; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 0.68rem; color: var(--meta); margin-top: 2px; line-height: 1; }
.meta-tag { padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.14); }
.meta-tag.ai::before { content: '✦ '; }
.wa-code { background: var(--code-bg); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 4px 0; font-size: 0.82rem; white-space: pre; }
.wa-inline { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; font-size: 0.85em; }
.bubble a { color: var(--info); }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 14px; background: var(--panel-2);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; background: var(--panel-3); border-radius: 10px; padding: 10px 14px; line-height: 1.35;
}
:root[data-theme='light'] .composer textarea { background: #fff; }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--accent-contrast);
}
.send-btn svg { width: 22px; height: 22px; }
.send-btn:hover { background: var(--accent-strong); }

.conversation-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px;
  border-bottom: 6px solid var(--accent);
}
.conversation-empty h2 { font-size: 1.8rem; font-weight: 300; }
.empty-illustration { color: var(--panel-3); }
.empty-illustration svg { width: 96px; height: 96px; }

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--meta); animation: bounce 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- contacts ---------- */
.contact-table { display: flex; flex-direction: column; }
.ct-row {
  display: grid; grid-template-columns: minmax(180px, 2fr) minmax(140px, 2fr) 90px 80px 70px 110px 90px;
  gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--border);
}
.ct-head { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ct-contact { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ct-contact > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.ct-name, .ct-phone { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-phone { font-size: 0.8rem; }
.inline-input { background: transparent; padding: 5px 8px; border: 1px solid transparent; }
.inline-input:hover { border-color: var(--panel-3); }
.ct-actions { display: flex; justify-content: flex-end; }
.ct-last { font-size: 0.82rem; }

/* ---------- logs ---------- */
.logs-page { display: flex; flex-direction: column; gap: 12px; }
.logs-toolbar { margin: 0; }
.log-view {
  flex: 1; min-height: 240px; overflow: auto; background: #0a1014; color: #cfd8dc; border-radius: 10px; padding: 8px 0;
  font: 12.5px/1.55 ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace; border: 1px solid var(--border);
}
.log-line { padding: 0 12px; white-space: pre-wrap; word-break: break-word; }
.log-line:hover { background: rgba(255, 255, 255, 0.04); }
details.log-line summary { cursor: pointer; list-style: none; }
details.log-line summary::-webkit-details-marker { display: none; }
.log-ts { color: #6b7d87; margin-right: 10px; }
.log-lvl { display: inline-block; width: 52px; font-weight: 700; }
.log-svc { color: #b39ddb; margin-right: 10px; display: inline-block; min-width: 60px; }
.log-meta-hint { color: #6b7d87; margin-left: 8px; font-style: italic; }
.log-meta-hint::before { content: '▸ '; }
details[open] .log-meta-hint::before { content: '▾ '; }
.log-meta { margin: 4px 0 6px 132px; color: #9fb3bd; background: rgba(255, 255, 255, 0.04); padding: 6px 10px; border-radius: 6px; overflow-x: auto; }
.lvl-debug { color: #78909c; }
.lvl-info { color: #4fc3f7; }
.lvl-warn { color: #ffca28; }
.lvl-error, .lvl-fatal { color: #ff6b81; }
.chip.lvl-debug.active { color: #90a4ae; }
.chip.lvl-info.active { color: var(--info); }
.chip.lvl-warn.active { color: var(--warn); background: color-mix(in srgb, var(--warn) 18%, transparent); }
.chip.lvl-error.active { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }

/* ---------- knowledge base ---------- */
.kb-page { display: flex; flex-direction: column; }
.kb-grid {
  flex: 1; min-height: 0; display: grid; gap: 16px;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(280px, 380px);
}
.kb-grid > .card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.kb-file-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.kb-file {
  width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 9px 10px; border-radius: 8px;
  border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit;
}
.kb-file svg { width: 18px; height: 18px; color: var(--muted); margin-top: 2px; }
.kb-file:hover { background: var(--hover); }
.kb-file.active { background: var(--active); }
.kb-file-body { display: flex; flex-direction: column; min-width: 0; }
.kb-file-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.kb-editor-head .card-title { margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-area { font: 13px/1.55 ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace; resize: vertical; tab-size: 2; }
.kb-editor .code-area { flex: 1; min-height: 320px; resize: none; }
.small-area { font-size: 12.5px; }
.kb-search .inline-form { margin-bottom: 12px; }
.kb-results { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.term-list { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.kb-result { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.kb-result-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; }
.kb-path { font-weight: 600; overflow-wrap: anywhere; }
.score { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent-strong); }
.score-bar { height: 4px; background: var(--panel-3); border-radius: 2px; margin: 6px 0; overflow: hidden; }
.score-bar span { display: block; height: 100%; background: var(--accent); }
.kb-snippet { margin: 4px 0; font-size: 0.85rem; color: var(--text-2); white-space: pre-wrap; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.radio-card { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border-radius: 10px; border: 1px solid var(--panel-3); cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.radio-card input { margin-top: 3px; }
.radio-card span { display: flex; flex-direction: column; }
.radio-card small { color: var(--muted); font-size: 0.75rem; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 12px 0; }
.model-card { border: 1px solid var(--panel-3); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.model-card.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.model-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.model-name { font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
.model-note { margin: 4px 0; font-size: 0.82rem; color: var(--text-2); flex: 1; }
.model-actions { display: flex; align-items: center; gap: 8px; }
.installed { margin: 6px 0 12px; }
.installed summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 4px 0; }
.simple-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 6px; }
.simple-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.75rem; }
.simple-table th, .simple-table td { padding: 6px; border-bottom: 1px solid var(--border); }
.pull-row { margin-top: 10px; }
.pull-row.error { color: var(--bad); }
.pull-label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; margin-bottom: 4px; }
.progress { height: 6px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.progress span.indeterminate { animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(330%); } }
.playground { display: flex; flex-direction: column; }
.pg-messages { height: 340px; overflow-y: auto; padding: 12px; border-radius: 10px 10px 0 0; display: flex; flex-direction: column; gap: 4px; }
.playground .composer { border-radius: 0 0 10px 10px; }
.pg-sources { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.bubble.pending { min-width: 56px; }

/* ---------- dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat-tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: 1.75rem; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.8rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar-in { fill: var(--chart-in); }
.chart .bar-out { fill: var(--chart-out); }
.legend { display: flex; gap: 16px; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw-in { background: var(--chart-in); }
.sw-out { background: var(--chart-out); }

/* ---------- connection ---------- */
.connect-page { max-width: 1000px; }
.conn-card { padding: 28px; }
.conn-status { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 16px; font-weight: 600; font-size: 0.85rem; }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tone-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.tone-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.tone-warn .pill-dot { animation: pulse 1.6s ease-in-out infinite; }
.tone-bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.conn-body { display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center; }
.conn-text { display: flex; flex-direction: column; gap: 12px; }
.conn-text h1 { font-size: 1.7rem; font-weight: 300; }
.conn-text p { margin: 0; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }
.conn-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.qr-frame { width: 296px; height: 296px; display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.qr-frame img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-frame.placeholder { background: var(--panel-2); box-shadow: none; }
.qr-frame.placeholder svg { width: 96px; height: 96px; }
.qr-frame.placeholder.tone-ok, .qr-frame.placeholder.tone-bad, .qr-frame.placeholder.tone-warn { background: var(--panel-2); }
.me-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--panel-2); border-radius: 10px; }
.conn-foot { margin: 18px 0 0; }

/* ---------- login ---------- */
#login-root { height: 100%; overflow: auto; }
.login-card {
  position: relative; width: 100%; max-width: 400px; background: var(--panel); border-radius: 12px; padding: 32px 28px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.login-logo { color: var(--accent); }
.login-logo svg { width: 44px; height: 44px; }
.login-card p { margin: 0; }

/* ---------- toast & dialog ---------- */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; width: min(92vw, 420px); }
.toast {
  background: var(--panel-3); color: var(--text); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; border-left: 4px solid var(--info); font-size: 0.9rem;
}
:root[data-theme='light'] .toast { background: #fff; }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--bad); }
.dialog { border: 0; border-radius: 12px; padding: 22px; background: var(--panel); color: var(--text); max-width: min(92vw, 440px); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog p { margin: 0; color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kb-grid { grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); }
  .kb-search { grid-column: 1 / -1; }
  .ct-row { grid-template-columns: minmax(160px, 2fr) minmax(120px, 2fr) 80px 70px 70px 80px; }
  .ct-row .ct-last { display: none; }
  .ct-head span:nth-child(6) { display: none; }
}

@media (max-width: 820px) {
  body { overflow: hidden; }
  .app { flex-direction: column-reverse; }
  .rail {
    width: 100%; height: auto; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border); justify-content: space-between;
  }
  .rail-brand { display: none; }
  .rail-items, .rail-bottom { flex-direction: row; gap: 0; }
  .rail-items { flex: 1; justify-content: space-around; }
  .rail-item { width: 44px; height: 44px; }
  .rail-item svg { width: 22px; height: 22px; }
  .status-dot { top: 7px; right: 7px; }

  .list-pane { width: 100%; max-width: none; min-width: 0; border: 0; }
  .conversation-pane { display: none; }
  .chats-layout.show-detail .list-pane { display: none; }
  .chats-layout.show-detail .conversation-pane { display: flex; }
  .back-btn { display: inline-grid; }
  .messages { padding: 10px 10px 14px; }
  .bubble { max-width: 85%; }
  .conv-actions .icon-btn { width: 36px; height: 36px; }

  .page { padding: 16px; gap: 14px; }
  .kb-grid { grid-template-columns: 1fr; }
  .kb-editor .code-area { min-height: 260px; }
  .settings-grid { grid-template-columns: 1fr; }
  .radio-cards { grid-template-columns: 1fr; }
  .conn-body { grid-template-columns: 1fr; }
  .conn-visual { order: -1; justify-self: center; }
  .qr-frame { width: min(296px, 78vw); height: min(296px, 78vw); }
  .form-grid .span-2 { grid-column: auto; }

  .ct-head { display: none; }
  .ct-row { grid-template-columns: repeat(3, auto) 1fr; gap: 8px 14px; padding: 12px 4px; }
  .ct-row > span[data-label] { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); grid-row: 3; }
  .ct-row > span[data-label]::before { content: attr(data-label); }
  .ct-contact { grid-column: 1 / 4; }
  .ct-actions { grid-column: 4; grid-row: 1; }
  .ct-notes { grid-column: 1 / -1; grid-row: 2; }
  .search-bar.compact { max-width: none; min-width: 0; }
  .page-full { height: auto; min-height: 100%; }
  .log-view { min-height: 60vh; }
}

@media (max-width: 420px) {
  .conv-header { padding: 8px 6px; gap: 6px; }
  .conv-header .avatar { display: none; }
  .conv-actions .icon-btn { width: 32px; height: 32px; }
  .conv-actions .icon-btn svg { width: 19px; height: 19px; }
  .rail-item { width: 40px; height: 40px; }
  .btn { padding: 8px 12px; }
  .conn-card { padding: 18px; }
}

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

/* ---------- sessions & memory ---------- */
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.conversation-pane { position: relative; }
.conv-actions { align-items: center; }
.session-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ok); white-space: nowrap;
  padding: 3px 9px; border-radius: 12px; background: color-mix(in srgb, var(--ok) 14%, transparent);
}
.session-pill .pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); z-index: 20; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow); animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); min-height: 60px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 22px; }
.drawer-sub { font-size: 0.95rem; font-weight: 600; margin: 0; }
.drawer-body p { margin: 4px 0 0; }
.turns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.turn { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); font-size: 0.85rem; }
.turn-assistant { background: color-mix(in srgb, var(--bubble-out) 55%, var(--panel-2)); }
.turn-role { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.turn-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.section-title { font-size: 0.95rem; font-weight: 600; margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.placeholder-help { margin: -6px 0 0; line-height: 1.9; }
.session-list { list-style: none; margin: 0; padding: 0; }
.session-item {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 9px 6px;
  border-bottom: 1px solid var(--border); color: var(--text) !important; text-decoration: none !important;
}
.session-item:hover { background: var(--hover); }
.session-main { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 820px) {
  .session-pill { display: none; }
  .session-item { grid-template-columns: auto 1fr auto; }
  .session-item > .muted.small:nth-child(3) { display: none; }
}

/* =====================================================================
   Motion layer: vanilla ports of Aceternity effects + global polish.
   Transforms/opacity only (compositor-friendly); JS writes CSS vars once per frame.
   ===================================================================== */
:root { --ease-out: cubic-bezier(0.22, 1, 0.36, 1); --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1); }

/* ---------- global polish ---------- */
#view > * { animation: view-in 0.32s var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.btn, .icon-btn, .rail-item { transition: background 0.18s, color 0.18s, opacity 0.18s, transform 0.12s var(--ease-out), box-shadow 0.18s; }
.btn:active:not(:disabled), .icon-btn:active, .rail-item:active { transform: scale(0.96); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.rail-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.card, .stat-tile, .model-card, .conn-card { transition: transform 0.25s var(--ease-out), box-shadow 0.25s, border-color 0.25s, filter 0.3s, opacity 0.3s; }
.chat-item { transition: background 0.15s; content-visibility: auto; contain-intrinsic-size: auto 72px; }
.msg-row.is-new { animation: msg-in 0.28s var(--ease-spring) both; }
.msg-row.is-new.in { transform-origin: left bottom; }
.msg-row.is-new.out { transform-origin: right bottom; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.dialog[open] { animation: dialog-in 0.22s var(--ease-out); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(2px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.toast { transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out); }
input, textarea, select { transition: border-color 0.15s, box-shadow 0.15s; }
input:focus-visible, textarea:focus-visible, select:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.log-line { content-visibility: auto; contain-intrinsic-size: auto 20px; }

/* ---------- Focus cards (hover one, the rest blur) ---------- */
.focus-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.focus-cards > * { transition: filter 0.3s var(--ease-out), transform 0.3s var(--ease-out), opacity 0.3s, box-shadow 0.3s, border-color 0.3s; }
@media (hover: hover) {
  .focus-cards:has(> :hover) > :not(:hover) { filter: blur(3px); transform: scale(0.98); opacity: 0.75; }
}
/* data grids get a lighter version so numbers stay legible */
.stat-grid.focus-cards { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.model-grid.focus-cards { gap: 12px; }
@media (hover: hover) {
  .stat-grid.focus-cards:has(> :hover) > :not(:hover), .model-grid.focus-cards:has(> :hover) > :not(:hover) { filter: blur(1.5px); opacity: 0.7; }
  .stat-grid.focus-cards > :hover, .model-grid.focus-cards > :hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
}
.focus-card {
  position: relative; height: 15rem; border-radius: 16px; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 90% at 15% 10%, hsl(var(--h) 75% 55% / 0.55), transparent 60%),
    radial-gradient(90% 80% at 90% 100%, hsl(calc(var(--h) + 50) 80% 50% / 0.45), transparent 60%),
    linear-gradient(160deg, hsl(var(--h) 30% 18%), hsl(calc(var(--h) + 30) 35% 10%));
}
.focus-art { position: absolute; inset: 0; display: grid; place-items: center; color: hsl(var(--h) 90% 85% / 0.9); }
.focus-art svg { width: 72px; height: 72px; transition: transform 0.5s var(--ease-out); }
.focus-card:hover .focus-art svg { transform: scale(1.12) rotate(-4deg); }
.focus-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 20px 18px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent 65%); color: #fff;
  opacity: 0; transition: opacity 0.3s var(--ease-out);
}
.focus-overlay h3 { font-size: 1.2rem; font-weight: 600; }
.focus-overlay p { margin: 0; font-size: 0.9rem; color: rgba(255, 255, 255, 0.82); }
.focus-card:hover .focus-overlay, .focus-card:focus-within .focus-overlay { opacity: 1; }
@media (hover: none) { .focus-overlay { opacity: 1; } }

/* ---------- Evervault card ---------- */
.ev { padding: 2px; aspect-ratio: 1; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.ev-inner { --mx: -999px; --my: -999px; position: relative; width: 100%; height: 100%; border-radius: 24px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.ev-pattern { pointer-events: none; }
.ev-gradient, .ev-chars {
  position: absolute; inset: 0; border-radius: 16px; opacity: 0;
  -webkit-mask-image: radial-gradient(250px at var(--mx) var(--my), #fff, transparent);
  mask-image: radial-gradient(250px at var(--mx) var(--my), #fff, transparent);
}
.ev-gradient { background: linear-gradient(to right, #00a884, #027eb5 60%, #1d4ed8); transition: opacity 0.5s; }
.ev-chars { mix-blend-mode: overlay; }
.ev-chars p {
  position: absolute; inset: 0; margin: 0; height: 100%; font: 700 0.75rem/1.33 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #fff; overflow-wrap: anywhere; white-space: pre-wrap;
}
.ev-inner:hover .ev-gradient, .ev-inner:hover .ev-chars { opacity: 1; }
.ev-label { position: relative; z-index: 1; width: 11rem; height: 11rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 2.25rem; }
.ev-blur { position: absolute; inset: 0; border-radius: 50%; background: color-mix(in srgb, var(--bg) 80%, transparent); filter: blur(4px); }
.ev-text { position: relative; color: var(--text); letter-spacing: -0.02em; }
.ev-plus { position: absolute; width: 24px; height: 24px; color: var(--text); }
.ev-plus.tl { top: -12px; left: -12px; }
.ev-plus.bl { bottom: -12px; left: -12px; }
.ev-plus.tr { top: -12px; right: -12px; }
.ev-plus.br { bottom: -12px; right: -12px; }

/* QR frame: Evervault glow around the code (the QR itself stays on white, fully scannable) */
.qr-ev { position: relative; padding: 18px; border-radius: 22px; border: 1px solid var(--border); }
.qr-ev > .ev { position: absolute; inset: 0; padding: 0; aspect-ratio: auto; }
.qr-ev > .ev .ev-inner { border-radius: 22px; }
.qr-ev > .ev .ev-label { display: none; }
.qr-ev > .qr-frame { position: relative; z-index: 1; }

/* ---------- landing / sign-in ---------- */
#login-root { scroll-behavior: smooth; overflow-x: hidden; }
.lp { min-height: 100%; background: var(--bg); }
.lp-top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.lp-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.lp-brand svg { width: 22px; height: 22px; color: var(--accent); }
.lp-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: clamp(24px, 5vw, 72px); align-items: center;
  max-width: 1080px; margin: 0 auto; padding: clamp(28px, 6vh, 72px) clamp(16px, 4vw, 40px) 24px; min-height: calc(100vh - 140px);
}
.lp-hero .login-card { animation: view-in 0.5s 0.1s var(--ease-out) both; }
.lp-ev-wrap {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; max-width: 24rem; width: 100%; height: 30rem;
  padding: 16px; border: 1px solid color-mix(in srgb, var(--text) 20%, transparent); justify-self: center; animation: view-in 0.5s var(--ease-out) both;
}
.lp-ev-caption { margin-top: 16px; font-size: 0.9rem; font-weight: 300; color: var(--text); }
.lp-pill { margin: 14px 0 0; font-size: 0.82rem; font-weight: 300; padding: 2px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--text) 20%, transparent); }
.lp-cue { display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 24px; border-radius: 50%; color: var(--muted); border: 1px solid var(--border); animation: cue 2.2s ease-in-out infinite; }
.lp-cue svg { width: 20px; height: 20px; }
@keyframes cue { 50% { transform: translateY(5px); } }
.lp-section { overflow: hidden; }
.lp-h2 { text-align: center; font-size: clamp(1.6rem, 3.5vw, 2.4rem); font-weight: 700; margin-bottom: 28px; }
.lp-features { max-width: 1080px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 40px) 72px; overflow: visible; }
.lp-foot { text-align: center; padding: 28px 16px 40px; border-top: 1px solid var(--border); }

/* ---------- Container scroll ---------- */
.cs { --cs-rotate: 20deg; --cs-scale: 1.05; --cs-translate: 0px; height: 80rem; display: flex; align-items: center; justify-content: center; position: relative; padding: 40px 80px 0; }
.cs-stage { width: 100%; padding: 160px 0; position: relative; perspective: 1000px; }
.cs-header { max-width: 64rem; margin: 0 auto; text-align: center; transform: translateY(var(--cs-translate)); will-change: transform; }
.cs-header p { margin: 12px 0 0; }
.cs-title { font-size: 2.25rem; font-weight: 600; color: var(--text); }
.cs-title-big { display: inline-block; margin-top: 4px; font-size: 6rem; font-weight: 800; line-height: 1; color: var(--accent-strong); letter-spacing: -0.04em; }
.cs-card {
  max-width: 64rem; height: 40rem; width: 100%; margin: -48px auto 0; padding: 24px; border: 4px solid #6c6c6c; background: #222; border-radius: 30px;
  transform: rotateX(var(--cs-rotate)) scale(var(--cs-scale)); will-change: transform;
  box-shadow: 0 0 #0000004d, 0 9px 20px #0000004a, 0 37px 37px #00000042, 0 84px 50px #00000026, 0 149px 60px #0000000a, 0 233px 65px #00000003;
}
.cs-screen { height: 100%; width: 100%; overflow: hidden; border-radius: 16px; background: var(--panel-2); padding: 16px; }
.demo-chat { height: 100%; border-radius: 12px; padding: 20px 6%; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; overflow: hidden; }
.demo-chat .bubble { max-width: min(78%, 520px); }
@media (max-width: 768px) {
  .cs { height: 60rem; padding: 8px; }
  .cs-stage { padding: 40px 0; }
  .cs-card { height: 30rem; padding: 8px; }
  .cs-screen { padding: 0; }
  .cs-title { font-size: 1.6rem; }
  .cs-title-big { font-size: 4rem; }
}

/* ---------- Macbook scroll ---------- */
.mb {
  display: flex; min-height: 200vh; flex-shrink: 0; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 120px 0 0; perspective: 800px; transform: scale(0.35); transform-origin: top center;
}
@media (min-width: 640px) { .mb { transform: scale(0.5); } }
@media (min-width: 768px) { .mb { transform: none; } }
.mb-title {
  margin-bottom: 80px; text-align: center; font-size: 1.875rem; font-weight: 700; color: var(--text);
  transform: translateY(var(--mb-tt, 0px)); opacity: var(--mb-to, 1); will-change: transform, opacity;
}
.mb-lid { position: relative; perspective: 800px; }
.mb-lid-back {
  position: relative; height: 12rem; width: 32rem; border-radius: 16px; background: #010101; padding: 8px;
  transform: perspective(800px) rotateX(-25deg) translateZ(0); transform-origin: bottom; transform-style: preserve-3d;
}
.mb-lid-logo { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 8px; background: #010101; box-shadow: 0 2px 0 2px #171717 inset; color: #fff; }
.mb-lid-logo svg { width: 14px; height: 14px; }
.mb-screen {
  --mb-sx: 1.2; --mb-sy: 0.6; --mb-rotate: -28deg; --mb-translate: 0px;
  position: absolute; inset: 0; height: 24rem; width: 32rem; border-radius: 16px; background: #010101; padding: 8px;
  transform: translateY(var(--mb-translate)) rotateX(var(--mb-rotate)) scaleX(var(--mb-sx)) scaleY(var(--mb-sy));
  transform-origin: top; transform-style: preserve-3d; will-change: transform;
}
.mb-screen-bg { position: absolute; inset: 0; border-radius: 8px; background: #272729; }
.mb-screen-content { position: absolute; inset: 8px; border-radius: 8px; overflow: hidden; }
.mb-base { position: relative; z-index: -1; height: 22rem; width: 32rem; overflow: hidden; border-radius: 16px; background: #e5e7eb; }
:root[data-theme='dark'] .mb-base { background: #272729; }
.mb-hinge { position: relative; height: 40px; width: 100%; }
.mb-hinge div { position: absolute; inset: 0 0 auto; margin: 0 auto; height: 16px; width: 80%; background: #050505; }
.mb-deck { display: flex; }
.mb-speaker {
  width: 10%; margin: 8px auto 0; height: 10rem;
  background-image: radial-gradient(circle, #08080a 0.5px, transparent 0.5px); background-size: 3px 3px;
}
.mb-keys { width: 80%; margin: 0 4px; padding: 4px; border-radius: 6px; background: #050505; transform: translateZ(0); }
.kb-row { display: flex; gap: 2px; margin-bottom: 2px; }
.kb-key { border-radius: 4px; padding: 0.5px; background: rgba(255, 255, 255, 0.2); box-shadow: 0 0 6px -1px rgba(255, 255, 255, 0.55); }
.kb-cap {
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 3.5px;
  background: #0a090d; color: #fff; font-size: 5px; line-height: 1.3; box-shadow: 0 -0.5px 2px 0 #0d0d0f inset, -0.5px 0 2px 0 #0d0d0f inset;
}
.kb-key.wide .kb-cap { width: 40px; align-items: flex-start; justify-content: flex-end; padding: 0 0 2px 4px; }
.kb-key.end .kb-cap { align-items: flex-end; padding: 0 4px 2px 0; }
.kb-key.caps .kb-cap { width: 2.8rem; align-items: flex-start; justify-content: flex-end; padding: 0 0 2px 4px; }
.kb-key.ret .kb-cap { width: 2.85rem; }
.kb-key.shift .kb-cap { width: 3.65rem; align-items: flex-start; justify-content: flex-end; padding: 0 0 2px 4px; }
.kb-key.shift.end .kb-cap { align-items: flex-end; padding: 0 4px 2px 0; }
.kb-key.cmd .kb-cap { width: 32px; }
.kb-key.space .kb-cap { width: 8.2rem; }
.kb-key.arrows .kb-cap { width: 4.9rem; letter-spacing: 6px; font-size: 6px; }
.kb-key.power .kb-cap span { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(#000 60%, #1c1c1c); font-size: 0; }
.mb-trackpad { margin: 4px auto; height: 8rem; width: 40%; border-radius: 12px; box-shadow: 0 0 1px 1px #00000020 inset; }
.mb-notch { position: absolute; inset: auto 0 0; margin: 0 auto; height: 8px; width: 80px; border-radius: 24px 24px 0 0; background: linear-gradient(to top, #272729, #050505); }
.mb-badge { position: absolute; bottom: 16px; left: 16px; }
.mb-badge-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; transform: rotate(-12deg); box-shadow: 0 0 0 2px #219653 inset; }
.mb-badge-icon svg { width: 22px; height: 22px; }

/* console sketch shown on the laptop screen */
.sk { display: grid; grid-template-columns: 7% 32% 1fr; height: 100%; background: #111b21; font-size: 0; }
.sk-rail { background: #202c33; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 10px 0; }
.sk-rail i { width: 12px; height: 12px; border-radius: 4px; background: #374248; }
.sk-rail i:nth-child(1) { background: #00a884; }
.sk-list { border-right: 1px solid #222d34; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.sk-search { height: 14px; border-radius: 7px; background: #202c33; margin-bottom: 4px; }
.sk-item { display: flex; gap: 6px; align-items: center; }
.sk-item i { width: 18px; height: 18px; border-radius: 50%; background: hsl(var(--h) 45% 45%); flex-shrink: 0; }
.sk-item span { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sk-item b { height: 5px; width: 60%; border-radius: 3px; background: #3b4a54; }
.sk-item em { height: 4px; width: 85%; border-radius: 3px; background: #2a3942; }
.sk-conv { display: flex; flex-direction: column; gap: 6px; padding: 0 0 8px; --wallpaper: #0b141a; --wallpaper-dot: rgba(255, 255, 255, 0.03); }
.sk-head { height: 24px; background: #202c33; margin-bottom: auto; }
.sk-b { height: 14px; border-radius: 5px; margin: 0 10px; }
.sk-b.in { background: #202c33; align-self: flex-start; }
.sk-b.out { background: #005c4b; align-self: flex-end; }
.sk-compose { height: 16px; margin: 6px 10px 0; border-radius: 8px; background: #2a3942; }

@media (max-width: 860px) {
  .lp-hero { grid-template-columns: 1fr; min-height: 0; }
  .lp-hero .login-card { justify-self: center; order: -1; }
  .lp-ev-wrap { height: 24rem; max-width: 20rem; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-card, .cs-header, .mb-screen, .mb-title, .focus-cards > * { will-change: auto; }
  .focus-cards:has(> :hover) > :not(:hover) { filter: none !important; transform: none !important; opacity: 1 !important; }
  #login-root { scroll-behavior: auto; }
}

/* LLM health card (dashboard) */
.llm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 24px; margin-top: 10px; }
.llm-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border, rgba(127, 127, 127, 0.18)); font-size: 0.9rem; }
.llm-row span:last-child { text-align: right; overflow-wrap: anywhere; }

/* Typing animation: header/list label + live bubble in the thread */
.typing-dots-sm { margin-left: 3px; padding: 0; vertical-align: middle; }
.typing-dots-sm i { width: 4px; height: 4px; background: currentColor; }
.typing-row .bubble { padding: 10px 14px; }
@media (prefers-reduced-motion: reduce) {
  .typing-dots i { animation: pulse 1.6s ease-in-out infinite; }
}

/* ---------- Agenda ---------- */
.agenda-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.agenda-head-actions .btn svg { width: 18px; height: 18px; }
.agenda-tile-warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.agenda-tile-warn .stat-value { color: var(--warn); }
.agenda-tile-bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.agenda-tile-bad .stat-value { color: var(--bad); }
.agenda-tile-link { display: block; color: inherit; text-decoration: none; }
.agenda-tile-link:hover, .agenda-tile-link:focus-visible { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.agenda-toolbar { justify-content: space-between; }
.agenda-notify { color: var(--text-2); }
.agenda-count {
  display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 9px; font-size: 0.72rem; font-weight: 600;
  text-align: center; background: var(--panel-3); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.chip.active .agenda-count { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; }
.agenda-group { margin-top: 18px; }
.agenda-group:first-child { margin-top: 4px; }
.agenda-day { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; margin: 0 0 8px; color: var(--text-2); }
.agenda-group-overdue .agenda-day { color: var(--bad); }
.agenda-items { display: flex; flex-direction: column; gap: 10px; }
.agenda-item {
  display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2);
  border-left: 3px solid var(--panel-3); min-width: 0;
}
.agenda-item.agenda-st-pending.agenda-appointment { border-left-color: var(--warn); }
.agenda-item.agenda-st-confirmed { border-left-color: var(--ok); }
.agenda-item.agenda-st-declined { border-left-color: var(--bad); }
.agenda-item.agenda-st-done, .agenda-item.agenda-st-declined { opacity: 0.8; }
.agenda-group-overdue .agenda-item { border-left-color: var(--bad); }
.agenda-ico { color: var(--accent-strong); flex-shrink: 0; padding-top: 2px; }
:root[data-theme='light'] .agenda-ico { color: var(--accent); }
.agenda-ico svg { width: 22px; height: 22px; }
.agenda-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.agenda-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.agenda-title { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.agenda-st-done .agenda-title { text-decoration: line-through; text-decoration-color: var(--muted); }
.agenda-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.agenda-loc::before { content: '\1F4CD\FE0E '; }
.agenda-who { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.agenda-who svg { width: 14px; height: 14px; }
.agenda-contact { font-weight: 600; }
.agenda-details { margin: 0; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.agenda-quote { margin: 0; padding-left: 10px; border-left: 2px solid var(--panel-3); font-style: italic; overflow-wrap: anywhere; white-space: pre-wrap; }
.agenda-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.agenda-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.agenda-actions .btn svg { width: 16px; height: 16px; }
.agenda-del { color: var(--muted); }
.agenda-del:not(:disabled):hover { color: var(--bad); }
.agenda-dialog { width: min(92vw, 480px); max-width: min(92vw, 480px); max-height: 92vh; overflow-y: auto; }
.agenda-dialog .form-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.agenda-dialog textarea { resize: vertical; }
@media (max-width: 640px) {
  .agenda-head-actions .btn span { display: none; }
  .agenda-item { padding: 12px; gap: 10px; }
  .agenda-toolbar { align-items: flex-start; }
  .agenda-actions .btn { flex: 1 1 auto; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .agenda-item, .agenda-tile-link { transition: none; }
}
