:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: #101216;
  --panel-2: #15181d;
  --line: #272b32;
  --line-soft: #1d2026;
  --text: #f4f2ed;
  --muted: #979ba4;
  --text-soft: #cbd2da;
  --text-faint: #737985;
  --surface: #12151a;
  --surface-raised: #171a1f;
  --surface-inset: #0c0e11;
  --surface-deep: #090b0e;
  --control: #15191f;
  --graph-bg: #0d0f12;
  --node-ring: #0d0f12;
  --scroll-thumb: #353942;
  --shadow: rgba(0, 0, 0, .38);
  --on-accent: #0f1318;
  --accent: #aeb7c2;
  --accent-dark: #20252c;
  --danger: #ff6b6b;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 28rem),
    var(--bg);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 72px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 10px;
}

.settings-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel-2);
  cursor: pointer;
}

.settings-button:hover,
.settings-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.settings-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.session-title-control {
  flex: 1 1000 auto;
  min-width: 0;
  text-align: center;
  overflow: hidden;
}

.session-title-control .eyebrow {
  margin-bottom: 2px;
  font-size: 8px;
}

.session-title-row {
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.session-title-row h1 {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-title-edit {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.session-title-edit:hover,
.session-title-edit:focus-visible {
  border-color: var(--line);
  color: var(--accent);
  background: #15181d;
  outline: none;
}

.session-title-edit svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.session-title-input {
  width: min(42vw, 520px);
  padding: 6px 9px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  background: #111419;
  text-align: center;
  outline: none;
}

.credit-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.credit-control strong { color: var(--accent); }

.credit-control button,
.credit-control a {
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.credit-control .credit-balance-button {
  border-color: var(--line);
  color: var(--muted);
  background: #13161a;
  font-weight: 600;
}

.upgrade-promo {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 50;
  width: min(320px, calc(100vw - 36px));
  display: flex;
  gap: 12px;
  padding: 16px 16px 16px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 16px;
  background:
    radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--surface-raised);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  animation: promo-in .35s ease;
}
@keyframes promo-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.upgrade-promo-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  color: var(--text-faint);
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.upgrade-promo-close:hover { color: var(--text); }
.upgrade-promo-spark {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.upgrade-promo-spark::before { content: "\2726"; color: var(--accent); font-size: 15px; }
.upgrade-promo-body { min-width: 0; }
.upgrade-promo-body strong { display: block; font-size: 14px; letter-spacing: -.01em; }
.upgrade-promo-body p { margin: 4px 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.upgrade-promo-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.upgrade-promo-cta:hover { text-decoration: underline; }
@media (max-width: 560px) { .upgrade-promo { left: 12px; right: 12px; bottom: 12px; width: auto; } }
@media (prefers-reduced-motion: reduce) { .upgrade-promo { animation: none; } }

.history-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #13161a;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.history-button:hover { border-color: #4b515b; }

.more-control {
  position: relative;
  flex: 0 0 auto;
}

.more-button { white-space: nowrap; }

.more-button[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 60px var(--shadow);
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.more-menu-item:hover,
.more-menu-item:focus-visible {
  border-color: var(--line);
  background: var(--surface-raised);
  outline: none;
}

.more-menu-link {
  text-decoration: none;
}

.more-menu-accent { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.plans-menu-icon {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
}

.admin-icon {
  position: relative;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 22%, 100% 60%, 50% 100%, 0 60%, 0 22%);
}

.history-icon {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}

.history-icon::before {
  content: "";
  position: absolute;
  width: 4px;
  height: 3px;
  left: 5px;
  top: 2px;
  border-left: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
}

.assets-icon {
  position: relative;
  width: 13px;
  height: 13px;
}

.assets-icon::before,
.assets-icon::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
}

.assets-icon::before { left: 0; top: 2px; }
.assets-icon::after { left: 4px; top: 0; }

.export-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.export-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 6px solid var(--accent);
}
.export-icon::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 5px;
  border: 1.5px solid var(--accent);
  border-top: none;
  border-radius: 0 0 2px 2px;
}

.api-keys-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.api-keys-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.api-keys-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 4.75px;
  width: 7px;
  height: 1.5px;
  background: var(--accent);
  box-shadow: -1px 4px 0 -0.25px var(--accent);
}

.webhooks-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.webhooks-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.webhooks-icon::after {
  content: "";
  position: absolute;
  left: 5.75px;
  top: 5.75px;
  width: 1.5px;
  height: 1.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 -4px 0 var(--accent), 3px 2.5px 0 var(--accent), -3px 2.5px 0 var(--accent);
}

.presets-icon {
  width: 13px;
  height: 13px;
  background: var(--accent);
  clip-path: polygon(58% 0, 0 60%, 40% 60%, 36% 100%, 100% 40%, 58% 40%);
}

.timeline-icon {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
}
.timeline-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-left: 5px solid var(--accent);
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
}

.collab-icon {
  position: relative;
  width: 13px;
  height: 12px;
  border: 1.5px solid var(--accent);
  border-radius: 4px 4px 4px 0;
}
.collab-icon::before {
  content: "";
  position: absolute;
  left: -1.5px;
  bottom: -4px;
  width: 0;
  height: 0;
  border-left: 4px solid var(--accent);
  border-bottom: 4px solid transparent;
}
.collab-icon::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 3px;
  width: 7px;
  border-top: 1.5px solid var(--accent);
  box-shadow: 0 3px 0 -0.25px var(--accent);
}

.more-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.more-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 5px 0 0 var(--accent), 10px 0 0 var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand-mark, .message-symbol {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-weight: 900;
}

.brand-mark {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, var(--accent) 44%, transparent);
  color: transparent;
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, #62c8ff 20%, transparent) 0 28%, transparent 58%),
    linear-gradient(145deg, #222831, #10151c 56%, #0b0d10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 12px 30px rgba(0, 0, 0, .28);
  font-size: 0;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: 1;
  background: url("/icons/graph-galaxy-symbol.svg") center / contain no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .42));
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 9px;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, #62c8ff 12%, transparent) 0 18%, transparent 19%);
  opacity: .64;
}

.message-symbol {
  color: var(--on-accent);
  background: var(--accent);
}

.brand > span:last-child { min-width: 0; }
.brand strong, .brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand strong { letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.backend-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot, .mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #777;
}

.backend-status.ready .status-dot {
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 52%, transparent);
}

.backend-status.warning .status-dot {
  background: #f2b84b;
  box-shadow: 0 0 10px rgba(242, 184, 75, .45);
}

.backend-status.error .status-dot { background: var(--danger); }

.workspace {
  --conversation-width: 420px;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px var(--conversation-width);
  gap: 4px;
  padding: 16px;
}

.workspace-splitter {
  position: relative;
  z-index: 8;
  min-height: 0;
  cursor: col-resize;
  touch-action: none;
}

.workspace-splitter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 4px;
  height: 64px;
  border-radius: 999px;
  background: #30353d;
  transform: translateY(-50%);
  transition: background .15s, height .15s;
}

.workspace-splitter:hover::after,
.workspace-splitter:focus-visible::after,
.workspace-splitter.dragging::after {
  height: 88px;
  background: var(--accent);
  outline: none;
}

.canvas-panel, .conversation-panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.canvas-panel {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
}

.canvas-toolbar, .conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(20px, 2.1vw, 30px); letter-spacing: -.04em; }
h2 { font-size: 19px; letter-spacing: -.025em; }

.toolbar-actions { display: flex; align-items: center; gap: 8px; }

.drop-zone {
  min-height: 0;
  margin: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #343942;
  border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.018) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.018) 75%),
    linear-gradient(45deg, rgba(255,255,255,.018) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.018) 75%),
    #0c0e11;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  transition: border-color .2s, background-color .2s, transform .2s;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background-color: var(--accent-dark);
  transform: scale(.995);
}

.empty-state {
  max-width: 430px;
  padding: 60px 30px;
  text-align: center;
}

.empty-state h2 { margin-top: 20px; font-size: 24px; }
.empty-state p { margin: 10px 0 22px; color: var(--muted); line-height: 1.6; }
.empty-state small { display: block; margin-top: 13px; color: #6f747d; }

.intro-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 22px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s, transform .18s, background-color .18s;
}

.intro-card:hover,
.intro-card:focus-visible {
  border-color: var(--accent);
  background: var(--surface-raised);
  transform: translateY(-2px);
  outline: none;
}

.intro-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--accent);
  background: var(--accent-dark);
  font-size: 22px;
}

.intro-card strong { font-size: 15px; }
.intro-card small { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.intro-back {
  align-self: flex-start;
  margin-bottom: 6px;
  padding: 0;
  border: none;
  color: var(--muted);
  background: none;
  cursor: pointer;
  font-size: 12px;
}

.intro-back:hover { color: var(--text); }

.intro-name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px auto 18px;
  max-width: 320px;
  text-align: left;
}

.intro-name-field span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.intro-name-field input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #12151a;
  font-size: 13px;
}

.intro-name-field input:focus {
  border-color: var(--accent);
  outline: none;
}

.intro-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.upload-icon {
  position: relative;
  width: 66px;
  height: 66px;
  margin: auto;
  border: 1px solid #3b4049;
  border-radius: 19px;
  background: #171a1f;
}

.upload-icon::before {
  content: "↑";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 28px;
  font-weight: 300;
}

.image-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  gap: 1px;
  background: var(--line-soft);
}

.image-stage.comparing {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.image-frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0c0e11;
}

.image-frame img,
.image-frame video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 230px);
  object-fit: contain;
  transition: opacity .2s;
  background: #090b0e;
}

.canvas-text {
  width: min(760px, 88%);
  max-height: calc(100vh - 270px);
  margin: 0;
  padding: 28px;
  overflow: auto;
  border: 1px solid #323842;
  border-radius: 14px;
  color: #e8ebef;
  background: #12151a;
  font: 14px/1.7 Inter, ui-sans-serif, system-ui, sans-serif;
  white-space: normal;
}

