:root {
  --bg: #0d0f12;
  --surface: #16181c;
  --surface-2: #1c1f24;
  --surface-3: #22262c;
  --border: #2a2e35;
  --border-strong: #3a3f47;
  --text: #e7e9ea;
  --text-muted: #8b929b;
  --text-dim: #5f6671;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29, 155, 240, 0.12);
  /* Prose hyperlinks. Deliberately NOT --accent: a blue link is hard to pick out
     against the blue-accented chrome, and the browser default is worse. */
  --link: #8b929b;
  --link-hover: #e7e9ea;
  --link-underline: rgba(139, 146, 155, 0.45);
  --good: #18b663;
  --warn: #e0a32e;
  --radius: 14px;
  --radius-sm: 10px;
  --rail-w: 68px;
  /* Height of #client-bar when it is showing (.main.has-bar raises it).
     Inherits into the full-height layouts, which are sized off 100vh, so they
     stay correct whether or not a client bar is present. */
  --chrome-top: 0px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

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

button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 0.22s ease;
}
/* Collapsed = icon rail (workspace icons + client avatars stay clickable),
   not a full hide. The localStorage key is still `sidebarHidden`. */
.app.sidebar-rail {
  grid-template-columns: var(--rail-w) 1fr;
}

/* ===================== Sidebar ===================== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  overflow: hidden;
  transition: padding 0.22s ease, opacity 0.18s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
}

/* ---- Rail mode: icons only. Duplicated verbatim in the 920px query below and
   undone in the 700px slide-over block, matching this file's existing
   convention of explicit duplication over clever selectors. ---- */
.app.sidebar-rail .sidebar { padding: 20px 8px; }
.app.sidebar-rail .brand { flex-direction: column; gap: 8px; padding: 6px 0 18px; }
.app.sidebar-rail .brand-text,
.app.sidebar-rail .brand-sub,
.app.sidebar-rail .client-switch-label,
.app.sidebar-rail .client-item-name,
.app.sidebar-rail .nav-item > span:last-child,
.app.sidebar-rail .add-client-btn > span:last-child { display: none; }
.app.sidebar-rail .nav-item,
.app.sidebar-rail .add-client-btn { justify-content: center; gap: 0; padding: 11px 0; }
.app.sidebar-rail .client-item-av { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; font-size: 12px; }
.app.sidebar-rail .client-list { scrollbar-width: none; }
.app.sidebar-rail .client-list::-webkit-scrollbar { width: 0; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #0a6bb0);
  display: grid; place-items: center;
  font-weight: 800; font-size: 19px; color: #fff;
}
/* The logo mark collapses/expands the sidebar (wireSidebarToggle). */
#brand-toggle { cursor: pointer; flex-shrink: 0; transition: transform 0.12s ease, filter 0.12s ease; }
#brand-toggle:hover { transform: scale(1.06); filter: brightness(1.1); }
#brand-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* No subtitle — the wordmark centers against the logo mark. */
.brand-text { display: flex; align-items: center; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: none;
  color: var(--text-muted);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 550;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-ico { font-size: 11px; width: 16px; text-align: center; opacity: 0.85; }

/* ===================== Main ===================== */
.main { display: flex; flex-direction: column; overflow: hidden; }

/* There is no topbar. For a client, #client-bar IS the top bar: avatar, name,
   channel, the Overview/Workspace/Wiki buttons, Visit channel and a ⋯ menu, all
   on one aligned row. It is a real in-flow row, so --chrome-top carries its
   height down into the full-height layouts (which are sized off 100vh) and
   collapses to 0 on Home / Swipe File / My Wiki, where there is no bar. */
.main.has-bar { --chrome-top: 64px; }
.main-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }

.client-bar {
  flex: 0 0 64px; height: 64px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
}
.bar-id { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 0 1 auto; }
.bar-id-text { min-width: 0; }
.bar-warn { color: #e5534b; }
/* The tab strip sits directly beside the client it belongs to, with "Visit channel"
   trailing it rather than exiled to the right corner. */
.bar-mid { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 0 1 auto; }
.client-bar .subtabs { flex: 0 0 auto; }
.bar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: 0 0 auto; }
.bar-more {
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); font-size: 17px; line-height: 1;
  padding: 5px 9px; border-radius: var(--radius-sm);
}
.bar-more:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }

/* My Wiki card (Home) */
.mywiki-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.mywiki-card-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mywiki-card-icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.mywiki-card-icon svg { width: 20px; height: 20px; }
.mywiki-card-text { min-width: 0; }
.mywiki-card-text h3 { margin: 0 0 3px; }
.mywiki-card-text p { margin: 0; font-size: 13px; color: var(--text-dim); }
.mywiki-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mywiki-card .accent { color: var(--accent); }

.avatar {
  position: relative;
  width: 38px; height: 38px; border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #0a6bb0);
  display: grid; place-items: center;
  border: 1px solid var(--border-strong);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 2; }
.avatar img[data-hidden] { display: none; }
.avatar-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; z-index: 1; }

.content { flex: 1; min-height: 0; overflow: auto; padding: 26px 28px 40px; }

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

/* ===================== Cards / Overview ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-head h3 { font-size: 15px; }
.card-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head-actions .is-busy { opacity: 0.6; pointer-events: none; }
.card-tag { font-size: 11.5px; color: var(--text-dim); background: var(--surface-2); padding: 3px 9px; border-radius: 20px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.metric-label { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.metric-value { font-size: 30px; font-weight: 750; margin-top: 8px; letter-spacing: -0.02em; }
.metric-foot { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.metric .pin { width: 9px; height: 9px; border-radius: 3px; }

.overview-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

/* SVG chart */
.chart-wrap svg { width: 100%; height: 180px; display: block; }
.bar-rect { fill: var(--accent); }
.bar-rect.dim { fill: var(--surface-3); }
.axis-label { fill: var(--text-dim); font-size: 11px; }

/* Format bars */
.fmt-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.fmt-name { width: 120px; font-size: 13px; color: var(--text-muted); flex: 0 0 120px; }
.fmt-track { flex: 1; height: 9px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fmt-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.fmt-num { width: 22px; text-align: right; font-size: 13px; color: var(--text-muted); }

.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 4px; border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: none; }
.recent-title { flex: 1; font-size: 14px; }
.recent-meta { font-size: 12px; color: var(--text-dim); }

/* status + format badges */
.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-status { background: var(--surface-2); color: var(--text-muted); }
.fmt-badge { font-size: 10.5px; padding: 2px 8px; border-radius: 6px; font-weight: 600; letter-spacing: 0.02em; }

/* ===================== Chat ===================== */
.chat-stream {
  flex: 1; overflow-y: auto; overflow-x: hidden; min-width: 0;
  padding: 6px 2px 18px;
  display: flex; flex-direction: column; gap: 18px;
}
.chat-empty { margin: auto; text-align: center; color: var(--text-muted); max-width: 460px; }
.chat-empty-mark {
  width: 56px; height: 56px; margin: 0 auto 18px;
  border-radius: 16px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 22px;
}
.chat-empty h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; }
.chat-empty p { font-size: 14px; margin: 0 0 20px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.chip {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); padding: 8px 14px; border-radius: 20px; font-size: 13px;
  transition: border-color 0.12s, color 0.12s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
/* A prompt pill stays lit while its instruction sits in the composer, so it's obvious
   which prompt the next message will run. Plain chips never take this class. */
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.msg { display: flex; gap: 12px; max-width: 820px; }
.msg-av {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.msg-user .msg-av { background: var(--surface-3); color: var(--text-muted); }
.msg-bot .msg-av { background: linear-gradient(135deg, var(--accent), #0a6bb0); color: #fff; }
/* min-width:0 is what keeps every chat inside its padding. A flex child defaults to its
   min-content width, so a code block or wide table used to stretch the message past the
   pane and the stream scrolled sideways. With it, pre/tables scroll inside their own box
   and prose reflows as the pane is dragged narrower or wider. */
.msg { min-width: 0; }
.msg-body { padding-top: 3px; line-height: 1.6; overflow-wrap: anywhere; min-width: 0; }
.msg-bot .msg-body { flex: 1 1 auto; }
.msg-user .msg-body { flex: 0 1 auto; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-user .msg-body { background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; }
.msg-bot .msg-body { color: var(--text); }
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 6px 0 12px; padding-left: 22px; }
.msg-body li { margin: 4px 0; }
.msg-body code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-family: var(--mono); font-size: 13px; }
.msg-body pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; max-width: 100%; }
.msg-body img { max-width: 100%; height: auto; }
.msg-body details { margin: 6px 0 10px; }
.msg-body summary { cursor: pointer; color: var(--text-muted); }
.msg-body pre code { background: none; padding: 0; }
.msg-body h1, .msg-body h2, .msg-body h3,
.msg-body h4, .msg-body h5, .msg-body h6 { margin: 14px 0 8px; font-size: 16px; }
.msg-body h4, .msg-body h5, .msg-body h6 { font-size: 14.5px; color: var(--text-muted); }
.msg-body a { color: var(--link); }
.msg-body strong { color: #fff; }
.msg-body blockquote { margin: 8px 0 12px; padding: 2px 0 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.msg-body blockquote p:last-child { margin-bottom: 0; }
.msg-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
/* Tables scroll inside their own box so a wide one never stretches the chat column. */
/* The table is sized to its content (never squeezed to the bubble), so the wrapper is what scrolls;
   cells opt out of the bubble's overflow-wrap:anywhere or the browser would break words instead. */
.msg-body .md-table-wrap { overflow-x: auto; max-width: 100%; margin: 8px 0 12px; -webkit-overflow-scrolling: touch; }
.msg-body table { border-collapse: collapse; width: 100%; table-layout: auto; font-size: 13px; margin: 0; }
.msg-body th, .msg-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; overflow-wrap: normal; word-break: normal; white-space: normal; min-width: 110px; }
.msg-body th { background: var(--surface-2); color: var(--text); font-weight: 650; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* per-message hover actions (copy / edit & resend) */
.msg { position: relative; }
.msg-actions { display: flex; gap: 5px; align-self: flex-end; opacity: 0; transition: opacity 0.12s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-act { width: 27px; height: 27px; flex: 0 0 27px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); display: grid; place-items: center; cursor: pointer; transition: color 0.12s, border-color 0.12s; }
.msg-act:hover { color: var(--text); border-color: var(--border-strong); }
.msg-act svg { width: 14px; height: 14px; }

.composer {
  flex: 0 0 auto;
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 9px 9px 9px 16px;
  margin-top: 10px;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--text); font-size: 14.5px; line-height: 1.5; max-height: 180px; padding: 6px 0;
}
.send-btn {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; border: none;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 700;
  display: grid; place-items: center; transition: background 0.12s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-dim); cursor: default; }
/* Stop: the same button, while a request is in flight. Muted rather than accent-coloured so
   the composer reads as "working" instead of "ready to send", and clearly still clickable. */
.send-btn.is-stop { background: var(--surface-3); color: var(--text); font-size: 13px; cursor: pointer; }
.send-btn.is-stop:hover { background: #e5484d; color: #fff; }

/* ----- chat attachments: pick / drop / paste a file into any composer ----- */
.attach-btn {
  width: 28px; height: 26px; flex: 0 0 28px; padding: 0; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--text-dim);
  display: grid; place-items: center; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.attach-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--text-dim); }
.attach-btn svg { width: 15px; height: 15px; }
.attach-tray { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-tray.hidden { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 9px;
  background: var(--accent-soft); border: 1px solid rgba(29,155,240,0.25); border-radius: 8px;
  font-size: 12px; color: var(--text-muted); max-width: 240px;
}
.attach-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip svg { width: 12px; height: 12px; flex: 0 0 12px; color: var(--accent); }
.attach-x { border: none; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.attach-x:hover { color: #e5484d; }
/* Whole composer highlights while a file is dragged over it. */
.attach-over { outline: 2px dashed var(--accent); outline-offset: 3px; border-radius: 12px; }

/* model picker + skill buttons in the composer */
.composer-rich { flex-direction: column; align-items: stretch; gap: 8px; }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer-row textarea { flex: 1; }
.composer-skills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.composer-skills.hidden { display: none; }
.skill-btn {
  font-size: 12.5px; font-weight: 600; color: var(--text-dim);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 4px 11px; cursor: pointer; transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.skill-btn:hover { color: var(--text); border-color: var(--accent); }
.skill-btn.active { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: var(--glow-accent); }

/* editor sidebar: Skill (left) + Model (right) share a top tools row above the input */
.composer-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer-model { display: flex; align-items: center; gap: 6px; margin-left: auto; }
/* Effort picker: sits directly after the skill + prompt pickers. No margin-left:auto,
   so .composer-model stays pinned to the right edge and this stays on the left. */
.composer-effort { display: flex; align-items: center; gap: 6px; }
/* skills collapse into one dropdown; widen past the .mini cap so labels fit, and accent the trigger when a skill is armed */
.model-select.mini.skill-select { max-width: 150px; }
.composer-skills.skill-armed .dd-trigger { color: var(--text); border-color: var(--accent); }

.model-select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--surface-3); color: var(--text-muted);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b929b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 12.5px; font-weight: 600; padding: 8px 26px 8px 10px; cursor: pointer;
  max-width: 132px;
}
.model-select:hover { color: var(--text); border-color: var(--accent); }
.model-select:focus { outline: none; border-color: var(--accent); }
.model-select.mini { font-size: 11.5px; padding: 6px 22px 6px 8px; max-width: 108px; }
/* Native option popup inherits the select's dark bg by default — force readable contrast. */
.model-select option { background: var(--surface-2); color: var(--text); }

/* ---- branded dropdown (custom menu over a hidden native <select>) ---- */
.dd { position: relative; display: inline-flex; }
.dd-native { position: absolute; width: 0; height: 0; padding: 0; margin: 0; border: 0; opacity: 0; pointer-events: none; }
/* trigger copies .model-select/.content-select for its closed look; just fix button defaults */
.dd-trigger { font-family: var(--sans); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-menu {
  position: fixed; z-index: 250; min-width: 132px; max-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--glass-shadow, 0 18px 40px -22px rgba(0,0,0,0.85)), var(--glass-hi);
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
  animation: dd-in 0.12s ease;
}
.dd-menu.hidden { display: none; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dd-opt {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; white-space: nowrap;
  background: transparent; border: none; cursor: pointer; color: var(--text);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600; padding: 8px 11px; border-radius: 8px;
  transition: background 0.1s, color 0.1s;
}
.dd-opt:hover, .dd-opt:focus { background: var(--accent-soft); color: var(--text); outline: none; }
.dd-opt.is-selected { color: var(--accent); }
.dd-opt::before {
  content: ''; flex: none; width: 13px; height: 13px; background-repeat: no-repeat; background-position: center; background-size: 12px;
}
.dd-opt.is-selected::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 14 14'%3E%3Cpath d='M3 7.5l3 3 5-6' fill='none' stroke='%231d9bf0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.err-bubble { color: #ff8585; background: rgba(255,90,90,0.08); border: 1px solid rgba(255,90,90,0.25); padding: 10px 14px; border-radius: 10px; font-size: 13.5px; max-width: 820px; }
.err-retry { margin-left: 10px; background: none; border: 1px solid rgba(255,90,90,0.4); color: #ffb0b0; font-size: 12px; font-weight: 650; padding: 2px 10px; border-radius: 6px; cursor: pointer; font-family: var(--sans); }
.err-retry:hover { background: rgba(255,90,90,0.14); color: #fff; }

/* ===================== Tasks ===================== */
.tasks-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.seg-btn { background: transparent; border: none; color: var(--text-muted); padding: 7px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600; }
.seg-btn.active { background: var(--accent); color: #fff; }
.muted-note { font-size: 12.5px; color: var(--text-dim); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 2px 4px; }
.col-title { font-size: 13px; font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.col-count { font-size: 12px; color: var(--text-dim); background: var(--surface-2); border-radius: 20px; padding: 1px 8px; }
.tcard {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 9px;
}
.tcard-title { font-size: 13.5px; line-height: 1.4; margin-bottom: 9px; }
.tcard-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tcard-date { font-size: 11.5px; color: var(--text-dim); }

/* Calendar */
.calendar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h3 { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 11px; color: var(--text-dim); text-align: center; padding: 4px 0 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.cal-cell { min-height: 128px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 6px; }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-num { font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.today .cal-num { color: var(--accent); font-weight: 700; }
.cal-pill { font-size: 10.5px; line-height: 1.25; padding: 3px 6px; border-radius: 6px; margin-bottom: 4px; background: var(--surface-3); border-left: 3px solid var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Wiki (concept map) ===================== */
.wiki-layout { display: grid; grid-template-columns: 1fr 0; gap: 18px; height: calc(100vh - 52px - var(--chrome-top)); transition: grid-template-columns 0.22s ease; }
.wiki-layout.chat-open { grid-template-columns: minmax(0, 1fr) var(--wiki-chat-w, 440px); }
.wiki-layout.resizing { transition: none; }

.wiki-map-area { display: grid; grid-template-rows: auto 1fr; grid-template-columns: 1fr 0; column-gap: 16px; min-width: 0; min-height: 0; transition: grid-template-columns 0.22s ease; }
.wiki-map-area.node-selected { grid-template-columns: 1fr 340px; }

.wiki-mapbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.wiki-mapbar-title h2 { font-size: 20px; font-weight: 650; line-height: 1.15; }
.wiki-mapbar-title h2 .accent { color: var(--accent); }
.wiki-mapbar-title p { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 0; max-width: 520px; line-height: 1.4; }
.wiki-search { margin-left: auto; width: 240px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; color: var(--text); font-size: 13px; font-family: var(--sans); outline: none; transition: border-color 0.12s; }
.wiki-search:focus { border-color: var(--accent); }
.wiki-search::placeholder { color: var(--text-dim); }
.wiki-chat-toggle { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.12s; }
.wiki-chat-toggle:hover { border-color: var(--accent); color: var(--text); }
.wiki-chat-toggle svg { width: 16px; height: 16px; }
.wiki-layout.chat-open .wiki-chat-toggle#wiki-chat-toggle { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* "Connections" map toggle — lit when edges are shown */
.wiki-chat-toggle.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.wiki-canvas { grid-row: 2; grid-column: 1; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 24px; overflow: auto; box-shadow: var(--glass-shadow); }
.wiki-edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 0; }
.wiki-bands { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 26px; }
.wiki-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-dim); font-size: 13px; z-index: 2; }

.wiki-band-label { display: flex; align-items: center; gap: 9px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); margin-bottom: 12px; }
.wiki-band-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.wiki-band-desc { color: var(--text-dim); text-transform: none; letter-spacing: 0; font-size: 11px; opacity: 0.8; }
.wiki-band-nodes { display: flex; flex-wrap: wrap; gap: 10px; }

.wiki-node { position: relative; z-index: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 15px; color: var(--text-muted); font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap; transition: border-color 0.12s, color 0.12s, background 0.12s, opacity 0.18s, transform 0.08s; }
.wiki-node:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.wiki-node.is-selected { background: var(--grad-accent); border-color: transparent; color: #fff; box-shadow: var(--glow-accent); }
.wiki-node.is-neighbor { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.wiki-node.is-dim { opacity: 0.32; }
.wiki-node.search-hide { opacity: 0.14; }

/* Node detail panel */
.wiki-detail { grid-row: 2; grid-column: 2; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; overflow-y: auto; box-shadow: var(--glass-shadow); display: none; flex-direction: column; min-width: 0; }
.wiki-map-area.node-selected .wiki-detail { display: flex; }
.wiki-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.wiki-detail-badge { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.wiki-detail-close { background: none; border: none; color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.wiki-detail-close:hover { color: var(--text); }
.wiki-detail-title { font-size: 19px; font-weight: 650; line-height: 1.2; margin-bottom: 12px; }
.wiki-detail-body { font-size: 13px; line-height: 1.55; color: var(--text-muted); }
.wiki-detail-body p { margin: 0 0 10px; }
.wiki-detail-body code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.wiki-detail-body h2 { font-size: 14px; font-weight: 650; color: var(--text); margin: 18px 0 8px; }
.wiki-detail-body h3 { font-size: 13px; font-weight: 650; color: var(--text); margin: 14px 0 6px; }
.wiki-detail-body ul, .wiki-detail-body ol { margin: 0 0 10px; padding-left: 20px; }
.wiki-detail-body li { margin: 0 0 5px; }
.wiki-detail-body strong { color: var(--text); font-weight: 650; }
/* Collapsible deep-dive toggles (multi-step framework pages) */
.wiki-detail-body details { margin: 12px 0 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.wiki-detail-body details[open] { border-color: var(--border-strong); }
.wiki-detail-body summary { cursor: pointer; list-style: none; padding: 11px 14px; font-size: 12.5px; font-weight: 650; color: var(--accent); display: flex; align-items: center; gap: 8px; user-select: none; }
.wiki-detail-body summary::-webkit-details-marker { display: none; }
.wiki-detail-body summary::before { content: "\25B8"; font-size: 11px; color: var(--text-dim); transition: transform 0.15s; }
.wiki-detail-body details[open] summary::before { transform: rotate(90deg); }
.wiki-detail-body summary:hover { color: var(--accent-hover); }
.wiki-detail-body details > :not(summary) { margin-left: 14px; margin-right: 14px; }
.wiki-detail-body details summary + * { margin-top: 4px; }
.wiki-detail-body details > :last-child { margin-bottom: 12px; }
.wiki-detail-conns { margin-top: 16px; }
.wiki-conn-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 14px 0 8px; }
.wiki-conn-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.wiki-conn-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; color: var(--text-muted); font-size: 12px; cursor: pointer; transition: all 0.12s; }
.wiki-conn-chip:hover { border-color: var(--accent); color: var(--text); }
/* Two ways into a node's files: the untouched original (primary — what the user pasted)
   and the wiki page's own .md (the distilled summary). Concepts/entities have no original. */
.wiki-detail-links { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.wiki-detail-source { font-size: 12px; color: var(--accent); font-weight: 600; text-decoration: none; }
.wiki-detail-source:hover { text-decoration: underline; }
.wiki-detail-pagefile { font-size: 11.5px; color: var(--text-muted); text-decoration: none; }
.wiki-detail-pagefile:hover { color: var(--text); text-decoration: underline; }

/* Chat sidebar */
.wiki-chat-sidebar { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; overflow: hidden; box-shadow: var(--glass-shadow); }
.wiki-layout:not(.chat-open) .wiki-chat-sidebar { display: none; }
.wiki-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.wiki-chat-head-label { font-size: 13px; font-weight: 650; }
/* breathing room around the wiki conversation so it isn't compressed against the edges */
.wiki-chat-sidebar .chat-stream { padding: 18px 18px 16px; gap: 16px; }
.wiki-chat-sidebar .composer { margin: 0 16px 16px; }

.drawer { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: grid; place-items: center; z-index: 50; padding: 30px; }
.drawer-panel { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); width: min(760px, 100%); max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 13px; color: var(--text-muted); }
.drawer-head #drawer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.drawer-meta { font-size: 11px; color: var(--text-muted); opacity: 0.8; }
.drawer-close { background: none; border: none; color: var(--text-muted); font-size: 22px; line-height: 1; }
.drawer-body { margin: 0; padding: 18px; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--text); white-space: pre-wrap; }

/* Scripts board (kanban) */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.board-col { flex: 1 1 0; min-width: 178px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; max-height: 70vh; transition: background 0.12s, border-color 0.12s; }
.board-col.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.board-col.collapsed { flex: 0 0 auto; min-width: 0; width: 44px; align-items: center; }
.board-col-head { display: flex; align-items: center; gap: 7px; padding: 4px 6px 9px; cursor: pointer; user-select: none; width: 100%; }
.board-col-toggle { background: none; border: none; color: var(--text-muted); font-size: 11px; padding: 0; width: 14px; flex: 0 0 auto; }
.board-col-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.board-col-name { font-size: 12px; font-weight: 650; text-transform: capitalize; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-col-count { margin-left: auto; font-size: 11px; color: var(--text-dim); background: var(--surface-3); border-radius: 10px; padding: 1px 7px; flex: 0 0 auto; }
.board-col.collapsed .board-col-head { flex-direction: column; gap: 8px; padding: 4px 0; }
.board-col.collapsed .board-col-name { writing-mode: vertical-rl; max-height: 130px; }
.board-col.collapsed .board-col-count { margin: 0; }
.board-col-body { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; min-height: 22px; width: 100%; }
.board-col.collapsed .board-col-body { display: none; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; cursor: pointer; }
.board-card:hover { border-color: var(--border-strong); }
.board-card.dragging { opacity: 0.45; }
.board-card-title { font-size: 13px; font-weight: 600; line-height: 1.32; margin-bottom: 6px; }
.board-card-client { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; }
.board-card-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.board-card-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }

/* Avatars (channel profile picture with letter fallback) */
.av { position: relative; overflow: hidden; display: grid; place-items: center; }
.av .av-letter { line-height: 1; }
.av .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.board-card-av { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), #0a6bb0); color: #fff; font-weight: 700; font-size: 10px; flex: 0 0 auto; }
.content-head-av { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #0a6bb0); color: #fff; font-weight: 800; font-size: 13px; flex: 0 0 auto; }

.hidden { display: none !important; }

@media (max-width: 920px) {
  /* Always a rail at this width, so the toggle is a no-op — hide it. */
  .app, .app.sidebar-rail { grid-template-columns: var(--rail-w) 1fr; }
  #brand-toggle, #brand-toggle:hover { cursor: default; transform: none; filter: none; }
  .sidebar { padding: 20px 8px; }
  .brand { flex-direction: column; gap: 8px; padding: 6px 0 18px; }
  /* Child combinator, not descendant: avatarHtml() nests a .av-letter fallback
     inside the row, and its <img> self-removes on 404 — a descendant selector
     would hide the letter and leave a blank square. */
  .brand-text, .brand-sub, .client-switch-label, .client-item-name,
  .nav-item > span:last-child, .add-client-btn > span:last-child { display: none; }
  .nav-item, .add-client-btn { justify-content: center; gap: 0; padding: 11px 0; }
  .client-item-av { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; font-size: 12px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-cols { grid-template-columns: 1fr; }
  .wiki-layout, .wiki-layout.chat-open { grid-template-columns: 1fr; }
  .wiki-map-area, .wiki-map-area.node-selected { grid-template-columns: 1fr; }
  .wiki-detail, .wiki-chat-sidebar { position: absolute; top: calc(26px + var(--chrome-top)); right: 0; bottom: 0; width: min(360px, 92vw); z-index: 40; }
  .wiki-mapbar-title p { display: none; }
  .wiki-search { width: 150px; }
  .create-grid { grid-template-columns: 1fr; }
  .chan-videos { grid-template-columns: 1fr; }
}

/* ===================== Create Content ===================== */
.create-intro { margin: 4px 2px 18px; }
.create-intro h2 { font-size: 21px; margin-bottom: 6px; }
.create-intro p { font-size: 14px; color: var(--text-muted); margin: 0; max-width: 620px; line-height: 1.5; }

.create-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.create-card {
  display: flex; align-items: flex-start; gap: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 18px;
  transition: border-color 0.12s, transform 0.08s, background 0.12s;
}
.create-card:hover { border-color: var(--accent); background: var(--surface-2); transform: translateY(-1px); }
.create-ico {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 19px; color: #fff;
}
.create-card-body { flex: 1; }
.create-card-title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.create-card-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.create-card-go { font-size: 12px; color: var(--accent); margin-top: 9px; font-weight: 600; }

/* Channel snapshot card */
.chan-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.chan-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.chan-card-title { font-size: 15px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-card-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: 0 0 auto; }
.chan-src { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.chan-refresh:disabled { opacity: 0.6; cursor: default; }
.chan-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 0; }
.chan-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.chan-stat-val { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.chan-stat-lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.chan-visit { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; color: var(--text); font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: border-color 0.15s ease, background 0.15s ease; }
.chan-visit:hover { border-color: var(--border-strong); background: var(--surface-3); }

/* =======================================================================
   MODERN THEME v2 — glassmorphism + blue gradient depth.
   Override layer (loads last). Keeps the original dark + blue palette,
   adds translucent glass surfaces, gradient accents, glow, softer radii.
   Design philosophy borrowed from blue fintech / SaaS dashboards.
   ======================================================================= */
:root {
  --bg: #070a11;
  --surface: rgba(21, 27, 39, 0.72);
  --surface-2: rgba(32, 40, 56, 0.58);
  --surface-3: rgba(46, 56, 78, 0.55);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #1d9bf0;
  --accent-hover: #38aaff;
  --accent-soft: rgba(29, 155, 240, 0.14);
  --link: #8b929b;
  --link-hover: #e7e9ea;
  --link-underline: rgba(139, 146, 155, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --grad-accent: linear-gradient(135deg, #38aaff 0%, #1574d8 100%);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.85);
  --glow-accent: 0 10px 26px -10px rgba(29, 155, 240, 0.65);
}

/* Blue-tinted gradient backdrop with soft light blooms */
html, body { background: #070a11; }
body {
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(29, 120, 240, 0.20), transparent 60%),
    radial-gradient(1000px 700px at 102% 2%, rgba(29, 170, 255, 0.12), transparent 55%),
    radial-gradient(900px 650px at 50% 118%, rgba(48, 84, 210, 0.16), transparent 60%),
    #070a11;
  background-attachment: fixed;
}

/* Glass surfaces */
.sidebar, .client-bar {
  background: linear-gradient(180deg, rgba(20, 26, 40, 0.82), rgba(12, 16, 26, 0.82));
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}
.sidebar { border-right: 1px solid var(--border); box-shadow: var(--glass-hi); }

.card, .metric, .col, .calendar, .wiki-sources, .chan-card,
.create-card, .composer, .modal-panel, .drawer-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)),
              rgba(18, 24, 37, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: var(--glass-hi), var(--glass-shadow);
}
.metric { transition: transform 0.14s ease, border-color 0.14s ease; }
.metric:hover { transform: translateY(-2px); border-color: var(--border-strong); }

/* Hero numbers get a subtle light gradient */
.metric-value, .chan-stat-val {
  background: linear-gradient(180deg, #ffffff 0%, #b9d4f2 110%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Brand mark + active nav + primary actions: gradient + glow */
.brand-mark { background: var(--grad-accent); box-shadow: var(--glow-accent); }
.nav-item { border-radius: 12px; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(29, 155, 240, 0.26), rgba(29, 155, 240, 0.07));
  color: #eaf4ff;
  box-shadow: inset 0 0 0 1px rgba(29, 155, 240, 0.30), 0 8px 22px -12px rgba(29, 155, 240, 0.7);
}
.nav-item.active .nav-ico { opacity: 1; color: var(--accent); }

.btn-primary, .send-btn { background: var(--grad-accent); box-shadow: var(--glow-accent); border: none; }
.btn-primary:hover, .send-btn:hover { filter: brightness(1.08); background: var(--grad-accent); }
.seg-btn.active { background: var(--grad-accent); box-shadow: var(--glow-accent); }

/* Segmented / pill toggles + tags get the glass treatment */
.seg, .modal-input { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); }
.card-tag, .badge-status, .col-count { background: rgba(255, 255, 255, 0.05); }

/* Search-style focus + interactive chips */
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip { background: rgba(255, 255, 255, 0.04); }
.chip:hover { border-color: var(--accent); box-shadow: var(--glow-accent); }

/* Create cards: stronger lift */
.create-card:hover { box-shadow: var(--glass-hi), 0 18px 34px -16px rgba(29, 155, 240, 0.5); border-color: var(--accent); }
.create-ico { box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.8); }

/* Chart bars glow */
.bar-rect { filter: drop-shadow(0 6px 10px rgba(29, 155, 240, 0.35)); }

/* Task cards: glassy with a soft left accent */
.tcard { background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border); }
.tcard:hover { border-color: var(--border-strong); }

/* Avatar ring */
.avatar { box-shadow: 0 0 0 2px rgba(29, 155, 240, 0.25), var(--glow-accent); }

/* Refined scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.10); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* =======================================================================
   v3 — brand icons, briefed-task picker, chat history, drag board, calendar fix
   ======================================================================= */

/* Crisp line icons everywhere (inherit color via currentColor) */
[data-ico] svg, .nav-ico svg, .create-ico svg, .tool-ico svg { display: block; }
.nav-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; opacity: 0.9; }
.nav-ico svg { width: 18px; height: 18px; }
.nav-item.active .nav-ico { opacity: 1; }
.chat-empty-mark svg { width: 26px; height: 26px; }

/* Create / tool icons: blue background, white icon (on-brand) */
.create-ico, .tool-ico {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px;
  display: grid; place-items: center; color: #fff;
  background: var(--grad-accent, var(--accent));
  box-shadow: 0 8px 20px -10px rgba(29, 155, 240, 0.7);
}
.create-ico svg, .tool-ico svg { width: 22px; height: 22px; }

.create-section-head { margin: 28px 2px 12px; }
.create-section-head h3 { font-size: 15px; color: var(--text-muted); }
.create-card-count { margin-left: auto; font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 20px; font-weight: 650; white-space: nowrap; }
.create-card-batch { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; margin-left: 8px; }

/* Briefed-task picker drawer */
.writer-panel { width: min(560px, 100%); max-height: 82vh; display: flex; flex-direction: column; }
.writer-body { padding: 16px 18px; overflow-y: auto; }
.writer-intro { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.writer-blank { width: 100%; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-muted); border-radius: 11px; padding: 12px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.writer-blank:hover { color: var(--text); border-color: var(--accent); }
.brief-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 4px 2px 8px; }
.brief-item { display: block; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 12px 13px; margin-bottom: 10px; transition: border-color 0.12s, transform 0.08s; }
.brief-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.brief-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.brief-title { font-size: 13.5px; font-weight: 650; color: var(--text); flex: 1; }
.brief-snippet { font-size: 12px; color: var(--text-muted); line-height: 1.45; white-space: pre-wrap; max-height: 60px; overflow: hidden; }
.brief-go { font-size: 11.5px; color: var(--accent); font-weight: 600; margin-top: 8px; }
.brief-empty { font-size: 12.5px; color: var(--text-dim); padding: 6px 2px 12px; line-height: 1.5; }

/* Chat header bar: new chat + history */
.chat-bar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 2px 10px; border-bottom: 1px solid var(--border); }
.chat-bar-left, .chat-bar-right { display: flex; align-items: center; gap: 10px; }
.chat-bar-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); padding: 6px 11px; border-radius: 9px; font-size: 13px; font-weight: 600; }
.chat-bar-btn:hover { color: var(--text); border-color: var(--border-strong); }
.chat-bar-btn.icon-only { padding: 7px; }
.chat-bar-btn svg { width: 15px; height: 15px; }
.chat-mode-tag { font-size: 11.5px; color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.chat-mode-tag:empty { display: none; }
.chat-title { font-size: 12.5px; color: var(--text-dim); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: 320px; max-height: 360px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px; box-shadow: var(--glass-shadow, 0 18px 40px -22px rgba(0,0,0,0.85)); }
.chat-hist-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text-muted); padding: 9px 10px; border-radius: 8px; font-size: 13px; }
.chat-hist-item:hover { background: var(--surface-2); color: var(--text); }
.chat-hist-item .ch-meta { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.chat-hist-empty { padding: 16px; font-size: 12.5px; color: var(--text-dim); text-align: center; }

/* In-chat action buttons (Save to ClickUp, etc.) */
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.chat-action-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); padding: 7px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; }
.chat-action-btn:hover { color: var(--text); border-color: var(--accent); }
.chat-action-btn svg { width: 14px; height: 14px; }
.chat-action-btn.done { color: var(--good); border-color: rgba(24,182,99,0.4); }

/* Drag-and-drop board */
.tcard { cursor: grab; }
.tcard:active { cursor: grabbing; }
.tcard.dragging { opacity: 0.45; }
.col.drop-target { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 18px; border-radius: 11px; font-size: 13px; z-index: 200; box-shadow: var(--glass-shadow, 0 18px 40px -22px rgba(0,0,0,0.85)); max-width: 80vw; }
.toast.err { border-color: rgba(255,90,90,0.4); color: #ffb4b4; }

/* Modal (Add context, etc.) + buttons */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: grid; place-items: center; z-index: 60; padding: 30px; }
.modal-panel { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); width: min(440px, 100%); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 650; }
.modal-body { padding: 18px; max-height: 78vh; overflow-y: auto; }
.modal-label { display: block; font-size: 13px; color: var(--text-muted); margin: 12px 0 7px; }
.modal-label:first-child { margin-top: 0; }
.modal-input { width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text); padding: 11px 13px; font-size: 14px; font-family: var(--sans); }
.modal-input:focus { outline: none; border-color: var(--accent); }
select.modal-input { cursor: pointer; }
.modal-note { font-size: 12px; color: var(--text-dim); margin: 12px 0 16px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; }
.btn-ghost:hover { color: var(--text); }
.btn-primary { background: var(--grad-accent, var(--accent)); box-shadow: var(--glow-accent); border: none; color: #fff; padding: 9px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 650; }
.btn-primary:hover { filter: brightness(1.08); }
.ctx-panel { width: min(560px, 100%); }
.ctx-textarea { font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; min-height: 120px; }
.ctx-file { padding: 9px 11px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; }
.ctx-file::file-selector-button { background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; margin-right: 12px; cursor: pointer; }
.ctx-file::file-selector-button:hover { border-color: var(--accent); }
.drawer-orig { color: var(--accent); font-size: 12.5px; text-decoration: none; }
.drawer-orig:hover { text-decoration: underline; }
.ctx-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.ctx-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; font-size: 12.5px; color: var(--text-muted); }
.ctx-chip b { color: var(--text); font-weight: 650; }
.ctx-empty { font-size: 13px; color: var(--text-dim); }

/* Outlier ideas (Overview) */
.ideas-head-right { display: flex; align-items: center; gap: 10px; }
.btn-sm { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 9px; font-size: 12.5px; font-weight: 650; color: #fff; }
.btn-sm svg { width: 14px; height: 14px; }
.ideas-list { display: flex; flex-direction: column; gap: 10px; }
.ideas-empty { font-size: 13px; color: var(--text-dim); padding: 6px 2px; line-height: 1.5; }
.idea-row { display: flex; gap: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; }
.idea-score { flex: 0 0 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: var(--accent-soft); border: 1px solid rgba(29,155,240,0.25); border-radius: 10px; padding: 8px 0; }
.idea-score-val { font-size: 18px; font-weight: 750; color: #eaf4ff; letter-spacing: -0.02em; }
.idea-score-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.idea-body { flex: 1; min-width: 0; }
.idea-title { font-size: 14px; font-weight: 650; line-height: 1.35; margin-bottom: 4px; }
.idea-meta { font-size: 11.5px; color: var(--text-dim); margin-bottom: 8px; }
.idea-summary { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; margin-bottom: 7px; }
.idea-angle { font-size: 12.5px; color: var(--text); line-height: 1.45; background: rgba(255,255,255,0.03); border-left: 2px solid var(--accent); padding: 7px 11px; border-radius: 0 8px 8px 0; margin-bottom: 10px; }
.idea-angle b { color: var(--accent); font-weight: 650; }
.idea-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.idea-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 6px 11px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.idea-btn:hover { color: var(--text); border-color: var(--accent); }
.idea-btn.primary { background: var(--accent-soft); color: #eaf4ff; border-color: rgba(29,155,240,0.3); }
.idea-btn svg { width: 13px; height: 13px; }

/* Chat sidebar collapse */
.chat-workspace.sidebar-collapsed { grid-template-columns: 1fr; }
.chat-workspace.sidebar-collapsed .chat-sidebar { display: none; }

/* Chat tabs (clean pills, consistent height, + button inline after the last tab) */
.chat-tabs { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.chat-tabs-btn { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); border-radius: 8px; }
.chat-tabs-btn:hover { color: var(--text); border-color: var(--border-strong); }
.chat-tabs-btn svg { width: 15px; height: 15px; }
.chat-tabs-strip { display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; overflow-x: auto; }
.chat-tabs-strip::-webkit-scrollbar { height: 0; }
.chat-tab { display: flex; align-items: center; gap: 8px; height: 32px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 6px 0 10px; font-size: 12.5px; color: var(--text-muted); max-width: 190px; cursor: pointer; flex: 0 0 auto; }
.chat-tab:hover { color: var(--text); border-color: var(--border-strong); }
.chat-tab.active { background: var(--accent-soft); border-color: rgba(29, 155, 240, 0.4); color: #eaf4ff; }
.chat-tab.dragging { opacity: 0.4; }
.chat-tab.drag-over { border-color: var(--accent); box-shadow: -2px 0 0 var(--accent); }
.chat-tab .ct-ico { flex: 0 0 14px; display: grid; place-items: center; color: var(--accent); }
.chat-tab .ct-ico svg { width: 14px; height: 14px; }
.chat-tab .ct-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tab .ct-close { background: transparent; border: none; color: var(--text-dim); font-size: 16px; line-height: 1; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 5px; }
.chat-tab .ct-close:hover { color: #ff8585; background: rgba(255,90,90,0.12); }
.chat-tab .si-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-tab-new { flex: 0 0 auto; }


/* Chat workspace: sidebar of open sessions + history, multi-session main pane */
.chat-workspace { display: grid; grid-template-columns: 240px 1fr; gap: 16px; height: calc(100vh - 52px - var(--chrome-top)); }
.chat-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-new-btn { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--grad-accent, var(--accent)); box-shadow: var(--glow-accent); color: #fff; border: none; border-radius: 10px; padding: 10px; font-size: 13.5px; font-weight: 650; margin-bottom: 12px; }
.chat-new-btn:hover { filter: brightness(1.08); }
.chat-new-btn svg { width: 16px; height: 16px; }
.chat-side-section { display: flex; flex-direction: column; min-height: 0; }
.chat-side-history { flex: 1; margin-top: 12px; }
.chat-side-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 4px 4px 6px; }
.chat-side-list { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.chat-side-history .chat-side-list { flex: 1; }
.session-item, .hist-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; color: var(--text-muted); padding: 8px 9px; border-radius: 9px; font-size: 12.5px; }
.session-item:hover, .hist-item:hover { background: var(--surface-2); color: var(--text); }
.session-item.active { background: var(--accent-soft); color: #eaf4ff; border-color: rgba(29, 155, 240, 0.3); }
.session-item .si-ico { flex: 0 0 16px; display: grid; place-items: center; color: var(--accent); }
.session-item .si-ico svg { width: 15px; height: 15px; }
.session-item .si-title, .hist-item .hi-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .si-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 6px; box-shadow: 0 0 0 3px var(--accent-soft); }
.session-close { flex: 0 0 auto; background: transparent; border: none; color: var(--text-dim); font-size: 16px; line-height: 1; padding: 0 3px; border-radius: 5px; }
.session-close:hover { color: #ff8585; }
.hist-item { flex-direction: column; align-items: flex-start; gap: 2px; }
.hist-item .hi-meta { font-size: 10.5px; color: var(--text-dim); }
.hist-empty { font-size: 12px; color: var(--text-dim); padding: 8px 4px; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; height: 100%; }
.chat-sessions { flex: 1; min-height: 0; display: flex; }
.chat-sessions .chat-stream { display: none; flex: 1; }
.chat-sessions .chat-stream.active { display: flex; }

/* ============================ Onboarding (first-run full-screen takeover) ============================ */
.onboard { position: fixed; inset: 0; z-index: 300; background: radial-gradient(1200px 700px at 50% -10%, rgba(29,155,240,0.10), transparent 60%), var(--bg); overflow-y: auto; display: flex; justify-content: center; }
.onboard-inner { width: min(640px, 100%); padding: 48px 28px 80px; }
.onboard-brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px; color: var(--text); margin-bottom: 28px; }
.onboard-brand .brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--grad-accent, var(--accent)); color: #fff; font-weight: 800; box-shadow: var(--glow-accent); }
.onboard-steps { display: flex; gap: 8px; margin-bottom: 32px; flex-wrap: wrap; }
.ob-step { font-size: 11.5px; font-weight: 650; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-dim); padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface-2); }
.ob-step.active { color: #fff; border-color: transparent; background: var(--grad-accent, var(--accent)); box-shadow: var(--glow-accent); }
.onboard-panel { display: none; animation: ob-fade 0.25s ease; }
.onboard-panel.active { display: block; }
@keyframes ob-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.onboard-panel h1 { font-size: 26px; font-weight: 760; letter-spacing: -0.02em; margin: 0 0 10px; color: var(--text); }
.onboard-lead { font-size: 14.5px; line-height: 1.6; color: var(--text-muted); margin: 0 0 24px; }
.ob-hint { color: var(--text-dim); font-weight: 400; font-size: 11.5px; text-transform: none; letter-spacing: 0; }
.onboard-panel .modal-input { margin-bottom: 4px; }
.onboard-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; }
.onboard-actions .btn-primary { padding: 11px 22px; font-size: 14px; }
.onboard-actions .btn-ghost { padding: 11px 20px; font-size: 14px; }
.ob-add-actions { justify-content: flex-start; margin-top: 14px; }
.ob-added { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.ob-added-empty { font-size: 13px; color: var(--text-dim); line-height: 1.5; padding: 4px 2px; }
.ob-added-item { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 10px 13px; }
.ob-added-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--accent); flex: 0 0 auto; }
.ob-added-title { font-size: 13px; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-added-state { font-size: 11.5px; font-weight: 650; flex: 0 0 auto; }
.ob-added-state.ok { color: var(--good); }
.ob-added-state.err { color: #ff8c8c; }
.ob-added-state.pending { color: var(--warn); }
.ob-spinner { width: 34px; height: 34px; margin: 26px 0; border: 3px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: ob-spin 0.8s linear infinite; }
@keyframes ob-spin { to { transform: rotate(360deg); } }
.onboard-panel[data-panel="3"] .onboard-actions { justify-content: flex-start; }

/* Branded content-type picker (replaces the native dropdown) */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 4px; }
.type-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 13px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; font-weight: 600; text-align: center; transition: border-color .15s, color .15s, background .15s, transform .1s; }
.type-btn:hover { color: var(--text); border-color: var(--border-strong); }
.type-btn .type-ico { width: 22px; height: 22px; display: grid; place-items: center; color: currentColor; }
.type-btn .type-ico svg { width: 22px; height: 22px; }
.type-btn .type-lbl { line-height: 1.15; }
.type-btn.active { color: #fff; border-color: transparent; background: var(--grad-accent, var(--accent)); box-shadow: var(--glow-accent); }
.ctx-url-area { font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; min-height: 42px; white-space: pre; overflow-x: auto; }

/* Transcript attached to a chat message */
.msg-attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 10px; background: var(--accent-soft); border: 1px solid rgba(29,155,240,0.25); border-radius: 8px; font-size: 12px; color: var(--text-muted); }
.msg-attach svg { width: 12px; height: 12px; color: var(--accent); }

/* Calendar overflow fix: equal-height rows, clipped cells, capped pills */
.cal-grid { grid-auto-rows: 1fr; }
/* Tall enough for 4 pills + the day number + a "+N more" line. */
.cal-cell { min-height: 128px; max-height: 184px; display: flex; flex-direction: column; overflow: hidden; }
.cal-cell-pills { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.cal-more { font-size: 10px; color: var(--text-dim); margin-top: auto; padding-top: 2px; }
.cal-pill { margin-bottom: 0; flex: 0 0 auto; }

/* ===================== Search box (tasks + publish toolbars) ===================== */
.search-box { position: relative; display: inline-flex; align-items: center; flex: 1; max-width: 360px; margin: 0 14px; }
.search-ico { position: absolute; left: 11px; display: grid; place-items: center; color: var(--text-dim); pointer-events: none; }
.search-ico svg { width: 15px; height: 15px; }
.search-input { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); padding: 9px 12px 9px 34px; font-size: 13px; }
.search-input:focus { outline: none; border-color: var(--accent); }

/* ===================== Collapsible board columns ===================== */
.col-head { cursor: pointer; user-select: none; gap: 7px; }
.col-caret { display: grid; place-items: center; color: var(--text-dim); transition: transform 0.15s; }
.col-caret svg { width: 15px; height: 15px; }
.col.collapsed .col-caret { transform: rotate(-90deg); }
.col-title { flex: 1; }
.col-body { display: flex; flex-direction: column; gap: 10px; }
.col.collapsed .col-body { display: none; }

/* draggable calendar pills */
.cal-pill { cursor: grab; }
.cal-pill.dragging { opacity: 0.5; }
.cal-cell.cal-drop { border-color: var(--accent); background: var(--accent-soft); }

/* ===================== Content editor drawer ===================== */
/* The panel is a query container so the header responds to the EDITOR's width, not the
   viewport's — that's what keeps it tidy in a small popped-out browser window. */
.content-panel { width: min(820px, 100%); max-height: 88vh; container-type: inline-size; container-name: edpanel; }
.content-head { gap: 10px; }
/* Script-editor header = 3 columns: [icons] [title] [actions]. The title owns the middle
   column, so it ellipses inside its own reserved space instead of colliding with either
   side. (The note drawer reuses .content-head and keeps the simpler flex row.) */
#content-drawer .content-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.content-head-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.content-title { font-family: var(--mono); font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; cursor: text; }
.content-head-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; justify-self: end; }
.content-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 12.5px; text-decoration: none; }
.content-link:hover { text-decoration: underline; }
.content-link svg { width: 14px; height: 14px; }
.content-toolbar { display: flex; align-items: center; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ed-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); height: 30px; min-width: 30px; padding: 0 9px; border-radius: 8px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.ed-btn:hover { color: var(--text); border-color: var(--border-strong); }
.ed-btn svg { width: 15px; height: 15px; }
.brief-toggle { font-weight: 700; }
.brief-toggle.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ed-bold { font-weight: 800; }
.ed-italic { font-style: italic; }
.ed-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.ed-spacer { flex: 1; }
.content-status { font-size: 12px; color: var(--text-dim); }
.content-editor { padding: 18px 22px; overflow-y: auto; flex: 1; min-height: 240px; font-size: 14.5px; line-height: 1.65; color: var(--text); outline: none; }
.content-editor:focus { outline: none; }
.content-editor h1 { font-size: 24px; margin: 14px 0 8px; }
.content-editor h2 { font-size: 20px; margin: 14px 0 7px; }
.content-editor h3 { font-size: 16.5px; margin: 12px 0 6px; }
.content-editor p { margin: 0 0 10px; }
.content-editor ul, .content-editor ol { margin: 0 0 10px; padding-left: 22px; }
.content-editor li { margin: 3px 0; }
.content-editor img, .nb-editor img { max-width: 100%; border-radius: 8px; margin: 8px 0; display: block; cursor: zoom-in; }
/* Tables in the editors: a real <table>, one block, saved as a GFM pipe table. Cells hold inline content. */
.content-editor table, .nb-editor table { width: 100%; table-layout: auto; border-collapse: collapse; margin: 8px 0 14px; font-size: 0.95em; }
.content-editor th, .content-editor td, .nb-editor th, .nb-editor td { border: 1px solid var(--border); padding: 6px 10px; vertical-align: top; text-align: left; min-width: 80px; overflow-wrap: anywhere; }
.content-editor th, .nb-editor th { background: var(--surface-2); font-weight: 650; }
.content-editor td:focus-within, .content-editor th:focus-within, .nb-editor td:focus-within, .nb-editor th:focus-within { outline: 1px solid var(--accent); outline-offset: -1px; }
.content-editor td img, .content-editor th img, .nb-editor td img, .nb-editor th img { display: inline-block; max-height: 120px; width: auto; max-width: 100%; margin: 2px 0; vertical-align: middle; }
.content-editor img:hover, .nb-editor img:hover { outline: 2px solid var(--accent); outline-offset: 2px; }
.content-editor strong { font-weight: 700; }
.ed-loading { color: var(--text-dim); }
.content-actions { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); }
.content-actions-left { display: flex; gap: 10px; }
.content-actions-right { display: flex; gap: 10px; }