.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 14px; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 18px 0 8px;
  color: var(--text);
  line-height: 1.25;
}
.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body strong { color: #fff; font-weight: 800; }
.markdown-body em { color: #cbd2da; }
.markdown-body ul,
.markdown-body ol { margin: 8px 0 16px; padding-left: 24px; }
.markdown-body li { margin: 5px 0; }
.markdown-body code {
  padding: 2px 5px;
  border: 1px solid #343b45;
  border-radius: 5px;
  color: var(--accent);
  background: #0b0d10;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.markdown-body pre {
  margin: 12px 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #343b45;
  border-radius: 9px;
  background: #090b0e;
}
.markdown-body pre code { padding: 0; border: 0; color: #e8ebef; }
.markdown-body a { color: #79d6ff; }

.current-frame.document-source-view {
  --document-summary-width: 42%;
  grid-template-columns:
    minmax(240px, var(--document-summary-width))
    7px
    minmax(320px, 1fr);
  align-items: stretch;
  gap: 0;
}
.current-frame.document-reader-only {
  display: block;
  overflow: hidden;
}
.current-frame.document-reader-only .document-reader { height: 100%; }

.current-frame.document-source-view .canvas-text {
  width: auto;
  max-height: calc(100vh - 230px);
  margin: 18px;
}

.document-splitter {
  position: relative;
  z-index: 6;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  background: #181c22;
  touch-action: none;
}
.document-splitter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 3px;
  height: 42px;
  border-radius: 999px;
  background: #59616d;
  transform: translateY(-50%);
}
.document-splitter:hover::after,
.document-splitter.dragging::after { background: var(--accent); }

.document-reader {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  overflow: auto;
  background: #080a0c;
  user-select: none;
}

.document-reader > header {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: rgba(8,9,11,.94);
  backdrop-filter: blur(10px);
  font-size: 10px;
}

.document-reader-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.document-reader-controls button,
.document-reader-controls select {
  height: 26px;
  border: 1px solid #343a43;
  border-radius: 6px;
  color: var(--text);
  background: #15191f;
  font-size: 9px;
}
.document-reader-controls button { width: 28px; padding: 0; cursor: pointer; }
.document-reader-controls button:disabled { opacity: .35; cursor: default; }
.document-reader-controls label {
  display: flex;
  align-items: center;
  gap: 5px;
}
.document-reader-controls select { padding: 0 6px; }
.document-reader-controls > span { min-width: 48px; text-align: center; }

.document-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 18px;
}

.document-page {
  position: relative;
  width: min(760px, 96%);
  aspect-ratio: var(--page-ratio);
  border: 1px solid #343a43;
  box-shadow: 0 14px 34px rgba(0,0,0,.38);
  color: #171a1d;
  background: #f7f6f1;
  overflow: hidden;
}
.document-pages.single-page .document-page { display: none; }
.document-pages.single-page .document-page.page-visible { display: block; }

.image-frame .document-page-image {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: fill;
  background: transparent;
  transition: none;
  user-select: none;
  pointer-events: none;
}

.document-page-number {
  position: absolute;
  z-index: 3;
  right: 8px;
  bottom: 6px;
  color: #777;
  font-size: 8px;
}

.pdf-text-block {
  position: absolute;
  z-index: 2;
  padding: 0;
  color: transparent;
  font-family: Arial, sans-serif;
  font-size: clamp(4px, .55vw, 9px);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}

.pdf-text-block.selection-active {
  outline: 1px solid rgba(55,145,255,.42);
  background: rgba(91,170,255,.28);
}

.pdf-node-region {
  position: absolute;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  border-radius: 3px;
  pointer-events: none;
}
.pdf-node-region.node-focus {
  outline: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.pdf-node-region.node-related { background: rgba(98,200,255,.12); }

.pdf-annotation {
  position: absolute;
  z-index: 1;
  border-radius: 2px;
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: box-shadow .15s ease;
}
.pdf-annotation.has-note {
  border-bottom: 2px solid rgba(40,40,40,.55);
}
.pdf-annotation.active {
  box-shadow: 0 0 0 2px rgba(40,40,40,.65);
}
.pdf-annotation.flash {
  animation: pdfAnnotationFlash 1.1s ease;
}
@keyframes pdfAnnotationFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
  20% { box-shadow: 0 0 0 3px rgba(40,40,40,.8); }
  60% { box-shadow: 0 0 0 3px rgba(40,40,40,.4); }
}

.pdf-selection-popover {
  position: fixed;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid #2b323c;
  border-radius: 11px;
  background: rgba(14,16,20,.97);
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  backdrop-filter: blur(8px);
}
.pdf-selection-popover.hidden { display: none; }
.pdf-popover-colors {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-right: 8px;
  border-right: 1px solid #2b323c;
}
.pdf-color-swatch {
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.pdf-color-swatch:hover { transform: scale(1.12); }
.pdf-color-swatch.active {
  box-shadow: 0 0 0 2px rgba(255,255,255,.85);
}
.pdf-popover-buttons { display: flex; gap: 5px; }
.pdf-popover-buttons button {
  height: 26px;
  padding: 0 10px;
  border: 1px solid #343a43;
  border-radius: 7px;
  color: var(--text);
  background: #1b2027;
  font-size: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
.pdf-popover-buttons button:hover { background: #232a33; }
.pdf-popover-buttons button[data-action="highlight"] {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
}

.pdf-toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 9px 15px;
  border: 1px solid #2b323c;
  border-radius: 999px;
  color: var(--text);
  background: rgba(14,16,20,.97);
  box-shadow: 0 10px 26px rgba(0,0,0,.45);
  font-size: 11px;
  opacity: 1;
  transition: opacity .25s ease;
}
.pdf-toast.hidden { opacity: 0; pointer-events: none; }

.document-notes-panel {
  position: absolute;
  z-index: 7;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(320px, 82%);
  border-left: 1px solid var(--line);
  background: rgba(10,12,15,.98);
  box-shadow: -14px 0 34px rgba(0,0,0,.42);
}
.document-notes-panel.hidden { display: none; }
.document-notes-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
}
.document-notes-actions { display: flex; align-items: center; gap: 6px; }
.document-notes-actions button {
  height: 26px;
  padding: 0 10px;
  border: 1px solid #343a43;
  border-radius: 7px;
  color: var(--text);
  background: #15191f;
  font-size: 10px;
  cursor: pointer;
}
.document-notes-actions button:hover { background: #1d232b; }
#documentNotesClose { width: 26px; padding: 0; font-size: 14px; line-height: 1; }

.document-notes-list {
  flex: 1;
  overflow: auto;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.document-notes-empty {
  margin: 18px 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.document-note {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #12151a;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.document-note:hover { background: #161a20; }
.document-note.active { border-color: var(--accent); }
.document-note-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}
.document-note-color {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 50%;
  cursor: pointer;
  flex: none;
}
.document-note-page {
  padding: 2px 7px;
  border: 1px solid #343a43;
  border-radius: 6px;
  color: var(--accent);
  background: transparent;
  font-size: 9px;
  cursor: pointer;
}
.document-note-spacer { flex: 1; }
.document-note-action {
  padding: 2px 7px;
  border: 1px solid #343a43;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  cursor: pointer;
}
.document-note-action:hover { color: var(--text); background: #1b2027; }
.document-note-action.danger:hover {
  color: #ff8f6b;
  border-color: rgba(255,143,107,.5);
}
.document-note-quote {
  margin: 0 0 7px;
  padding: 5px 9px;
  border-left: 2px solid var(--accent);
  color: #cbd2da;
  background: rgba(255,255,255,.03);
  font-size: 10px;
  line-height: 1.5;
  max-height: 74px;
  overflow: hidden;
}
.document-note-input {
  width: 100%;
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid #343a43;
  border-radius: 8px;
  color: var(--text);
  background: #0b0d10;
  font: 11px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  resize: vertical;
}
.document-note-input:focus {
  outline: none;
  border-color: var(--accent);
}

.notes-toggle.active {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent) !important;
  color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 10%, transparent) !important;
}
.document-reader-controls .notes-toggle {
  width: auto;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.notes-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  color: #0b0d10;
  background: var(--accent);
  font-size: 8px;
  font-weight: 700;
}
.notes-toggle:not(.active) .notes-count { background: #343a43; color: var(--text); }

.selection-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  gap: 10px;
  margin: 10px 10px 0;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.selection-context strong,
.selection-context small { display: block; }
.selection-context strong { color: var(--accent); font-size: 10px; }
.selection-context small {
  max-height: 34px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}
.selection-context button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: #1b2027;
  cursor: pointer;
}

.canvas-audio {
  width: min(560px, 82%);
  padding: 18px;
  border: 1px solid #323842;
  border-radius: 14px;
  background: #15191f;
}

/* --- Canvas annotations -------------------------------------------------- */
.canvas-anno-layer {
  position: absolute;
  z-index: 7;
  /* left/top/width/height set in JS to match the displayed media box */
}
.canvas-anno-layer.hidden { display: none; }

.canvas-anno-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.canvas-anno-layer.tool-select .canvas-anno-surface { cursor: default; }

.canvas-anno-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.canvas-anno-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0c0e11;
  border-radius: 999px;
  color: #0c0e11;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
  transition: transform .12s ease;
}
.canvas-anno-marker:hover,
.canvas-anno-marker.active { transform: translate(-50%, -50%) scale(1.18); }
.canvas-anno-marker.has-note::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid #0c0e11;
}
/* While a drawing tool is active the markers must not steal the pointer. */
.canvas-anno-layer:not(.tool-select) .canvas-anno-marker { pointer-events: none; }

.canvas-anno-toolbar {
  position: absolute;
  z-index: 9;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  padding: 7px 9px;
  border: 1px solid #313741;
  border-radius: 14px;
  background: rgba(14, 17, 21, .94);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  flex-wrap: wrap;
  justify-content: center;
}
.canvas-anno-toolbar.hidden { display: none; }

.canvas-anno-tools { display: inline-flex; gap: 3px; }
.canvas-anno-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #c2c9d2;
  background: transparent;
  font: 700 11px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}
.canvas-anno-tool span { font-size: 14px; line-height: 1; }
.canvas-anno-tool:hover { color: var(--text); background: #1b2027; }
.canvas-anno-tool.active {
  color: #0c0e11;
  background: var(--accent);
  border-color: var(--accent);
}

.canvas-anno-divider { width: 1px; height: 22px; background: #2c323b; }

.canvas-anno-colors { display: inline-flex; gap: 4px; }
.canvas-anno-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}
.canvas-anno-swatch.active { border-color: #fff; }

.canvas-anno-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.canvas-anno-size.hidden { display: none; }
.canvas-anno-size input { width: 92px; accent-color: var(--accent); }

.canvas-anno-mini,
.canvas-anno-done {
  height: 30px;
  padding: 0 11px;
  border: 1px solid #313741;
  border-radius: 9px;
  color: #c2c9d2;
  background: #15191f;
  font: 800 11px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}
.canvas-anno-mini.hidden { display: none; }
.canvas-anno-mini:hover,
.canvas-anno-done:hover { color: var(--text); border-color: var(--accent); }
.canvas-anno-mini.primary {
  color: #0c0e11;
  background: var(--accent);
  border-color: var(--accent);
}
.canvas-anno-count { color: var(--muted); font-size: 11px; font-weight: 700; }

/* Keyboard focus rings for the annotation toolbar (roving-tabindex controls). */
.canvas-anno-tool:focus-visible,
.canvas-anno-swatch:focus-visible,
.canvas-anno-mini:focus-visible,
.canvas-anno-done:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.canvas-notes-panel {
  position: absolute;
  z-index: 8;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--canvas-notes-w, min(300px, 45%));
  display: flex;
  flex-direction: column;
  border-left: 1px solid #232830;
  background: rgba(12, 14, 17, .92);
  backdrop-filter: blur(12px);
}
.canvas-notes-panel.hidden { display: none; }
/* While the comments panel is open we reserve its width so the media (and the
   drawing surface over it) shifts clear of the panel instead of hiding under
   it. The toolbar re-centers over the remaining media area. */
.current-frame.canvas-annotating {
  --canvas-notes-w: min(300px, 45%);
  padding-right: var(--canvas-notes-w);
}
.current-frame.canvas-annotating .canvas-anno-toolbar {
  left: calc((100% - var(--canvas-notes-w)) / 2);
}
.canvas-notes-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #232830;
}
.canvas-notes-panel > header strong { font-size: 13px; }
.canvas-notes-panel > header button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}
.canvas-notes-panel > header button:hover { color: var(--text); background: #1b2027; }

.canvas-notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.canvas-notes-empty {
  margin: 18px 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.canvas-note {
  padding: 10px;
  border: 1px solid #262c34;
  border-radius: 11px;
  background: #12151a;
  cursor: pointer;
}
.canvas-note.active { border-color: var(--accent); }
.canvas-note-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.canvas-note-color {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}
.canvas-note-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.canvas-note-spacer { flex: 1; }
.canvas-note-action {
  padding: 3px 7px;
  border: 1px solid #2c333d;
  border-radius: 7px;
  color: #c2c9d2;
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.canvas-note-action:hover { color: var(--text); border-color: var(--accent); }
.canvas-note-action.danger { color: #ff9b9b; }
.canvas-note-action.danger:hover { border-color: #ff9b9b; }
.canvas-note-input {
  width: 100%;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid #2a313b;
  border-radius: 8px;
  color: var(--text);
  background: #0d1014;
  font: 12px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  resize: vertical;
}
.canvas-note-input:focus { outline: none; border-color: var(--accent); }

.canvas-inpaint {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid #232830;
  background: rgba(8, 10, 13, .55);
}
.canvas-inpaint.hidden { display: none; }
.canvas-inpaint-go {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  color: var(--on-accent);
  background: var(--accent);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: filter .12s ease, opacity .12s ease;
}
.canvas-inpaint-go:hover:not(:disabled) { filter: brightness(1.06); }
.canvas-inpaint-go:disabled { opacity: .45; cursor: not-allowed; }
.canvas-inpaint-go.ghost {
  width: auto;
  flex-shrink: 0;
  color: #c2c9d2;
  background: transparent;
  border-color: #2c333d;
}
.canvas-inpaint-go.ghost:hover:not(:disabled) {
  filter: none;
  color: var(--text);
  border-color: var(--accent);
}
.canvas-inpaint-out {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.canvas-inpaint-dir {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.canvas-inpaint-dir > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.canvas-inpaint-dir select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #2a313b;
  border-radius: 8px;
  color: var(--text);
  background: #0d1014;
  font: 11px Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}
.canvas-inpaint-dir select:focus { outline: none; border-color: var(--accent); }
.canvas-inpaint-out input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.canvas-inpaint-hint {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

:root[data-theme="light"] .canvas-anno-toolbar {
  border-color: #d3d8e0;
  background: rgba(255, 255, 255, .95);
}
:root[data-theme="light"] .canvas-anno-tool { color: #3a4250; }
:root[data-theme="light"] .canvas-anno-tool:hover { background: #eef1f5; }
:root[data-theme="light"] .canvas-anno-mini,
:root[data-theme="light"] .canvas-anno-done {
  color: #3a4250;
  background: #f2f4f7;
  border-color: #d3d8e0;
}
:root[data-theme="light"] .canvas-anno-divider { background: #d8dde4; }
:root[data-theme="light"] .canvas-notes-panel {
  border-color: #e2e6ec;
  background: rgba(248, 250, 252, .95);
}
:root[data-theme="light"] .canvas-notes-panel > header { border-color: #e2e6ec; }
:root[data-theme="light"] .canvas-note { border-color: #e2e6ec; background: #fff; }
:root[data-theme="light"] .canvas-note-input {
  color: #1a1f27;
  background: #fff;
  border-color: #d8dde4;
}
:root[data-theme="light"] .canvas-inpaint {
  border-color: #e2e6ec;
  background: rgba(255, 255, 255, .6);
}
:root[data-theme="light"] .canvas-inpaint-go.ghost {
  color: #3a4250;
  background: #f2f4f7;
  border-color: #d3d8e0;
}
:root[data-theme="light"] .canvas-inpaint-dir select {
  color: #1a1f27;
  background: #fff;
  border-color: #d8dde4;
}
:root[data-theme="light"] .canvas-anno-marker { border-color: #fff; color: #0c0e11; }

.image-frame-label {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  color: var(--text);
  background: rgba(8, 9, 11, .78);
  backdrop-filter: blur(10px);
  font-size: 10px;
  font-weight: 750;
}

.working-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(8, 9, 11, .72);
  backdrop-filter: blur(8px);
}

.image-stage.merge-preview .working-overlay {
  background: rgba(8, 9, 11, .46);
  backdrop-filter: blur(3px);
}

.working-overlay span { color: var(--muted); font-size: 13px; }
.working-overlay small { color: #777e88; font-size: 10px; }

.working-stream {
  width: min(620px, 86%);
  max-height: 42%;
  margin-top: 6px;
  padding: 12px 16px;
  overflow-y: auto;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  background: rgba(18, 20, 24, .72);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}

.working-stream::after {
  content: "▍";
  margin-left: 1px;
  color: var(--accent, #aeb7c2);
  animation: stream-caret 1s steps(1) infinite;
}

@keyframes stream-caret {
  50% { opacity: 0; }
}

.generation-progress {
  width: min(280px, 58%);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #30353d;
}

.generation-progress span {
  width: 2%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 68%, #606975), var(--accent));
  transition: width 1s linear;
}

.empty-state .generation-progress {
  margin: 16px auto 0;
}

.file-signal {
  --signal-color: var(--signal-color-dark, var(--accent));
  --signal-secondary: var(--signal-secondary-dark, #62c8ff);
  width: min(390px, 78vw);
  margin: 0 auto 4px;
  color: var(--signal-color);
}

.file-signal svg {
  width: 100%;
  height: 92px;
  display: block;
  overflow: visible;
}

.nn-edge-base {
  stroke: color-mix(in srgb, var(--signal-color) 16%, transparent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.nn-edge-pulse {
  fill: none;
  stroke: var(--signal-secondary);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-dasharray: 14 86;
  opacity: .92;
  filter: drop-shadow(0 0 3px var(--signal-secondary));
  animation: nn-pulse-travel linear infinite;
}

.nn-node {
  fill: var(--signal-color);
  filter: drop-shadow(0 0 4px var(--signal-color));
  animation: nn-node-fire ease-in-out infinite;
}

.nn-node.out {
  fill: var(--signal-secondary);
  filter: drop-shadow(0 0 5px var(--signal-secondary));
}

.file-signal > span {
  display: block;
  margin-top: -7px;
  color: var(--signal-color);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .18em;
  text-align: center;
}

.file-signal.compact {
  width: 150px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.file-signal.compact svg {
  width: 88px;
  height: 30px;
}

.file-signal.compact > span {
  margin: 0;
  font-size: 8px;
  letter-spacing: .08em;
}

.canvas-footer.file-signal-active {
  min-height: clamp(280px, 43vh, 520px);
  justify-content: center;
  padding: 24px 5%;
}

.canvas-footer.file-signal-active #imageMeta {
  width: 100%;
  display: grid;
  place-items: center;
}

.file-signal.canvas-signal {
  width: min(1100px, 92%);
  margin: 0;
}

.file-signal.canvas-signal svg {
  height: clamp(180px, 28vh, 330px);
}

.file-signal.canvas-signal > span {
  margin-top: -18px;
  font-size: 11px;
  letter-spacing: .24em;
}

.file-signal.ingest-signal {
  width: min(360px, 78%);
  margin: 0 auto 18px;
}

.file-signal.ingest-signal svg {
  height: clamp(96px, 16vh, 150px);
}

.file-signal.working-signal {
  width: min(320px, 74%);
  margin: 2px auto 6px;
}

.file-signal.working-signal svg {
  height: clamp(88px, 14vh, 130px);
}

.ingest-network,
.working-network {
  display: grid;
  place-items: center;
  width: 100%;
}

@keyframes nn-pulse-travel {
  from { stroke-dashoffset: 100; }
  to { stroke-dashoffset: -100; }
}

@keyframes nn-node-fire {
  0%, 100% { opacity: .5; }
  45% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .nn-edge-pulse,
  .nn-node {
    animation: none;
  }
  .nn-edge-pulse { opacity: .6; }
  .nn-node { opacity: .9; }
}

.node-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #12151a;
}

.node-detail-title {
  font-size: 16px;
  letter-spacing: -.01em;
  color: var(--text);
}

.node-detail-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.node-detail-label {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.node-detail-block p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.node-detail-block .markdown-body {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.concept-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.concept-list dt {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.concept-list dd {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.node-detail-label.whatif-label { color: #ff9393; }

.exclusion-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.exclusion-chip {
  padding: 4px 10px;
  border: 1px solid rgba(255,107,107,.4);
  border-radius: 999px;
  color: #ffb3b3;
  background: rgba(255,107,107,.08);
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.exclusion-chip:hover,
.exclusion-chip:focus-visible {
  border-color: rgba(255,107,107,.7);
  background: rgba(255,107,107,.16);
  color: #ffd0d0;
  outline: none;
}

.node-detail-empty {
  color: #6f747d;
  font-size: 13px;
}
.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 8px;
  border: 3px solid #333840;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.timeline-panel {
  min-width: 0;
  max-width: 100%;
  position: relative;
  overflow: hidden;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line-soft);
  background: #0d0f12;
}

.timeline-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.timeline-heading > div:first-child {
  min-width: 0;
}

.timeline-heading strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-heading-tools {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  gap: 12px;
}

.timeline-heading-tools > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-zoom-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #343a43;
  border-radius: 8px;
  background: #15181d;
}

.timeline-zoom-controls button {
  min-width: 28px;
  height: 27px;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid #343a43;
  color: #d7dbe1;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.timeline-zoom-controls button:hover:not(:disabled),
.timeline-zoom-controls button:focus-visible {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  outline: none;
}

.timeline-zoom-controls button:disabled {
  color: #5e646d;
  cursor: default;
}

.timeline-zoom-controls span {
  min-width: 45px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.timeline-zoom-controls .timeline-fit-button {
  min-width: 38px;
  border-right: 0;
  border-left: 1px solid #343a43;
  font-size: 9px;
  font-weight: 750;
}

/* Semantic graph layout controls: mode switch + cluster toggle. */
.graph-layout-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.graph-mode-toggle {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #343a43;
  border-radius: 8px;
  background: #15181d;
}

.graph-mode-toggle button {
  height: 27px;
  padding: 0 10px;
  border: 0;
  color: #aab2bd;
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.graph-mode-toggle button + button {
  border-left: 1px solid #343a43;
}

.graph-mode-toggle button:hover {
  color: #e4e8ee;
}

.graph-mode-toggle button.active {
  color: #0d0f12;
  background: var(--accent);
}

.graph-tool-button {
  height: 27px;
  padding: 0 11px;
  border: 1px solid #343a43;
  border-radius: 8px;
  color: #aab2bd;
  background: #15181d;
  cursor: pointer;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.graph-tool-button:hover {
  color: #e4e8ee;
  border-color: #475061;
}

.graph-tool-button.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Translucent halos drawn behind clusters of related nodes. */
.graph-cluster-layer .cluster-hull {
  fill: var(--cluster-color);
  fill-opacity: .07;
  stroke: var(--cluster-color);
  stroke-opacity: .42;
  stroke-width: 1.5;
  stroke-dasharray: 7 6;
  pointer-events: none;
}

.graph-cluster-layer .cluster-hull-label {
  fill: var(--cluster-color);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .82;
  pointer-events: none;
}

/* Per-node collapse / expand control for branches. */
.timeline-collapse-button {
  z-index: 3;
  position: absolute;
  top: 11px;
  right: 2px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #4a535f;
  border-radius: 50%;
  color: #dce3eb;
  background: #161b21;
  box-shadow: 0 0 0 2px #0d0f12;
  cursor: pointer;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.timeline-collapse-button:hover,
.timeline-collapse-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.timeline-collapse-button.collapsed {
  min-width: 16px;
  width: auto;
  padding: 0 3px;
  border-radius: 8px;
  border-color: var(--accent);
  color: var(--accent);
  background: #1a2108;
}

/* Minimap overview pinned to the corner of the graph viewport. */
.graph-minimap {
  z-index: 5;
  position: absolute;
  right: 26px;
  bottom: 30px;
  width: 168px;
  height: 108px;
  padding: 0;
  border: 1px solid #343a43;
  border-radius: 8px;
  background: rgba(13, 15, 18, .82);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
  backdrop-filter: blur(4px);
}

.graph-minimap.hidden {
  display: none;
}

.graph-minimap-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.graph-minimap-edge {
  stroke: #454c57;
  stroke-width: 1;
}

.graph-minimap-node {
  fill: #6b7280;
}

.graph-minimap-node.active {
  fill: var(--accent);
}

.graph-minimap-viewport {
  fill: color-mix(in srgb, var(--accent) 12%, transparent);
  stroke: var(--accent);
  stroke-width: 1.2;
  rx: 2;
}

.timeline-resizer {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 12px;
  margin: 4px -18px -10px;
  cursor: ns-resize;
  touch-action: none;
}

.timeline-resizer::before {
  content: "";
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: #2c3038;
  transition: background .15s, width .15s;
}

.timeline-resizer:hover::before,
.timeline-resizer:focus-visible::before,
.timeline-resizer.dragging::before {
  background: var(--accent);
  width: 64px;
  outline: none;
}

.timeline-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: 360px;
  overflow: auto;
  padding: 2px 5px 6px;
  cursor: grab;
  scrollbar-color: #353942 transparent;
  touch-action: none;
  user-select: none;
}

.timeline-scroll.panning {
  cursor: grabbing;
}

.timeline-scroll.panning * {
  cursor: grabbing !important;
}

.timeline-scroll button {
  cursor: pointer;
}

.timeline-track {
  position: relative;
  min-width: 100%;
  padding: 0 4px;
}

.timeline-graph {
  position: relative;
  min-height: 82px;
  transform-origin: top left;
}

.timeline-connectors {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.timeline-connectors path {
  fill: none;
  stroke: #454c57;
  stroke-width: 2;
}

.timeline-connectors path.merge-edge {
  stroke: var(--accent);
  stroke-dasharray: 5 4;
  opacity: .78;
}

.timeline-connectors path.reference-edge {
  stroke: #62c8ff;
  stroke-dasharray: 3 4;
  opacity: .68;
}

.timeline-connectors path.lineage-edge {
  stroke: var(--accent);
  stroke-width: 3;
  opacity: 1;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 38%, transparent));
}

/* Secondary "also discusses" relations found in the post-processing pass. */
.timeline-connectors path.cross-ref-edge {
  stroke: #c89bff;
  stroke-width: 2;
  stroke-dasharray: 4 4;
  stroke-linecap: round;
  opacity: .72;
  filter: drop-shadow(0 0 3px rgba(185, 140, 255, .45));
  pointer-events: stroke;
}

.timeline-connectors path.cross-ref-edge:hover {
  opacity: 1;
}

.timeline-connectors path.lineage-muted {
  opacity: .34;
}

.timeline-connectors .document-edge-label {
  fill: #82909f;
  font-size: 7px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #0d1115;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.timeline-connectors .document-edge-label.lineage-edge {
  fill: var(--accent);
}

.timeline-connectors .document-edge-label.lineage-muted {
  opacity: .42;
}

.timeline-node {
  z-index: 1;
  position: absolute;
  width: 78px;
  color: var(--muted);
  text-align: center;
}

.timeline-node.lineage-muted {
  opacity: .62;
  filter: saturate(.7);
}

.timeline-node.lineage .timeline-node-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px #0d0f12, 0 0 16px color-mix(in srgb, var(--accent) 28%, transparent);
}

.timeline-regenerate-button {
  z-index: 4;
  position: absolute;
  top: -4px;
  right: 6px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #4a535f;
  border-radius: 50%;
  color: #dce3eb;
  background: #161b21;
  box-shadow: 0 0 0 2px #0d0f12;
  cursor: pointer;
}

.timeline-regenerate-button:hover,
.timeline-regenerate-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.timeline-regenerate-button svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.timeline-redo-button {
  top: -6px;
  left: 6px;
  right: auto;
  width: 22px;
  height: 22px;
  border-color: var(--accent);
  color: var(--accent);
  background: #1a2108;
}

.timeline-node-dot.category-dot {
  border-color: var(--category-color);
  background: #15181d;
  box-shadow: 0 0 0 5px #0d0f12, 0 0 12px color-mix(in srgb, var(--category-color) 45%, transparent);
}

.category-glyph {
  font-size: 17px;
  line-height: 1;
}

.timeline-node.current .timeline-node-dot.category-dot {
  border-color: var(--accent);
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 4px 2px;
}

.graph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.graph-legend-swatch {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--category-color);
  border-radius: 50%;
  background: color-mix(in srgb, var(--category-color) 14%, #15181d);
  font-size: 12px;
  line-height: 1;
}

.timeline-node-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
}

.timeline-node-actions .timeline-branch-button {
  grid-column: 1 / -1;
}

.timeline-node-main {
  position: relative;
  width: 78px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: center;
}

.timeline-modality-badge,
.timeline-exclusion-record,
.timeline-version-record,
.timeline-batch-record,
.timeline-milestone-record {
  z-index: 2;
  position: absolute;
  display: grid;
  place-items: center;
  border: 1px solid #49515c;
  color: #edf2f6;
  background: #15191f;
  box-shadow: 0 0 0 2px #0d0f12;
}

.timeline-version-record {
  right: 14px;
  top: 10px;
  width: 14px;
  height: 14px;
  border-color: rgba(183,153,255,.62);
  border-radius: 4px;
  color: #cfbaff;
  font-size: 7px;
  font-weight: 900;
}

.timeline-milestone-record {
  right: 31px;
  top: 10px;
  width: 14px;
  height: 14px;
  border-color: color-mix(in srgb, var(--accent) 72%, transparent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 7px;
  font-weight: 900;
}

.timeline-modality-badge {
  left: 15px;
  top: 27px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.timeline-modality-badge svg {
  width: 9px;
  height: 9px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.timeline-exclusion-record {
  right: 14px;
  top: 27px;
  width: 14px;
  height: 14px;
  border-color: rgba(255,107,107,.55);
  border-radius: 50%;
  color: #ff8b8b;
  font-size: 10px;
  font-weight: 900;
}

.timeline-batch-record {
  right: 31px;
  top: 27px;
  width: 14px;
  height: 14px;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
}

.timeline-comment-record {
  z-index: 3;
  position: absolute;
  left: 7px;
  top: 8px;
  height: 16px;
  min-width: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(120,180,255,.6);
  border-radius: 8px;
  color: #bcd6ff;
  background: #15191f;
  box-shadow: 0 0 0 2px #0d0f12;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.timeline-comment-record:hover { border-color: var(--accent); color: var(--accent); }

.timeline-feedback-record {
  z-index: 3;
  position: absolute;
  right: 7px;
  top: 8px;
  height: 16px;
  min-width: 16px;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15191f;
  box-shadow: 0 0 0 2px #0d0f12;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
}
.timeline-feedback-record.positive { border-color: rgba(120, 210, 140, .65); }
.timeline-feedback-record.negative { border-color: rgba(255, 140, 120, .65); }
.timeline-feedback-record:hover { border-color: var(--accent); }

.timeline-node-dot {
  width: 38px;
  height: 38px;
  margin: 0 auto 7px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid #424852;
  border-radius: 50%;
  background: #15181d;
  box-shadow: 0 0 0 5px #0d0f12;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}

.timeline-node-dot img,
.timeline-node-dot video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.timeline-node-label {
  display: block;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-node-main:hover .timeline-node-dot,
.timeline-node-main:focus-visible .timeline-node-dot {
  border-color: #8d96a3;
  transform: translateY(-2px);
}

/* A strong, clearly visible focus ring as the keyboard moves across the graph. */
.timeline-node-main:focus-visible { outline: none; }
.timeline-node-main:focus-visible .timeline-node-dot {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-color: var(--accent);
}

.timeline-node.current .timeline-node-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px #0d0f12, 0 0 14px color-mix(in srgb, var(--accent) 25%, transparent);
}

.timeline-node.current {
  color: var(--accent);
}

.timeline-node.selected .timeline-node-dot {
  border-color: #fff;
  box-shadow: 0 0 0 5px #0d0f12, 0 0 0 7px color-mix(in srgb, var(--accent) 55%, transparent);
}

.timeline-node.merge-selected .timeline-node-dot {
  border-color: #62c8ff;
  box-shadow: 0 0 0 5px #0d0f12, 0 0 0 7px rgba(98,200,255,.55);
}

.timeline-node.fuse-selected .timeline-node-dot {
  border-color: #c7a3ff;
  box-shadow: 0 0 0 5px #0d0f12, 0 0 0 7px rgba(199,163,255,.55);
}

.timeline-node.context-excluded .timeline-node-dot {
  border-color: var(--danger);
  opacity: .58;
  filter: grayscale(.55);
}

.timeline-node.reference .timeline-node-dot {
  border-color: #62c8ff;
  border-radius: 10px;
  box-shadow: 0 0 0 5px #0d0f12, 0 0 14px rgba(98,200,255,.2);
}

.timeline-node.reference .timeline-node-label {
  color: #9ddfff;
}

.timeline-node.pending {
  opacity: .9;
}

.timeline-node.pending .timeline-node-main {
  cursor: pointer;
}

.timeline-node.pending .timeline-node-dot {
  position: relative;
  border-color: #69717c;
}

.timeline-node.pending .timeline-node-dot img {
  opacity: .34;
  filter: grayscale(.35);
}

.timeline-node-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #f5ffd6;
  background:
    radial-gradient(circle, rgba(12,14,17,.72) 0 54%, transparent 56%),
    conic-gradient(var(--accent) var(--progress), rgba(255,255,255,.16) 0);
  font-size: 7px;
  font-weight: 850;
}

.timeline-node.pending.current .timeline-node-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px #0d0f12, 0 0 14px color-mix(in srgb, var(--accent) 25%, transparent);
}

.timeline-branch-button,
.timeline-merge-button,
.timeline-exclude-button {
  width: 100%;
  margin: 0;
  padding: 4px 5px;
  border: 1px solid #343a43;
  border-radius: 6px;
  color: #c5cad1;
  background: #171a1f;
  cursor: pointer;
  font-size: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.timeline-branch-button:hover:not(:disabled),
.timeline-merge-button:hover:not(:disabled),
.timeline-exclude-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.timeline-branch-button:disabled,
.timeline-merge-button:disabled,
.timeline-exclude-button:disabled {
  color: #727882;
  cursor: default;
  opacity: .75;
}

.timeline-merge-button {
  color: #9ddfff;
}

.timeline-exclude-button {
  color: #ff9a9a;
}

.timeline-node.context-excluded .timeline-exclude-button {
  border-color: rgba(255,107,107,.55);
  color: #ffb0b0;
  background: rgba(255,107,107,.08);
}

.timeline-node.merge-selected .timeline-merge-button {
  border-color: rgba(98,200,255,.55);
  color: #bceaff;
  background: rgba(98,200,255,.08);
}

.timeline-node.current .timeline-branch-button {
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

@keyframes timelinePulse {
  50% { opacity: .25; transform: scale(.72); }
}

.timeline-balloon {
  position: fixed;
  z-index: 60;
  width: 232px;
  overflow: hidden;
  border: 1px solid #414751;
  border-radius: 13px;
  background: #15181d;
  box-shadow: 0 16px 44px rgba(0,0,0,.55);
  /* Interactive: the pointer can enter the balloon to use its actions. */
  pointer-events: auto;
}

.timeline-balloon-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.timeline-balloon-actions button,
.timeline-balloon-actions .button {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid #343a43;
  border-radius: 7px;
  color: #cdd2d9;
  background: #181c21;
  cursor: pointer;
  font-size: 9px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.timeline-balloon-actions button:hover:not(:disabled),
.timeline-balloon-actions .button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.timeline-balloon-actions button:disabled {
  opacity: .38;
  cursor: default;
}

.timeline-balloon-actions .hidden {
  display: none;
}

.timeline-balloon > img,
.timeline-balloon > video {
  width: 100%;
  height: 148px;
  display: block;
  object-fit: contain;
  background: #090b0e;
}

.timeline-balloon-text {
  width: 100%;
  height: 126px;
  margin: 0;
  padding: 12px;
  overflow: hidden;
  color: #dfe4ea;
  background: #0d1014;
  font: 9px/1.5 ui-monospace, monospace;
  white-space: pre-wrap;
}

.timeline-balloon > div {
  padding: 10px 11px 11px;
}

.timeline-balloon strong,
.timeline-balloon span {
  display: block;
}

.timeline-balloon strong {
  font-size: 12px;
}

.timeline-balloon span {
  margin-top: 3px;
  color: var(--accent);
  font-size: 9px;
}

.timeline-balloon p {
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-footer {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto auto auto;
  max-height: calc(100vh - 104px);
}

.conversation-panel.settings-expanded {
  max-height: none;
  overflow: visible;
  align-self: start;
}

.conversation-panel.settings-expanded .messages {
  height: max(240px, calc(100vh - 520px));
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  scrollbar-color: #353942 transparent;
}

.welcome-message {
  display: flex;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #12151a;
}

.message-symbol {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 13px;
}

.welcome-message p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.message {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.5;
}

.bubble > span {
  display: block;
}

.message-attachment {
  width: min(240px, 100%);
  max-height: 220px;
  display: block;
  margin: -5px -7px 9px;
  border-radius: 9px;
  object-fit: cover;
  background: #0a0c0f;
}

.user .bubble {
  color: #171b0b;
  background: var(--accent);
  border-bottom-right-radius: 4px;
}

.assistant .bubble {
  background: #1a1e24;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.message-time { color: #6f747d; font-size: 10px; }

.conversation-origin,
.conversation-reference {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
  padding: 9px;
  border: 1px solid #303741;
  border-radius: 12px;
  background: #11151a;
}

.conversation-origin {
  border-left: 3px solid var(--accent);
}

.conversation-reference {
  border-left: 3px solid #62c8ff;
  background: linear-gradient(145deg, rgba(98,200,255,.08), #11151a 55%);
}

.conversation-origin img,
.conversation-reference img {
  width: 58px;
  height: 58px;
  border-radius: 9px;
  object-fit: cover;
  background: #090b0e;
}

.conversation-document-link {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(98,200,255,.45);
  border-radius: 9px;
  color: #aee5ff;
  background: rgba(98,200,255,.08);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-decoration: none;
}

.conversation-origin span,
.conversation-origin strong,
.conversation-origin small,
.conversation-reference strong,
.conversation-reference small {
  display: block;
}

.conversation-origin span {
  color: var(--accent);
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.conversation-origin strong {
  margin-top: 3px;
  font-size: 12px;
}

.conversation-origin small,
.conversation-reference small {
  margin-top: 4px;
  color: #737b86;
  font-size: 8px;
}

.conversation-reference > div > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-reference strong {
  font-size: 11px;
}

.conversation-reference > div > div span {
  padding: 3px 6px;
  border: 1px solid rgba(98,200,255,.4);
  border-radius: 999px;
  color: #aee5ff;
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .07em;
}

.conversation-reference p {
  margin-top: 6px;
  overflow: hidden;
  color: #b8c0ca;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-message {
  width: 100%;
  align-items: stretch;
}

.result-card {
  width: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(104px, 34%) minmax(0, 1fr);
  border: 1px solid #323944;
  border-left: 3px solid var(--accent);
  border-radius: 13px;
  color: var(--text);
  background: linear-gradient(145deg, #171b21, #111419);
}

.result-card.video { border-left-color: #b799ff; }
.result-card.text { border-left-color: #62c8ff; }
.result-card.audio { border-left-color: #ffb85c; }

.result-card-preview {
  min-width: 0;
  min-height: 112px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-right: 1px solid #2b313a;
  background: #090b0e;
}

.result-card-preview img,
.result-card-preview video {
  width: 100%;
  height: 100%;
  min-height: 112px;
  max-height: 180px;
  display: block;
  object-fit: cover;
}

.result-card-preview audio {
  width: calc(100% - 18px);
  min-width: 96px;
}

.result-card.audio .result-card-preview {
  align-content: center;
  gap: 10px;
  padding: 15px 4px;
}

.result-card-symbol {
  color: #ffcf8b;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .14em;
}

.result-card-text {
  width: 100%;
  max-height: 180px;
  margin: 0;
  padding: 13px;
  overflow: auto;
  color: #dfeeff;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.result-card-body {
  min-width: 0;
  padding: 12px;
}

.result-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.result-card-heading strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-kind {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid #46505c;
  border-radius: 999px;
  color: #bdc5cf;
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .08em;
}

.result-card-instruction {
  margin-top: 8px;
  overflow: hidden;
  color: #aeb6c1;
  font-size: 10px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 12px;
}

.result-card-metadata div {
  min-width: 0;
}

.result-card-metadata dt {
  color: #686f79;
  font-size: 7px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.result-card-metadata dd {
  max-width: 100px;
  margin: 2px 0 0;
  overflow: hidden;
  color: #d4dae2;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card.compact {
  grid-template-columns: 1fr;
  border-left-width: 2px;
  border-radius: 9px;
}

.result-card.compact .result-card-preview {
  min-height: 74px;
  border-right: 0;
  border-bottom: 1px solid #2b313a;
}

.result-card.compact .result-card-preview img,
.result-card.compact .result-card-preview video {
  min-height: 74px;
  max-height: 104px;
}

.result-card.compact .result-card-body {
  padding: 8px;
}

.result-card.compact .result-card-instruction,
.result-card.compact .result-card-metadata {
  margin-top: 6px;
}

.result-card.compact .result-card-text {
  max-height: 104px;
  padding: 9px;
  font-size: 9px;
}

.version-diff {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.version-diff-prompts {
  display: grid;
  gap: 10px;
}

.version-diff-prompts > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-inset);
}

.version-diff-prompts strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
}

.version-diff-prompts p,
.prompt-diff-line {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.6;
}

.prompt-diff-line {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-inset);
}

.prompt-diff-add,
.prompt-diff-remove {
  padding: 1px 3px;
  border-radius: 4px;
}

.prompt-diff-add {
  color: #dfffb1;
  background: rgba(116, 185, 72, .22);
}

.prompt-diff-remove {
  color: #ffb9b9;
  background: rgba(255, 107, 107, .18);
  text-decoration: line-through;
}

.conversation-step {
  display: contents;
}

.conversation-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0 13px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.conversation-section-heading small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.conversation-branches {
  min-width: 310px;
  display: grid;
  grid-template-columns: repeat(2, minmax(145px, 1fr));
  gap: 9px;
  margin: 5px 0 14px;
}

.conversation-branch {
  min-width: 0;
  align-self: start;
  padding: 9px;
  border: 1px solid #303640;
  border-radius: 13px;
  background: #111419;
}

.conversation-branch.first {
  border-top-color: #62c8ff;
}

.conversation-branch.second {
  border-top-color: var(--accent);
}

.branch-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.branch-heading strong {
  overflow: hidden;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-branch.first .branch-heading strong { color: #8ed8ff; }
.conversation-branch.second .branch-heading strong { color: var(--accent); }

.branch-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 8px;
}

.branch-step + .branch-step {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px dashed #2b3038;
}

.branch-history-reveal {
  width: 100%;
  display: grid;
  place-items: center;
  gap: 3px;
  margin: 11px 0;
  padding: 9px 6px;
  border: 1px dashed #3a424d;
  border-radius: 9px;
  color: #aeb5bf;
  background: #171b21;
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.branch-history-reveal:hover,
.branch-history-reveal:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  outline: none;
}

.branch-history-reveal + .branch-step {
  margin-top: 0;
  padding-top: 11px;
  border-top: 1px dashed #2b3038;
}

.branch-history-dots {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .18em;
  line-height: .7;
}

.branch-history-reveal strong {
  font-size: 9px;
  font-weight: 700;
}

.branch-history-reveal small {
  color: var(--muted);
  font-size: 8px;
}

.branch-step .message {
  margin-bottom: 7px;
  gap: 4px;
}

.branch-step .message:last-child {
  margin-bottom: 0;
}

.branch-step .bubble {
  width: 100%;
  max-width: 100%;
  padding: 8px 9px;
  border-radius: 9px;
  font-size: 10px;
  line-height: 1.4;
}

.branch-step .message-time {
  font-size: 8px;
}

.branch-empty {
  padding: 13px 4px;
  color: #747a84;
  font-size: 9px;
  text-align: center;
}

.conversation-merge-join {
  position: relative;
  display: grid;
  place-items: center;
  margin: 3px 0 17px;
}

.conversation-merge-join::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #4a525e 20%, #4a525e 80%, transparent);
}

.conversation-merge-join span {
  position: relative;
  z-index: 1;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  color: var(--accent);
  background: #111419;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.suggestions {
  display: flex;
  gap: 7px;
  padding: 0 20px 12px;
  overflow-x: auto;
}

.suggestions button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

.suggestions button:hover { color: var(--text); border-color: #4a505b; }

.merge-bar {
  margin: 0 18px 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(98,200,255,.35);
  border-radius: 12px;
  background: rgba(98,200,255,.06);
}

.fuse-bar {
  margin: 0 18px 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(199,163,255,.35);
  border-radius: 12px;
  background: rgba(199,163,255,.07);
}

.fuse-bar > div { min-width: 0; }
.fuse-bar .eyebrow { color: #c7a3ff; }
.fuse-bar strong,
.fuse-bar small { display: block; }
.fuse-bar strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fuse-bar small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.fuse-strategy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.fuse-strategy span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.fuse-strategy select {
  padding: 6px 8px;
  border: 1px solid rgba(199,163,255,.4);
  border-radius: 9px;
  color: var(--text);
  background: #15191f;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}
.fuse-strategy select:focus {
  outline: none;
  border-color: #c7a3ff;
}
#runFuseButton {
  flex: 0 0 auto;
  padding: 7px 14px;
  font-size: 10px;
}
#runFuseButton:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.exclusion-bar {
  margin: 0 18px 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255,107,107,.35);
  border-radius: 12px;
  background: rgba(255,107,107,.06);
}

.exclusion-bar .eyebrow { color: #ff9393; }
.exclusion-bar strong,
.exclusion-bar small { display: block; }
.exclusion-bar strong { font-size: 11px; }
.exclusion-bar small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.request-cost {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0 14px 10px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.cost-help-button {
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #39404a;
  border-radius: 50%;
  color: var(--muted);
  background: #15191f;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.cost-help-button:hover,
.cost-help-button[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.cost-help-popover {
  position: absolute;
  z-index: 40;
  right: 10px;
  bottom: calc(100% + 5px);
  width: min(300px, calc(100vw - 44px));
  padding: 11px 12px;
  border: 1px solid #39404a;
  border-radius: 10px;
  color: var(--text);
  background: #15191f;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .32);
  white-space: normal;
}

.cost-help-popover strong {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
}

.cost-help-popover p {
  margin: 4px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.cost-help-popover p:last-child {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.merge-bar strong,
.merge-bar small {
  display: block;
}

.merge-bar strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-bar small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.composer {
  margin: 0 18px 14px;
  border: 1px solid #343943;
  border-radius: 15px;
  background: #0c0e12;
  overflow: hidden;
  transition: border-color .2s;
}

.composer-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px solid #252a32;
  color: var(--muted);
  background: #111419;
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}

.composer-toggle span:last-child {
  color: var(--accent);
  transition: transform .15s;
}

.composer.collapsed .composer-toggle {
  border-bottom: 0;
}

.composer.collapsed .composer-toggle span:last-child {
  transform: rotate(180deg);
}

.composer.collapsed .composer-body {
  display: none;
}

.composer:focus-within { border-color: #646b77; }

.composer.attachment-dragging {
  border-color: #62c8ff;
  background: rgba(98,200,255,.06);
}

.composer-attachment {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 10px;
  margin: 10px 10px 0;
  padding: 8px;
  border: 1px solid rgba(98,200,255,.3);
  border-radius: 11px;
  background: rgba(98,200,255,.06);
}

.composer-attachment img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #090b0e;
}

.composer-attachment img.generic {
  border: 1px dashed #4a5360;
  background:
    linear-gradient(135deg, rgba(98,200,255,.14), color-mix(in srgb, var(--accent) 8%, transparent)),
    #11151a;
}

.composer-attachment div {
  min-width: 0;
}

.composer-attachment strong,
.composer-attachment small {
  display: block;
}

.composer-attachment strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.composer-attachment button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: #1b2027;
  cursor: pointer;
}

.composer-attachment button:hover {
  color: var(--text);
  background: #252b34;
}

.composer textarea {
  width: 100%;
  min-height: 86px;
  padding: 15px 16px 8px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  line-height: 1.45;
}

.composer textarea::placeholder { color: #666b74; }

.modality-field {
  position: relative;
  flex-shrink: 0;
  display: flex;
}

.modality-glyph { color: var(--accent); font-size: 13px; line-height: 1; }
.chip-caret { margin-left: 1px; color: var(--muted); font-size: 9px; line-height: 1; }

.modality-popover {
  position: fixed;
  z-index: 60;
  display: grid;
  gap: 3px;
  min-width: 172px;
  margin: 0;
  padding: 6px;
  border: 1px solid #39404a;
  border-radius: 12px;
  background: #15191f;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .36);
}

.modality-popover.hidden { display: none; }

.modality-popover legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.modality-popover label { cursor: pointer; }

.modality-popover input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.modality-popover span {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.modality-popover span b {
  width: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.modality-popover label:hover span { background: #1f242c; }

.modality-popover input:checked + span {
  color: #111508;
  background: var(--accent);
}

.modality-popover input:checked + span b { color: #111508; }

.modality-popover input:focus-visible + span {
  outline: 2px solid #8ed8ff;
  outline-offset: 1px;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 8px 9px 9px 14px;
}

.composer-tools {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 5px;
}

.attach-image-button {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid #313741;
  border-radius: 8px;
  color: #b9c0c9;
  background: #15191f;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.attach-image-button span {
  color: #8ed8ff;
  font-size: 14px;
  line-height: .7;
}

.attach-image-button:hover:not(:disabled) {
  border-color: #62c8ff;
  color: #dff4ff;
}

.attach-image-button:disabled {
  cursor: wait;
  opacity: .45;
}

.composer-chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid #313741;
  border-radius: 9px;
  color: #c2c9d2;
  background: #15191f;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.composer-chip > span[aria-hidden="true"]:first-child {
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
}

.composer-chip:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.composer-chip:disabled { cursor: wait; opacity: .45; }

.icon-chip {
  width: 30px;
  padding: 0;
  justify-content: center;
}

.composer-chip.icon-chip > span[aria-hidden="true"] { font-size: 15px; }

.mode-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-shrink: 1;
  margin-left: 2px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.mode-pill #modeText {
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-pill .mode-dot { flex-shrink: 0; background: #5b8aff; }
.mode-pill.edit .mode-dot { background: var(--accent); }

.send-button {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border: 0;
  border-radius: 10px;
  color: #101308;
  background: var(--accent);
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
}

.send-button b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(0,0,0,.13);
  font-size: 14px;
}

.send-button:disabled { cursor: wait; opacity: .55; }

.settings {
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 11px;
}

.settings summary { cursor: pointer; user-select: none; }
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.settings label { display: grid; gap: 5px; }
.settings .seed-field { grid-column: 1 / -1; }
.settings .adherence-field { grid-column: 1 / -1; }
.settings .model-field { grid-column: 1 / -1; }
.settings .model-field small {
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.35;
}

.video-settings,
.audio-settings {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(98,200,255,.22);
  border-radius: 10px;
  background: rgba(98,200,255,.04);
}

.video-settings .range-field,
.audio-settings .range-field {
  grid-column: 1 / -1;
}

.audio-settings-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text-faint);
  font-size: 9px;
}

.video-estimate {
  grid-column: 1 / -1;
  padding: 7px 8px;
  border-radius: 7px;
  color: #aeb5bf;
  background: rgba(0,0,0,.18);
  font-size: 9px;
  line-height: 1.4;
}

.range-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-field output {
  min-width: 28px;
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 9px;
  text-align: center;
}

.range-field small {
  color: #737985;
  font-size: 9px;
  line-height: 1.35;
}

.settings input, .settings select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0d0f13;
  outline: 0;
}

.settings input[type="range"] {
  height: 18px;
  padding: 0;
  border: 0;
  accent-color: var(--accent);
  background: transparent;
}

.settings-field {
  position: relative;
  flex-shrink: 0;
  display: flex;
}

.settings-gear { color: var(--accent); font-size: 13px; line-height: 1; }

.settings-popover {
  position: fixed;
  z-index: 60;
  left: 16px;
  bottom: 16px;
  width: min(340px, calc(100vw - 28px));
  max-height: min(62vh, 460px);
  margin: 0;
  padding: 14px;
  overflow-y: auto;
  border: 1px solid #39404a;
  border-radius: 14px;
  background: #14181e;
  box-shadow: 0 22px 46px rgba(0, 0, 0, .46);
}

.settings-popover.hidden { display: none; }

.settings-popover-head { margin-bottom: 12px; }

.settings-popover-head strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.settings-popover .settings-grid { margin-top: 0; }

.button, .icon-button, .text-button {
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 750;
}

.button.secondary, .icon-button {
  border: 1px solid var(--line);
  background: #171a1f;
}

.icon-button {
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 11px;
}

.text-button { padding: 0; color: var(--muted); font-size: 11px; }
.text-button:hover { color: var(--text); }
.hidden { display: none !important; }

.history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, .56);
  backdrop-filter: blur(3px);
}

.history-drawer {
  position: fixed;
  z-index: 31;
  top: 0;
  right: 0;
  width: min(430px, 94vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-left: 1px solid var(--line);
  background: #0d0f12;
  box-shadow: -20px 0 60px rgba(0,0,0,.4);
  transform: translateX(102%);
  transition: transform .24s ease;
}

.history-drawer.open { transform: translateX(0); }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 23px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #15181d;
  cursor: pointer;
  font-size: 20px;
}

.history-list {
  overflow-y: auto;
  padding: 12px;
}

.history-loading, .history-empty {
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.history-card {
  width: 100%;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 28px;
  gap: 12px;
  align-items: center;
  margin-bottom: 9px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  color: var(--text);
  background: #12151a;
  text-align: left;
  cursor: pointer;
}

.history-card:hover, .history-card.active {
  border-color: #444a54;
  background: #171a20;
}

.history-card.active { box-shadow: inset 3px 0 var(--accent); }

.history-thumb {
  position: relative;
  width: 86px;
  height: 68px;
  overflow: hidden;
  border-radius: 9px;
  background: #090b0e;
}

.history-thumb img,
.history-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb.audio::after {
  content: "\266A";
  position: absolute;
  right: 4px;
  bottom: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(8, 10, 14, .72);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.history-thumb.empty {
  display: grid;
  place-items: center;
  color: #555b64;
  font-size: 20px;
}

.history-details { min-width: 0; }
.history-details strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-details span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.history-details span.pending {
  color: var(--accent);
}

.history-delete {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  color: #777d86;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
}

.history-delete:hover {
  color: var(--danger);
  background: rgba(255,107,107,.08);
}

.history-delete:disabled {
  cursor: wait;
  opacity: .55;
}

.history-footer {
  display: grid;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}

.history-new {
  color: #101308;
  background: var(--accent);
}

.history-footer small { color: #686e77; font-size: 10px; }

.library-drawer {
  position: fixed;
  z-index: 31;
  top: 0;
  right: 0;
  width: min(560px, 96vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  border-left: 1px solid var(--line);
  background: #0d0f12;
  box-shadow: -20px 0 60px rgba(0,0,0,.4);
  transform: translateX(102%);
  transition: transform .24s ease;
}

.library-drawer.open { transform: translateX(0); }

/* --- Collaboration drawer ------------------------------------------------ */
.collab-drawer {
  position: fixed;
  z-index: 31;
  top: 0;
  right: 0;
  width: min(440px, 95vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  border-left: 1px solid var(--line);
  background: #0d0f12;
  box-shadow: -20px 0 60px rgba(0,0,0,.4);
  transform: translateX(102%);
  transition: transform .24s ease;
}
.collab-drawer.open { transform: translateX(0); }

.collab-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 18px 0;
}
.collab-tab {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  color: var(--muted);
  background: #12151a;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}
.collab-tab:hover { border-color: #4b515b; }
.collab-tab.active {
  color: #101308;
  background: var(--accent);
  border-color: var(--accent);
}

.collab-body {
  min-height: 0;
  overflow: hidden;
  display: grid;
}
.collab-panel {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.collab-panel[hidden] { display: none; }

.collab-comments-context {
  padding: 12px 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  border-bottom: 1px solid var(--line-soft);
}
.collab-comments-context strong { color: var(--text); }

.collab-comment-list,
.collab-activity-list,
.collab-people-list {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.collab-empty {
  padding: 44px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.collab-comment {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
}
.collab-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #0b0c10;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
}
.collab-avatar img { width: 100%; height: 100%; object-fit: cover; }

.collab-comment-main { min-width: 0; }
.collab-comment-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.collab-comment-author { color: var(--text); font-size: 12px; font-weight: 700; }
.collab-comment-time { color: var(--muted); font-size: 10px; }
.collab-comment-body {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.collab-mention { color: var(--accent); font-weight: 700; }
.collab-comment-actions {
  display: flex;
  gap: 12px;
  margin-top: 5px;
}
.collab-comment-actions button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  padding: 0;
}
.collab-comment-actions button:hover { color: var(--text); }
.collab-comment-actions button.danger:hover { color: var(--danger); }

.collab-composer {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line-soft);
}
.collab-composer-field { position: relative; min-width: 0; }
.collab-composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--text);
  background: #12151a;
  font: inherit;
  font-size: 12px;
}
.collab-composer textarea:disabled { opacity: .5; cursor: not-allowed; }

.collab-mention-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 5;
  width: 100%;
  max-height: 168px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #14181d;
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
}
.collab-mention-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 11px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}
.collab-mention-option:hover,
.collab-mention-option.active { background: #1d222a; }

.collab-activity-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
}
.collab-activity-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1b1f26;
  font-size: 12px;
}
.collab-activity-text { font-size: 12px; color: var(--text-soft); line-height: 1.45; }
.collab-activity-text strong { color: var(--text); font-weight: 700; }
.collab-activity-time { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

.collab-person {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #12151a;
}
.collab-person-main { min-width: 0; flex: 1; }
.collab-person-name { color: var(--text); font-size: 12px; font-weight: 700; }
.collab-person-meta { color: var(--muted); font-size: 10px; }
.collab-role-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: #1d222a;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.collab-presence-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4b515b;
}
.collab-presence-dot.online { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.collab-people-hint {
  margin: 0;
  padding: 4px 18px 16px;
  color: var(--muted);
  font-size: 10px;
}

/* Live presence cursors layered inside the timeline graph */
.collab-cursor-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}
.collab-cursor {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  pointer-events: none;
  will-change: transform;
  transition: transform .12s linear;
}
.collab-cursor svg {
  display: block;
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.45));
}
.collab-cursor-label {
  position: absolute;
  left: 13px;
  top: 14px;
  padding: 2px 7px;
  border-radius: 7px;
  color: #0b0c10;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.library-toolbar {
  display: flex;
  gap: 10px;
  padding: 14px 20px 0;
}

.library-upload {
  color: #101308;
  background: var(--accent);
}

.library-upload.busy { opacity: .6; pointer-events: none; }

.library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px 4px;
}

.library-filter {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #14171c;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.library-filter:hover { border-color: #4b515b; }

.library-filter.active {
  color: #101308;
  border-color: var(--accent);
  background: var(--accent);
}

.library-list {
  overflow-y: auto;
  padding: 14px 16px;
}

.library-loading, .library-empty {
  padding: 60px 22px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.library-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #15181d;
  overflow: hidden;
}

.library-card:hover { border-color: #3a414b; }

.library-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0d10;
  overflow: hidden;
}

.library-thumb img,
.library-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-thumb-glyph {
  font-size: 34px;
  line-height: 1;
  color: var(--accent);
  opacity: .85;
}

.library-kind-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(8, 10, 13, .78);
  color: var(--text);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.library-card.kind-image .library-kind-badge { color: var(--accent); }
.library-card.kind-video .library-kind-badge { color: #62c8ff; }
.library-card.kind-audio .library-kind-badge,
.library-card.kind-audio .library-thumb-glyph { color: #c7a3ff; }
.library-card.kind-document .library-kind-badge,
.library-card.kind-document .library-thumb-glyph { color: #ffd27c; }
.library-card.kind-file .library-kind-badge,
.library-card.kind-file .library-thumb-glyph { color: #9aa3b2; }

.library-card-body {
  display: grid;
  gap: 3px;
  padding: 9px 11px 6px;
}

.library-card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-card-meta {
  color: var(--muted);
  font-size: 10.5px;
}

.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 11px 11px;
  margin-top: auto;
}

.library-action {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #1b1f25;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.5;
}

.library-action:hover { border-color: #4b515b; }

.library-action.primary {
  color: #101308;
  border-color: var(--accent);
  background: var(--accent);
}

.library-action.danger { color: #ff9b9b; }
.library-action.danger:hover { border-color: rgba(255, 107, 107, .5); }

.settings-backdrop {
  position: fixed;
  z-index: 110;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(5px);
}

.appearance-dialog {
  position: fixed;
  z-index: 111;
  top: 76px;
  right: 24px;
  width: min(390px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}

.share-dialog {
  position: fixed;
  z-index: 111;
  top: 50%;
  left: 50%;
  width: min(520px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
  transform: translate(-50%, -50%);
}

.appearance-dialog > header,
.share-dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.appearance-dialog h2,
.share-dialog h2 { margin: 3px 0 0; font-size: 20px; }

.appearance-section {
  display: grid;
  gap: 13px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.appearance-section:last-child { border-bottom: 0; }
.appearance-section > strong,
.appearance-section strong { font-size: 12px; }
.appearance-section small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.share-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px auto;
  gap: 10px;
  align-items: end;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.share-link-panel {
  display: grid;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.share-link-panel strong,
.share-link-panel small {
  display: block;
}

.share-link-panel strong { font-size: 12px; }
.share-link-panel small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.share-link-controls,
.share-link-result {
  display: grid;
  grid-template-columns: 130px auto;
  gap: 10px;
  align-items: center;
}

.share-link-result {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.share-link-panel input,
.share-link-panel select {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.share-link-panel input:focus,
.share-link-panel select:focus { border-color: var(--accent); }

.share-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.share-form input,
.share-form select {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.share-form input:focus,
.share-form select:focus { border-color: var(--accent); }

.share-list {
  display: grid;
  gap: 8px;
  padding: 16px 20px 20px;
}

.share-empty {
  color: var(--muted);
  font-size: 12px;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.share-row strong,
.share-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-row strong { font-size: 13px; }
.share-row small { color: var(--muted); font-size: 11px; }

.share-role-badge {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 10px;
  text-transform: capitalize;
}

.share-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-raised);
  cursor: pointer;
}

.share-remove:hover,
.share-remove:focus-visible {
  border-color: var(--danger);
  color: var(--danger);
  outline: none;
}

/* --- Prompt Studio ------------------------------------------------------ */
.studio-button span { color: var(--accent); }
.studio-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.settings-button .settings-button-label { display: none; }

/* --- Batch generation --------------------------------------------------- */
.batch-field {
  position: relative;
  flex-shrink: 0;
  display: flex;
}
.batch-field.hidden { display: none; }

#batchButtonLabel:empty { display: none; }
.batch-button span:first-child { color: var(--accent); }
.batch-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}
.batch-button.active {
  width: auto;
  padding: 0 9px;
  border-color: var(--accent);
  color: #0d0f12;
  background: var(--accent);
}
.batch-button.active span:first-child { color: #0d0f12; }

/* --- Auto-pilot --------------------------------------------------------- */
.autopilot-button .autopilot-glyph { color: var(--accent); font-size: 14px; }
.autopilot-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}
.autopilot-button[aria-pressed="true"] {
  border-color: var(--accent);
  color: #0d0f12;
  background: var(--accent);
}
.autopilot-button[aria-pressed="true"] .autopilot-glyph { color: #0d0f12; }

.autopilot-panel {
  margin: 0 0 10px;
  padding: 12px 13px;
  border: 1px solid #39404a;
  border-radius: 12px;
  background: #14181e;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}
.autopilot-panel.hidden { display: none; }
.autopilot-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.autopilot-panel-head strong { font-size: 12px; }
.autopilot-plan-source {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid #39404a;
}
.autopilot-plan-source.is-llm { color: var(--accent); border-color: var(--accent); }
.autopilot-plan-source.is-fallback { color: #f0b866; border-color: #6a5326; }
.autopilot-plan-source:empty { display: none; }
.autopilot-panel-close {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.autopilot-panel-close:hover { color: var(--text); background: #1f242c; }
.autopilot-panel-lead {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.autopilot-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.autopilot-step {
  padding: 8px 10px;
  border: 1px solid #2b313a;
  border-radius: 9px;
  background: #0f1318;
}
.autopilot-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.autopilot-step-glyph { color: var(--accent); font-size: 13px; line-height: 1; }
.autopilot-step-label { font-size: 11px; font-weight: 700; color: var(--text); }
.autopilot-step-why {
  margin: 4px 0 0 21px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}
.autopilot-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
}
.autopilot-plan-cost { color: var(--muted); font-size: 10px; font-weight: 700; }
.autopilot-panel-actions { display: flex; gap: 8px; }
.autopilot-panel-actions .ghost-button,
.autopilot-panel-actions .primary-button {
  height: 30px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.autopilot-panel-actions .ghost-button {
  border: 1px solid #39404a;
  color: var(--text);
  background: transparent;
}
.autopilot-panel-actions .ghost-button:hover { border-color: var(--accent); }
.autopilot-panel-actions .primary-button {
  border: 1px solid var(--accent);
  color: #0d0f12;
  background: var(--accent);
}
.autopilot-panel-actions .primary-button:disabled { opacity: .5; cursor: not-allowed; }

.batch-popover {
  position: fixed;
  z-index: 60;
  width: min(264px, calc(100vw - 44px));
  padding: 12px 13px;
  border: 1px solid #39404a;
  border-radius: 12px;
  color: var(--text);
  background: #15191f;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .36);
  white-space: normal;
}
.batch-popover.hidden { display: none; }
.batch-popover strong {
  display: block;
  font-size: 11px;
}
.batch-popover-lead {
  margin: 5px 0 10px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}
.batch-count-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.batch-count-field select {
  width: 84px;
  padding: 6px 8px;
  border: 1px solid #39404a;
  border-radius: 8px;
  color: var(--text);
  background: #0f1318;
  font-size: 11px;
  font-weight: 700;
}
.batch-mode {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}
.batch-mode-option {
  padding: 8px 9px;
  border: 1px solid #313741;
  border-radius: 9px;
  color: #b9c0c9;
  background: #0f1318;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  text-align: left;
}
.batch-mode-option:hover { border-color: var(--accent); }
.batch-mode-option.active {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.batch-hint {
  display: block;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.batch-compare {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 8, 11, .72);
  backdrop-filter: blur(4px);
}
.batch-compare.hidden { display: none; }
.batch-compare-panel {
  width: min(1080px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #2c333d;
  border-radius: 16px;
  background: #11151b;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.batch-compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #232a33;
}
.batch-compare-head strong { font-size: 13px; }
.batch-compare-close {
  width: 30px;
  height: 30px;
  border: 1px solid #39404a;
  border-radius: 8px;
  color: var(--muted);
  background: #15191f;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.batch-compare-close:hover {
  border-color: var(--accent);
  color: var(--text);
}
.batch-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
  overflow: auto;
}
.batch-compare-tile {
  margin: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #2a313b;
  border-radius: 12px;
  background: #0f1318;
  overflow: hidden;
}
.batch-compare-tile.current { border-color: var(--accent); }
.batch-compare-media {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #0a0d11;
}
.batch-compare-media.clickable { cursor: pointer; }
.batch-compare-media.audio,
.batch-compare-media.text {
  display: grid;
  place-items: center;
  aspect-ratio: auto;
  min-height: 120px;
}
.batch-compare-text {
  max-height: 180px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.batch-compare-tile figcaption {
  padding: 10px 11px;
  border-top: 1px solid #232a33;
}
.batch-compare-tile figcaption strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.batch-compare-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}
.batch-compare-pick {
  width: 100%;
  margin-top: 9px;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 8px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}
.batch-compare-pick:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.batch-compare-pick:disabled {
  border-color: #39404a;
  color: var(--muted);
  background: transparent;
  cursor: default;
}
.batch-compare-tile.origin { border-color: color-mix(in srgb, var(--accent) 45%, #2a313b); }
.batch-compare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.regen-chip {
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* Regeneration controls dialog */
.regen-dialog {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 8, 11, .72);
  backdrop-filter: blur(4px);
}
.regen-dialog.hidden { display: none; }
.regen-card {
  width: min(540px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #2c333d;
  border-radius: 16px;
  background: #11151b;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.regen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #232a33;
}
.regen-source { display: flex; align-items: center; gap: 11px; min-width: 0; }
.regen-source-preview {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid #2a313b;
  border-radius: 10px;
  background: #0a0d11;
  overflow: hidden;
}
.regen-source-preview img { width: 100%; height: 100%; object-fit: cover; }
.regen-source-glyph { color: var(--muted); font-size: 18px; }
.regen-source-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.regen-source-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.regen-close {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid #39404a;
  border-radius: 8px;
  color: var(--muted);
  background: #15191f;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.regen-close:hover { border-color: var(--accent); color: var(--text); }
.regen-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow: auto;
}
.regen-row { display: flex; flex-direction: column; gap: 7px; }
.regen-row-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--text);
}
.regen-row-hint { color: var(--muted); font-size: 9px; line-height: 1.45; }
.regen-row select,
#regenLockCustom {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #2c333d;
  border-radius: 9px;
  color: var(--text);
  background: #0f1318;
  font-size: 12px;
}
.regen-row select:focus,
#regenLockCustom:focus { outline: none; border-color: var(--accent); }
.regen-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid #2a313b;
  border-radius: 11px;
  background: #0f1318;
  cursor: pointer;
}
.regen-toggle input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--accent); }
.regen-row-copy { display: flex; flex-direction: column; gap: 3px; }
.regen-locks { display: flex; flex-wrap: wrap; gap: 7px; }
.regen-lock-chip {
  padding: 6px 11px;
  border: 1px solid #39404a;
  border-radius: 999px;
  color: var(--muted);
  background: #12161c;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}
.regen-lock-chip:hover { border-color: var(--accent); color: var(--text); }
.regen-lock-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.regen-versions { display: flex; gap: 7px; }
.regen-version-option {
  width: 46px;
  padding: 8px 0;
  border: 1px solid #39404a;
  border-radius: 9px;
  color: var(--muted);
  background: #12161c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.regen-version-option:hover { border-color: var(--accent); color: var(--text); }
.regen-version-option.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.regen-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-top: 1px solid #232a33;
  background: #0f1318;
}
.regen-summary { flex: 1; min-width: 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.regen-foot-buttons { display: flex; gap: 9px; flex-shrink: 0; }
.regen-foot-buttons .button { font-size: 11px; padding: 8px 14px; }

.negative-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  gap: 10px;
  margin: 10px 10px 0;
  padding: 9px 10px;
  border: 1px solid rgba(255, 120, 120, .38);
  border-radius: 11px;
  background: rgba(255, 120, 120, .08);
}
.negative-chip strong,
.negative-chip small { display: block; }
.negative-chip strong { color: #ff9a9a; font-size: 10px; }
.negative-chip small {
  max-height: 34px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}
.negative-chip button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: #1b2027;
  cursor: pointer;
}
.negative-chip button:hover { color: var(--text); }

.studio-dialog {
  position: fixed;
  z-index: 111;
  top: 50%;
  left: 50%;
  width: min(620px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
  transform: translate(-50%, -50%);
}

.studio-dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.studio-dialog h2 { margin: 3px 0 0; font-size: 20px; }

.export-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  overflow-y: auto;
}
.export-block { display: flex; flex-direction: column; gap: 10px; }
.export-block h3 { margin: 0; font-size: 14px; font-weight: 800; }
.export-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.export-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.export-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.export-card:disabled { opacity: .55; cursor: progress; transform: none; }
.export-card-title { font-size: 13px; font-weight: 800; }
.export-card-sub { font-size: 11px; color: var(--muted); }

.export-import-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.export-import-name {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.export-dialog .button { cursor: pointer; }
.export-import-start {
  align-self: flex-start;
  border: 1px solid var(--accent);
  background: var(--accent-dark);
  color: var(--text);
}
.export-import-start:disabled { opacity: .5; cursor: not-allowed; }

.export-status { margin: 0; min-height: 16px; font-size: 12px; color: var(--muted); }
.export-status.ok { color: var(--accent); }
.export-status.error { color: #ff6b6b; }

.api-keys-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}
.api-keys-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.api-keys-hint code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.api-keys-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.api-keys-form > label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.api-keys-form > label small { color: var(--muted); font-weight: 500; }
.api-keys-form input[type="text"],
.api-keys-form input[type="number"] {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}
.api-keys-form input:focus { outline: none; border-color: var(--accent); }
.api-keys-scope {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 600 !important;
  color: var(--muted) !important;
}
.api-keys-scope input { width: 14px; height: 14px; accent-color: var(--accent); }
.api-keys-form .button {
  align-self: flex-start;
  border: 1px solid var(--accent);
  background: var(--accent-dark);
  color: var(--text);
  cursor: pointer;
}
.api-key-reveal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent-dark);
}
.api-key-reveal strong { font-size: 13px; }
.api-key-reveal small { color: var(--muted); font-size: 11px; }
.api-key-reveal-row { display: flex; gap: 8px; margin-top: 6px; }
.api-key-reveal-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.api-key-reveal-row .button { cursor: pointer; }
.api-keys-list { display: flex; flex-direction: column; gap: 8px; }
.api-keys-empty { margin: 0; color: var(--muted); font-size: 12px; }
.api-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.api-key-row.revoked { opacity: .6; }
.api-key-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.api-key-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.api-key-name { font-size: 13px; font-weight: 800; }
.api-key-prefix {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}
.api-key-meta { font-size: 11px; color: var(--muted); }
.api-key-actions { flex-shrink: 0; }
.text-button.danger { color: #ff6b6b; }
.text-button.danger:hover { color: #ff9090; }

/* Outbound webhooks (reuses the .api-keys-* dialog chrome) */
.webhooks-events {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.webhooks-events legend {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.webhooks-events label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.webhooks-events input { width: 14px; height: 14px; accent-color: var(--accent); }
.webhook-row { flex-wrap: wrap; }
.webhook-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}
.webhook-row.disabled { opacity: .6; }
.webhook-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}
.webhook-actions { display: flex; flex-wrap: wrap; gap: 4px 10px; }

/* Completion notifications (More menu icon + settings dialog) */
.notify-icon {
  position: relative;
  width: 13px;
  height: 11px;
  background: var(--accent);
  clip-path: polygon(50% 0, 64% 7%, 80% 26%, 82% 70%, 100% 88%, 0 88%, 18% 70%, 20% 26%, 36% 7%);
}
.notify-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}
.notifications-dialog { width: min(460px, calc(100vw - 32px)); }
.notifications-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
}
.notifications-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.notifications-hint span { color: var(--text); font-weight: 700; }
.notify-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.notify-option input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.notify-option-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notify-option-text strong { font-size: 13px; font-weight: 750; }
.notify-option-text small { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.notify-option.disabled { opacity: .55; cursor: not-allowed; }
.notify-option.disabled input { cursor: not-allowed; }
.notifications-status { margin: 0; min-height: 16px; font-size: 12px; color: var(--accent); }

/* Model marketplace (More menu icon + dialog) */
.marketplace-icon {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1.6px solid var(--accent);
  border-radius: 3px;
}
.marketplace-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: 5px;
  height: 5px;
  margin-left: -3px;
  transform: rotate(45deg);
  border-right: 1.6px solid var(--accent);
  border-bottom: 1.6px solid var(--accent);
}
.marketplace-dialog { width: min(680px, calc(100vw - 32px)); }
.marketplace-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 20px 0;
}
.marketplace-filter {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.marketplace-filter:hover { color: var(--text); }
.marketplace-filter.active {
  border-color: var(--accent);
  color: var(--on-accent);
  background: var(--accent);
}
.marketplace-body {
  padding: 16px 20px;
  overflow-y: auto;
}
.marketplace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.marketplace-empty { margin: 8px 0; color: var(--muted); font-size: 13px; text-align: center; }
.marketplace-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.marketplace-card[data-status="installed"] {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.marketplace-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.marketplace-card-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.marketplace-card-title h3 { margin: 0; font-size: 15px; font-weight: 800; }
.marketplace-card-family { font-size: 11.5px; color: var(--muted); }
.marketplace-card-meta { font-size: 12px; color: var(--muted); }
.marketplace-card-notes { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-soft); }
.marketplace-card-rating { margin: 0; font-size: 12px; font-weight: 700; color: var(--text-soft); }
.marketplace-card-error { margin: 0; font-size: 12px; color: var(--danger); line-height: 1.4; }
.marketplace-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.marketplace-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
}
.marketplace-status-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}
.marketplace-status-badge[data-status="installed"] {
  color: #ffffff;
  border-color: #2f9e57;
  background: #2f9e57;
}
.marketplace-status-badge[data-status="downloading"] {
  color: var(--on-accent);
  border-color: var(--accent);
  background: var(--accent);
}
.marketplace-status-badge[data-status="builtin"] {
  color: var(--text-soft);
  border-color: var(--line);
  background: var(--surface-raised);
}
.marketplace-status-badge[data-status="error"] {
  color: #ffffff;
  border-color: var(--danger);
  background: var(--danger);
}
.marketplace-card-actions { display: flex; align-items: center; gap: 10px; }
.marketplace-action {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12.5px;
  font-weight: 750;
  cursor: pointer;
}
.marketplace-action:hover { filter: brightness(1.08); }
.marketplace-action:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.marketplace-action.remove {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}
.marketplace-action.remove:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  filter: none;
}
.marketplace-action.remove.armed {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}
.marketplace-action-note { font-size: 11.5px; color: var(--muted); }
.marketplace-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
}
.marketplace-cache { font-size: 12px; color: var(--muted); }
.marketplace-status { font-size: 12px; color: var(--accent); min-height: 16px; text-align: right; }
.marketplace-status[data-tone="error"] { color: var(--danger); }

/* Semantic search & RAG (More menu icon + dialog) */
.search-icon {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1.6px solid var(--accent);
  border-radius: 50%;
}
.search-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 6px;
  height: 1.6px;
  background: var(--accent);
  transform: rotate(45deg);
  transform-origin: left center;
}
.search-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(80vh, 760px);
}
.search-modes {
  display: inline-flex;
  gap: 4px;
  margin: 14px 20px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  align-self: flex-start;
}
.search-mode-option {
  padding: 6px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 750;
  cursor: pointer;
}
.search-mode-option:hover { color: var(--text); }
.search-mode-option.active {
  color: var(--on-accent);
  background: var(--accent);
}
.search-query {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0;
}
.search-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}
.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px 0;
}
.search-filter {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.search-filter:hover { color: var(--text); }
.search-filter.active {
  border-color: var(--accent);
  color: var(--on-accent);
  background: var(--accent);
}
.search-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.search-answer {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 13px;
  background: var(--surface);
}
.search-answer-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}
.search-answer-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.search-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  max-width: 100%;
}
.search-source-chip:hover { border-color: var(--accent); color: var(--text); }
.search-source-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-source-index {
  flex-shrink: 0;
  font-weight: 800;
  color: var(--accent);
}
.search-results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.search-result-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}
.search-result-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.search-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.search-result-title { margin: 0; font-size: 14px; font-weight: 800; min-width: 0; }
.search-result-type {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.search-result-snippet { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-soft); }
.search-result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}
.search-result-score { font-weight: 700; }
.search-empty { margin: 10px 0; color: var(--muted); font-size: 13px; text-align: center; }
.search-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
}
.search-footer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
}
.search-provider { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.search-index-info { font-size: 11px; color: var(--muted); }
.search-footer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-model-label { font-size: 11.5px; color: var(--muted); }
.search-model-select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  max-width: 220px;
}
.search-status { width: 100%; font-size: 12px; color: var(--accent); min-height: 16px; }
.search-status[data-tone="error"] { color: var(--danger); }

/* Project / session memory */
.memory-icon {
  position: relative;
  width: 11px;
  height: 13px;
  border: 1.6px solid var(--accent);
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}
.memory-icon::after {
  content: "";
  position: absolute;
  left: -1.6px;
  right: -1.6px;
  bottom: -1px;
  height: 6px;
  border: 1.6px solid var(--accent);
  border-top: none;
  clip-path: polygon(0 0, 100% 0, 50% 70%);
}
.memory-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(82vh, 780px);
}
.memory-intro {
  margin: 12px 20px 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-soft);
}
.memory-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 20px 0;
}
.memory-form-row { display: flex; gap: 8px; }
.memory-kind-select {
  flex-shrink: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.memory-title-input,
.memory-body-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
.memory-body-input { width: 100%; resize: vertical; line-height: 1.5; }
.memory-title-input:focus,
.memory-body-input:focus,
.memory-kind-select:focus { outline: none; border-color: var(--accent); }
.memory-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.memory-pin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-soft);
  margin-right: auto;
}
.memory-body-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.memory-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.memory-card.pinned {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.memory-card-head { display: flex; align-items: center; gap: 9px; }
.memory-card-kind {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.memory-card-title { margin: 0; font-size: 14px; font-weight: 800; min-width: 0; flex: 1; }
.memory-card-auto {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 750;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.memory-card-body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-soft);
  white-space: pre-wrap;
}
.memory-card-actions { display: flex; gap: 8px; }
.memory-card-action {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.memory-card-action:hover { border-color: var(--accent); color: var(--text); }
.memory-card-action.danger:hover { border-color: var(--danger); color: var(--danger); }
.memory-empty { margin: 10px 20px; color: var(--muted); font-size: 13px; text-align: center; }
.memory-footer {
  display: flex;
  align-items: center;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
}
.memory-status { font-size: 12px; color: var(--accent); min-height: 16px; }
.memory-status[data-tone="error"] { color: var(--danger); }

.studio-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 20px 0;
}
.studio-tab {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.studio-tab:hover { color: var(--text); }
.studio-tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dark);
}

.studio-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
}
.studio-kind-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.studio-toolbar .button {
  border: 1px solid var(--line);
  background: var(--surface-raised);
  white-space: nowrap;
  text-transform: capitalize;
}
.studio-toolbar .button:hover { border-color: var(--accent); }

.studio-editor {
  display: grid;
  gap: 10px;
  margin: 0 20px 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.studio-editor input,
.studio-editor textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  outline: none;
  resize: vertical;
}
.studio-editor input:focus,
.studio-editor textarea:focus { border-color: var(--accent); }
.studio-editor-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.studio-editor-hint {
  flex: 1;
  color: var(--muted);
  font-size: 10px;
  text-transform: capitalize;
}
.studio-editor .button {
  color: #101308;
  background: var(--accent);
}

.studio-body {
  overflow-y: auto;
  padding: 4px 20px 20px;
}
.studio-section { display: grid; gap: 8px; margin-top: 14px; }
.studio-group-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.studio-list { display: grid; gap: 8px; }
.studio-empty { margin: 0; color: var(--muted); font-size: 12px; }

.studio-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
}
.studio-entry-text { min-width: 0; }
.studio-entry-text strong { display: block; font-size: 13px; }
.studio-entry-text small {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.studio-entry-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.studio-entry-actions .button {
  padding: 7px 11px;
  color: #101308;
  background: var(--accent);
}
.studio-entry-actions .button:hover { filter: brightness(1.06); }
.studio-delete:hover { color: var(--danger); }

@media (max-width: 620px) {
  .studio-entry { grid-template-columns: minmax(0, 1fr); }
  .studio-entry-actions { justify-content: flex-end; }
}

/* Magic prompt - LLM-assisted expand / negatives / critique inside the studio */
.studio-magic {
  display: grid;
  gap: 12px;
  padding: 4px 20px 20px;
  overflow-y: auto;
}
.studio-magic textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel);
  outline: none;
  resize: vertical;
  font: inherit;
}
.studio-magic textarea:focus { border-color: var(--accent); }
.studio-magic-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.studio-magic-target {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.studio-magic-target select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}
.studio-magic-modes { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-magic-status {
  margin: 0;
  min-height: 16px;
  color: var(--accent);
  font-size: 12px;
}
.studio-magic-status[data-tone="error"] { color: var(--danger); }
.studio-magic-result {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.studio-magic-note {
  margin: 0;
  padding: 9px 11px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.5;
}
.studio-magic-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.studio-magic-result-actions .button {
  color: #101308;
  background: var(--accent);
}
.studio-magic-result-actions .button:hover { filter: brightness(1.06); }

/* Quality feedback dialog (reuses .studio-dialog chrome) */
.feedback-dialog { width: min(480px, calc(100vw - 32px)); }
.feedback-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}
.feedback-target {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.4;
}
.feedback-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.feedback-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.feedback-choice:hover { transform: translateY(-1px); border-color: var(--muted); }
.feedback-choice-glyph { font-size: 26px; line-height: 1; }
.feedback-choice[data-choice="up"].active {
  border-color: #2f9e57;
  background: #2f9e57;
  color: #ffffff;
}
.feedback-choice[data-choice="down"].active {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}
.feedback-reasons { display: flex; flex-direction: column; gap: 10px; }
.feedback-section-label,
.feedback-note-label {
  margin: 0;
  font-size: 12px;
  font-weight: 750;
  color: var(--text-soft);
}
.feedback-reason-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.feedback-reason-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.feedback-reason-chip:hover { border-color: var(--muted); color: var(--text); }
.feedback-reason-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.feedback-note {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.feedback-note:focus { outline: none; border-color: var(--accent); }
.feedback-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--line-soft);
}
.feedback-footer .feedback-status { margin-right: auto; font-size: 12px; color: var(--muted); }
.feedback-footer .text-button.danger { margin-right: auto; }
.feedback-footer .text-button.danger + .feedback-status { margin-right: 0; }

/* Safety & privacy dialog (reuses .studio-dialog chrome) */
.privacy-icon {
  position: relative;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 22%, 100% 60%, 50% 100%, 0 60%, 0 22%);
}
.privacy-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 44%;
  width: 3px;
  height: 4px;
  margin-left: -1.5px;
  margin-top: -2px;
  border-radius: 1px;
  background: var(--on-accent);
}
.privacy-dialog { width: min(520px, calc(100vw - 32px)); }
.privacy-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
}
.privacy-intro { margin: 0; font-size: 12.5px; color: var(--text-soft); line-height: 1.45; }
.privacy-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  cursor: pointer;
}
.privacy-toggle-text { display: flex; flex-direction: column; gap: 3px; }
.privacy-toggle-title { font-size: 13px; font-weight: 750; color: var(--text); }
.privacy-toggle-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.privacy-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.privacy-switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-50%);
  transition: transform .16s ease, background .16s ease;
}
.privacy-switch:checked { background: var(--accent); border-color: var(--accent); }
.privacy-switch:checked::before { background: var(--on-accent); transform: translate(18px, -50%); }
.privacy-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.privacy-switch:disabled { opacity: .5; cursor: not-allowed; }
.privacy-hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.4;
}
.privacy-danger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}
.privacy-danger-text { display: flex; flex-direction: column; gap: 3px; }
.button.danger {
  border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  cursor: pointer;
}
.button.danger:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.button.danger.armed { background: var(--danger); border-color: var(--danger); color: #2a0606; }
.button.danger[disabled] { opacity: .5; cursor: not-allowed; }
.privacy-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--line-soft);
}
.privacy-footer .privacy-status { margin-right: auto; font-size: 12px; color: var(--muted); }
.privacy-footer .privacy-status.error { color: var(--danger); }
.privacy-footer .button:not(.secondary) { color: var(--on-accent); background: var(--accent); }
.privacy-footer .button:disabled { opacity: .5; cursor: not-allowed; }

/* Workflow Presets dialog (reuses .studio-dialog chrome) */
.presets-hint {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.preset-entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
}
.preset-entry.is-disabled { opacity: .55; }
.preset-glyph {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-dark);
  font-size: 17px;
  line-height: 1;
}
.presets-enhance {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.presets-enhance-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.presets-enhance-head strong { font-size: 14px; }
.presets-enhance-source { color: var(--muted); font-size: 11px; }
.presets-enhance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.presets-enhance-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.presets-enhance-grid input {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  outline: none;
}
.presets-enhance-grid input:focus { border-color: var(--accent); }
.presets-enhance-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.presets-enhance-check input { width: auto; }
.presets-enhance-out { margin: 0; color: var(--text); font-size: 12px; font-weight: 700; }
.presets-enhance-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.presets-enhance-cost { flex: 1; color: var(--muted); font-size: 11px; }
.presets-enhance .button { color: #101308; background: var(--accent); }
.presets-enhance .button[disabled] { opacity: .5; cursor: not-allowed; }
.presets-enhance > label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.presets-enhance select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  outline: none;
}
.presets-enhance select:focus { border-color: var(--accent); }
.presets-enhance select option[disabled] { color: var(--muted); }
.presets-enhance-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.presets-enhance-note.is-warn { color: var(--warn, #d98324); }

.reference-extra { display: grid; gap: 6px; }
.reference-extra-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.reference-extra-list { display: grid; gap: 4px; max-height: 132px; overflow-y: auto; }
.reference-extra-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
}
.reference-extra-item input { width: auto; }
.reference-extra-item small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-extra-empty { color: var(--muted); font-size: 11px; }

@media (max-width: 620px) {
  .preset-entry { grid-template-columns: auto minmax(0, 1fr); }
  .preset-entry .studio-entry-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Video Timeline Editor dialog (reuses .studio-dialog chrome) */
.video-tool-empty {
  margin: 4px 0 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  background: var(--surface);
}
.video-tool-empty strong { color: var(--text); }
.video-tool {
  display: grid;
  gap: 14px;
  margin-top: 4px;
}
.video-tool-field,
.video-tool-grid label,
.video-tool-grid-single {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.video-tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}
.video-tool-grid-single { max-width: 180px; }
.video-tool select,
.video-tool input[type="text"],
.video-tool input[type="number"],
.video-tool textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
  outline: none;
  font: inherit;
  resize: vertical;
}
.video-tool select:focus,
.video-tool input:focus,
.video-tool textarea:focus { border-color: var(--accent); }
.video-tool .range-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.video-tool .range-field > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.video-tool .range-field output { color: var(--accent); font-weight: 800; }
.video-tool .range-field small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.45;
}
.video-tool input[type="range"] { width: 100%; accent-color: var(--accent); }
.video-tool-label { margin: 0; color: var(--muted); font-size: 12px; }
.video-clip-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.video-clip-option {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
}
.video-clip-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.video-clip-option input { accent-color: var(--accent); }
.video-clip-order {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #101308;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
  visibility: hidden;
}
.video-clip-option.is-picked .video-clip-order { visibility: visible; }
.video-clip-text { min-width: 0; }
.video-clip-text strong { display: block; font-size: 12px; color: var(--text); }
.video-clip-text small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.video-tool-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}
.video-tool-cost { flex: 1; color: var(--muted); font-size: 11px; }
.video-tool .button { color: #101308; background: var(--accent); }
.video-tool .button[disabled] { opacity: .5; cursor: not-allowed; }

@media (max-width: 620px) {
  .video-tool-grid { grid-template-columns: 1fr; }
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-options label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--panel-2);
  cursor: pointer;
  font-size: 11px;
}

.theme-options label:has(input:checked) {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.theme-options input { accent-color: var(--accent); }

.accent-picker,
.language-picker,
.credit-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.language-picker span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.language-picker select {
  min-width: 132px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.language-picker select:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.accent-picker input {
  width: 48px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  cursor: pointer;
}

.accent-presets { display: flex; gap: 9px; }
.accent-presets button {
  width: 26px;
  height: 26px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.accent-presets button:hover { transform: scale(1.1); }
.credit-settings { grid-template-columns: 1fr auto; }
.credit-settings b { color: var(--accent); }

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --line: #c8ced8;
  --line-soft: #e1e5eb;
  --text: #151922;
  --muted: #596273;
  --text-soft: #354052;
  --text-faint: #758094;
  --surface: #f7f8fa;
  --surface-raised: #ffffff;
  --surface-inset: #eef1f5;
  --surface-deep: #e5e9ef;
  --control: #f7f8fa;
  --graph-bg: #f7f8fa;
  --node-ring: #f7f8fa;
  --scroll-thumb: #aeb6c2;
  --shadow: rgba(31, 41, 55, .14);
  --on-accent: #182006;
  --danger: #c83f4b;
  --accent-dark: color-mix(in srgb, var(--accent) 20%, #ffffff);
}

:root[data-theme="light"] .file-signal {
  --signal-color: var(--signal-color-light);
  --signal-secondary: var(--signal-secondary-light);
}

:root[data-theme="light"] .canvas-panel,
:root[data-theme="light"] .conversation-panel,
:root[data-theme="light"] .timeline-panel,
:root[data-theme="light"] .history-drawer,
:root[data-theme="light"] .timeline-balloon,
:root[data-theme="light"] .composer,
:root[data-theme="light"] .messages,
:root[data-theme="light"] .document-summary,
:root[data-theme="light"] .settings {
  color: var(--text);
  background-color: var(--panel);
}

:root[data-theme="light"] .drop-zone,
:root[data-theme="light"] .image-frame,
:root[data-theme="light"] .timeline-scroll,
:root[data-theme="light"] .document-reader,
:root[data-theme="light"] .canvas-text {
  background-color: var(--surface);
}

:root[data-theme="light"] button,
:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select {
  color: var(--text);
}

:root[data-theme="light"] .history-button,
:root[data-theme="light"] .credit-control .credit-balance-button,
:root[data-theme="light"] .session-title-input,
:root[data-theme="light"] .timeline-zoom-controls,
:root[data-theme="light"] .settings input,
:root[data-theme="light"] .settings select {
  background: var(--panel-2);
}

:root[data-theme="light"] .topbar {
  border-bottom-color: var(--line);
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
}

:root[data-theme="light"] .canvas-panel,
:root[data-theme="light"] .conversation-panel {
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(31, 41, 55, .045);
}

:root[data-theme="light"] .canvas-text {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--surface-raised);
  scrollbar-color: var(--scroll-thumb) transparent;
}

:root[data-theme="light"] .markdown-body,
:root[data-theme="light"] .markdown-body p,
:root[data-theme="light"] .markdown-body li {
  color: var(--text-soft);
}

:root[data-theme="light"] .markdown-body strong {
  color: var(--text);
}

:root[data-theme="light"] .markdown-body em {
  color: var(--muted);
}

:root[data-theme="light"] .markdown-body code {
  border-color: var(--line);
  color: #536f0e;
  background: #edf3dd;
}

:root[data-theme="light"] .markdown-body pre {
  border-color: var(--line);
  background: #f1f3f6;
}

:root[data-theme="light"] .markdown-body pre code {
  color: var(--text-soft);
  background: transparent;
}

:root[data-theme="light"] .markdown-body a {
  color: #176b9d;
}

:root[data-theme="light"] .document-splitter {
  background: var(--surface-deep);
}

:root[data-theme="light"] .document-splitter::after,
:root[data-theme="light"] .workspace-splitter::after,
:root[data-theme="light"] .timeline-resizer::before {
  background: #aab2bf;
}

:root[data-theme="light"] .document-reader {
  background: #e9edf2;
  scrollbar-color: var(--scroll-thumb) transparent;
}

:root[data-theme="light"] .document-reader > header {
  border-bottom-color: var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 8px rgba(31, 41, 55, .08);
}

:root[data-theme="light"] .document-reader-controls button,
:root[data-theme="light"] .document-reader-controls select {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}

:root[data-theme="light"] .document-page {
  border-color: #b9c0ca;
  box-shadow: 0 14px 34px var(--shadow);
}

:root[data-theme="light"] .node-detail {
  border-color: var(--line);
  background: var(--surface-raised);
}

:root[data-theme="light"] .node-detail-block p,
:root[data-theme="light"] .node-detail-block .markdown-body,
:root[data-theme="light"] .concept-list dd {
  color: var(--text-soft);
}

:root[data-theme="light"] .node-detail-empty {
  color: var(--text-faint);
}

:root[data-theme="light"] .node-detail-label.whatif-label { color: #c0392b; }

:root[data-theme="light"] .exclusion-chip {
  border-color: rgba(214,69,69,.4);
  color: #b23b3b;
  background: rgba(214,69,69,.08);
}

:root[data-theme="light"] .exclusion-chip:hover,
:root[data-theme="light"] .exclusion-chip:focus-visible {
  border-color: rgba(214,69,69,.65);
  background: rgba(214,69,69,.16);
  color: #962f2f;
}

:root[data-theme="light"] .timeline-panel {
  border-color: var(--line-soft);
  background: var(--graph-bg);
}

:root[data-theme="light"] .timeline-scroll {
  scrollbar-color: var(--scroll-thumb) transparent;
}

:root[data-theme="light"] .timeline-zoom-controls {
  border-color: var(--line);
  background: var(--surface-raised);
  box-shadow: 0 1px 3px rgba(31, 41, 55, .06);
}

:root[data-theme="light"] .timeline-zoom-controls button {
  border-color: var(--line);
  color: var(--text-soft);
}

:root[data-theme="light"] .graph-mode-toggle,
:root[data-theme="light"] .graph-tool-button {
  border-color: var(--line);
  background: var(--surface-raised);
}

:root[data-theme="light"] .graph-mode-toggle button {
  color: var(--text-soft);
}

:root[data-theme="light"] .graph-mode-toggle button + button {
  border-left-color: var(--line);
}

:root[data-theme="light"] .graph-mode-toggle button.active {
  color: #2b3508;
}

:root[data-theme="light"] .graph-tool-button {
  color: var(--text-soft);
}

:root[data-theme="light"] .graph-minimap {
  border-color: var(--line);
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 6px 18px rgba(31, 41, 55, .14);
}

:root[data-theme="light"] .graph-minimap-edge {
  stroke: #c2c9d4;
}

:root[data-theme="light"] .graph-minimap-node {
  fill: #94a0b0;
}

:root[data-theme="light"] .timeline-collapse-button {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--graph-bg);
}

:root[data-theme="light"] .timeline-connectors path {
  stroke: #99a3b1;
}

:root[data-theme="light"] .timeline-connectors .document-edge-label {
  fill: #657184;
  stroke: var(--graph-bg);
}

:root[data-theme="light"] .timeline-node {
  color: #5f6979;
}

:root[data-theme="light"] .timeline-node.lineage-muted {
  opacity: .72;
}

:root[data-theme="light"] .timeline-node-dot,
:root[data-theme="light"] .timeline-node-dot.category-dot {
  border-color: #7f8998;
  background: var(--surface-raised);
  box-shadow: 0 0 0 5px var(--node-ring);
}

:root[data-theme="light"] .timeline-node-dot.category-dot {
  border-color: var(--category-color-light, var(--category-color));
}

:root[data-theme="light"] .timeline-node.lineage .timeline-node-dot,
:root[data-theme="light"] .timeline-node.current .timeline-node-dot,
:root[data-theme="light"] .timeline-node.pending.current .timeline-node-dot {
  box-shadow:
    0 0 0 5px var(--node-ring),
    0 0 14px color-mix(in srgb, var(--accent) 36%, transparent);
}

:root[data-theme="light"] .timeline-node.selected .timeline-node-dot,
:root[data-theme="light"] .timeline-node.merge-selected .timeline-node-dot,
:root[data-theme="light"] .timeline-node.reference .timeline-node-dot {
  box-shadow: 0 0 0 5px var(--node-ring), 0 0 0 7px rgba(98, 200, 255, .34);
}

:root[data-theme="light"] .timeline-node.fuse-selected .timeline-node-dot {
  border-color: #9a6ff0;
  box-shadow: 0 0 0 5px var(--node-ring), 0 0 0 7px rgba(154, 111, 240, .34);
}

:root[data-theme="light"] .graph-legend-swatch {
  color: var(--text);
  border-color: var(--category-color-light, var(--category-color));
  background: color-mix(
    in srgb,
    var(--category-color-light, var(--category-color)) 14%,
    white
  );
}

:root[data-theme="light"] .timeline-modality-badge,
:root[data-theme="light"] .timeline-exclusion-record,
:root[data-theme="light"] .timeline-version-record,
:root[data-theme="light"] .timeline-batch-record,
:root[data-theme="light"] .timeline-milestone-record,
:root[data-theme="light"] .timeline-regenerate-button {
  border-color: #9aa4b2;
  color: var(--text-soft);
  background: var(--surface-raised);
  box-shadow: 0 0 0 2px var(--node-ring);
}

:root[data-theme="light"] .timeline-batch-record {
  border-color: rgba(126,160,16,.55);
  color: #5f7d0c;
}

:root[data-theme="light"] .timeline-branch-button,
:root[data-theme="light"] .timeline-merge-button,
:root[data-theme="light"] .timeline-exclude-button {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--surface-raised);
}

:root[data-theme="light"] .timeline-balloon {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 18px 55px rgba(31, 41, 55, .2);
}

:root[data-theme="light"] .timeline-balloon-text {
  color: var(--text-soft);
  background: var(--surface);
}

:root[data-theme="light"] .timeline-balloon-actions button,
:root[data-theme="light"] .timeline-balloon-actions .button {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}

:root[data-theme="light"] .messages {
  color: var(--text);
  background: var(--panel);
  scrollbar-color: var(--scroll-thumb) transparent;
}

:root[data-theme="light"] .welcome-message,
:root[data-theme="light"] .assistant .bubble,
:root[data-theme="light"] .conversation-origin,
:root[data-theme="light"] .conversation-reference,
:root[data-theme="light"] .conversation-branch,
:root[data-theme="light"] .branch-history-reveal,
:root[data-theme="light"] .history-card {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
}

:root[data-theme="light"] .conversation-reference {
  background: linear-gradient(145deg, rgba(30, 136, 191, .08), var(--surface) 58%);
}

:root[data-theme="light"] .message-time,
:root[data-theme="light"] .conversation-origin small,
:root[data-theme="light"] .conversation-reference small,
:root[data-theme="light"] .result-card-instruction,
:root[data-theme="light"] .result-card-kind,
:root[data-theme="light"] .result-card-metadata dt,
:root[data-theme="light"] .request-cost small {
  color: var(--text-faint);
}

:root[data-theme="light"] .conversation-reference p,
:root[data-theme="light"] .result-card-metadata dd {
  color: var(--text-soft);
}

:root[data-theme="light"] .result-card {
  border-color: var(--line);
  color: var(--text);
  background: linear-gradient(145deg, #ffffff, #f5f7fa);
}

:root[data-theme="light"] .result-card-preview {
  border-color: var(--line);
  background: var(--surface-inset);
}

:root[data-theme="light"] .result-card-text {
  color: var(--text-soft);
  background: var(--surface);
}

:root[data-theme="light"] .conversation-merge-join span {
  background: var(--panel);
}

:root[data-theme="light"] .suggestions button {
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface-raised);
}

:root[data-theme="light"] .composer {
  border-color: #b8c0cb;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 2px 8px rgba(31, 41, 55, .06);
}

:root[data-theme="light"] .composer-toggle,
:root[data-theme="light"] .cost-help-button,
:root[data-theme="light"] .cost-help-popover {
  color: var(--text-soft);
  border-color: var(--line);
  background: var(--surface-raised);
}

:root[data-theme="light"] .batch-popover,
:root[data-theme="light"] .batch-compare-panel {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-raised);
}
:root[data-theme="light"] .batch-count-field select,
:root[data-theme="light"] .batch-mode-option {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}
:root[data-theme="light"] .batch-mode-option.active {
  border-color: rgba(126,160,16,.55);
  color: #5f7d0c;
  background: rgba(126,160,16,.12);
}
:root[data-theme="light"] .batch-button.active {
  color: #2b3508;
  background: var(--accent);
}
:root[data-theme="light"] .batch-button.active span:first-child { color: #2b3508; }
:root[data-theme="light"] .composer-chip {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}
:root[data-theme="light"] .modality-popover,
:root[data-theme="light"] .settings-popover {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-raised);
}
:root[data-theme="light"] .modality-popover label:hover span { background: var(--control); }
:root[data-theme="light"] .modality-popover input:checked + span,
:root[data-theme="light"] .modality-popover input:checked + span b { color: #2b3508; }
:root[data-theme="light"] .batch-compare-head,
:root[data-theme="light"] .batch-compare-tile figcaption {
  border-color: var(--line);
}
:root[data-theme="light"] .batch-compare-tile {
  border-color: var(--line);
  background: var(--surface);
}
:root[data-theme="light"] .batch-compare-close {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}

:root[data-theme="light"] .regen-card {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-raised);
}
:root[data-theme="light"] .regen-head,
:root[data-theme="light"] .regen-foot {
  border-color: var(--line);
}
:root[data-theme="light"] .regen-foot { background: var(--surface); }
:root[data-theme="light"] .regen-source-preview,
:root[data-theme="light"] .regen-toggle,
:root[data-theme="light"] .regen-row select,
:root[data-theme="light"] #regenLockCustom,
:root[data-theme="light"] .regen-lock-chip,
:root[data-theme="light"] .regen-version-option,
:root[data-theme="light"] .regen-close {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}
:root[data-theme="light"] .regen-lock-chip.active,
:root[data-theme="light"] .regen-version-option.active {
  border-color: rgba(126,160,16,.55);
  color: #5f7d0c;
  background: rgba(126,160,16,.12);
}

:root[data-theme="light"] .composer:focus-within {
  border-color: #788495;
  box-shadow: 0 0 0 3px rgba(98, 200, 255, .12);
}

:root[data-theme="light"] .composer textarea::placeholder {
  color: #7b8594;
}

/* --- Light mode: holistic dark-surface fixes --------------------------- */
/* Components below hardcode dark hex (the app is dark-first); these light
   overrides recolour them to the light surface variables. */
:root[data-theme="light"] .composer { background: var(--panel); }
:root[data-theme="light"] .composer-toggle {
  background: var(--panel-2);
  border-bottom-color: var(--line-soft);
}

/* Account button (username was dark text on a hardcoded dark pill = invisible). */
:root[data-theme="light"] .user-button {
  background: var(--panel-2);
  color: var(--text);
}
:root[data-theme="light"] .user-button:hover { border-color: var(--accent); }

/* PDF selection toolbar + its action buttons. */
:root[data-theme="light"] .pdf-selection-popover {
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 97%, transparent);
  box-shadow: 0 12px 30px rgba(31, 41, 55, .18);
}
:root[data-theme="light"] .pdf-popover-colors { border-right-color: var(--line); }
:root[data-theme="light"] .pdf-popover-buttons button {
  border-color: var(--line);
  background: var(--surface-raised);
  color: var(--text);
}
:root[data-theme="light"] .pdf-popover-buttons button:hover { background: var(--surface-inset); }

/* All text inputs / textareas (prompt box, note fields, search, forms). */
:root[data-theme="light"] textarea,
:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] input[type="search"],
:root[data-theme="light"] input[type="url"],
:root[data-theme="light"] input[type="email"],
:root[data-theme="light"] input[type="number"],
:root[data-theme="light"] input[type="password"],
:root[data-theme="light"] input:not([type]) {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--line);
}
/* The composer textarea sits on the (now white) composer, so keep it clear. */
:root[data-theme="light"] .composer textarea { background: transparent; }


:root[data-theme="light"] .output-type {
  border-color: var(--line);
  background: var(--surface-inset);
}

:root[data-theme="light"] .attach-image-button,
:root[data-theme="light"] .composer-attachment button,
:root[data-theme="light"] .button.secondary,
:root[data-theme="light"] .icon-button,
:root[data-theme="light"] .drawer-close {
  border-color: var(--line);
  color: var(--text-soft);
  background: var(--control);
}

:root[data-theme="light"] .settings {
  border-color: var(--line-soft);
  background: var(--panel);
}

:root[data-theme="light"] .settings input,
:root[data-theme="light"] .settings select {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-raised);
}

:root[data-theme="light"] .video-estimate {
  color: var(--text-soft);
  background: var(--surface-inset);
}

:root[data-theme="light"] .range-field small {
  color: var(--text-faint);
}

:root[data-theme="light"] .history-drawer {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: -20px 0 60px rgba(31, 41, 55, .16);
}

:root[data-theme="light"] .library-drawer {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: -20px 0 60px rgba(31, 41, 55, .16);
}

:root[data-theme="light"] .collab-drawer {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: -20px 0 60px rgba(31, 41, 55, .16);
}
:root[data-theme="light"] .collab-tab,
:root[data-theme="light"] .collab-person,
:root[data-theme="light"] .collab-composer textarea {
  background: var(--panel-2);
}
:root[data-theme="light"] .collab-tab.active {
  color: #101308;
  background: var(--accent);
}

/* --- Model arena (A/B duels & ELO leaderboard) --------------------------- */
.arena-icon {
  position: relative;
  width: 14px;
  height: 14px;
}
.arena-icon::before,
.arena-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 0;
  border-top: 1.6px solid var(--accent);
}
.arena-icon::before { transform: translate(-50%, -50%) rotate(45deg); }
.arena-icon::after { transform: translate(-50%, -50%) rotate(-45deg); }
.arena-dialog { width: min(720px, calc(100vw - 32px)); }
.arena-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 20px 0;
}
.arena-tab {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
}
.arena-tab.is-active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.arena-panel { padding: 16px 20px 0; }
.arena-intro {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.arena-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.arena-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-raised);
}
.arena-card-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.arena-card-media img,
.arena-card-media video {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
}
.arena-card-media audio { width: 100%; }
.arena-card-model {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}
.arena-versus {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.arena-verdicts {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  margin-top: 16px;
}
.arena-verdict {
  padding: 11px 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.arena-verdict:hover {
  background: var(--accent);
  color: var(--on-accent);
}
.arena-verdict.tie {
  border-color: var(--line);
  color: var(--text-soft);
}
.arena-verdict.tie:hover {
  background: var(--surface-raised);
  color: var(--text);
}
.arena-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.arena-progress { font-size: 12px; color: var(--text-soft); }
.arena-empty {
  margin: 18px 0 4px;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
}
.arena-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.arena-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}
.arena-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  min-width: 32px;
}
.arena-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.arena-row-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arena-record { font-size: 12px; color: var(--text-soft); }
.arena-elo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.arena-footer {
  display: flex;
  align-items: center;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
}
.arena-status { font-size: 12px; color: var(--accent); min-height: 16px; }
.arena-status[data-tone="error"] { color: var(--danger); }
@media (max-width: 640px) {
  .arena-stage { grid-template-columns: 1fr; }
  .arena-versus { display: none; }
}

:root[data-theme="light"] .collab-mention-menu {
  background: var(--surface-raised);
}
:root[data-theme="light"] .collab-mention-option:hover,
:root[data-theme="light"] .collab-mention-option.active {
  background: var(--panel-2);
}
:root[data-theme="light"] .collab-activity-icon,
:root[data-theme="light"] .collab-role-badge {
  background: var(--panel-2);
}
:root[data-theme="light"] .timeline-comment-record {
  color: #2563a8;
  background: var(--panel);
  box-shadow: 0 0 0 2px var(--panel);
}

:root[data-theme="light"] .library-filter,
:root[data-theme="light"] .library-card,
:root[data-theme="light"] .library-action {
  background: var(--panel-2);
}

:root[data-theme="light"] .library-thumb { background: #eef2f6; }
:root[data-theme="light"] .library-card:hover { border-color: #aeb6c2; }

:root[data-theme="light"] .library-filter.active,
:root[data-theme="light"] .library-action.primary,
:root[data-theme="light"] .library-upload {
  color: #101308;
}

:root[data-theme="light"] .history-card:hover,
:root[data-theme="light"] .history-card.active {
  border-color: #aeb6c2;
  background: #eef2f6;
}

@media (max-width: 1260px) {
  /* Collapse the engine status to its dot when the action row gets tight. */
  .backend-status span:last-child { display: none; }
}

@media (max-width: 1180px) {
  /* Tuck away the credits pill and brand subtitle so the action row never
     collides with the brand. Balance stays available in the account menu. */
  .credit-control { display: none; }
  .brand small { display: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-rows: 62px auto; }
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0 18px;
  }
  .brand small { display: none; }
  .session-title-row h1 { max-width: 100%; }
  .workspace { grid-template-columns: 1fr; padding: 10px; }
  .workspace-splitter { display: none; }
  .canvas-panel { min-height: 65vh; }
  .conversation-panel { max-height: none; min-height: 620px; }
  .image-frame img,
  .image-frame video { max-height: 65vh; }
  .current-frame.document-source-view { grid-template-columns: 1fr; overflow: auto; }
  .document-splitter { display: none !important; }
  .document-reader { min-height: 360px; }
}

@media (max-width: 560px) {
  .backend-status span:last-child { display: none; }
  .brand > span:last-child { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .credit-control { display: none; }
  .session-title-row h1 { font-size: 12px; }
  .session-title-control .eyebrow { display: none; }
  .topbar-actions { gap: 8px; }
  .history-button { padding: 8px; font-size: 0; }
  .history-icon { margin: 0 1px; }
  .canvas-toolbar, .conversation-header { padding: 18px; }
  .canvas-toolbar { align-items: flex-start; }
  .toolbar-actions { flex-direction: column; align-items: flex-end; }
  .drop-zone { margin: 10px; }
  .canvas-footer { padding: 0 16px; }
  .empty-state { padding: 40px 20px; }
  .image-stage.comparing { grid-template-columns: 1fr; }
  .image-stage.comparing .image-frame { min-height: 280px; }
  .timeline-heading-tools > span { display: none; }
  .timeline-heading { align-items: center; }
  .share-form { grid-template-columns: 1fr; }
  .share-link-controls,
  .share-link-result { grid-template-columns: 1fr; }
  .share-form .button { width: 100%; }
}

/* --- Authentication pages (login / register) --------------------------- */
.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.auth-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 34px 32px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 30px 80px var(--shadow);
}

.auth-brand {
  align-self: flex-start;
  gap: 12px;
}

.auth-intro h1 {
  margin-top: 4px;
  font-size: 24px;
  letter-spacing: -.03em;
}

.auth-subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-benefits {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.auth-benefits li {
  position: relative;
  padding-left: 26px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.4;
}

.auth-benefits li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    linear-gradient(transparent, transparent),
    var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m4 8 2.5 2.5L12 5'/%3E%3C/svg%3E") center / 12px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m4 8 2.5 2.5L12 5'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.auth-providers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface-raised);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, transform .05s, box-shadow .15s;
}

/* --- Workflow plugins ----------------------------------------------------- */
.plugins-button .plugins-glyph { color: var(--accent); font-size: 14px; line-height: 1; }
.composer-chip.plugins-button.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(126, 160, 16, .14);
}

.active-plugin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 26px;
  padding: 0 6px 0 9px;
  border: 1px solid rgba(126, 160, 16, .55);
  border-radius: 999px;
  color: var(--text);
  background: rgba(126, 160, 16, .14);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.active-plugin-pill .active-plugin-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(126, 160, 16, .8);
}
.active-plugin-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.active-plugin-clear:hover { background: rgba(255, 255, 255, .12); }

.plugins-dialog .studio-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.plugins-dialog .studio-kind-hint code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-inset);
  font-size: 11px;
}

.plugin-editor,
.plugin-use {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plugin-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
}
.plugin-editor input,
.plugin-editor select,
.plugin-editor textarea,
.plugin-use input {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 13px;
}
.plugin-editor textarea {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  resize: vertical;
}
.plugin-inspect-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.plugin-inspect-status { font-size: 12px; color: var(--muted); }
.plugin-inspect-status[data-tone="error"] { color: var(--danger); }

.plugin-inspect-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-inset);
}
.plugin-output-node {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.plugin-output-node input { flex: 1; }

.plugin-params { display: flex; flex-direction: column; gap: 8px; }
.plugin-param-empty { font-size: 12px; color: var(--muted); margin: 0; }
.plugin-param-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.plugin-param-token {
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--accent);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plugin-param-req {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.plugin-use-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.plugin-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-inset);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .plugin-field-row { grid-template-columns: minmax(0, 1fr); }
  .plugin-param-row { grid-template-columns: minmax(0, 1fr); }
}

:root[data-theme="light"] .plugin-editor input,
:root[data-theme="light"] .plugin-editor select,
:root[data-theme="light"] .plugin-editor textarea,
:root[data-theme="light"] .plugin-use input {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-raised);
}
:root[data-theme="light"] .plugin-inspect-detail {
  border-color: var(--line);
  background: var(--surface);
}


.google-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.google-button:active { transform: translateY(1px); }

.discord-button:hover {
  border-color: #5865F2;
  box-shadow: 0 0 0 3px color-mix(in srgb, #5865F2 22%, transparent);
}

.google-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.auth-error {
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 11px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  font-size: 13px;
}

.auth-config-note {
  margin: -8px 0 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
}

.auth-footer {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.auth-footer a,
.auth-legal a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.auth-footer a:hover,
.auth-legal a:hover { text-decoration: underline; }

.auth-legal {
  margin: 0;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

/* --- Standard site footer (public pages) ------------------------------- */
.site-footer {
  width: 100%;
  padding: 20px clamp(16px, 4vw, 48px);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
}
.site-footer p { margin: 0; }
.site-footer a {
  color: var(--text-soft);
  text-decoration: none;
}
.site-footer a:hover { color: var(--text); text-decoration: underline; }
.site-footer--bordered {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.settings-legal {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

/* --- Signed-in user menu (topbar) -------------------------------------- */
.login-button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 9px;
  color: var(--on-accent);
  background: var(--accent);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.login-button:hover { filter: brightness(1.06); }

.login-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-control {
  position: relative;
  flex: 0 0 auto;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #13161a;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.user-button:hover { border-color: #4b515b; }

.user-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  color: var(--on-accent);
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-button-name {
  max-width: 120px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 60px var(--shadow);
}

.user-menu-name {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-email {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-divider {
  height: 1px;
  margin: 4px -14px 8px;
  background: var(--line-soft);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
}
.user-menu-item:hover { border-color: var(--line); background: var(--surface-raised); }

.user-menu-signout {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.user-menu-signout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

@media (max-width: 560px) {
  .user-button-name { display: none; }
}

/* --- Admin console -------------------------------------------------------- */

.admin-body {
  min-height: 100vh;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(14px);
}

.admin-brand {
  text-decoration: none;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-whoami {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-auto {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.admin-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.admin-card-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.admin-card-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.admin-card-hint {
  color: var(--text-faint);
  font-size: 11px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
}

.admin-tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.admin-tab:hover {
  border-color: #4b515b;
  color: var(--text);
}

.admin-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-dark);
  color: var(--accent);
}

.admin-panel {
  min-height: 240px;
}

.admin-loading,
.admin-empty,
.admin-error {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.admin-error {
  border-style: solid;
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}

.admin-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 0 12px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-soft);
}

.admin-count {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 11px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.admin-table th {
  position: sticky;
  top: 0;
  padding: 11px 14px;
  text-align: left;
  background: var(--surface-inset);
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: .05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--surface-raised);
}

.admin-num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; color: var(--text-soft); }
.amount-pos { color: var(--accent); }
.amount-neg { color: var(--danger); }

.admin-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-dark);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.admin-avatar img { width: 100%; height: 100%; object-fit: cover; }

.admin-user-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.admin-user-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.admin-user-email { color: var(--text-faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.admin-badge.provider-google { background: rgba(66, 133, 244, .16); color: #8ab4f8; }
.admin-badge.provider-discord { background: rgba(88, 101, 242, .18); color: #a4adf6; }
.admin-badge.provider-local { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.admin-badge.status-success { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.admin-badge.status-succeeded { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.admin-badge.status-error,
.admin-badge.status-failed { background: rgba(255, 107, 107, .16); color: var(--danger); }
.admin-badge.status-pending,
.admin-badge.status-queued,
.admin-badge.status-cancelled,
.admin-badge.status-connecting { background: rgba(151, 155, 164, .16); color: var(--text-soft); }
.admin-badge.status-interrupted { background: rgba(245, 179, 90, .18); color: #f5b35a; }
.admin-badge.status-running { background: rgba(96, 165, 250, .18); color: #93c5fd; }
.admin-badge.kind-admin { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.admin-badge.kind-generation { background: rgba(255, 107, 107, .12); color: #ff9d9d; }
.admin-badge.kind-purchase { background: rgba(96, 165, 250, .16); color: #93c5fd; }
.admin-badge.ok { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.admin-hint {
  margin: 12px 2px 0;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.5;
}
.admin-hint code,
.admin-table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-raised);
  padding: 1px 5px;
  border-radius: 5px;
}

.admin-actions-cell { white-space: nowrap; }

.admin-link-btn {
  margin-right: 10px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.admin-link-btn:last-child { margin-right: 0; }
.admin-link-btn:hover { text-decoration: underline; }
.admin-link-btn.danger { color: var(--danger); }
.admin-link-btn:disabled { color: var(--text-soft); cursor: default; text-decoration: none; opacity: .6; }

.admin-error-msg {
  max-width: 520px;
  color: #ff9d9d;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-progress {
  width: 120px;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-inset);
  overflow: hidden;
}

.admin-progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .3s ease;
}

.admin-progress-fill.status-failed,
.admin-progress-fill.status-error { background: var(--danger); }

.admin-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.admin-stat span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.admin-stat strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-logs {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-inset);
  overflow: hidden;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
}

.admin-logline {
  display: grid;
  grid-template-columns: 168px 56px 150px 1fr;
  gap: 12px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

.admin-logline:last-child { border-bottom: none; }
.admin-log-time { color: var(--text-faint); }
.admin-log-level { font-weight: 800; }
.admin-log-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.admin-log-msg { color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }

.admin-logline.level-WARNING .admin-log-level { color: #fbbf24; }
.admin-logline.level-ERROR .admin-log-level,
.admin-logline.level-CRITICAL .admin-log-level { color: var(--danger); }
.admin-logline.level-INFO .admin-log-level { color: #93c5fd; }
.admin-logline.level-DEBUG .admin-log-level { color: var(--text-faint); }

.admin-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 480px;
  padding: 12px 18px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 24px 60px var(--shadow);
}

.admin-toast.error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 720px) {
  .admin-topbar { padding: 12px 16px; }
  .admin-main { padding: 18px 14px 56px; }
  .admin-whoami { display: none; }
  .admin-logline { grid-template-columns: 1fr; gap: 2px; white-space: normal; }
}

/* --- Smart suggestions (related nodes / next step) ----------------------- */
.suggest-icon {
  position: relative;
  width: 14px;
  height: 14px;
}
.suggest-icon::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50% 50% 50% 50%;
  border: 1.6px solid var(--accent);
  transform: translateX(-50%);
}
.suggest-icon::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 5px;
  height: 3px;
  border: 1.6px solid var(--accent);
  border-top: none;
  transform: translateX(-50%);
}
.suggest-dialog { width: min(640px, calc(100vw - 32px)); }
.suggest-intro {
  margin: 0;
  padding: 12px 20px 0;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.suggest-context {
  margin: 8px 20px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.suggest-section { padding: 16px 20px 0; }
.suggest-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.suggest-next-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.suggest-next-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface-raised);
}
.suggest-next-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggest-next-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.suggest-kind {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--accent);
  border: 1px solid var(--line);
  background: var(--surface);
}
.suggest-next-instruction {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-soft);
}
.suggest-next-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.suggest-support { font-size: 12px; color: var(--muted); }
.suggest-apply {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--on-accent);
  background: var(--accent);
}
.suggest-apply:hover { filter: brightness(1.05); }
.suggest-related-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suggest-related-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-raised);
  cursor: pointer;
}
.suggest-related-card:hover { border-color: var(--accent); }
.suggest-related-thumb {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  font-size: 20px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}
.suggest-related-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.suggest-related-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.suggest-related-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest-related-session {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest-related-badge {
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--line);
}
.suggest-related-score {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.suggest-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.suggest-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
}
.suggest-status { font-size: 12px; color: var(--accent); min-height: 16px; }
.suggest-status[data-tone="error"] { color: var(--danger); }
.suggest-footer .text-button { margin-left: auto; }

/* Saved pipelines & scheduling (More menu icon + dialog) */
.pipelines-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.pipelines-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  box-shadow: 7px 7px 0 -1px var(--accent);
}
.pipelines-icon::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 5px;
  height: 5px;
  border-bottom: 1.5px solid var(--accent);
  border-left: 1.5px solid var(--accent);
}

.pipelines-dialog .pipelines-body { gap: 12px; }
.pipeline-row { flex-wrap: wrap; }
.pipeline-row.disabled { opacity: .6; }
.pipeline-actions { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pipeline-error { color: var(--danger); word-break: break-word; }

.pipeline-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pipeline-editor > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.pipeline-editor > label small { color: var(--muted); font-weight: 500; }
.pipeline-editor input[type="text"],
.pipeline-editor input[type="url"],
.pipeline-editor input[type="number"],
.pipeline-editor select,
.pipeline-editor textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  box-sizing: border-box;
}
.pipeline-editor textarea { resize: vertical; min-height: 44px; }

.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pipeline-steps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pipeline-steps-head strong { font-size: 12px; color: var(--text); }

.pipeline-step-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.pipeline-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pipeline-step-index {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.pipeline-step-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.pipeline-step-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.pipeline-step-grid label.hidden { display: none; }

.pipeline-schedule {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  margin: 0;
}
.pipeline-schedule legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  padding: 0 4px;
}
.pipeline-schedule label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.pipeline-inline {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}
.pipeline-inline input { width: 15px; height: 15px; accent-color: var(--accent); }
.pipeline-editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 640px) {
  .pipeline-step-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

:root[data-theme="light"] .pipeline-editor input,
:root[data-theme="light"] .pipeline-editor select,
:root[data-theme="light"] .pipeline-editor textarea,
:root[data-theme="light"] .pipeline-step-row {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-raised);
}

/* Teams / workspaces (More menu icon + dialog) */
.workspaces-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.workspaces-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 9px 0 0 0 var(--accent), 4.5px -2px 0 0 var(--accent);
}
.workspaces-icon::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 13px;
  height: 5px;
  border-radius: 3px 3px 0 0;
  border: 1.5px solid var(--accent);
  border-bottom: none;
}

.workspaces-dialog .workspaces-body { gap: 12px; }
.workspace-create-form,
.workspace-member-form,
.workspace-library-form,
.workspace-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.workspace-member-form,
.workspace-library-form { align-items: center; }
.workspace-row { width: 100%; text-align: left; cursor: pointer; }
.workspace-row:hover { border-color: var(--accent); }

.workspace-detail { display: flex; flex-direction: column; gap: 12px; }
.workspace-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.workspace-detail-head h3 { margin: 0; font-size: 16px; }
.workspace-quota {
  font-size: 12.5px;
  color: var(--text-soft);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.workspace-section-title {
  margin: 6px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.workspace-actions-row { display: flex; gap: 12px; align-items: center; }
.workspace-member-row .api-key-actions,
.workspace-library-row .api-key-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.workspace-library-form textarea {
  flex: 1 1 100%;
  resize: vertical;
  min-height: 40px;
}
.workspace-library-row .api-key-meta {
  white-space: pre-wrap;
  word-break: break-word;
}

:root[data-theme="light"] .workspace-quota,
:root[data-theme="light"] .workspace-create-form input,
:root[data-theme="light"] .workspace-settings input,
:root[data-theme="light"] .workspace-member-form input,
:root[data-theme="light"] .workspace-member-form select,
:root[data-theme="light"] .workspace-library-form input,
:root[data-theme="light"] .workspace-library-form select,
:root[data-theme="light"] .workspace-library-form textarea {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-raised);
}

/* --- PWA: install affordance, standalone, mobile & touch --------------- */

/* "Install app" more-menu glyph: a down arrow dropping into a tray. */
.install-icon {
  position: relative;
  width: 13px;
  height: 13px;
}
.install-icon::before {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0;
  width: 6px;
  height: 8px;
  background: var(--accent);
  clip-path: polygon(40% 0, 60% 0, 60% 45%, 100% 45%, 50% 100%, 0 45%, 40% 45%);
}
.install-icon::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 13px;
  height: 4px;
  border: 1.5px solid var(--accent);
  border-top: none;
  border-radius: 0 0 3px 3px;
}

/* When launched as an installed app, respect the device safe areas (notches)
   and never offer to install again. */
@media (display-mode: standalone) {
  .topbar {
    padding-top: env(safe-area-inset-top);
    padding-left: max(28px, env(safe-area-inset-left));
    padding-right: max(28px, env(safe-area-inset-right));
  }
  .composer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  #installAppButton { display: none !important; }
}

/* Coarse (touch) pointers: enlarge the small drawing/graph hit targets. */
@media (pointer: coarse) {
  .canvas-anno-marker { min-width: 30px; height: 30px; }
  .canvas-anno-tool,
  .timeline-heading-tools button,
  .composer-tools button { min-height: 40px; }
  .more-menu-item { padding-top: 12px; padding-bottom: 12px; }
  .timeline-node { touch-action: none; }
}

/* Phones: turn modal dialogs into full-screen sheets and keep form fields at
   16px so iOS doesn't auto-zoom the viewport on focus. */
@media (max-width: 640px) {
  .shell { min-height: 100dvh; }
  .studio-dialog,
  .appearance-dialog {
    top: 0;
    left: 0;
    transform: none;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .studio-dialog > header,
  .appearance-dialog > header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
    padding-top: max(16px, env(safe-area-inset-top));
  }
  textarea,
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  select {
    font-size: 16px;
  }
}

/* Narrow phones: give the graph more height and let the composer breathe. */
@media (max-width: 480px) {
  .timeline-scroll { max-height: 46vh; }
  .more-menu { width: min(280px, calc(100vw - 24px)); }
}

/* --- Usage & cost analytics dashboard --------------------------------- */
.usage-icon {
  width: 13px;
  height: 13px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 100% / 3px 6px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 5px 100% / 3px 11px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 10px 100% / 3px 8px no-repeat;
}

.usage-dialog .usage-body { gap: 14px; }

.usage-range {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  align-self: flex-start;
}
.usage-range-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.usage-range-btn.active {
  background: var(--accent);
  color: #101308;
}

.usage-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.usage-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.usage-card strong { font-size: 22px; color: var(--text); }
.usage-card-label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.usage-card small { font-size: 11px; color: var(--muted); }

.usage-section-title {
  margin: 4px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.usage-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.usage-chart-svg {
  width: 100%;
  height: 110px;
  display: block;
}
.usage-chart-bar { fill: var(--accent); }
.usage-chart-bar.empty { fill: var(--line); }
.usage-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
}

.usage-breakdowns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.usage-bars { display: flex; flex-direction: column; gap: 7px; }
.usage-bar-row {
  display: grid;
  grid-template-columns: minmax(60px, 84px) 1fr auto;
  align-items: center;
  gap: 8px;
}
.usage-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usage-bar-track {
  height: 8px;
  border-radius: 5px;
  background: var(--surface-raised);
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--accent);
}
.usage-bar-value {
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .usage-cards { grid-template-columns: 1fr; }
  .usage-breakdowns { grid-template-columns: 1fr; }
}

:root[data-theme="light"] .usage-card,
:root[data-theme="light"] .usage-range {
  border-color: var(--line);
  background: var(--surface-raised);
}
:root[data-theme="light"] .usage-bar-track {
  background: var(--surface);
}