/* ----- editor body row: [reference pane | script | AI sidebar], each toggleable ----- */
.content-body-row { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* ----- AI assistant sidebar inside the editor ----- */
.editor-chat-toggle { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 6px 11px; color: var(--text-muted); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all 0.12s; }
.editor-chat-toggle:hover { border-color: var(--accent); color: var(--text); }
.editor-chat-toggle svg { width: 15px; height: 15px; }
#content-drawer.chat-open #editor-chat-toggle { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.editor-chat-toggle.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.editor-chat-sidebar { width: var(--editor-chat-w, 360px); flex: 0 0 var(--editor-chat-w, 360px); border-left: 1px solid var(--border); background: var(--surface); display: none; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
#content-drawer.chat-open .editor-chat-sidebar { display: flex; }
/* draggable seam between the editor and the AI chat (shown only when chat is open) */
.editor-chat-divider { display: none; flex: 0 0 6px; cursor: col-resize; background: var(--border); transition: background .12s; }
#content-drawer.chat-open .editor-chat-divider { display: block; }
.editor-chat-divider:hover, .editor-chat-divider.dragging { background: var(--accent); }
.editor-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.editor-chat-head-label { font-size: 13px; font-weight: 650; color: var(--text); }
.editor-chat-head-sub { font-weight: 500; color: var(--text-dim); font-size: 11.5px; margin-left: 4px; }
.editor-chat-sidebar .chat-stream { padding: 16px; gap: 16px; flex: 1; overflow-y: auto; min-height: 0; }
.editor-chat-sidebar .composer { margin: 0 14px 14px; }
.editor-chat-sidebar .msg { max-width: 100%; }
/* widen the panel when the assistant is open so the editor stays usable (popup only;
   in side-pane mode the panel width is the draggable --content-pane-w). */
#content-drawer.mode-popup.chat-open .content-panel { width: min(1180px, 100%); }

.content-main { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; min-width: 0; overflow: hidden; }
.content-main .content-editor { flex: 1; }

/* ----- editor: reference-doc toggles (open Outline/Brief/Research in the left pane) ----- */
.content-tabs { display: flex; align-items: center; gap: 2px; padding: 8px 14px 0; flex: 0 0 auto; }
.content-tabs-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); margin-right: 6px; }
.content-tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 12.5px; font-weight: 650; padding: 6px 12px 8px; cursor: pointer; }
.content-tab:hover { color: var(--text); }
.content-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.content-outline:empty::before { content: attr(data-placeholder); color: var(--text-dim); pointer-events: none; }

/* ----- editor: left reference pane (outline / brief / research beside the script) ----- */
.content-ref-pane { display: none; flex-direction: column; width: var(--editor-ref-w, 300px); flex: 0 0 var(--editor-ref-w, 300px); border-right: 1px solid var(--border); background: var(--surface-2); min-height: 0; min-width: 0; overflow: hidden; }
#content-drawer.ref-open .content-ref-pane { display: flex; }
.content-ref-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.content-ref-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
/* ONE scroller for the whole pane: the toggle boxes sit at the top at their natural
   height and the doc editor follows, so an expanded box is never clipped — you just
   scroll the pane down. (Capping .ref-boxes instead squeezed long notes into half
   the pane with the rest unreachable.) */
.content-ref-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.content-ref-body .content-editor { flex: 1 0 auto; min-height: 260px; }
.content-ref-divider { display: none; flex: 0 0 6px; cursor: col-resize; background: var(--border); transition: background .12s; }
#content-drawer.ref-open .content-ref-divider { display: block; }
.content-ref-divider:hover, .content-ref-divider.dragging { background: var(--accent); }

/* ----- Notion-style centered text column: cap line length, gutter the sides ----- */
.content-main .content-editor > * { max-width: 640px; margin-left: auto; margin-right: auto; }

/* ----- editor chat: Build | Edit panes + switch ----- */
.editor-chat-pane { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.editor-chat-switch { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.ecs-btn { background: none; border: none; color: var(--text-muted); font-size: 11.5px; font-weight: 650; padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.ecs-btn:hover { color: var(--text); }
.ecs-btn.active { background: var(--accent); color: #fff; }
.editor-chat-new { margin-left: auto; margin-right: 6px; background: none; border: 1px solid var(--border); color: var(--text-muted); font-size: 11.5px; font-weight: 650; padding: 4px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; font-family: var(--sans); }
.editor-chat-new:hover { color: var(--text); border-color: var(--border-strong); }

/* ----- chat history: rename + delete affordances ----- */
.hist-row { display: flex; align-items: stretch; gap: 2px; }
.hist-row .hist-item { flex: 1; width: auto; min-width: 0; }
.hist-rename, .hist-delete { display: flex; align-items: center; justify-content: center; width: 30px; flex: 0 0 auto; background: transparent; border: 1px solid transparent; border-radius: 9px; color: var(--text-dim); cursor: pointer; opacity: 0; transition: opacity 0.12s; }
.hist-row:hover .hist-rename, .hist-row:hover .hist-delete { opacity: 1; }
.hist-rename:hover { background: var(--surface-2); color: var(--text); }
.hist-delete:hover { background: rgba(229, 72, 77, 0.12); color: #e5484d; }

/* ----- destructive action button (e.g. delete script) ----- */
.btn-danger { background: transparent; border: 1px solid rgba(229, 72, 77, 0.4); color: #e5484d; font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 9px; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.btn-danger:hover { background: rgba(229, 72, 77, 0.12); border-color: #e5484d; }

/* ----- editor view-mode toggle ----- */
.content-modes { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.mode-btn { background: none; border: none; color: var(--text-muted); padding: 5px 7px; border-radius: 999px; cursor: pointer; line-height: 0; display: inline-flex; align-items: center; }
.mode-btn svg { width: 16px; height: 16px; }
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--accent); color: #fff; }

/* ----- Design-1 editor header: clickable photo (channel) + status badge, plus the new menus ----- */
.content-selects-hidden { display: none !important; }
.content-chan-btn { border: none; background: none; padding: 0; border-radius: 8px; line-height: 0; cursor: pointer; flex: 0 0 auto; }
.content-chan-btn .content-head-av { transition: box-shadow 0.12s; }
.content-chan-btn:hover .content-head-av { box-shadow: 0 0 0 2px var(--accent); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-family: var(--mono); font-size: 11px; text-transform: capitalize; padding: 4px 10px; line-height: 1.2; }
.status-badge .badge-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.status-badge .badge-car { opacity: 0.55; font-size: 9px; }
.status-badge:hover { filter: brightness(1.12); }
.ideation-toggle svg { width: 15px; height: 15px; }
#content-drawer.ref-open .ideation-toggle { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* header pick menus (status / channel) reuse .dd-menu; add swatch + avatar bits */
.head-menu .dd-opt { text-transform: capitalize; }
.pick-swatch { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.pick-av { display: inline-flex; flex: 0 0 auto; }
.pick-av .pick-av-inner { width: 18px; height: 18px; border-radius: 5px; font-size: 10px; }

/* ----- ideation pane: Brief / Outline / Research tabs live in the pane header now ----- */
/* Five tabs outgrow a narrow pane — wrap to a second row rather than clip or scroll. */
.content-ref-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
.content-ref-tabs .content-tab { padding: 4px 10px 5px; font-size: 12px; white-space: nowrap; flex: 0 0 auto; }

/* ----- Notion-style "/" block menu ----- */
.slash-menu { min-width: 232px; max-height: 320px; overflow-y: auto; }
.slash-opt { justify-content: flex-start; }
.slash-opt svg { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }
.slash-opt.hl, .slash-opt:hover { background: var(--accent-soft); }
.slash-opt.hl svg { color: var(--text); }
.slash-opt .slash-key { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-dim); }
.slash-opt::before { display: none; }

/* ----- right-click-a-highlight prompt menu (same shell as the "/" menu) ----- */
.sel-menu { min-width: 224px; max-height: 360px; overflow-y: auto; }
.sel-opt { justify-content: flex-start; }
.sel-opt svg { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }
.sel-opt:hover svg { color: var(--text); }
.sel-opt::before { display: none; }
.sel-menu-group {
  padding: 8px 11px 3px; font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
  border-top: 1px solid var(--border); margin-top: 4px;
}

/* ----- inline embed card (YouTube player / link) inside any editor doc ----- */
.embed-card {
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin: 14px auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012)), rgba(18,24,37,0.55);
  box-shadow: var(--glass-hi), var(--glass-shadow); max-width: 640px;
}
.embed-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Vertical video (Instagram reels). Height-capped so a tall reel can't push the
   caption and transcript below the fold in the detail view. */
.embed-frame-tall { aspect-ratio: 9 / 16; max-height: 70vh; width: auto; max-width: 100%; margin: 0 auto; }
.embed-meta { display: flex; align-items: center; gap: 8px; padding: 8px 11px; font-size: 11.5px; color: var(--text-muted); }
.embed-meta svg { width: 15px; height: 15px; color: #ff5c5c; }
.embed-card.link { }
.embed-card.link a { display: flex; gap: 11px; align-items: center; padding: 12px 13px; text-decoration: none; color: var(--text); }
.embed-card.link .lk-ico { width: 38px; height: 38px; border-radius: 9px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--accent); flex: 0 0 auto; }
.embed-card.link .lk-text { display: flex; flex-direction: column; min-width: 0; }
.embed-card.link .lk-title { font-size: 13px; }
.embed-card.link .lk-url { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* popup = current centered modal (default, no extra rules needed) */
/* full view = panel fills viewport (the default mode for a newly opened script) */
#content-drawer.mode-full { padding: 0; }
#content-drawer.mode-full .content-panel { width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; }

/* narrow screens: stack the reference pane + assistant instead of three columns */
@media (max-width: 720px) {
  .content-body-row { flex-direction: column; }
  .content-ref-pane { width: auto; flex: 1 1 35%; border-right: none; border-bottom: 1px solid var(--border); }
  .content-ref-divider { display: none !important; }
  .editor-chat-sidebar { width: auto; flex: 1 1 45%; border-left: none; border-top: 1px solid var(--border); }
  .editor-chat-divider { display: none; }
  .editor-chat-toggle-label { display: none; }
  .content-main .content-editor > * { max-width: none; }
}

/* ----- AI edit preview (diff overlay over the editor) ----- */
.content-main { position: relative; }
.editor-diff-panel { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: var(--surface); }
.editor-diff-panel.hidden { display: none; }
.editor-diff-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.editor-diff-title { font-size: 13px; font-weight: 650; color: var(--text); }
.editor-diff-sub { font-weight: 500; color: var(--text-dim); font-size: 11.5px; margin-left: 6px; }
.editor-diff-actions { display: flex; gap: 10px; flex: 0 0 auto; }
.editor-diff-actions .btn-ghost, .editor-diff-actions .btn-primary { padding: 7px 15px; font-size: 12.5px; border-radius: 9px; }
.editor-diff-body { flex: 1; overflow-y: auto; padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }

/* ----- Version history panel (shares the diff panel's overlay + head) -----
   Opaque base: the modern theme redefines --surface as rgba(...,0.72), so a panel
   that covers the editor would otherwise show the script text bleeding through it.
   --bg stays opaque in both themes; --surface layers on top for the right tone. */
.versions-panel { background: var(--bg); }
.versions-panel > .editor-diff-head, .versions-panel .versions-body { background: var(--surface); }
.versions-body { flex: 1; min-height: 0; display: flex; }
.versions-list { flex: 0 0 260px; min-width: 0; overflow-y: auto; border-right: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.versions-item { text-align: left; width: 100%; background: none; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 11px; cursor: pointer; color: var(--text); font-family: var(--sans); transition: background 0.12s, border-color 0.12s; }
.versions-item:hover { background: var(--surface-2); }
.versions-item.active { background: var(--surface-2); border-color: var(--accent); }
.versions-when { font-size: 12.5px; font-weight: 650; }
.versions-why { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.versions-meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); margin-top: 3px; }
.versions-empty { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; padding: 12px 4px; }
.versions-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.versions-preview-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; min-height: 44px; font-size: 12.5px; color: var(--text-muted); }
.versions-preview-head .btn-primary { padding: 6px 14px; font-size: 12.5px; border-radius: 9px; margin-left: auto; }
.versions-preview-doc { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; font-size: 14.5px; line-height: 1.7; }
.versions-preview-doc h1, .versions-preview-doc h2, .versions-preview-doc h3 { margin: 18px 0 8px; }
.versions-preview-doc p { margin: 0 0 10px; }
.versions-preview-doc ul, .versions-preview-doc ol { margin: 6px 0; padding-left: 22px; }
@media (max-width: 720px) {
  .versions-body { flex-direction: column; }
  .versions-list { flex: 0 0 auto; max-height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
}
.diff-line { display: flex; gap: 8px; padding: 1px 6px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; }
.diff-gutter { flex: 0 0 14px; text-align: center; color: var(--text-dim); user-select: none; }
.diff-text { flex: 1; min-width: 0; }
.diff-add { background: rgba(24, 182, 99, 0.14); }
.diff-add .diff-gutter, .diff-add .diff-text { color: #7fe0a8; }
.diff-del { background: rgba(255, 90, 90, 0.13); }
.diff-del .diff-gutter, .diff-del .diff-text { color: #ffb4b4; }
.diff-same { color: var(--text-muted); }

/* one-click undo toast after an apply */
.toast-action { display: flex; align-items: center; gap: 10px; }
.toast-btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12.5px; font-weight: 650; cursor: pointer; }
.toast-btn:hover { filter: brightness(1.08); }

/* ----- status-list popup (Overview metric cards) ----- */
.metric-click { cursor: pointer; }
.status-panel { width: min(640px, 100%); }
.status-head { font-family: inherit; }
.status-modal-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; color: var(--text); }
.status-modal-title .col-count { background: var(--surface-2); border-radius: 20px; padding: 1px 9px; font-size: 12px; color: var(--text-muted); }
.status-list { padding: 8px; overflow-y: auto; max-height: 70vh; }
.status-empty { padding: 28px 16px; text-align: center; color: var(--text-dim); font-size: 13px; }
.status-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.status-row:hover { background: var(--surface-2); }
.status-row-title { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-row-date { font-size: 12px; color: var(--text-dim); }
.status-row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.12s ease; }
.status-row:hover .status-row-actions, .recent-item:hover .status-row-actions { opacity: 1; }
.row-act { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.row-act:hover { color: var(--text); border-color: var(--border-strong); }
.row-act svg { width: 15px; height: 15px; }

/* ----- recent activity: clickable ----- */
.recent-item { cursor: pointer; border-radius: 8px; }
.recent-item:hover { background: var(--surface-2); }

/* ----- output chart time-range select ----- */
.output-range { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 600; border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.output-range:hover { color: var(--text); border-color: var(--border-strong); }

/* ===================== Publish view ===================== */
.publish-intro h2 { font-size: 18px; margin: 0 0 3px; }
.publish-intro p { font-size: 13px; color: var(--text-muted); margin: 0; }
.publish-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.publish-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 9px; }
.publish-card-head { display: flex; align-items: center; gap: 9px; }
.publish-card-title { flex: 1; font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.publish-card-meta { font-size: 12px; color: var(--text-dim); }
.publish-card-body { font-size: 13px; line-height: 1.55; color: var(--text-muted); max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; background: var(--surface-2); }
.publish-card-body h1, .publish-card-body h2, .publish-card-body h3 { font-size: 14px; margin: 8px 0 4px; color: var(--text); }
.publish-card-body ul, .publish-card-body ol { padding-left: 20px; margin: 6px 0; }
.publish-card-body img { max-width: 100%; border-radius: 6px; margin: 6px 0; }
.publish-card-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: auto; }
.publish-card-actions .btn-ghost { padding: 7px 13px; border-radius: 9px; font-size: 12.5px; }
.publish-empty { grid-column: 1 / -1; font-size: 13px; color: var(--text-dim); padding: 20px 2px; line-height: 1.5; }

/* ===================== BrandOS: multi-client ===================== */
/* logo on the blue brand mark */
.brand-mark { overflow: hidden; position: relative; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 6px; position: relative; z-index: 2; }
.brand-fallback { display: none; position: absolute; inset: 0; place-items: center; font-weight: 800; font-size: 19px; color: #fff; z-index: 1; }

/* sidebar client switcher */
.nav-home { width: 100%; margin-bottom: 6px; }
.client-switch-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); padding: 6px 12px 6px; margin-top: 6px; }
.client-list { gap: 2px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.client-item { width: 100%; }
.client-item-av { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); color: var(--text-muted); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: 0 0 22px; }
.client-item.active .client-item-av { background: var(--accent); color: #fff; }
.client-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-empty { font-size: 12px; color: var(--text-dim); padding: 8px 12px; }

/* Archived clients: a collapsed group at the foot of the sidebar list. */
.archive-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 8px; padding: 8px 12px;
  background: transparent; border: none; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; text-align: left;
}
.archive-head:hover { color: var(--text-muted); }
.archive-caret { display: inline-block; transition: transform 0.14s ease; font-size: 9px; }
.archive-head.open .archive-caret { transform: rotate(90deg); }
.archive-count { margin-left: auto; font-size: 10.5px; color: var(--text-dim); }
.archive-body { display: flex; flex-direction: column; gap: 2px; }
.client-item.client-archived { opacity: 0.62; }
.client-item.client-archived:hover, .client-item.client-archived.active { opacity: 1; }
/* Rail mode: the group header shrinks to its caret + count. */
.app.sidebar-rail .archive-head { justify-content: center; padding: 8px 0; gap: 4px; }
.app.sidebar-rail .archive-head-label { display: none; }
.app.sidebar-rail .archive-count { margin-left: 0; }

/* "Archived" badge next to the client name on Overview. */
.archive-tag {
  margin-left: 10px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle;
}
.overview-archive-actions { display: inline-flex; align-items: center; gap: 8px; }
.add-client-btn { display: flex; align-items: center; gap: 9px; width: 100%; margin-top: 8px; background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--text-muted); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; }
.add-client-btn:hover { color: var(--accent); border-color: var(--accent); }
.add-client-btn svg { width: 15px; height: 15px; }

/* sub-tabs in the topbar */
.subtabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.subtab { background: none; border: none; color: var(--text-muted); font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 7px; }
.subtab:hover { color: var(--text); }
.subtab.active { background: var(--accent-soft); color: var(--accent); }

/* buttons */
.btn-block { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 650; margin-bottom: 8px; }
.btn-block svg { width: 16px; height: 16px; }

/* Home: clients grid */
.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.client-card { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.client-card:hover { border-color: var(--accent); }
.client-card-av { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), #0a6bb0); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: 0 0 40px; }
.client-card-name { font-weight: 650; font-size: 14.5px; }
.client-card-meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

/* client overview head */
.client-head-av { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), #0a6bb0); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; flex: 0 0 38px; }
.client-head-name { font-size: 16px; font-weight: 700; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-head-meta { font-size: 12px; color: var(--text-dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* script lists */
.script-list, .script-channels { display: flex; flex-direction: column; gap: 4px; }
.script-channel-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 12px 0 4px; }
.script-channel-label:first-child { margin-top: 0; }
.script-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.script-row:hover { background: var(--surface-2); }
.status-pill { font-size: 11px; font-weight: 650; padding: 3px 9px; border-radius: 20px; flex: 0 0 auto; text-transform: capitalize; }
.script-row-title { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-row-client { font-size: 12.5px; color: var(--text-muted); }
.script-row-channel { font-size: 12px; color: var(--text-dim); }
.script-row-meta { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }

/* editor metabar (channel + status selects) */
.content-metabar { display: flex; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.content-meta-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.content-select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--surface); color: var(--text); font-size: 12.5px; border-radius: 8px; padding: 6px 26px 6px 10px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b929b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 12px;
}
.content-select:hover { border-color: var(--accent); }
.content-select:focus { outline: none; border-color: var(--accent); }
.content-select option { background: var(--surface-2); color: var(--text); }
.content-body-row .content-main { flex: 1; min-width: 0; }

/* add-client wizard steps */
.cl-steps { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.cl-step { font-size: 12px; font-weight: 650; color: var(--text-dim); background: var(--surface-2); border: 1px solid var(--border); padding: 5px 12px; border-radius: 20px; }
.cl-step.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.cl-panel { display: none; }
.cl-panel.active { display: block; }
.cl-panel h1 { font-size: 22px; margin-bottom: 6px; }

/* Full-page create-client view */
#tab-create-client { overflow-y: auto; }
.create-view { max-width: 560px; margin: 0 auto; padding: 32px 24px 48px; }
.create-view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.create-view-title { font-size: 22px; font-weight: 700; }
.cl-build-actions { justify-content: space-between; margin-top: 28px; }
.cl-build-actions .btn-ghost { color: var(--text-dim); }

/* Progress bar */
.cl-progress-wrap { margin: 20px 0 4px; }
.cl-progress-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cl-progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }
.cl-progress-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.cl-progress-pct { font-weight: 650; color: var(--accent); }

/* Background jobs bar */
.jobs-bar { display: flex; flex: 0 0 auto; gap: 10px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.job-pill { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; min-width: 220px; flex: 0 0 auto; }
.job-pill-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.job-pill-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-pill-eta { font-size: 11px; color: var(--text-dim); }
.job-pill-bar { width: 80px; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.job-pill-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }
.job-pill .btn-ghost { padding: 5px 10px; font-size: 12px; flex-shrink: 0; }
.job-pill-close {
  background: transparent; border: none;
  color: var(--text-dim); font-size: 16px; line-height: 1;
  padding: 2px 5px; border-radius: 4px; cursor: pointer; flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.job-pill-close:hover { color: var(--text); background: var(--surface-3); }
.job-pill-done { opacity: 0.85; }
.job-pill-done .job-pill-bar { display: none; }

/* =====================================================================
   MOBILE / PHONE  (<= 700px): bottom tab bar, slide-over sidebar,
   single-column content, vertical scripts list, full-screen editor.
   All desktop/tablet rules above are untouched; these only switch on
   at phone widths. The tab bar / scrim / back button are hidden until
   then by the three base rules just below.
   ===================================================================== */
.mobile-tabbar { display: none; }
.nav-scrim { display: none; }
.editor-chat-back { display: none; }

@media (max-width: 700px) {
  /* ----- shell: one column; sidebar becomes a left slide-over ----- */
  .app { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed !important; top: 0; left: 0; bottom: 0;
    width: 272px !important; max-width: 82vw; z-index: 120;
    transform: translateX(-100%); transition: transform 0.24s ease;
    padding: 18px 14px !important; opacity: 1 !important; pointer-events: auto !important;
    overflow-y: auto; box-shadow: 10px 0 44px rgba(0,0,0,0.55);
  }
  /* The slide-over scrolls as one piece, so the list keeps its natural height here. */
  .client-list { flex: 0 0 auto; min-height: 0; overflow: visible; }
  .app.sidebar-rail .sidebar { opacity: 1 !important; pointer-events: auto !important; padding: 18px 14px !important; }
  body.nav-open .sidebar { transform: translateX(0); }
  /* Undo the icon-rail collapsing (both the 920px query and .sidebar-rail) —
     the slide-over always shows full labels. !important is required here: the
     .app.sidebar-rail rules outrank these plain selectors. */
  .brand { flex-direction: row !important; gap: 12px !important; padding: 6px 8px 22px !important; }
  .brand-text, .brand-sub { display: block !important; }
  .client-switch-label, .client-item-name { display: block !important; }
  .nav-item > span:last-child, .add-client-btn > span:last-child { display: inline !important; }
  .nav-item, .add-client-btn { justify-content: flex-start !important; gap: 12px !important; padding: 11px 12px !important; }
  .client-item-av { width: 22px !important; height: 22px !important; flex: 0 0 22px !important; border-radius: 6px !important; font-size: 11px !important; }
  .archive-head { justify-content: flex-start !important; padding: 8px 12px !important; gap: 8px !important; }
  .archive-head-label { display: inline !important; }
  .archive-count { margin-left: auto !important; }

  .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 110; opacity: 0; pointer-events: none; transition: opacity 0.24s ease; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

  /* ----- workspace chrome trim ----- */
  #brand-toggle, #brand-toggle:hover { cursor: default; transform: none; filter: none; }   /* the Clients tab opens the sidebar */
  #subtabs { display: none !important; }    /* replaced by the bottom tab bar */
  /* Compact bar on phones; the 100dvh calcs below subtract it. */
  .client-bar { height: 52px; flex: 0 0 52px; padding: 0 14px; gap: 10px; }
  .main.has-bar { --chrome-top: 52px; }
  .client-bar .subtabs { display: none !important; }   /* bottom tab bar owns these */
  .client-bar .bar-mid .chan-visit { display: none; }  /* don't leave it floating alone */
  .client-head-meta { display: none; }

  /* ----- content: leave room for the tab bar ----- */
  .content { padding: 16px 14px calc(76px + env(safe-area-inset-bottom, 0)); }
  .card { padding: 15px 15px; margin-bottom: 14px; }

  /* keep modals / drawers above the tab bar (100) and slide-over (120) */
  .drawer, .modal { z-index: 130; }

  /* ----- scripts board => vertical, full-width accordion list ----- */
  .board { flex-direction: column; overflow-x: visible; gap: 8px; }
  .board-col { flex: 1 1 auto !important; min-width: 0 !important; width: 100% !important; max-height: none; }
  .board-col.collapsed { width: 100% !important; align-items: stretch !important; }
  .board-col.collapsed .board-col-head { flex-direction: row !important; gap: 7px !important; padding: 10px 8px !important; }
  .board-col.collapsed .board-col-name { writing-mode: horizontal-tb !important; max-height: none !important; }
  .board-col.collapsed .board-col-count { margin-left: auto !important; }
  .board-col-head { padding: 11px 8px; }
  .board-col-name { font-size: 13px; }
  .board-card { padding: 12px 12px; }

  /* ----- chat workspace: single column ----- */
  .chat-workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: calc(100dvh - 76px); gap: 10px; }
  .chat-sidebar { max-height: 33vh; }

  /* ----- wiki: stacked mapbar, full-width search ----- */
  .wiki-layout, .wiki-layout.chat-open { height: calc(100dvh - 76px); }
  .swipe-layout { height: calc(100dvh - 76px); }
  .wiki-mapbar { flex-wrap: wrap; gap: 10px; }
  .wiki-search { margin-left: 0; width: 100%; order: 3; }
  .wiki-detail, .wiki-chat-sidebar { top: 0; width: min(360px, 92vw); }

  /* ----- editor: always full-screen, no mode toggle ----- */
  #content-modes { display: none !important; }
  #content-drawer { padding: 0 !important; }
  #content-drawer .content-panel,
  #content-drawer.mode-popup.chat-open .content-panel {
    width: 100% !important; height: 100dvh !important; max-height: 100dvh !important; border-radius: 0 !important;
  }
  /* "Ask AI" opens the script chat full-screen over the editor, with a Back button */
  #content-drawer.chat-open .editor-chat-sidebar {
    position: fixed; inset: 0; z-index: 70; width: 100%; flex: none; border: none; display: flex;
  }
  #content-drawer.chat-open .content-body-row > .content-main,
  #content-drawer.chat-open .editor-chat-divider { display: none; }
  .editor-chat-head .editor-chat-head-label { display: none; }
  .editor-chat-back {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
    border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 650;
  }

  /* ----- bottom tab bar ----- */
  .mobile-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    height: calc(60px + env(safe-area-inset-bottom, 0)); padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(18,20,24,0.94); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  }
  .mtab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: none; color: var(--text-dim); font-size: 10.5px; font-weight: 600; }
  .mtab .mtab-ico { display: grid; place-items: center; }
  .mtab .mtab-ico svg { width: 21px; height: 21px; }
  .mtab.active { color: var(--accent); }
}

/* ----- editor header: deadline + working-file link, both reduced to icon buttons -----
   Everything that used to sit inline (a date field, a 150px URL box, an open arrow) is now
   one 26px icon each, so the header never runs out of room. The date opens the native
   picker; the link opens a popover holding the URL box. */
.head-field { position: relative; display: inline-flex; align-items: center; flex: 0 0 auto; }
.head-icon-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 7px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); cursor: pointer; line-height: 1; transition: all 0.12s;
}
.head-icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.head-icon-btn svg { width: 15px; height: 15px; }
.head-icon-btn.is-set { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.head-icon-label { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.head-icon-label:empty { display: none; }
/* The real <input type="date"> stays in the DOM (all the save paths read it) but is
   collapsed to a 1px sliver under the button so the native picker still anchors here. */
.head-hidden-input {
  position: absolute; left: 4px; bottom: 0; width: 1px; height: 1px;
  opacity: 0; pointer-events: none; border: 0; padding: 0; color-scheme: dark;
}
.workfile-pop {
  position: absolute; top: calc(100% + 7px); left: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 7px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--glass-shadow, 0 10px 30px rgba(0,0,0,0.35));
}
/* The popover sits inside .drawer-head, which is mono — reset it so labels and the
   note read as UI text, not as part of the editor chrome. */
.workfile-pop, .workfile-pop input { font-family: var(--sans); }
/* One row per destination (Notion working file, ClickUp task): label, URL box, open arrow. */
.workfile-row { display: flex; align-items: center; gap: 6px; }
.workfile-label {
  width: 52px; flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-dim);
}
/* Sits under both rows and explains what the ClickUp link is wired to do. */
.workfile-note { font-size: 11px; line-height: 1.35; color: var(--text-dim); padding: 1px 2px 0 58px; }
.workfile-note:empty { display: none; }
.workfile-input {
  width: 260px; max-width: 50vw; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 5px 9px; font-size: 12px; outline: none;
}
.workfile-input:focus { border-color: var(--accent); }
.workfile-input::placeholder { color: var(--text-dim); }
.workfile-open {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  color: var(--accent); background: var(--accent-soft); flex: 0 0 auto;
}
.workfile-open:hover { background: var(--accent); color: #fff; }

/* ----- editor header at narrow PANEL widths -----
   These are container queries, not media queries: they fire on the editor panel's own
   width, so a popped-out browser window and Popup mode both collapse correctly even when
   the viewport itself is wide. */
@container edpanel (max-width: 1000px) {
  #content-drawer .editor-chat-toggle-label { display: none; }
  #content-drawer .editor-chat-toggle { padding: 6px 8px; }
}
@container edpanel (max-width: 780px) {
  #content-drawer .content-head { gap: 8px; padding-left: 12px; padding-right: 12px; }
  #content-drawer .content-head-left { gap: 6px; }
  #content-drawer .content-head-right { gap: 7px; }
  #content-drawer .content-status { display: none; }
  #content-drawer .status-badge .badge-label,
  #content-drawer .status-badge .badge-car { display: none; }
  #content-drawer .status-badge { padding: 5px 6px; }
  #content-drawer .head-icon-label { display: none; }
}

/* ----- board card deadline chip ----- */
.board-card-due { color: var(--text-muted); white-space: nowrap; }

/* ----- home scripts view switch (Board | Calendar) ----- */
.view-switch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.vs-btn {
  border: none; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.vs-btn.active { background: var(--surface-3); color: var(--text); }

/* ----- deadline calendar refresh ----- */
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .btn-ghost { padding: 4px 10px; }
.cal-pill { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.cal-pill:hover { background: var(--surface-2); }
.cal-pill-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-pill-av { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; font-size: 8px; font-weight: 700; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--accent), #0a6bb0); color: #fff; position: relative; overflow: hidden; }
.cal-pill-av .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cal-more { cursor: pointer; }
.cal-more:hover { color: var(--text); }

/* ----- sidebar sign-out ----- */
.nav-signout { margin-top: auto; color: var(--text-dim); }
.nav-signout:hover { color: var(--text); }

/* Calendar view mounts inside the .board container (a horizontal flex row for kanban
   columns) — switch it to block flow so the calendar spans the full card width. */
.board.is-calendar { display: block; overflow-x: visible; padding-bottom: 0; }
.board.is-calendar .calendar { width: 100%; }

/* ----- Draft | Final tabs above the script editor ----- */
.content-main-tabs { padding: 8px 16px 0; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.content-wordcount { margin-left: auto; padding-bottom: 5px; font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The block gutter (drag handles / collapse toggles) belongs to the Draft doc only. */

/* ----- client notes (Overview card grid) ----- */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 14px 16px 16px; }
.note-card { text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer; transition: transform .14s ease, border-color .14s ease; }
.note-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.note-card-name { font-size: 13px; font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-date { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.notes-empty { padding: 14px 16px 16px; color: var(--text-dim); font-size: 12.5px; }

/* The note drawer has no mode classes, so give its panel a definite height —
   otherwise .content-main (flex: 1 1 0; min-height: 0) collapses to zero. */

/* ----- branded dialog (replaces window.prompt / window.confirm) ----- */
#os-dialog { z-index: 200; }   /* above drawers (50/60) and the mobile override (130) */
.os-dialog-msg { font-size: 13.5px; color: var(--text-muted); white-space: pre-line; margin: 0; line-height: 1.55; }
#os-dialog .modal-input { margin-top: 12px; }
/* osChoice(): a row of equal buttons instead of OK — the preselected one carries the accent border. */
.os-choices { display: flex; gap: 8px; margin-top: 14px; }
.os-choices .os-choice { flex: 1; padding: 10px 12px; font-size: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.os-choices .os-choice:hover, .os-choices .os-choice:focus-visible { border-color: var(--border-strong); outline: none; }
.os-choices .os-choice.is-pre { border-color: var(--accent); }
#os-dialog .modal-actions { margin-top: 18px; }
#os-dialog-ok.btn-danger { padding: 9px 16px; font-size: 13px; }

/* ===================== Swipe File (global boards) ===================== */
#tab-swipe { min-height: 0; }
.swipe-layout { display: flex; align-items: stretch; gap: 16px; height: calc(100vh - 52px - var(--chrome-top)); }
/* container-type so the masonry's column count reacts to THIS column's width
   (i.e. it reflows when the chat/notes panel opens), not the viewport's. */
.swipe-maincol { flex: 1; min-width: 0; display: flex; flex-direction: column; container-type: inline-size; }
.swipe-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.swipe-controls { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.swipe-search-box { margin: 0; max-width: 260px; }
.board-search-box { margin: 0; max-width: 220px; flex: none; }
.board-search-box .search-input { padding: 7px 12px 7px 32px; font-size: 12.5px; border-radius: 9px; }
.swipe-select { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); padding: 9px 12px; font-size: 13px; font-family: var(--sans); }
.swipe-select:focus { outline: none; border-color: var(--accent); }
.swipe-tool-btn { display: inline-flex; align-items: center; gap: 7px; }
.swipe-tool-btn svg { width: 15px; height: 15px; }
.swipe-tool-btn.active { border-color: var(--accent); color: var(--accent); }

/* Long-form / short-form switch — swaps the whole board list under it. */
.swipe-space { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; gap: 2px; }
.swipe-space-btn { background: none; border: none; color: var(--text-dim); font-family: var(--sans); font-size: 12.5px; font-weight: 650; padding: 6px 13px; border-radius: 8px; cursor: pointer; transition: background 0.12s, color 0.12s; }
.swipe-space-btn:hover { color: var(--text); }
.swipe-space-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16); }

.swipe-title-picker { position: relative; }
.swipe-title-btn { display: inline-flex; align-items: center; gap: 8px; background: none; border: none; color: var(--text); font-size: 19px; font-weight: 700; cursor: pointer; padding: 4px 6px; border-radius: 9px; font-family: var(--sans); }
.swipe-title-btn:hover { background: var(--surface-2); }
.swipe-title-caret { color: var(--text-dim); font-size: 13px; }
/* Solid background on purpose: the glass theme turns --surface-2 translucent,
   which made the masonry cards bleed through the open board menu. */
.swipe-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 260px; background: #1a212e; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5); padding: 6px; }
.swipe-board { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.swipe-board:hover { background: var(--surface-3); }
.swipe-board.active { background: var(--accent-soft); color: var(--accent); }
.swipe-board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swipe-board-right { display: inline-flex; align-items: center; gap: 4px; }
.swipe-board-right .count { font-size: 11.5px; color: var(--text-dim); min-width: 18px; text-align: right; }
.swipe-board-right button { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 2px 5px; border-radius: 6px; opacity: 0; transition: opacity 0.12s; }
.swipe-board:hover .swipe-board-right button { opacity: 1; }
.swipe-board-right button:hover { color: var(--text); background: var(--surface-2); }
.swipe-board-del:hover { color: #e5484d !important; }
.swipe-menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* Explicit flex columns, filled round-robin by renderSwipeMasonry (card i -> col i%N).
   CSS `column-count` balances COLUMN-BY-COLUMN: with 4 cards it aims for ~2-card-tall
   columns and lays them out 2+2 instead of 3-then-1. Round-robin over real column
   elements gives row-major order across the top AND keeps independent column heights,
   so it still packs like masonry. Column count comes from a ResizeObserver in app.js
   (the container query that used to set it can't drive JS). */
.swipe-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 24px; }
.swipe-masonry { display: flex; align-items: flex-start; gap: 14px; }
.swipe-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.swipe-empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 26px; color: var(--text-muted); font-size: 13.5px; text-align: center; }

/* Creator filter strip: one pill per channel/author, scrolls sideways on its own. */
/* No scrollbar overrides here on purpose — it inherits the app's global refined
   scrollbar (see "Refined scrollbars") so it looks like every other scroll area. */
.swipe-chips { display: flex; align-items: center; gap: 8px; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; padding: 2px 0 10px; }
.swipe-chips:empty { display: none; }
.swipe-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); padding: 5px 12px 5px 5px; border-radius: 20px; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; font-family: var(--sans); transition: border-color 0.12s, color 0.12s, background 0.12s; }
.swipe-chip:hover { border-color: var(--border-strong); color: var(--text); }
.swipe-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.swipe-chip-all { padding-left: 12px; }
.swipe-chip .swipe-avatar { width: 22px; height: 22px; font-size: 9px; }
.swipe-chip-count { color: var(--text-dim); font-weight: 500; }
.swipe-chip.active .swipe-chip-count { color: var(--accent); }
/* break-inside: avoid keeps a card whole instead of splitting it across two columns. */
.swipe-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color 0.12s, transform 0.12s; }
.swipe-card:hover { border-color: var(--border-strong); }
.swipe-card-body { padding: 12px 13px; display: flex; flex-direction: column; gap: 9px; }
.swipe-card-platform { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.swipe-card-thread { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.swipe-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.swipe-avatar-fallback { display: grid; place-items: center; background: var(--surface-3); color: var(--text-muted); font-size: 12.5px; font-weight: 700; }
.swipe-post-head { display: flex; align-items: center; gap: 10px; }
.swipe-post-who { flex: 1; min-width: 0; }
.swipe-post-name { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swipe-post-meta { font-size: 11.5px; color: var(--text-dim); }
.swipe-post-caption { font-size: 13px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; }
/* Card captions are NOT clamped — masonry handles tall cards, and cropping the text
   was the whole complaint. (Titles + article bodies keep their short clamps.) */
.swipe-post-images { display: grid; gap: 6px; border-radius: 10px; overflow: hidden; }
.swipe-post-images.multi { grid-template-columns: 1fr 1fr; }
.swipe-post-images img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; cursor: zoom-in; }
.swipe-thread-seg { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.swipe-thread-seg:last-child { border-bottom: none; }

.swipe-yt-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.swipe-yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.swipe-yt-duration { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 11px; font-weight: 600; border-radius: 5px; padding: 2px 6px; }
.swipe-yt-meta { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.swipe-yt-meta > div { min-width: 0; }
.swipe-yt-title { font-size: 13.5px; font-weight: 650; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.swipe-yt-channel { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.swipe-yt-stats { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.swipe-art-thumb { aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.swipe-art-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; cursor: zoom-in; }
.swipe-art-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.swipe-art-site { font-size: 11.5px; color: var(--text-dim); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swipe-art-title { font-size: 14px; font-weight: 650; line-height: 1.35; }
.swipe-art-text { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }

.swipe-ig-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; }
.swipe-ig-handle { color: var(--text-dim); font-weight: 500; }
.swipe-ig-well { border-radius: 10px; overflow: hidden; background: #fff; }

/* Reels — 9:16 cover with a play affordance, in place of IG's embed widget
   (which loads a whole iframe per card and fights the masonry column flow). */
.swipe-reel-thumb { position: relative; aspect-ratio: 9 / 16; background: var(--surface-2); }
.swipe-reel-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.swipe-reel-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.swipe-reel-play::after {
  content: ''; width: 0; height: 0; margin-left: 4px;
  border-left: 17px solid rgba(255, 255, 255, 0.95);
  border-top: 11px solid transparent; border-bottom: 11px solid transparent;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.55));
}
.swipe-reel-badge { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; border-radius: 5px; padding: 2px 6px; }

.swipe-card-actions { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); padding-top: 9px; margin-top: 2px; }
.swipe-card-actions .spacer { flex: 1; }
.swipe-card-actions button, .swipe-card-src { display: grid; place-items: center; background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 5px; border-radius: 7px; transition: color 0.12s, background 0.12s; }
.swipe-card-actions button:hover, .swipe-card-src:hover { color: var(--text); background: var(--surface-2); }
.swipe-card-actions .swipe-del:hover { color: #e5484d; }
.swipe-card-actions svg { width: 15px; height: 15px; }

/* Board chat slide-over + notes panel */
.swipe-chat-panel, .swipe-notes-panel { width: 0; flex: 0 0 auto; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; opacity: 0; transition: width 0.18s ease, opacity 0.18s ease; }
.swipe-layout.chat-open .swipe-chat-panel { width: var(--swipe-chat-w, 420px); opacity: 1; }
.swipe-chat-panel { position: relative; min-width: 0; }
.swipe-layout.resizing .swipe-chat-panel { transition: none; }
.swipe-layout.notes-open .swipe-notes-panel { width: 380px; opacity: 1; }
.swipe-chat-head { flex-shrink: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.swipe-chat-head h3 { font-size: 14.5px; }
.swipe-chat-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.swipe-chat-log { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.swipe-msg { flex: 0 0 auto; max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.55; word-break: break-word; }
.swipe-msg.user { align-self: flex-end; background: var(--accent-soft); border: 1px solid rgba(29, 155, 240, 0.25); white-space: pre-wrap; }
.swipe-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); position: relative; }
.swipe-msg-copy { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 24px; height: 24px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 7px; color: var(--text-dim); cursor: pointer; opacity: 0; transition: opacity 0.12s, color 0.12s; }
.swipe-msg.bot:hover .swipe-msg-copy { opacity: 1; }
.swipe-msg-copy:hover { color: var(--text); border-color: var(--border-strong); }
.swipe-msg-copy svg { width: 13px; height: 13px; }
.swipe-msg.bot p { margin: 0 0 8px; } .swipe-msg.bot p:last-child { margin-bottom: 0; }
.swipe-msg.bot ul, .swipe-msg.bot ol { margin: 4px 0 8px; padding-left: 20px; }
.swipe-msg.bot h1, .swipe-msg.bot h2, .swipe-msg.bot h3 { font-size: 13.5px; margin: 10px 0 5px; }
.swipe-msg.bot pre { background: var(--bg); border-radius: 8px; padding: 9px; overflow-x: auto; font-family: var(--mono); font-size: 12px; }
.swipe-msg.bot code { font-family: var(--mono); font-size: 12px; }
.swipe-msg { min-width: 0; }
.swipe-msg.bot .md-table-wrap { max-width: 100%; overflow-x: auto; margin: 6px 0 8px; }
.swipe-msg.bot table { border-collapse: collapse; width: 100%; table-layout: auto; font-size: 12px; margin: 0; }
.swipe-msg.bot th, .swipe-msg.bot td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; overflow-wrap: normal; word-break: normal; min-width: 90px; }
.swipe-chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.swipe-chat-input textarea { flex: 1; resize: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); padding: 9px 12px; font-size: 13px; font-family: var(--sans); min-height: 40px; }
.swipe-chat-input textarea:focus { outline: none; border-color: var(--accent); }

/* Starter-prompt pill strip */
/* Capped so a dozen prompts scroll inside the strip instead of squeezing the log. */
.sp-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 8px; max-height: 112px; overflow-y: auto; flex: none; }
.sp-strip:empty { display: none; }
.sp-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); font-size: 11.5px; font-weight: 600; padding: 5px 11px; cursor: pointer; transition: all 0.12s; font-family: var(--sans); }
.sp-btn:hover { border-color: var(--border-strong); color: var(--text); }
.sp-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.sp-btn svg { width: 13px; height: 13px; }

/* Full-screen post detail */
.swipe-detail { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; }
.swipe-detail.hidden { display: none; }
.swipe-detail-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.swipe-detail-tools { display: flex; gap: 8px; margin-left: auto; }
.sd-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 13px; color: var(--text-muted); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all 0.12s; font-family: var(--sans); }
.sd-btn:hover { color: var(--text); border-color: var(--border-strong); }
.sd-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.sd-btn svg { width: 15px; height: 15px; }
.swipe-detail-cols { flex: 1; min-height: 0; display: flex; }
.swipe-detail-main { flex: 1; min-width: 0; overflow-y: auto; }
.swipe-detail-inner { max-width: 720px; margin: 0 auto; padding: 26px 22px 60px; display: flex; flex-direction: column; gap: 14px; }
.swipe-detail-inner .swipe-yt-thumb { border-radius: var(--radius); overflow: hidden; }
/* Playable video in the detail view (reuses the editor's 16:9 .embed-frame). */
.swipe-detail-inner .embed-frame { border-radius: var(--radius); overflow: hidden; }
/* Transcript header + its copy button */
.swipe-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.swipe-section-head .swipe-section-label { margin-bottom: 0; }
.swipe-copy-btn { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; color: var(--text-dim); font-size: 11px; font-weight: 600; padding: 3px 8px; cursor: pointer; font-family: var(--sans); transition: color 0.12s, border-color 0.12s; }
.swipe-copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.swipe-copy-btn svg { width: 12px; height: 12px; }
.swipe-yt-watch { color: var(--accent); text-decoration: none; }
.swipe-yt-watch:hover { text-decoration: underline; }
.swipe-detail-aside { width: 420px; flex: 0 0 auto; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
.swipe-detail-aside.hidden { display: none; }
.swipe-section-label { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; }
.swipe-transcript { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 6px; }
.swipe-transcript-body { font-size: 13.5px; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.swipe-transcript-empty { color: var(--text-dim); font-style: italic; }

/* Save Post modal bits */
.swipe-url-row { display: flex; gap: 8px; }
.swipe-url-row .modal-input { flex: 1; }
.swipe-fetch-status { font-size: 12px; color: var(--text-dim); min-height: 16px; margin: 6px 0 2px; }
.swipe-cardpreview { margin: 8px 0 4px; }
.swipe-cardpreview .swipe-card { margin-bottom: 0; }
.swipe-manual-toggle { background: none; border: none; color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 6px 0; font-family: var(--sans); text-align: left; }
.swipe-manual { display: flex; flex-direction: column; }
.swipe-drop { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px; transition: border-color 0.12s, background 0.12s; }
.swipe-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.swipe-preview { max-width: 100%; max-height: 180px; border-radius: 8px; margin-top: 8px; }

/* Image lightbox / viewer — pan + zoom, opened by double-click in any editor */
.img-lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.88); overflow: hidden; }
.img-lightbox.hidden { display: none; }
.img-lightbox .ilb-stage { position: absolute; inset: 0; display: grid; place-items: center; cursor: zoom-in; overflow: hidden; }
.img-lightbox.is-zoomed .ilb-stage { cursor: grab; }
.img-lightbox.is-panning .ilb-stage { cursor: grabbing; }
.img-lightbox img {
  /* Fitted by CSS so the layout box never overflows the stage — an oversized grid item gets
     aligned to the start edge instead of centred, which is what threw the image into the corner.
     Zoom is a transform multiplier on top of this fitted size. */
  max-width: 92vw; max-height: 80vh; border-radius: 10px; user-select: none; -webkit-user-drag: none;
  transform-origin: center center; will-change: transform; transition: transform 0.12s ease-out;
}
.img-lightbox.is-panning img { transition: none; }
.img-lightbox .ilb-bar {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 4px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--glass-shadow, 0 18px 40px -22px rgba(0,0,0,0.85));
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1);
}
.img-lightbox .ilb-btn {
  min-width: 32px; height: 30px; padding: 0 9px; border: none; border-radius: 8px; background: transparent;
  color: var(--text); font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer;
}
.img-lightbox .ilb-btn:hover { background: var(--accent-soft); }
.img-lightbox .ilb-pct { min-width: 54px; text-align: center; color: var(--text-dim); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.img-lightbox .ilb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.img-lightbox .ilb-hint { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); color: rgba(255,255,255,0.5); font-size: 11.5px; font-family: var(--sans); pointer-events: none; }

/* ===================== Collapsible note boxes (swipe notes + Research toggle boxes) ===================== */
.swipe-notes-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* Notes reference tab in the script editor: the global Swipe File board notes,
   grouped by board. Scrolls as one list rather than per-group. */
/* flex: 1 0 auto (not 1 1 0) — .content-ref-body owns the scrolling now, so this
   grows to its content instead of shrinking and hiding notes behind a nested bar. */
.swipe-notes-ref { flex: 1 0 auto; overflow: visible; padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.swipe-ref-group { display: flex; flex-direction: column; gap: 8px; }
.swipe-ref-group-head {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-dim);
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.swipe-ref-group-head { cursor: pointer; user-select: none; border-radius: 4px; }
.swipe-ref-group-head:hover { color: var(--text-muted); }
.swipe-ref-group-head:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.swipe-ref-caret { display: grid; place-items: center; transition: transform 0.15s; }
.swipe-ref-group.collapsed .swipe-ref-caret { transform: rotate(-90deg); }
.swipe-ref-group.collapsed .swipe-ref-wrap { display: none; }
.swipe-ref-bar { display: flex; justify-content: flex-end; margin-bottom: -6px; }
.swipe-ref-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swipe-ref-count { margin-left: auto; color: var(--text-dim); }
.swipe-ref-wrap { display: flex; flex-direction: column; gap: 8px; }
.swipe-ref-empty { font-size: 13px; color: var(--text-dim); line-height: 1.55; padding: 10px 2px; }
/* flex: 0 0 auto everywhere these live in a column-flex scroller: without it, flex
   SHRINKS the boxes to fit the panel (clipping their text) instead of overflowing
   into the wrapper's scrollbar. */
.note-box { flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.note-box-head { display: flex; align-items: center; gap: 8px; padding: 9px 11px; cursor: pointer; user-select: none; }
.note-box-head:hover { background: var(--surface-3); }
/* Drag handle: the only draggable part, so the title stays click-to-rename. */
.note-box-grip { display: grid; place-items: center; color: var(--text-dim); cursor: grab; margin: -3px -4px -3px -5px; padding: 3px 1px; border-radius: 5px; opacity: 0.35; transition: opacity 0.12s; }
.note-box-grip svg { width: 14px; height: 14px; }
.note-box:hover .note-box-grip { opacity: 1; }
.note-box-grip:hover { background: var(--surface); color: var(--text); }
.note-box-grip:active { cursor: grabbing; }
.note-box.dragging { opacity: 0.4; }
.note-box.drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
.note-box.drop-after { box-shadow: 0 2px 0 0 var(--accent); }
.note-box-ic { display: grid; place-items: center; color: var(--text-dim); }
.note-box-ic svg { width: 14px; height: 14px; }
.note-box-t { flex: 1; min-width: 0; font-size: 13px; font-weight: 650; outline: none; border-radius: 5px; padding: 1px 4px; white-space: nowrap; overflow: hidden; }
.note-box-t:focus { background: var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.note-box-del { display: grid; place-items: center; background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 3px; border-radius: 6px; opacity: 0; transition: opacity 0.12s; }
.note-box:hover .note-box-del { opacity: 1; }
.note-box-del:hover { color: #e5484d; }
.note-box-del svg { width: 13px; height: 13px; }
.note-box-caret { display: grid; place-items: center; color: var(--text-dim); transition: transform 0.15s; }
.note-box-caret svg { width: 14px; height: 14px; }
.note-box.collapsed .note-box-caret { transform: rotate(-90deg); }
.note-box-body { border-top: 1px solid var(--border); padding: 10px 12px; }
.note-box.collapsed .note-box-body { display: none; }
.nb-editor { min-height: 60px; outline: none; font-size: 13px; line-height: 1.55; }
.nb-editor:empty::before, .nb-editor[data-placeholder]:not(:focus):has(> p:only-child > br:only-child)::before { content: attr(data-placeholder); color: var(--text-dim); position: absolute; pointer-events: none; }
.nb-editor { position: relative; }
.nb-editor h1, .nb-editor h2, .nb-editor h3 { font-size: 14px; margin: 8px 0 4px; }
.nb-editor ul, .nb-editor ol { margin: 4px 0; padding-left: 20px; }
.nb-editor p { margin: 0 0 6px; }
.note-box-add { flex: 0 0 auto; background: none; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12.5px; font-weight: 600; padding: 9px; cursor: pointer; transition: all 0.12s; font-family: var(--sans); }
.note-box-add:hover { color: var(--accent); border-color: var(--accent); }

/* Research/Outline tab toggle boxes: stacked above the doc editor, at their natural
   height. No max-height and no scroller of their own — .content-ref-body is the single
   scroller for the pane, so an expanded box shows all of its text. */
.ref-boxes { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 4px; flex: 0 0 auto; overflow: visible; }
.ref-boxes.hidden { display: none; }

/* ===================== Embed-card delete button ===================== */
.embed-card { position: relative; }
.embed-del { position: absolute; top: 6px; right: 6px; z-index: 2; width: 24px; height: 24px; display: grid; place-items: center; background: rgba(0, 0, 0, 0.65); border: 1px solid var(--border-strong); border-radius: 7px; color: var(--text-muted); font-size: 15px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.12s, color 0.12s; }
.embed-card:hover .embed-del { opacity: 1; }
.embed-del:hover { color: #fff; background: rgba(229, 72, 77, 0.85); border-color: transparent; }

/* Swipe layout on phones: stack the panels */
@media (max-width: 860px) {
  .swipe-layout { flex-direction: column; height: auto; }
  .swipe-layout.chat-open .swipe-chat-panel, .swipe-layout.notes-open .swipe-notes-panel { width: 100%; height: 55vh; }
  .swipe-scroll { overflow: visible; }
  .swipe-detail-cols { flex-direction: column; }
  .swipe-detail-aside { width: 100%; height: 50vh; border-left: none; border-top: 1px solid var(--border); }
}

/* ============================ ClickUp task inbox ============================ */

/* Pending-count pill on the sidebar nav item. */
.nav-count {
  margin-left: auto; flex: 0 0 auto;
  min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.nav-count.hidden { display: none; }
/* Rail mode. The generic rule hides `.nav-item > span:last-child`, which works for
   every other nav item (icon + label) but not this one — its last child is the badge,
   so the "Inbox" label survived. Target the label explicitly instead: the span that is
   neither the icon nor the count. The badge then floats as a corner dot over the icon. */
.app.sidebar-rail #nav-clickup { position: relative; }
.app.sidebar-rail #nav-clickup > span:not(.nav-ico):not(.nav-count) { display: none; }
.app.sidebar-rail #nav-clickup > span.nav-count:not(.hidden) {
  display: block; position: absolute; top: 5px; right: 9px;
  min-width: 15px; padding: 0 4px; font-size: 9.5px; line-height: 15px;
  border: 2px solid var(--bg);
}

.cu-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.cu-toolbar-text h2 { margin: 0 0 4px; }
.cu-toolbar .accent { color: var(--accent); }
.cu-sub { margin: 0; font-size: 13px; color: var(--text-dim); }
.cu-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cu-synced { font-size: 12px; color: var(--text-dim); }

.cu-banner {
  border: 1px solid var(--border); border-left: 3px solid var(--warn);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 13px 16px; margin-bottom: 16px; font-size: 13px; color: var(--text-muted); line-height: 1.55;
}
.cu-banner.err { border-left-color: #e0574e; }
.cu-banner strong { color: var(--text); }
.cu-banner code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-3); padding: 1px 5px; border-radius: 5px; color: var(--text);
}
.cu-banner.hidden { display: none; }

.cu-list { display: flex; flex-direction: column; gap: 12px; }
.cu-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 11px;
  transition: opacity 0.2s, border-color 0.12s;
}
.cu-card:hover { border-color: var(--border-strong); }
.cu-card.going { opacity: 0; }
.cu-card-title { margin: 0; font-size: 15px; font-weight: 650; color: var(--text); text-decoration: none; line-height: 1.4; }
a.cu-card-title:hover { color: var(--accent); }
.cu-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); }

.cu-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 3px 9px; font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
.cu-chip.ok { background: rgba(24, 182, 99, 0.11); border-color: rgba(24, 182, 99, 0.4); color: var(--good); }
.cu-chip.warn { background: rgba(224, 163, 46, 0.11); border-color: rgba(224, 163, 46, 0.4); color: var(--warn); }
.cu-chip.link { text-decoration: none; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.cu-chip.link:hover { border-color: var(--accent); color: var(--accent); }

.cu-pick { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.cu-pick-label { font-size: 12.5px; color: var(--warn); font-weight: 600; }
.cu-pick-label.ok { color: var(--text-muted); font-weight: 500; }
.cu-hint { font-size: 12px; color: var(--text-dim); }
.cu-map-row.is-default { opacity: 0.75; }
.cu-map-note { font-size: 11.5px; color: var(--text-dim); margin: 6px 0 0; }
.cu-select {
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.cu-select:focus { outline: none; border-color: var(--accent); }
.cu-linkinput {
  flex: 1 1 280px; min-width: 200px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-family: var(--mono);
}
.cu-linkinput:focus { outline: none; border-color: var(--accent); }

.cu-remember { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; user-select: none; }
.cu-remember input { accent-color: var(--accent); cursor: pointer; }

.cu-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 3px; }
.cu-actions .cu-spacer { flex: 1; }

.cu-empty { padding: 44px 20px; text-align: center; color: var(--text-dim); font-size: 14px; }

.cu-history { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 14px; }
.cu-history > summary { cursor: pointer; font-size: 13px; color: var(--text-muted); font-weight: 600; padding: 4px 0; }
.cu-history > summary:hover { color: var(--text); }
.cu-hist-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.cu-hist-row:last-child { border-bottom: none; }
.cu-hist-name { flex: 1 1 240px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
/* "#0004 The Title · same working file" — the matched script, kept on one line so a
   long title can't push the Not-a-duplicate button onto its own row. */
.cu-hist-row .cu-hint { flex: 0 1 auto; min-width: 0; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cu-maps { margin-top: 18px; }
.cu-maps h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.cu-map-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; color: var(--text-muted); }
.cu-map-row .cu-spacer { flex: 1; }

@media (max-width: 720px) {
  .cu-toolbar { align-items: flex-start; }
  .cu-chip.link { max-width: 100%; }
}

/* ----- Checklists ("/checklist"): <ul class="checklist"><li data-checked> ----- */
/* The box is drawn here, not an <input>; a mousedown on it toggles data-checked (app.js). */
ul.checklist, .content-editor ul.checklist, .nb-editor ul.checklist { list-style: none; padding-left: 2px; }
ul.checklist > li { position: relative; padding-left: 26px; }
ul.checklist > li::before {
  content: ''; position: absolute; left: 0; top: 0.3em; top: calc(0.5lh - 8px);
  width: 16px; height: 16px; box-sizing: border-box; border-radius: 4px;
  border: 1.5px solid var(--border-strong, var(--text-dim)); background: transparent;
  cursor: pointer; transition: background-color .12s ease, border-color .12s ease;
}
ul.checklist > li:hover::before { border-color: var(--accent); }
ul.checklist > li[data-checked="true"]::before {
  background: var(--accent) center / 12px 12px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  border-color: var(--accent);
}
ul.checklist > li[data-checked="true"] { color: var(--text-dim); text-decoration: line-through; }
/* Strike-through propagates into descendants and can't be switched off there, except that it
   never crosses into an inline-block — so a sub-list under a ticked item stays unstruck. */
ul.checklist > li[data-checked="true"] > ul, ul.checklist > li[data-checked="true"] > ol { display: inline-block; width: 100%; vertical-align: top; color: var(--text); text-decoration: none; }
/* Nesting: a saved doc nests the sub-list inside its <li> (already 26px in); Chrome's live
   Tab puts it directly inside the parent list, which needs the indent itself. */
ul.checklist > li > ul, ul.checklist > li > ol { margin: 0; }
ul.checklist > li > ul.checklist { padding-left: 0; }
ul.checklist > ul.checklist, ul.checklist > ul, ul.checklist > ol { margin: 0; padding-left: 26px; }

/* Left-edge drag handle for side chats that live in a grid/flex column (wiki, swipe).
   Sits over the pane's border so it adds no width of its own. */
.pane-grip { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 5; background: transparent; transition: background .12s; }
.pane-grip:hover, .pane-grip.dragging { background: var(--accent); }
@media (max-width: 760px) { .pane-grip { display: none; } }

/* ===================== Side dock (right pane) ===================== */
/* Fixed to the right edge and above the drawers; body.dock-open pushes the app AND the
   script editor left by the dock's width, so nothing sits underneath it. */
.side-dock { position: fixed; top: 0; right: 0; bottom: 0; width: var(--dock-w, 400px); z-index: 60; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,0.25); min-width: 0; }
.side-dock.hidden { display: none; }
body.dock-open .app { margin-right: var(--dock-w, 400px); }
body.dock-open .drawer { right: var(--dock-w, 400px); }
/* Each pane is its own block: a rounded card on the dock's darker backdrop, with a tinted
   title bar and a coloured top edge that says what it holds (blue = note, amber = script). */
.dock-slots { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow-y: auto; overscroll-behavior: contain; }
.dock-slot { --slot-tint: var(--accent); flex: 1 1 0; min-height: min(340px, 60vh); display: flex; flex-direction: column; position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)), rgb(23, 30, 45);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--glass-hi), var(--glass-shadow); transition: border-color 0.15s; }
.dock-slot[data-kind="script"] { --slot-tint: var(--warn); }
.dock-slot::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--slot-tint); opacity: 0.75; z-index: 1; }
.dock-slot:focus-within { border-color: var(--border-strong); }
.dock-slot:focus-within::before { opacity: 1; }
.dock-slot.collapsed { flex: 0 0 auto; min-height: 0; }
.dock-slot.collapsed .dock-slot-body { display: none; }
.dock-slot.flash .dock-slot-head { animation: dockFlash 0.9s ease; }
@keyframes dockFlash { 0% { background: var(--accent-soft); } 100% { background: var(--surface-2); } }
.dock-slot-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 8px 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); min-width: 0; }
.dock-slot.collapsed .dock-slot-head { border-bottom: none; }
.dock-slot-kind { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--slot-tint); background: color-mix(in srgb, var(--slot-tint) 16%, transparent); }
.dock-slot-kind svg { width: 14px; height: 14px; }
.dock-slot-names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dock-slot-title { font-size: 13px; font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.dock-slot-src { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-slot-status { font-size: 11px; color: var(--text-dim); flex: 0 0 auto; }
.dock-btn { flex: 0 0 auto; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; border: 1px solid transparent; background: none; color: var(--text-dim); cursor: pointer; font-size: 15px; line-height: 1; }
.dock-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.dock-btn-text { font-size: 11.5px; }
.dock-slot-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.dock-editor-host { min-height: 100%; display: flex; flex-direction: column; }
.dock-editor { flex: 1; min-height: 120px; padding: 14px 16px 24px; max-width: none; outline: none; overflow: visible; overflow-wrap: anywhere; }
.dock-lock { margin: 10px 14px 0; padding: 7px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--text-muted); font-size: 12px; }
.dock-lock.hidden { display: none; }
.dock-slot.locked .dock-editor { opacity: 0.75; }
@media (max-width: 760px) {
  body.dock-open .app { margin-right: 0; }
  body.dock-open .drawer { right: 0; }
  .side-dock { width: 100%; }
}

/* ===================== Client boards (Swipe File in client mode) ===================== */
body.dock-open .swipe-detail { right: var(--dock-w, 400px); }
.swipe-outlier { display: inline-flex; align-items: center; font-size: 11px; font-weight: 750; letter-spacing: 0.01em; padding: 1px 7px; border-radius: 6px; margin-left: 6px; vertical-align: 1px; background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }
.swipe-outlier.o-2 { background: rgba(29, 155, 240, 0.16); color: #58b4f5; border-color: rgba(29, 155, 240, 0.35); }
.swipe-outlier.o-5 { background: rgba(224, 163, 46, 0.18); color: #f0b545; border-color: rgba(224, 163, 46, 0.4); }
.swipe-outlier.o-10 { background: rgba(229, 72, 77, 0.2); color: #ff6b6f; border-color: rgba(229, 72, 77, 0.45); }
.swipe-outlier.on-thumb { position: absolute; left: 8px; top: 8px; margin: 0; backdrop-filter: blur(6px); background-color: rgba(0, 0, 0, 0.62); }
.swipe-yt-stats .sd-refresh-stats { margin-left: 8px; vertical-align: middle; }
.swipe-boxes { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 6px; }
.sd-tbox .note-box-head .swipe-copy-btn { flex: 0 0 auto; }
.sd-tbox .note-box-body { padding: 12px 14px; max-height: 60vh; overflow-y: auto; }
.swipe-boxes .swipe-transcript { border-top: none; padding-top: 0; margin-top: 0; }
.swipe-head-spacer { flex: 1; }
.swipe-script-name { font-size: 12.5px; font-weight: 650; color: var(--text-muted); margin: -2px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swipe-script-name:empty { display: none; }
.swipe-script-body h1, .swipe-script-body h2, .swipe-script-body h3, .swipe-script-body h4 { font-size: 14.5px; margin: 14px 0 6px; color: var(--text); }
.swipe-script-body ul, .swipe-script-body ol { padding-left: 22px; margin: 0 0 10px; }
.swipe-script-body { font-size: 13.5px; line-height: 1.7; color: var(--text); overflow-wrap: anywhere; }
.swipe-script-body p { margin: 0 0 10px; }
.swipe-script-empty { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 16px; color: var(--text-dim); font-size: 13px; }
.swipe-script-empty p { margin: 0 0 10px; }
.script-pick { z-index: 90; }
.script-pick-panel { width: min(560px, 100%); max-height: 80vh; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.script-pick-panel .drawer-head { display: flex; align-items: center; justify-content: space-between; }
.script-pick-q { width: 100%; }
.script-pick-list { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.script-pick-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; color: var(--text); cursor: pointer; }
.script-pick-row:hover { border-color: var(--accent); }
.script-pick-row.is-current { border-color: var(--accent); background: var(--accent-soft); }
.script-pick-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.script-pick-meta { font-size: 11.5px; color: var(--text-dim); }

/* ===================== System chat ===================== */
.sys-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; height: calc(100vh - 52px - var(--chrome-top)); }
.sys-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 12px; }
.sys-side-label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); margin-top: 6px; }
.sys-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sys-list-empty { font-size: 12.5px; color: var(--text-dim); padding: 4px 2px; }
.sys-list-row { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-size: 13px; }
.sys-list-row:hover { background: var(--surface-2); color: var(--text); }
.sys-list-row.active { background: var(--accent-soft); color: var(--text); }
.sys-list-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-list-del { opacity: 0; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px; }
.sys-list-row:hover .sys-list-del { opacity: 1; }
.sys-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.sys-head { flex: 0 0 auto; padding: 2px 4px 12px; }
.sys-head h2 { font-size: 20px; margin: 0 0 4px; }
.sys-head p { margin: 0; color: var(--text-muted); font-size: 13px; max-width: 760px; }
.sys-body { display: flex; flex-direction: column; gap: 2px; }
.sys-body .sys-text { margin-top: 6px; }
#sys-input { font-family: inherit; }
.sys-tool.is-staged .sys-tool-dot { background: #e0a32e; }
.sys-tool { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--text-muted); padding: 3px 0; min-width: 0; }
.sys-tool-dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); transform: translateY(-1px); }
.sys-tool.is-error .sys-tool-dot { background: #e5484d; }
.sys-tool.is-write .sys-tool-dot { background: #18b663; }
.sys-tool-label { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.sys-tool-detail { color: var(--text-dim); font-size: 11.5px; overflow-wrap: anywhere; }
.sys-tool.is-error .sys-tool-detail { color: #ff8a8d; }
.sys-sync { align-self: flex-start; margin-top: 4px; }
.sys-pending { flex: 0 0 auto; max-height: 45vh; overflow-y: auto; border: 1px solid rgba(224, 163, 46, 0.45); background: rgba(224, 163, 46, 0.07); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.sys-pending.hidden { display: none; }
.sys-pending-head { font-size: 12.5px; font-weight: 650; color: #f0b545; }
.sys-edit { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.sys-edit-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.sys-edit-path { font-family: var(--mono); font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; }
.sys-edit-new { font-size: 10.5px; padding: 1px 6px; border-radius: 5px; background: rgba(24, 182, 99, 0.15); color: #3fd58a; }
.sys-edit-spacer { flex: 1; }
.sys-edit-diff { border-top: 1px solid var(--border); max-height: 380px; overflow: auto; font-family: var(--mono); font-size: 12px; }
.sys-edit-diff.hidden { display: none; }
.sys-edit-diff .diff-text { white-space: pre; }
.diff-skip .diff-text { color: var(--text-dim); font-style: italic; }
@media (max-width: 760px) {
  .sys-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: calc(100dvh - 76px); }
  .sys-side { max-height: 140px; }
}

/* Boards box on a client's Overview */
.ob-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 0; }
.ob-chips:empty { display: none; }
.ob-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); border-radius: 16px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; }
.ob-chip span { color: var(--text-dim); font-size: 11px; }
.ob-chip:hover { color: var(--text); border-color: var(--border-strong); }
.ob-chip.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.ob-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 14px 16px 16px; align-items: start; }
@media (max-width: 1280px) { .ob-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .ob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .ob-grid { grid-template-columns: 1fr; } }
/* Full titles in the Overview box: no line clamp. */
.ob-card .swipe-yt-title { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; white-space: normal; }
.ob-grid .notes-empty { grid-column: 1 / -1; padding: 0; }
.ob-card { cursor: pointer; }
.ob-more { grid-column: 1 / -1; justify-self: center; }

/* =======================================================================
   PROSE LINKS, CODE-BLOCK COPY, DIVIDER
   ======================================================================= */

/* Hyperlinks inside prose: chat answers, the script/note editors, wiki pages.
   Grey + underline rather than the brand blue, which was hard to pick out against
   the blue-accented chrome. The editors and the wiki had NO rule at all before this
   and fell through to the browser's default #0000EE on a near-black background.
   Scoped to prose containers on purpose — the button- and card-shaped links
   (.embed-card.link a, .content-link, .wiki-detail-source, .chan-visit, …) keep
   their own colors, and each of those selectors outranks these on specificity. */
.msg-body a,
.content-editor a,
.nb-editor a,
.wiki-detail-body a,
.swipe-msg.bot a,
.chat-md a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 2px;
}
.msg-body a:hover,
.content-editor a:hover,
.nb-editor a:hover,
.wiki-detail-body a:hover,
.swipe-msg.bot a:hover,
.chat-md a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}
/* The link CARD's inner anchor is not prose — it keeps the card styling above. */
.embed-card.link a, .embed-card.link a:hover { text-decoration: none; color: var(--text); }

/* Copy button on every rendered code block. Answers often contain a block that is
   awkward to select by hand, so the button is faintly visible at rest (not
   hover-only) and comes forward on hover. */
.msg-body pre, .wiki-detail-body pre, .swipe-msg.bot pre { position: relative; }
.code-copy {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center;
  width: 24px; height: 24px; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text-dim); cursor: pointer; opacity: 0.55;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s; padding: 0;
}
pre:hover > .code-copy { opacity: 1; }
.code-copy:hover { color: var(--text); border-color: var(--border-strong); }
.code-copy svg { width: 13px; height: 13px; }
/* Keep the button clear of the first line of code. */
.msg-body pre code, .wiki-detail-body pre code, .swipe-msg.bot pre code { display: block; padding-right: 30px; }

/* Divider block (/divider, or "---" typed on its own line). */
.content-editor hr, .nb-editor hr {
  border: 0; border-top: 1px solid var(--border-strong);
  margin: 18px 0; height: 0;
}

/* A branded dropdown whose underlying <select> is disabled (e.g. Effort on a model
   that has no effort parameter). */
.dd-trigger.is-disabled { opacity: 0.45; cursor: not-allowed; }

/* ===================== Code blocks in the editors ===================== */
/* Wraps instead of scrolling sideways, so the Copy tag in the corner stays put. */
pre.ed-code {
  position: relative; margin: 10px 0; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--mono); font-size: 0.88em; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
}
pre.ed-code code { display: block; min-height: 1.55em; font: inherit; color: inherit; background: none; padding: 0; border: 0; white-space: inherit; }
pre.ed-code b, pre.ed-code strong, pre.ed-code i, pre.ed-code em { font: inherit; }
/* The language when there is one; "Copy" on hover. Clicks are read by position in app.js. */
pre.ed-code::after {
  content: attr(data-lang); position: absolute; top: 5px; right: 7px;
  font: 600 10.5px/1 var(--sans); letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim);
  padding: 5px 8px; border: 1px solid transparent; border-radius: 6px;
}
pre.ed-code:hover::after {
  content: 'Copy'; letter-spacing: 0; text-transform: none; cursor: pointer;
  color: var(--text-muted); background: var(--surface-3); border-color: var(--border);
}

/* ===================== Card detail: media | transcript reader | side panel ===================== */
:root {
  --hl-1: rgba(250, 204, 21, 0.30);  --hl-1-dot: #facc15;
  --hl-2: rgba(52, 211, 153, 0.28);  --hl-2-dot: #34d399;
  --hl-3: rgba(96, 165, 250, 0.32);  --hl-3-dot: #60a5fa;
  --hl-4: rgba(244, 114, 182, 0.30); --hl-4-dot: #f472b6;
  --hl-5: rgba(251, 146, 60, 0.32);  --hl-5-dot: #fb923c;
}
/* A container, so the layout reacts to the room it actually has: the side dock takes
   400px off the right edge without the viewport changing. */
.swipe-detail { container-type: inline-size; container-name: sdetail; }
.swipe-detail.has-reader .swipe-detail-main { flex: 0 0 clamp(280px, 30%, 460px); border-right: 1px solid var(--border); }
.swipe-detail.has-reader .swipe-detail-inner { max-width: none; padding: 20px 18px 40px; }
.swipe-detail-reader { flex: 1 1 0; min-width: 0; overflow-y: auto; padding: 22px 28px 80px; }
.swipe-detail-reader.hidden { display: none; }
.swipe-detail-reader > .swipe-transcript, .swipe-detail-reader > .swipe-boxes { max-width: 720px; margin: 0 auto; border-top: none; padding-top: 0; }
.swipe-detail-reader .swipe-transcript-body { font-size: 14.5px; line-height: 1.75; }
.swipe-detail-reader .swipe-section-head .swipe-copy-btn { margin-left: auto; }
.sd-follow { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; font-size: 11px; font-weight: 600; color: var(--good); }
.sd-follow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.sd-follow.hidden { display: none; }

/* Side panel tabs. Close lives at the end of the row: there is no top bar. */
.sd-tabs { flex: none; display: flex; align-items: center; gap: 2px; padding: 6px 8px 0 10px; border-bottom: 1px solid var(--border); }
.sd-tab { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-family: var(--sans); font-size: 12.5px; font-weight: 600; padding: 9px 10px 10px; cursor: pointer; }
.sd-tab:hover { color: var(--text); }
.sd-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.sd-tab.hidden { display: none; }
.sd-tab svg { width: 14px; height: 14px; }
.sd-tab-count { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sd-tab-count:empty { display: none; }
.sd-tabs .drawer-close { margin-left: auto; padding: 2px 8px 6px; border-radius: 8px; cursor: pointer; }
.sd-tabs .drawer-close:hover { color: var(--text); }
.sd-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sd-pane.hidden { display: none; }

/* Transcript paragraphs, highlights and the paragraph being spoken. */
.tr-p { border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background 0.2s, box-shadow 0.2s; }
.tr-p.now { background: rgba(255, 255, 255, 0.07); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.07); }
mark.hl { color: inherit; border-radius: 3px; padding: 1px 0; cursor: pointer; }
.hl-1 { background: var(--hl-1); } .hl-2 { background: var(--hl-2); } .hl-3 { background: var(--hl-3); } .hl-4 { background: var(--hl-4); } .hl-5 { background: var(--hl-5); }
.hl-dot.hl-1 { background: var(--hl-1-dot); } .hl-dot.hl-2 { background: var(--hl-2-dot); } .hl-dot.hl-3 { background: var(--hl-3-dot); } .hl-dot.hl-4 { background: var(--hl-4-dot); } .hl-dot.hl-5 { background: var(--hl-5-dot); }
::highlight(sd-sel) { background: rgba(29, 155, 240, 0.35); }
@keyframes sdFlash { 0%, 55% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.sd-flash { animation: sdFlash 1.3s ease-out; }
@media (prefers-reduced-motion: reduce) { .sd-flash { animation: none; outline: 2px solid var(--accent); } }

/* The floating colour bar. Built on .dd-menu, laid out as one row. */
.hl-bar { flex-direction: row; align-items: center; gap: 6px; padding: 6px 8px; min-width: 0; max-height: none; overflow: visible; border-radius: 12px; }
.hl-dot { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; }
.hl-dot:hover, .hl-dot.on { border-color: var(--text); }
.hl-bar-sep { width: 1px; align-self: stretch; background: var(--border-strong); margin: 0 2px; }
.hl-bar-btn { background: none; border: none; color: var(--text-muted); font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 5px 8px; border-radius: 7px; white-space: nowrap; cursor: pointer; }
.hl-bar-btn:hover { background: var(--surface-3); color: var(--text); }
.hl-bar-btn.del:hover { color: #e5484d; }

/* Highlights tab. */
.hl-list { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hl-note { flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 10px; display: flex; flex-direction: column; gap: 7px; }
.hl-quote { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-align: left; border: none; border-radius: 5px; padding: 3px 6px; color: var(--text); font-family: var(--sans); font-size: 12.5px; line-height: 1.5; cursor: pointer; }
.hl-quote:hover { filter: brightness(1.2); }
.hl-comment { resize: none; overflow: hidden; min-height: 28px; background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.5; padding: 3px 5px; }
.hl-comment:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.hl-comment::placeholder { color: var(--text-dim); }
.hl-foot { display: flex; align-items: center; gap: 5px; }
.hl-foot .hl-dot { width: 13px; height: 13px; border-width: 1.5px; }
.hl-time { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-right: 4px; font-variant-numeric: tabular-nums; }
.hl-del { margin-left: auto; background: none; border: none; color: var(--text-dim); font-family: var(--sans); font-size: 11.5px; padding: 2px 4px; border-radius: 5px; cursor: pointer; }
.hl-del:hover { color: #e5484d; }

/* The passage the chat will be asked about. */
.sd-sel-chip { flex: none; display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 6px 8px 6px 10px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 9px; font-size: 12px; min-width: 0; }
.sd-sel-chip.hidden { display: none; }
.sd-sel-label { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.sd-sel-text { flex: 1; min-width: 0; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-sel-chip button { flex: none; background: none; border: none; color: var(--text-dim); font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 5px; cursor: pointer; }
.sd-sel-chip button:hover { color: var(--text); }
.swipe-msg-re { margin-top: 6px; padding-top: 5px; border-top: 1px solid rgba(29, 155, 240, 0.25); font-size: 11.5px; color: var(--text-muted); white-space: normal; }

/* A paragraph's time badge: click to play from there. Drawn from data-t by CSS, so it adds
   no text to the transcript (highlight offsets depend on that). */
.tr-t { all: unset; display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 600; line-height: 1.4; color: var(--text-dim); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; margin-right: 7px; vertical-align: 1px; cursor: pointer; user-select: none; font-variant-numeric: tabular-nums; transition: color 0.12s, border-color 0.12s; }
.tr-t::before { content: attr(data-t); }
.tr-t:hover { color: var(--accent); border-color: var(--accent); }
.tr-p.now .tr-t { color: var(--text); }

/* Pop out. The main window keeps the media alone (has-reader is dropped, so the default
   one-column layout centres it) under a strip that says where the rest went. */
.swipe-detail.popped .swipe-detail-reader, .swipe-detail.popped .swipe-detail-aside { display: none; }
.swipe-detail.popped .swipe-detail-inner { max-width: 960px; }
.sd-popped { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 14px; font-size: 12.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--surface); }
.sd-popped.hidden { display: none; }
.sd-popped-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; color: var(--text-muted); font-family: var(--sans); font-size: 11.5px; font-weight: 600; padding: 3px 9px; cursor: pointer; }
.sd-popped-btn:hover { color: var(--text); border-color: var(--border-strong); }
.sd-popped .drawer-close { margin-left: 6px; padding: 2px 8px; border-radius: 8px; cursor: pointer; }
.sd-tabs .sd-popout { margin-left: auto; padding: 4px 8px; }
.sd-tabs .sd-popout + .drawer-close { margin-left: 0; }
.sd-popout svg { width: 14px; height: 14px; }

/* The pop-out window itself: only the card detail, with the reader and side panel filling
   it. Hide the app chrome by name — the highlight bar, toasts and drawers are appended to
   body at runtime and must stay visible. */
body.pane-mode > .app, body.pane-mode > #side-dock, body.pane-mode > #mobile-tabbar, body.pane-mode > #nav-scrim { display: none !important; }
body.pane-mode .swipe-detail { right: 0 !important; }
body.pane-mode .swipe-detail-main { display: none; }
body.pane-mode .swipe-detail-reader { flex: 1 1 0; }
body.pane-mode .swipe-detail-aside { width: clamp(360px, 40%, 520px); }
body.pane-mode #sd-popout { display: none; }

/* Not enough room for three columns: the media folds above the reader. */
@container sdetail (max-width: 1180px) {
  .swipe-detail.has-reader .swipe-detail-cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto minmax(0, 1fr); }
  .swipe-detail.has-reader .swipe-detail-main { grid-column: 1; grid-row: 1; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .swipe-detail.has-reader .swipe-detail-inner { max-width: 440px; margin: 0 auto; padding: 14px 18px; }
  .swipe-detail.has-reader .embed-frame-tall { max-height: 42vh; }
  .swipe-detail.has-reader .swipe-detail-reader { grid-column: 1; grid-row: 2; }
  .swipe-detail.has-reader .swipe-detail-aside { grid-column: 2; grid-row: 1 / span 2; width: auto; }
}
@media (max-width: 860px) {
  .swipe-detail.has-reader .swipe-detail-cols { display: flex; flex-direction: column; overflow-y: auto; }
  .swipe-detail.has-reader .swipe-detail-main, .swipe-detail.has-reader .swipe-detail-reader { flex: none; overflow: visible; }
  .swipe-detail.has-reader .swipe-detail-aside { flex: none; width: 100%; height: 70vh; }
}

/* ===================== "@" references: mention menu, chips, dock panes ===================== */
/* The dropdown: 5 rows max, title + source subheader. Sits above the card detail overlay (70). */
.ref-menu { min-width: 280px; max-width: 420px; max-height: none; z-index: 260; }
.ref-opt { justify-content: flex-start; align-items: center; gap: 10px; white-space: normal; padding: 7px 10px; }
.ref-opt::before { display: none; }
.ref-opt > svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-muted); }
.ref-opt.hl, .ref-opt:hover { background: var(--accent-soft); }
.ref-opt.hl > svg { color: var(--text); }
.ref-opt-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.ref-opt-title { font-size: 12.5px; font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-opt-sub { font-size: 11px; font-weight: 500; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-opt-sub em { font-style: normal; margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-dim); font-size: 10px; }
.ref-opt.dim .ref-opt-title { color: var(--text-muted); }
.ref-opt-empty { padding: 8px 11px; font-size: 12px; color: var(--text-dim); }
#ref-mirror { position: absolute; top: 0; left: -9999px; visibility: hidden; white-space: pre-wrap; overflow-wrap: break-word; pointer-events: none; }

/* The inserted reference: a pill, same everywhere it renders. Double-click opens the pane. */
a.ref-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; vertical-align: baseline; margin: 0 1px; padding: 1px 8px 1px 6px;
  border-radius: 999px; background: var(--accent-soft); border: 1px solid rgba(29,155,240,0.3); color: var(--text); text-decoration: none;
  font-size: 0.92em; font-weight: 600; line-height: 1.5; cursor: default; user-select: all; -webkit-user-select: all; }
a.ref-chip > svg { width: 12px; height: 12px; flex: 0 0 auto; color: var(--accent); }
a.ref-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ref-chip:hover { border-color: var(--accent); }
/* A link chip: the same pill for an outside URL (YouTube, a web page), title fetched by the server. */
a.link-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; vertical-align: baseline; margin: 0 1px; padding: 1px 8px 1px 6px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none;
  font-size: 0.92em; font-weight: 600; line-height: 1.5; cursor: pointer; user-select: all; -webkit-user-select: all; }
a.link-chip > svg { width: 12px; height: 12px; flex: 0 0 auto; color: var(--text-muted); }
a.link-chip[data-chip-kind="youtube"] > svg { color: #ff4d4d; }
a.link-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
a.link-chip[data-untitled] > span { color: var(--text-muted); }
a.link-chip:hover { border-color: var(--border-strong); }
a.ref-chip[data-ref-kind="swipe"] > svg { color: #ff5c5c; }
.msg-user .msg-body a.ref-chip { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.45); color: #fff; }
.msg-user .msg-body a.ref-chip > svg { color: #fff; }
.content-editor a.ref-chip, .nb-editor a.ref-chip { text-decoration: none; }

/* Dock panes opened from a reference */
.dock-slot[data-kind="script-final"] { --slot-tint: var(--warn); }
.dock-slot[data-kind="swipe"] { --slot-tint: #ff5c5c; }
.dock-final { padding: 14px 16px 24px; font-size: 13.5px; line-height: 1.65; overflow-wrap: anywhere; }
.dock-final p { margin: 0 0 10px; }
.dock-final h1, .dock-final h2, .dock-final h3 { font-size: 14px; margin: 14px 0 6px; }
.dock-final ul, .dock-final ol { margin: 4px 0 10px; padding-left: 20px; }
.dock-empty { padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--text-muted); font-size: 12.5px; }
.dock-swipe { padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 10px; }
.dock-swipe-media .embed-frame { border-radius: 10px; overflow: hidden; }
.dock-swipe-media .embed-frame-tall { max-height: 52vh; }
.dock-swipe-media .swipe-yt-thumb img, .dock-swipe-media .swipe-art-thumb img, .dock-swipe-media .swipe-post-images img { width: 100%; border-radius: 10px; display: block; }
.dock-swipe-meta { font-size: 12px; color: var(--text-muted); }
.dock-swipe .swipe-post-caption { font-size: 13px; white-space: pre-wrap; }
.dock-swipe .sd-tbox { margin: 0; }
.dock-swipe .sd-tbox .note-box-body { padding: 10px 12px; }
.dock-transcript { font-size: 13px; line-height: 1.65; max-height: 44vh; overflow-y: auto; }
.dock-swipe-notes-h { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); margin: 4px 0 6px; }
.dock-swipe .swipe-notes-wrap { display: flex; flex-direction: column; gap: 8px; }

/* ----- dock bar: one pill per open pane + collapse/expand/close all ----- */
.dock-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px 0; min-width: 0; }
.dock-bar:empty { display: none; }
.dock-pills { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.dock-pills::-webkit-scrollbar { display: none; }
.dock-pill { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; max-width: 160px; padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-family: var(--sans); font-size: 11.5px; font-weight: 600; cursor: pointer; transition: color .1s, border-color .1s; }
.dock-pill svg { width: 12px; height: 12px; flex: 0 0 auto; color: var(--accent); }
.dock-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-pill:hover { color: var(--text); border-color: var(--border-strong); }
.dock-pill.is-collapsed { opacity: 0.6; }
.dock-pill.is-collapsed svg { color: var(--text-dim); }
.dock-bar-tools { flex: 0 0 auto; display: flex; gap: 2px; }
.dock-slot-head { cursor: default; }

/* ============================ Spaces ============================ */
/* The swipe panel in Spaces mode: the YouTube/Reels toggle and the board picker's board
   semantics give way to a space switcher and a Board | Graph view toggle. */
#space-view-toggle { display: none; }
#tab-swipe.spaces-mode #swipe-space-toggle { display: none; }
#tab-swipe.spaces-mode #space-view-toggle { display: inline-flex; }
.space-graph { display: none; flex: 1; min-height: 0; }
#tab-swipe.spaces-mode.view-graph .space-graph { display: block; }
#tab-swipe.spaces-mode.view-graph .swipe-scroll,
#tab-swipe.spaces-mode.view-graph #swipe-chips { display: none; }
.space-graph .wiki-layout { height: 100%; }
/* A client's wiki as a board (#tab-swipe.wiki-board-mode): Spaces chrome, no space switcher caret. */
#tab-swipe.wiki-board-mode .swipe-title-caret { opacity: .55; }
.space-graph .wiki-mapbar-title h2 { font-size: 15px; }
.swipe-add-wrap { position: relative; }
.swipe-add-wrap .swipe-menu { left: auto; right: 0; min-width: 220px; }
.swipe-menu .swipe-board.disabled { opacity: .5; cursor: default; }
.swipe-menu .swipe-board-hint { font-size: 11.5px; color: var(--text-dim); margin-left: auto; }
.swipe-menu .swipe-menu-title { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); padding: 6px 10px 2px; }
.swipe-kind-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.swipe-kind-tag svg { width: 12px; height: 12px; }
.swipe-wiki-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); margin: 0 6px; flex: 0 0 8px; }
.swipe-wiki-dot.pending, .swipe-wiki-dot.staged, .swipe-wiki-dot.none { background: #e0a32e; }
.swipe-wiki-dot.stale { background: #6e8bff; }
.swipe-wiki-dot.failed { background: #e5484d; }
/* PDF / email / document tiles */
.swipe-pdf-cover { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.swipe-pdf-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.swipe-pdf-glyph { display: grid; place-items: center; gap: 8px; color: var(--text-dim); }
.swipe-pdf-glyph svg { width: 42px; height: 42px; }
.swipe-pdf-glyph span { font-size: 11.5px; font-weight: 650; letter-spacing: .06em; }
.swipe-pdf-pages { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff; font-size: 11px; font-weight: 650; padding: 2px 6px; border-radius: 6px; }
.swipe-doc-body, .swipe-email-body { padding: 12px 14px 8px; }
.swipe-doc-title, .swipe-email-subject { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; margin: 4px 0 6px; }
.swipe-doc-excerpt, .swipe-email-excerpt { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.swipe-email-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.swipe-email-head .swipe-avatar { width: 22px; height: 22px; font-size: 10px; }
.swipe-email-from { font-weight: 650; color: var(--text); }
.swipe-email-date { margin-left: auto; white-space: nowrap; }
.swipe-doc-foot, .swipe-email-foot, .swipe-pdf-foot { padding: 0 14px 10px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-dim); }
/* Detail view extras */
.sd-pdf-frame { width: 100%; height: calc(100vh - 140px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
/* The header block above a wide reader (email: From / To / Subject / Date; article or Substack
   post: who, where, when, title). The original sits right under it. */
.sd-rich-head { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 14px; font-size: 13px; }
.sd-email-head dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; }
.sd-email-head dt { color: var(--text-dim); } .sd-email-head dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.sd-rich-head .swipe-post-head .swipe-avatar { width: 34px; height: 34px; }
.sd-rich-head .swipe-post-name { font-size: 14px; }
.sd-rich-head .swipe-post-meta { font-size: 12px; margin-top: 1px; }
.sd-rich-title { font-size: 17px; font-weight: 700; line-height: 1.3; color: var(--text); margin-top: 10px; }
/* Wide reader: an email, an article or a Substack post reads in one column, as wide as the
   view. The media column is not shown; the side panel stays. */
.swipe-detail.wide-mode .swipe-detail-main { display: none; }
.swipe-detail.wide-mode .swipe-detail-reader { flex: 1 1 0; padding: 22px 32px 80px; }
.swipe-detail.wide-mode .swipe-detail-reader > .swipe-transcript { max-width: none; }
/* The rich reader: the email or post as it was sent, in a sandboxed frame; Original | Text. */
.sd-rich { display: block; width: 100%; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); min-height: 160px; }
.swipe-detail-reader.has-rich.rich-text .sd-rich { display: none; }
.swipe-detail-reader.has-rich:not(.rich-text) .swipe-transcript-body { display: none; }
.sd-view-toggle { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); margin-left: auto; }
.sd-view-btn { background: none; border: none; color: var(--text-dim); font-family: var(--sans); font-size: 12px; font-weight: 650; padding: 4px 11px; border-radius: 7px; cursor: pointer; transition: background 0.12s, color 0.12s; }
.sd-view-btn:hover { color: var(--text); }
.sd-view-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16); }
.swipe-detail-reader .sd-view-toggle + .swipe-copy-btn { margin-left: 8px; }
.sd-reader-note { font-size: 12px; color: var(--text-dim); margin: -2px 0 10px; }
/* Home card chips */
.spaces-card-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.spaces-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px 4px 8px; font-size: 12px; color: var(--text); cursor: pointer; }
.spaces-chip:hover { border-color: var(--accent); }
.spaces-chip .n { color: var(--text-dim); }
.note-card-space { font-size: 11px; color: var(--accent); margin-top: 3px; }
/* Email modal */
.modal-hint { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.modal-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.modal-row .spacer { flex: 1; }
#email-modal .modal-panel { width: min(640px, 100%); }
#email-text { width: 100%; font-family: var(--mono, ui-monospace, monospace); font-size: 12.5px; line-height: 1.5; resize: vertical; }

/* ============================ PDF e-reader ============================ */
.swipe-detail.pdf-mode.has-reader .swipe-detail-main { flex: 0 0 clamp(220px, 22%, 320px); }
.swipe-detail.pdf-mode .swipe-detail-reader { padding: 0; display: flex; flex-direction: column; background: var(--surface-2); }
.pdf-reader { display: flex; flex-direction: column; min-height: 100%; }
.pdf-toolbar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-dim); }
.pdf-pageno { display: inline-flex; align-items: center; gap: 5px; }
.pdf-page-input { width: 52px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 3px 6px; font-size: 12.5px; text-align: center; }
.pdf-tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.pdf-zoom-pct { min-width: 42px; text-align: center; }
.pdf-status { margin-left: auto; font-size: 11.5px; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px 12px 80px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.35); overflow: hidden; }
.pdf-page canvas { display: block; }
/* pdf.js text layer: transparent glyph boxes over the canvas so text can be selected. */
.pdf-page .textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; text-align: initial; }
.pdf-page .textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.pdf-page .textLayer ::selection { background: rgba(70, 140, 255, .38); }
.pdf-page .textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: -1; cursor: default; user-select: none; }
.pdf-hl-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pdf-hl { position: absolute; border-radius: 2px; mix-blend-mode: multiply; opacity: .55; }
.pdf-hl.hl-1 { background: #ffe066; } .pdf-hl.hl-2 { background: #8ce99a; } .pdf-hl.hl-3 { background: #74c0fc; } .pdf-hl.hl-4 { background: #faa2c1; } .pdf-hl.hl-5 { background: #ffc078; }
.pdf-hl.flash { outline: 2px solid var(--accent); }
/* Dock pane pop-out */
.dock-btn-pop svg { width: 13px; height: 13px; }
.dock-slot.popped .dock-slot-body { display: none; }
.dock-popped { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--text-dim); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.dock-popped span { flex: 1; }
body.pane-dock > .app, body.pane-dock > #mobile-tabbar, body.pane-dock > #nav-scrim, body.pane-dock #dock-bar { display: none !important; }
body.pane-dock .side-dock { position: fixed; inset: 0; width: auto !important; box-shadow: none; border-left: none; }
body.pane-dock .dock-slot { min-height: 100vh; border-radius: 0; }
body.pane-dock .dock-btn-collapse { display: none; }

/* PDF detail = the reader + the side panel, nothing else. */
.swipe-detail.pdf-mode .swipe-detail-main { display: none; }
.swipe-detail.pdf-mode .swipe-detail-reader { flex: 1 1 0; }
.pdf-title { font-weight: 650; color: var(--text); max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-status.warn { color: #e0a32e; }
.swipe-menu-ico { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; color: var(--text-dim); }
.swipe-menu-ico svg { width: 14px; height: 14px; }
.swipe-board-right button svg { width: 13px; height: 13px; display: block; }
/* PDF selection hygiene: only the text layers are selectable, and while dragging the
   end-of-content block covers the page so the selection cannot leap to another span. */
.pdf-pages { user-select: none; -webkit-user-select: none; }
.pdf-page .textLayer { user-select: text; -webkit-user-select: text; }
.pdf-page .textLayer.selecting .endOfContent { top: 0; }
.pdf-page .textLayer .endOfContent { z-index: 0; }
.pdf-page .textLayer :is(span, br) { z-index: 1; }
.pdf-page .textLayer span::selection { background: rgba(70, 140, 255, .38); color: transparent; }

/* Document / PDF / email tiles share .swipe-card-body with every other tile. */
.swipe-doc-text { display: flex; flex-direction: column; gap: 5px; }
.swipe-doc-title, .swipe-email-subject { margin: 0; }
.swipe-doc-foot, .swipe-email-foot, .swipe-pdf-foot { padding: 0; margin-top: 2px; }
.swipe-doc-body, .swipe-email-body { padding: 0; }
.swipe-email-head { margin-bottom: 2px; }
.swipe-card-actions .act-save.saved { color: var(--accent); }
.swipe-card-actions .act-save.busy { color: var(--text-dim); opacity: .55; cursor: progress; }
.swipe-wiki-dot.filing { background: #6e8bff; animation: wikiPulse 1.2s ease-in-out infinite; }
@keyframes wikiPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Home documents: one folder per space that holds a document. The folder row has its own
   classes on purpose: the sidebar's rail mode hides and centres .archive-* labels. */
.notes-grid.grouped { display: flex; flex-direction: column; gap: 8px; padding: 6px 16px 16px; }
.home-docs-folder { display: flex; flex-direction: column; }
.home-docs-head { display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); cursor: pointer; }
.home-docs-head:hover { border-color: var(--text-dim); }
.home-docs-head:hover .home-docs-name { color: var(--accent); }
.home-docs-folder.open .home-docs-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.home-docs-caret { display: inline-block; width: 12px; text-align: center; font-size: 13px; color: var(--text-muted); transition: transform 0.14s ease; }
.home-docs-head.open .home-docs-caret { transform: rotate(90deg); }
.home-docs-folder-ico { display: inline-flex; color: var(--accent); }
.home-docs-folder-ico svg { display: block; }
.home-docs-name { font-size: 14.5px; font-weight: 700; color: var(--text); }
.home-docs-count { margin-left: 2px; font-size: 11.5px; font-weight: 500; color: var(--text-dim); }
.home-docs-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 10px 0 6px; }
.home-docs-body.hidden { display: none; }

/* ----- Fix tools (Proofread / Fix AI writing): the review card in the Edit chat ----- */
::highlight(fix-flash) { background: rgba(29, 155, 240, 0.38); }
.msg-body.fix-card { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.fix-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 10px; }
.fix-title { flex: 1 1 140px; min-width: 0; }
.fix-title { font-size: 13px; line-height: 1.45; }
.fix-title strong { font-weight: 700; }
.fix-title-sub { display: block; color: var(--text-muted); font-size: 12px; }
.fix-head-actions, .fix-foot { display: flex; gap: 6px; flex: 0 0 auto; }
.fix-btn { background: transparent; border: 1px solid var(--border-strong); color: var(--text); font-family: var(--sans); font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 7px; white-space: nowrap; transition: background 0.1s, border-color 0.1s; }
.fix-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.fix-rows { display: flex; flex-direction: column; margin: 10px 0 4px; border-top: 1px solid var(--border); }
.fix-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--border); }
.fix-change { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; background: none; border: 0; padding: 0; text-align: left; color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.5; cursor: pointer; }
.fix-change:hover .fix-del, .fix-change:hover .fix-add { filter: brightness(1.15); }
.fix-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); font-weight: 700; }
.fix-del { color: #ffb4b4; background: rgba(255, 90, 90, 0.13); text-decoration: line-through; text-decoration-thickness: 1.5px; padding: 0 4px; border-radius: 4px; }
.fix-add { color: #7fe0a8; background: rgba(24, 182, 99, 0.14); padding: 0 4px; border-radius: 4px; }
.fix-row.applied .fix-change .fix-del, .fix-row.undone .fix-change .fix-add { opacity: 0.45; }
.fix-row:hover { background: var(--accent-soft); border-radius: 6px; }
.fix-state { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.fix-row.applied .fix-state { color: #7fe0a8; background: rgba(24, 182, 99, 0.14); }
.fix-row.undone .fix-state { color: #ffb4b4; background: rgba(255, 90, 90, 0.13); }
.fix-link.primary { color: var(--accent); }
.fix-toggle { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.fix-switch { width: 30px; height: 17px; border-radius: 999px; background: var(--border-strong); border: 0; position: relative; padding: 0; flex: none; transition: background 0.15s; }
.fix-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.fix-switch.on { background: var(--accent); }
.fix-switch.on::after { left: 15px; }
/* The marks inside the editor: red = what the tool removed (skipped on save), green = what it wrote. */
.content-editor del.fx-del { background: rgba(255, 90, 90, 0.16); color: #ffb4b4; text-decoration: line-through; text-decoration-color: #ff6b6b; text-decoration-thickness: 1.5px; padding: 0 3px; border-radius: 4px; user-select: none; }
.content-editor ins.fx-add { background: rgba(24, 182, 99, 0.18); color: #8fe6b4; text-decoration: none; padding: 0 3px; border-radius: 4px; }
.content-editor del.fx-del + ins.fx-add { margin-left: 2px; }
.content-editor .fx-hot { outline: 2px solid var(--accent); outline-offset: 1px; }
.content-editor.fx-hide del.fx-del { display: none; }
.content-editor.fx-hide ins.fx-add { background: transparent; color: inherit; padding: 0; }
.fix-arrow { display: inline-flex; color: var(--text-dim); align-self: center; }
.fix-count { font-size: 11px; color: var(--text-muted); }
.fix-row-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.fix-link { background: none; border: 0; color: var(--text-muted); font-family: var(--sans); font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.fix-link:hover { color: var(--text); background: var(--accent-soft); }
.fix-link.on { color: var(--accent); }
.fix-empty { padding: 8px 2px; color: var(--text-dim); font-size: 12.5px; }
.fix-notes { margin-top: 8px; font-size: 12.5px; color: var(--text-muted); }
.fix-notes-h { font-weight: 700; color: var(--text); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.fix-notes ul { margin: 0; padding-left: 18px; }
.fix-meta { margin-top: 8px; font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }
.fix-foot { margin-top: 10px; }
.fix-pointers-pop { width: min(420px, calc(100vw - 16px)); max-height: none; padding: 12px; gap: 8px; }
.fix-pointers-h { font-size: 13px; font-weight: 700; }
.fix-pointers-sub { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.fix-pointers-ta { width: 100%; min-height: 120px; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-family: var(--sans); font-size: 13px; line-height: 1.5; }
.fix-pointers-ta:focus { outline: none; border-color: var(--accent); }
.fix-pointers-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fix-pointers-actions .btn-ghost, .fix-pointers-actions .btn-primary { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; }
/* The folder row is a band, so the space name reads as the title of everything under it. */
.home-docs-folder { gap: 0; }
.home-docs-folder + .home-docs-folder { border-top: none; margin-top: 8px; padding-top: 0; }
.home-docs-head { width: 100%; justify-content: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 0; }
.home-docs-head:hover { background: var(--surface-3, var(--surface-2)); border-color: var(--text-dim); }
.home-docs-head .archive-head-label { font-size: 14.5px; }
.home-docs-folder.open .home-docs-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.home-docs-body { padding: 10px 0 6px; }


/* ============================ Discover (Eden) ============================ */
.nav-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--surface-3); color: var(--text-dim); vertical-align: 1px; }
.nav-item.active .nav-tag { background: var(--accent-soft); color: var(--accent); }
.main.rail .nav-tag { display: none; }
#tab-discover { min-height: 0; }
.dc-main { display: flex; flex-direction: column; height: calc(100vh - 52px - var(--chrome-top)); min-height: 0; container-type: inline-size; }
.dc-head { margin-bottom: 12px; }
.dc-toolbar { margin-bottom: 10px; }
.dc-search { min-width: 220px; position: relative; }
.dc-q-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 0 6px; }
.dc-q-btn:hover { color: var(--text); }
.dc-chips { padding-bottom: 12px; }
.dc-scroll { flex: 1; }
.dc-card { cursor: pointer; }
.dc-card .swipe-reel-thumb, .dc-card .swipe-yt-thumb { position: relative; }
.dc-card .swipe-outlier.on-thumb { position: absolute; left: 8px; top: 8px; }
.dc-card .swipe-post-head .swipe-outlier { margin-left: auto; }
.dc-clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.dc-notice { color: var(--text-dim); font-size: 12.5px; padding: 10px 2px; flex-basis: 100%; }
.dc-footer { color: var(--text-dim); font-size: 12px; padding: 18px 2px 6px; }
.dock-discover .dock-swipe-media img { width: 100%; border-radius: 10px; display: block; }
.dock-discover .dock-swipe-media.dc-tall img { max-height: 52vh; width: auto; margin: 0 auto; }
.dc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.dc-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.dc-tile-k { font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); }
.dc-tile-v { font-size: 15px; font-weight: 650; }
.dc-desc { font-size: 12.5px; color: var(--text-muted); }
.dc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dc-tag { cursor: default; padding: 4px 10px; font-size: 11.5px; }
.dc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dc-actions a.btn-ghost { text-decoration: none; }
.dc-post .swipe-transcript-body { max-height: 40vh; overflow: auto; white-space: pre-wrap; }
