/* =========================================================
   SOnIA instance dashboard — instance-specific layout only.
   Brand tokens, typography, buttons, cards, pills, modal,
   grid, row, stack, etc. come from brand.css (loaded first).
   This file only adds what is specific to this dashboard:
   page layout, tab bar, vault browser, drop zone, checklist,
   topbar layout, quick-command bar, collapsible section.
   ========================================================= */

/* ---- page shell ---- */
/* belt-and-suspenders: no element may cause a horizontal scroll (mobile) */
html, body { overflow-x: clip; max-width: 100%; }
.page-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ---- topbar: override spacer + right-side host label ---- */
.topbar .brand .name { font-size: 1.1rem; }
.topbar-host {
  font-size: 0.8rem;
  color: var(--sl);
  white-space: nowrap;
}

/* ---- tab bar ---- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  background: #fff;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--slate);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; /* overlap bar border */
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  border-radius: 0;
  line-height: 1;
}
.tab-btn .ic { width: 15px; height: 15px; }
.tab-btn:hover { color: var(--navy); }
.tab-btn.tab-active {
  color: var(--o);
  font-weight: 600;
  border-bottom-color: var(--o);
}

/* ---- tab panels ---- */
.tab-panel { }
.tab-panel.hidden { display: none; }

/* ---- KPI grid: responsive, fits 4–5 tiles per row naturally ---- */
/* ---- stat tiles: uniform height so the grid doesn't jump ---- */
.tile { min-height: 96px; }

/* storage tile: keep label icon at text baseline, not as a large glyph */
.tile .label .ic { width: 14px; height: 14px; vertical-align: middle; margin-right: 2px; }

/* ---- storage usage bar (inside .tile) ---- */
.storage-bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--o);
  transition: width 0.4s ease;
}
.storage-bar-fill.warn { background: #f59e0b; }
.storage-bar-fill.err  { background: var(--err); }

/* ---- pairing card ---- */
.pairing-card-inner { padding: 4px 0; }
.pairing-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.pairing-title .ic { width: 17px; height: 17px; color: var(--o); }
.pairing-hint { margin: 0 0 14px; }
.pairing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- collapsible section (Primeros pasos) ---- */
.collapsible-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 18px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.collapsible-hdr h3 {
  margin: 0;
  font-size: 1rem;
}
/* inline icon next to heading text — prevent the SVG from floating on its own line */
.collapsible-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.collapsible-title .ic { color: var(--ok); width: 17px; height: 17px; flex: none; }
.collapsible-hdr .toggle-icon {
  color: var(--slate);
  transition: transform 0.2s;
  line-height: 1;
}
.collapsible-hdr.open .toggle-icon { transform: rotate(180deg); }
.collapsible-body {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px;
  background: #fff;
}
.collapsible-body.hidden { display: none; }

/* ---- checklist ---- */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.step {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.step:first-child { border-top: none; }
.step-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--o-soft);
  color: var(--o);
  font-weight: 700;
  font-size: 0.85rem;
}
.step.done .step-num {
  background: #dcfce7;
  color: var(--ok);
}
.step.done .step-num .ic { width: 15px; height: 15px; }
.step-body { flex: 1; }
.step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--navy);
}
.step-title .ic { color: var(--o); width: 17px; height: 17px; }
.step-text {
  margin-top: 4px;
  color: var(--slate);
  font-size: 0.88rem;
  line-height: 1.5;
}
.step-text code {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.83rem;
  color: var(--navy);
}

/* ---- flow diagram (override brand .flow for labeled nodes) ---- */
.flow-wrap {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.flow-wrap .kicker { margin-bottom: 12px; }
/* Use brand .flow .node/.node.core/.arrow — no custom dark overrides */

/* ---- drop zone ---- */
.drop-zone {
  margin-top: 12px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  color: var(--slate);
  transition: border-color 0.15s, background 0.15s;
  background: var(--paper);
}
.drop-zone:hover,
.drop-zone.drag {
  border-color: var(--o);
  background: var(--o-soft);
}
.drop-zone .ic {
  width: 26px;
  height: 26px;
  color: var(--o);
}
.drop-zone p { margin: 6px 0 0; }
.ok-msg { color: var(--ok); }
.err-msg { color: var(--err); }

/* ---- vault browser ---- */
.vault-browser {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
  background: #fff;
}
.vault-sidebar {
  width: 240px;
  flex: 0 0 240px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: var(--paper);
  /* Column layout so the papelera footer pins to the bottom (margin-top:auto). */
  display: flex;
  flex-direction: column;
}
.vault-sidebar .vault-tree { flex: 1; }
.vault-sidebar-hdr {
  padding: 12px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sl);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vault-group-hdr {
  padding: 8px 14px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sl);
  display: flex;
  align-items: center;
  gap: 6px;
}
.vault-group-hdr .ic { width: 13px; height: 13px; }
.vault-note-item {
  display: block;
  padding: 6px 14px 6px 24px;
  font-size: 0.85rem;
  color: var(--navy);
  cursor: pointer;
  border-radius: 0;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.vault-note-item:hover { background: var(--o-soft); color: var(--od); }
.vault-note-item.active { background: var(--o-soft); color: var(--od); font-weight: 600; }

/* Note row = open button + hover-revealed trash (soft delete to .papelera). */
.vault-note-row { display: flex; align-items: center; }
.vault-note-row .vault-note-item { flex: 1; min-width: 0; }
.vault-note-trash {
  flex: none; display: none; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin-right: 6px; padding: 0;
  border: none; border-radius: 6px; background: transparent; color: var(--slate); cursor: pointer;
}
.vault-note-trash .ic { width: 13px; height: 13px; }
.vault-note-row:hover .vault-note-trash { display: inline-flex; }
.vault-note-trash:hover { background: #fce7f3; color: #be185d; }
.vault-note-row:hover .vault-note-item { background: var(--o-soft); color: var(--od); }
.vault-note-row.active .vault-note-item { background: var(--o-soft); color: var(--od); font-weight: 600; }

/* Sidebar search + section labels + papelera footer. */
.vault-search { padding: 8px 10px 4px; }
.vault-search input {
  width: 100%; padding: 7px 10px; font-size: 0.84rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--navy);
}
.vault-search input:focus { outline: none; border-color: var(--o); }
.vault-section-label {
  padding: 10px 14px 4px; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--slate);
}
.vault-trash-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-top: 1px solid var(--line); margin-top: auto;
}
.vault-trash-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--slate); }
.vault-trash-label .ic { width: 13px; height: 13px; }
.vault-trash-empty { color: #be185d; }

/* Reader breadcrumb + inbox trash. */
.vault-crumb { font-size: 0.76rem; color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.vault-crumb-sep { margin: 0 4px; color: var(--line); }
.vault-toolbar-spacer { flex: 1; }
.inbox-item { position: relative; }
.inbox-trash { display: none; margin-left: 8px; }
.inbox-item:hover .inbox-trash { display: inline-flex; }
.vault-reader {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
}
.vault-reader-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--sl);
  font-size: 0.95rem;
}
/* markdown rendering styles */
.md-render { font-size: 0.92rem; line-height: 1.65; color: var(--navy); }
.md-render h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 16px; }
.md-render h2 { font-size: 1.25rem; font-weight: 700; margin: 20px 0 10px; }
.md-render h3 { font-size: 1.05rem; font-weight: 700; margin: 16px 0 8px; }
.md-render h4 { font-size: 0.95rem; font-weight: 700; margin: 14px 0 6px; }
.md-render p { margin: 0 0 12px; }
.md-render strong { font-weight: 700; }
.md-render em { font-style: italic; }
.md-render code {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.85em;
}
.md-render pre {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 14px;
}
.md-render pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
}
.md-render a { color: var(--od); text-decoration: none; }
.md-render a:hover { text-decoration: underline; }
.md-render ul { margin: 0 0 12px; padding-left: 20px; }
.md-render li { margin-bottom: 4px; }
.vault-drop-area { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.vault-drop-area .kicker { margin-bottom: 10px; }

/* ---- Bandeja (raw/ inbox) ---- */
.vault-inbox { margin-top: 16px; }
.inbox-empty { padding: 8px 0; }
.inbox-processing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 10px;
}
.inbox-hdr {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.inbox-hdr .kicker { margin: 0; }
.inbox-count { margin-left: auto; }
.inbox-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.inbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.inbox-item + .inbox-item { border-top: 1px solid var(--line); }
.inbox-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.inbox-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-name .ic { width: 15px; height: 15px; flex: 0 0 auto; }
.inbox-item.pending .inbox-name { color: var(--od); }
.inbox-item.pending .inbox-name .ic { color: var(--o); }
.inbox-item.processed { color: var(--slate); }
.inbox-item.processed .inbox-name .ic { color: var(--ok); }
.inbox-badge {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.inbox-badge.unprocessed { background: var(--o-soft); color: var(--od); }
.inbox-badge.done { background: var(--paper); color: var(--slate); }
.inbox-processed { margin-bottom: 12px; }
.inbox-processed-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  list-style: none;
}
.inbox-processed-summary::-webkit-details-marker { display: none; }
.inbox-processed-summary .inbox-caret { display: inline-flex; }
.inbox-processed-summary .inbox-caret .ic {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}
.inbox-processed[open] .inbox-caret .ic { transform: rotate(90deg); }
.inbox-processed .inbox-list { margin-top: 8px; margin-bottom: 0; }

/* ---- vault reader toolbar (read + edit modes) ---- */
.vault-reader-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  min-height: 38px;
  flex-wrap: wrap;
}
.vault-editor-toolbar {
  border-bottom-color: var(--o);
}
.vault-reader-body {
  overflow-y: auto;
}
.vault-save-msg {
  margin-left: 4px;
  color: var(--err);
}
.vault-save-confirm {
  color: var(--ok);
  margin-left: 4px;
}

/* ---- vault editor area (textarea + preview) ---- */
.vault-editor-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: calc(100% - 56px);
}
.vault-editor-textarea {
  flex: 1;
  width: 100%;
  min-height: 320px;
  height: 100%;
  font-family: ui-monospace, "SFMono-Regular", "Fira Code", "Menlo", "Consolas", monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--navy);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.vault-editor-textarea:focus {
  border-color: var(--o);
  background: #fff;
}
.vault-preview-body {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--paper);
  min-height: 320px;
  overflow-y: auto;
}

/* ---- "Nueva nota" button in sidebar header ---- */
.vault-new-btn {
  font-size: 0.72rem;
  padding: 3px 8px;
  line-height: 1.2;
  flex-shrink: 0;
}
.vault-new-btn .ic {
  width: 12px;
  height: 12px;
}


/* ---- Panel tab ---- */
.panel-empty-card {
  max-width: 560px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--navy);
  font-size: 0.95rem;
}
.panel-header-title .ic { width: 17px; height: 17px; color: var(--o); }
.panel-header .muted { margin-left: 2px; }
.panel-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.panel-iframe-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.panel-iframe {
  display: block;
  width: 100%;
  height: 70vh;
  min-height: 480px;
  border: none;
  background: #fff;
}

/* ---- pairing modal ---- */
.pairing-link {
  word-break: break-all;
}

/* ---- state cards ---- */
.state-card {
  max-width: 480px;
  margin: 48px auto;
}
/* Branding logo on the access screen — centered at top, driven by branding.logoUrl
   (LOGO_URL env → pack → iTaum default). Hidden if the image fails to load. */
.state-card .access-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 70%;
  margin: 0 auto 22px;
  object-fit: contain;
}
.state-card .kicker { margin-bottom: 12px; }
.state-card h2 { margin: 0 0 8px; }
.state-card p { color: var(--slate); margin: 0 0 20px; }
.state-card .field { margin-bottom: 16px; }
.state-card .row { margin-top: 8px; }

/* ---- footer ---- */
.footer { text-align: center; margin-top: auto; padding: 24px 0 8px; font-size: .8rem; opacity: .6; }

@media (max-width: 700px) {
  .tab-bar { padding: 0 12px; }
  .tab-btn { padding: 10px 12px; font-size: 0.82rem; }
  .page-wrap { padding: 0 12px 40px; }
  .vault-browser { flex-direction: column; }
  .vault-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 200px; }
}

/* ---- mobile: keep the topbar from overflowing (it was the horizontal-scroll
   culprit that also pushed the chat FAB off-screen) ---- */
@media (max-width: 640px) {
  .topbar { padding: 12px 14px; gap: 8px; }
  .topbar-host { display: none; }          /* the long hostname doesn't fit */
  .topbar-help .btn-label { display: none; } /* help button → icon only */
  .topbar-help { padding: 6px 8px; }
  .brand .name { font-size: 1rem; }
  .brand { min-width: 0; }
  /* the floating chat button: a touch smaller + safe-area aware, always on top */
  .chat-fab { bottom: calc(18px + env(safe-area-inset-bottom)); right: calc(18px + env(safe-area-inset-right)); width: 56px; height: 56px; z-index: 1400; }
  /* let header rows + legends wrap instead of forcing width */
  .card-hdr { flex-wrap: wrap; gap: 6px; }
  .mem-hdr-right { flex-wrap: wrap; }
  .vault-graph-legend, .mem-graph-legend { flex-wrap: wrap; }
}

/* ---- card header (Memorias / Actividad) ---- */
.card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-hdr-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--navy);
}
.card-hdr-title .ic { color: var(--o); width: 18px; height: 18px; flex: none; }

/* ---- memorias: type chips + card grid ---- */
.mem-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.mem-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--slate);
}
.mem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.mem-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  text-align: left;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.mem-card:hover {
  border-color: var(--o);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.mem-badge {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--paper);
  color: var(--slate);
}
.mem-title { font-weight: 600; color: var(--navy); line-height: 1.25; }
.mem-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mem-ago { margin-top: 2px; }

/* type accents — shared palette, neutral by default */
.mem-chip.t-project,  .mem-badge.t-project  { background: var(--o-soft);  color: var(--od); }
.mem-chip.t-feedback, .mem-badge.t-feedback { background: #eef2ff; color: #4338ca; }
.mem-chip.t-user,     .mem-badge.t-user     { background: #ecfeff; color: #0e7490; }
.mem-chip.t-reference,.mem-badge.t-reference{ background: #f0fdf4; color: #15803d; }
.mem-chip.t-person,   .mem-badge.t-person   { background: #fdf2f8; color: #be185d; }
.mem-chip.t-meeting,  .mem-badge.t-meeting  { background: #fefce8; color: #a16207; }
.mem-chip.t-company,  .mem-badge.t-company  { background: #f1f5f9; color: #334155; }
.mem-chip.t-decision, .mem-badge.t-decision { background: #fff7ed; color: #c2410c; }

/* ---- cadencias (tareas programadas) ---- */
.cadencia-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 2px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.cadencia-row:first-of-type { border-top: none; }
.cadencia-label { color: var(--navy); font-weight: 600; min-width: 0; flex: 1 1 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cadencia-meta { flex: 1 1 auto; }
.cadencia-actions { display: inline-flex; gap: 6px; flex: none; margin-left: auto; }
.cadencia-actions button {
  font: inherit;
  font-size: 12px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--navy);
  cursor: pointer;
}
.cadencia-actions button:hover { border-color: var(--o); color: var(--o); }
.cadencia-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.cadencia-form input[name="prompt"] { flex: 1 1 220px; }
.cadencia-form input,
.cadencia-form select {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--navy);
}
.cadencia-form button[type="submit"] {
  font: inherit;
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: var(--o);
  color: #fff;
  cursor: pointer;
}
.cadencia-form button[type="submit"]:hover { background: #d4521f; }

/* ---- vault view toggle (Lista / Grafo) ---- */
.vault-viewbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.seg-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate);
  background: transparent;
  border: none;
  cursor: pointer;
}
.seg + .seg { border-left: 1px solid var(--line); }
.seg .ic { width: 15px; height: 15px; }
.seg:hover { color: var(--navy); }
.seg-active { background: var(--o-soft); color: var(--od); }

/* ---- vault graph legend ---- */
.vault-graph-legend { display: inline-flex; align-items: center; gap: 12px; }
.vault-graph-legend .lg {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--slate);
}
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-dot.g-wiki { background: #1f2a44; }
.lg-dot.g-raw  { background: #e8632d; }
.lg-dot.g-root { background: #64748b; }

/* ---- vault graph canvas ---- */
.vault-graph-canvas {
  width: 100%;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.vault-graph-canvas canvas { display: block; }
.vault-graph-hint { margin: 10px 2px 0; }

/* ---- Conversar tab (embedded interactive chat) ---- */
.chat-quickbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chat-quickbar-spacer { flex: 1 1 auto; }
.qcmd { font-family: var(--font); }
.chat-cmd-msg { min-width: 80px; }
.chat-term-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #08080d;
  box-shadow: var(--shadow);
}
.chat-term {
  width: 100%;
  height: 560px;
  border: 0;
  display: block;
  background: #08080d;
}
.chat-hint { margin: 12px 2px 0; }

@media (max-width: 720px) {
  .chat-term { height: 440px; }
}

/* ---- native chat (Conversar tab) ---- */
.chat-log {
  height: 460px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg {
  max-width: 80%;
  padding: 9px 12px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg.user { align-self: flex-end; background: var(--o-soft); color: var(--navy); }
.chat-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.chat-msg.tool, .chat-msg.think, .chat-msg.perm, .chat-msg.err {
  align-self: stretch; max-width: 100%; background: #fff; border: 1px dashed var(--line);
}
.chat-msg.err { border-color: var(--err); }
.chat-msg .md-render { margin: 0; }
.chat-msg .md-render :first-child { margin-top: 0; }
.chat-msg .md-render :last-child { margin-bottom: 0; }
.chat-tool-out {
  white-space: pre-wrap; font-size: 0.8rem; margin: 6px 0 0;
  max-height: 220px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chat-tool-out.err { color: var(--err); }
.perm-q { color: var(--navy); }
.perm-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.chat-composer { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1; resize: vertical; min-height: 44px; font-family: var(--font); font-size: 0.95rem;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: var(--navy);
}
.chat-composer textarea:focus { outline: none; border-color: var(--o); }

/* ---- chat attachments: bar, chips, note picker, drop affordance ---- */
.chat-attach-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  position: relative; /* anchor for the note picker popover */
}
.chat-modal .chat-attach-bar { padding: 8px 14px 0; flex: 0 0 auto; }
.chat-attach-bar .btn.sm .ic { width: 14px; height: 14px; }
.chat-attach-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-attach-chips[hidden] { display: none; }
/* pending-attachment chip (removable) + source chip (clickable) share a look */
.attach-chip, .src-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--o-soft); color: var(--od);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px; font-size: 0.78rem; max-width: 220px;
}
.attach-chip .ic, .src-chip .ic { width: 13px; height: 13px; flex: none; }
.attach-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; padding: 0; color: var(--slate);
}
.attach-chip-x:hover { color: var(--err); }
.attach-chip-x .ic { width: 12px; height: 12px; }
.src-chip { cursor: pointer; }
.src-chip:hover { border-color: var(--o); color: var(--o); }
/* "Fuentes:" row under an answer / attachments under a user message */
.msg-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.msg-sources .src-label { flex: none; }
/* drop affordance: highlight the log when dragging files over it */
.chat-log--drag { outline: 2px dashed var(--o); outline-offset: -4px; background: var(--o-soft); }
/* note picker popover */
.note-picker {
  position: absolute; bottom: calc(100% + 6px); left: 14px; z-index: 30;
  width: min(320px, calc(100% - 28px));
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.16); overflow: hidden;
}
.note-picker-search { padding: 8px; border-bottom: 1px solid var(--line); }
.note-picker-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-family: var(--font); font-size: 0.85rem; color: var(--navy);
}
.note-picker-search input:focus { outline: none; border-color: var(--o); }
.note-picker-list { max-height: 240px; overflow-y: auto; padding: 4px; }
.note-picker-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  cursor: pointer; font-family: var(--font); font-size: 0.85rem; color: var(--navy);
  padding: 7px 9px; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.note-picker-item:hover { background: var(--o-soft); color: var(--o); }
.note-picker-item[hidden] { display: none; }

/* ---- chat: tool cards, thinking, busy spinner ---- */
.tool-hdr { color: var(--navy); display: flex; align-items: center; gap: 6px; }
.tool-hdr .ic { width: 15px; height: 15px; color: var(--o); }
.chat-tool-out.tool-in { background: var(--paper); border-radius: 8px; padding: 8px 10px; }
.tool-res { margin-top: 8px; }
.tool-res details > summary, .chat-think > summary { cursor: pointer; user-select: none; }
.tool-res details[open] > summary { margin-bottom: 6px; }
.chat-think { }
.chat-think > summary { display: inline-flex; align-items: center; gap: 6px; }
.chat-think > summary .ic { width: 14px; height: 14px; }
.think-body { margin-top: 6px; white-space: pre-wrap; }
.chat-msg .err-msg { color: var(--err); }

@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy .ic { animation: spin 0.9s linear infinite; }
.btn.busy { opacity: 0.85; }

/* ---- vault file tree (Obsidian-style) ---- */
.vault-tree { padding: 4px 0; }
.vault-dir-row {
  display: flex; align-items: center; gap: 5px; width: 100%;
  text-align: left; background: none; border: none; cursor: pointer;
  font-family: var(--font); font-size: 0.85rem; color: var(--navy);
  padding: 5px 10px; border-radius: 6px;
}
.vault-dir-row:hover { background: var(--paper); }
.vault-dir-row .ic { width: 14px; height: 14px; flex: none; color: var(--slate); }
.vault-caret { display: inline-flex; }
.vault-caret .ic { width: 12px; height: 12px; }
.vault-dir-name { flex: 1; font-weight: 600; }
.vault-dir-row > .muted { flex: none; }
.vault-tree .vault-note-item { font-size: 0.84rem; }
.vault-tree .vault-empty-note { padding-top: 2px; padding-bottom: 4px; font-style: italic; }

/* ---- chat header right (status + nueva conversación) ---- */
.chat-hdr-right { display: inline-flex; align-items: center; gap: 12px; }

/* ===== Floating chat widget (FAB → docked modal) ===== */
.chat-fab {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); right: calc(24px + env(safe-area-inset-right)); z-index: 1100;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--o); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(232, 99, 45, 0.40);
  transition: transform .15s ease, opacity .15s ease;
}
.chat-fab svg { width: 26px; height: 26px; }
.chat-fab:hover { transform: scale(1.08); }
.chat-fab--hidden { opacity: 0; pointer-events: none; transform: scale(.8); }
/* green pulse while SOnIA is working (even with the modal closed) */
.chat-fab--working::after {
  content: ""; position: absolute; top: 4px; right: 4px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
  animation: fabPulse 1.2s ease-in-out infinite;
}
@keyframes fabPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .65; } }

.chat-teaser {
  position: fixed; bottom: 42px; right: 98px; z-index: 1100;
  background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: .9rem; box-shadow: 0 6px 18px rgba(0,0,0,.18); cursor: pointer;
  animation: teaserIn .3s ease;
}
.chat-teaser::after {
  content: ""; position: absolute; right: -6px; bottom: 13px;
  border: 6px solid transparent; border-left-color: var(--navy);
}
@keyframes teaserIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.chat-backdrop {
  display: none; position: fixed; inset: 0; z-index: 1200;
  background: rgba(15, 23, 42, .40);
}
.chat-backdrop--visible { display: block; }

.chat-modal {
  display: none; position: fixed; z-index: 1300;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(80vw, 1200px); height: min(85vh, 900px);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  flex-direction: column; overflow: hidden; animation: modalIn .2s ease;
}
.chat-modal--open { display: flex; }
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.98); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.chat-modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
/* commands sit at the top (under the header); the log fills the rest */
.chat-modal .chat-quickbar { padding: 12px 14px 8px; margin: 0; flex: 0 0 auto; }
.chat-modal .chat-hint { margin: 0; padding: 0 14px 10px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.chat-modal .chat-log { flex: 1 1 auto; height: auto; min-height: 0; border: none; border-radius: 0; background: var(--bg); }
.chat-modal .chat-composer { padding: 8px 14px 14px; margin-top: 0; flex: 0 0 auto; }

.icon-btn {
  background: none; border: none; cursor: pointer; color: #94a3b8;
  display: inline-flex; padding: 4px; border-radius: 8px; line-height: 0;
}
.icon-btn:hover { background: var(--o-soft); color: var(--o); }

@media (max-width: 560px) {
  /* 100dvh (dynamic viewport) so the on-screen keyboard shrinks the modal and the
     composer stays visible instead of being hidden behind the keyboard. */
  .chat-modal { top: 0; left: 0; transform: none; width: 100vw; height: 100dvh; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
  .chat-modal--open { animation: none; }
  .chat-teaser { display: none; }
  /* Header fit on narrow screens: title truncates instead of wrapping to 3
     lines and pushing the action group (incl. the close button) off-screen.
     The action group never shrinks so "Cerrar" is always reachable. */
  .chat-modal-header { gap: 8px; }
  .chat-modal-header .card-hdr-title {
    flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .chat-modal-header .chat-hdr-right { flex: 0 0 auto; gap: 6px; }
  /* status text ("pensando…") is also reflected in the log; hide it here to
     give the buttons room on mobile. */
  .chat-modal-header #chat-status { display: none; }
  .chat-modal-header .btn.sm { padding: 6px 9px; }
}

/* humanized tool activity line (no raw commands shown to the owner) */
.chat-msg.tool {
  align-self: flex-start; max-width: 100%; background: transparent; border: none;
  padding: 2px 2px; display: inline-flex; align-items: center; gap: 8px;
  color: var(--navy); opacity: .65; font-size: .9rem;
}
.chat-msg.tool .tool-spin svg { width: 15px; height: 15px; animation: spin 1s linear infinite; }
.chat-msg.tool .tool-ok { display: inline-flex; color: #16a34a; }
.chat-msg.tool .tool-x  { display: inline-flex; color: var(--err); }
.chat-msg.tool .tool-ok svg, .chat-msg.tool .tool-x svg { width: 15px; height: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== business graph (Mapa) in "Lo que SOnIA sabe de tu negocio" ===== */
.mem-hdr-right { display: inline-flex; align-items: center; gap: 12px; }
.mem-graph-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 6px; flex-wrap: wrap; }
.mem-graph-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.mem-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--navy); }
.mem-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.mem-graph-canvas {
  width: 100%; height: 440px; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; background: #fff;
}

/* ===== help modal ("¿Cómo funciona?") — tutorial hub v2 — reuses .chat-modal base ===== */
.help-modal { width: min(920px, 94vw); height: auto; max-height: 88vh; overflow: hidden; }
/* --- scrollable menu body --- */
.tut-menu { overflow-y: auto; max-height: calc(88vh - 52px); padding: 16px 20px 20px; }
.tut-section { margin-bottom: 22px; }
.tut-section:last-child { margin-bottom: 0; }
.tut-section-label {
  font-size: .75rem; font-weight: 700; color: var(--slate);
  text-transform: uppercase; letter-spacing: .05em; margin: 0 0 10px;
}
/* --- featured 2-up grid --- */
.tut-featured-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tut-featured-card {
  display: flex; flex-direction: column; gap: 5px;
  padding: 16px 18px; border-radius: 12px; border: 2px solid var(--o);
  background: var(--o-soft); cursor: pointer; text-align: left; width: 100%;
  transition: background .15s, border-color .15s;
}
.tut-featured-card:hover { background: #fde0ce; border-color: var(--od); }
.tut-featured-name { font-weight: 700; font-size: 1rem; color: var(--od); }
.tut-featured-sub { font-size: .83rem; color: var(--slate); }
/* --- section card grid --- */
.tut-section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tut-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; text-align: left; width: 100%;
  transition: background .12s, border-color .12s;
}
.tut-card:hover { background: var(--o-soft); border-color: var(--o); }
.tut-card-ico { color: var(--o); display: inline-flex; }
.tut-card-ico svg { width: 20px; height: 20px; }
.tut-card-name { font-weight: 600; font-size: .88rem; color: var(--navy); }
.tut-card-desc { font-size: .78rem; color: var(--slate); }
/* --- video player wrapper --- */
.tut-player-wrapper { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px; }
.tut-player-wrapper[hidden] { display: none; }
.tut-player-title { font-weight: 700; font-size: 1.05rem; color: var(--navy); margin: 0; }
#tut-player { width: 100%; height: auto; max-height: 55vh; border-radius: 8px; background: #000; display: block; }
.tut-back { align-self: flex-start; }
/* --- mobile: single column --- */
@media (max-width: 480px) {
  .tut-featured-grid { grid-template-columns: 1fr; }
  .tut-section-grid { grid-template-columns: 1fr; }
}
.topbar-help { white-space: nowrap; }

/* ===== Tareas: frequency builder + advanced cron ===== */
.cadencia-form { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-top: 14px; }
.cadencia-form > input[name="prompt"] { flex: 1 1 280px; }
.freq-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.freq-inputs { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); font-size: .9rem; }
.freq-preview { flex-basis: 100%; margin: 0; color: var(--od); font-size: .88rem; font-weight: 600; min-height: 1.1em; }
.freq-advanced { flex-basis: 100%; }
.linklike { background: none; border: none; color: var(--navy); cursor: pointer; font-size: .85rem; padding: 2px 0; }
.linklike:hover { color: var(--o); }
.freq-adv-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
#cron-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 160px; }
.cron-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: .8rem; cursor: pointer; color: var(--navy); }
.chip:hover { border-color: var(--o); color: var(--o); }
.cadencia-when { display: block; margin-top: 1px; }

/* ===== Tareas: compact cards (v2 card language) ===== */
.cadencia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin: 6px 0 16px;
}
.cadencia-card {
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--bg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cadencia-card:hover { border-color: var(--o); box-shadow: var(--shadow); }
.cadencia-card.is-off { opacity: 0.72; }
.cadencia-card-top { display: flex; align-items: center; gap: 10px; }
.cadencia-ico {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center; border-radius: 8px;
  background: var(--o-soft); color: var(--o);
}
.cadencia-ico .ic { width: 16px; height: 16px; }
.cadencia-head { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.cadencia-title {
  font-weight: 600; color: var(--navy); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cadencia-badge {
  flex: none; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--slate); background: var(--paper);
}
.cadencia-badge.ok { color: var(--ok); background: #f0fdf4; border-color: #bbf0cd; }
.cadencia-badge.off { color: var(--sl); }
.cadencia-badge.err { color: var(--err); background: #fef2f2; border-color: #f3c2c2; }
.cadencia-runs { line-height: 1.4; }
.cadencia-card .cadencia-actions { display: flex; gap: 6px; margin: 0; }
.cadencia-card .cadencia-actions button {
  flex: 1 1 auto;
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--slate); font: 600 0.8rem var(--font); cursor: pointer;
}
.cadencia-card .cadencia-actions button:hover { border-color: var(--o); color: var(--o); }
.cadencia-card .cadencia-actions button.cadencia-del:hover { border-color: #f3c2c2; color: var(--err); }

/* ===== Conexiones / Capacidades tabs ===== */
.cap-list { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 14px; }
.cap-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.cap-row:last-child { border-bottom: none; }
.cap-name { display: inline-flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 600; }
.cap-name > span { display: flex; flex-direction: column; }
.cap-name svg { color: var(--o); flex: 0 0 auto; width: 18px; height: 18px; }
.cap-desc { font-weight: 400; margin-top: 1px; }
.cap-badge { font-size: .78rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.cap-badge.ok { background: #f0fdf4; color: #15803d; }
.cap-cta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* Credenciales — same compact card/row language as the connection cards */
/* Credenciales: a grid of compact cards, consistent with the connection tiles
   (.tile-grid) above — same border/radius/padding, responsive columns. */
.cred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px; margin: 6px 0 14px;
}
.cred-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; min-width: 0;
  border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.cred-card:hover { border-color: var(--o); }
.cred-ico {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center; border-radius: 8px;
  background: var(--o-soft); color: var(--o);
}
.cred-ico .ic { width: 16px; height: 16px; }
.cred-nm {
  font-weight: 600; color: var(--navy);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.cred-pill {
  margin-left: auto; flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 600; color: var(--ok);
  background: #f0fdf4; border: 1px solid #bbf0cd; border-radius: 999px; padding: 2px 9px;
}
.cred-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.cred-del { flex: none; color: var(--sl); }
.cred-del:hover { color: var(--err); }

/* ===== Compact tile grid (Conexiones / Capacidades / OS-shell v2) ===== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 6px 0 16px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  padding: 13px 14px;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
.tile:hover {
  border-color: var(--o);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.tile-row { display: flex; align-items: center; gap: 9px; }
.tile-ico {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--o-soft);
  color: var(--o);
}
.tile-ico .ic { width: 16px; height: 16px; }
.tile-mem .tile-ico { background: #f1f5f9; color: var(--navy); }
.tile-nm { font-weight: 600; color: var(--navy); line-height: 1.2; }
.tile-one {
  color: var(--slate);
  font-size: 0.82rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tile-dot-ok {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ok); font-size: 0.74rem; font-weight: 600;
}
.tile-dot-ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.tile-tag {
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--sl);
}
.tile-more {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--sl); font-size: 0.7rem;
}
.tile-more .ic { width: 13px; height: 13px; }

/* ===== Detail modal (shared: Conexiones / Capacidades / Memorias) ===== */
.detail-backdrop { align-items: flex-start; overflow-y: auto; padding: 7vh 20px 20px; }
/* .modal.detail-modal (2 classes) so this max-height beats the generic single-class
   `.modal { max-height: calc(100dvh - 32px) }` rule that comes LATER in this file —
   without the bump that generic rule won (equal specificity, later source) and let
   the modal grow to 100dvh-32px, pushing the 7vh-offset footer past the viewport
   bottom (the .detail-actions button was clipped / unclickable). */
.modal.detail-modal {
  max-width: 640px;
  width: 100%;
  padding: 0;
  /* 7vh offset + modal + 20px bottom must fit the viewport so the pinned footer
     is always fully visible. Same unit (vh) as the padding offset for exact math;
     mobile uses dvh via the breakpoint override below. */
  max-height: calc(93vh - 20px);
  overflow: hidden;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  animation: detail-pop 0.15s ease;
}
@keyframes detail-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.detail-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff; flex: none;
}
.detail-ttl { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.detail-ttl-text {
  display: inline-flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-weight: 600; color: var(--navy); font-size: 1rem;
}
.detail-tag {
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--od); background: var(--o-soft); padding: 2px 8px; border-radius: 999px;
}
.detail-ico {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px; background: var(--o-soft); color: var(--o);
}
.detail-x { flex: none; }
.detail-body { padding: 16px 20px; color: var(--navy); line-height: 1.55; font-size: 0.9rem; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.detail-body p { margin: 0 0 12px; }
.detail-body p:last-child { margin-bottom: 0; }
.detail-h, .detail-body h4 {
  margin: 16px 0 6px; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--od);
}
.detail-code { white-space: pre-wrap; margin-top: 6px; }
/* Description formatting: emphasized first-sentence lead + softer body; env-var
   style ALL_CAPS tokens render as inline code (descHtml in app.js). */
.detail-lead { font-weight: 600; color: var(--navy); font-size: 0.95rem; }
.detail-desc { color: #3f4b63; }
.detail-lead code, .detail-desc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82em;
  background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 4px; }
.detail-meta-pill {
  font-size: 0.74rem; color: var(--slate);
  background: var(--paper); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px;
}
.detail-meta-pill.ok { border-color: transparent; background: #f0fdf4; }
.detail-actions {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px;
  flex: none; background: #fff;
}
@media (max-width: 560px) {
  .tile-grid, .cred-grid { grid-template-columns: 1fr; }
  .detail-backdrop { padding: 16px; }
  /* keep the 2-class specificity so it still beats the generic `.modal` rule;
     16px top + bottom padding → cap at 100dvh - 32px so the footer stays visible. */
  .modal.detail-modal { max-width: 100%; margin-top: 0; max-height: calc(100dvh - 32px); }
}

/* ===== Importar capacidad (skill-pack) ===== */
#cap-import-status:not(:empty) { margin-top: 10px; }
.cap-import-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: .9rem;
}
.cap-import-state svg { flex: 0 0 auto; width: 16px; height: 16px; }
.cap-import-state.installing { background: var(--o-soft); border-color: #f4c9af; color: var(--od); }
.cap-import-state.installing svg { color: var(--o); }
.cap-import-state.done { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.cap-import-state.done svg { color: var(--ok); }
.cap-import-state.sent { background: var(--paper); color: var(--navy); }
.cap-import-state.sent svg { color: var(--o); }
.cap-import-state.error { background: #fef2f2; border-color: #fecaca; color: var(--err); }
.cap-import-state.error svg { color: var(--err); }

/* ===== responsive tab bar: scroll horizontally instead of squishing ===== */
.tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn { white-space: nowrap; flex: 0 0 auto; }

/* ===== mobile polish (2026-06-17) ===== */
/* Generic modal (pairing, brand .modal): never exceed the viewport on a short
   screen — scroll inside instead of overflowing off the page. */
.modal { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* Inline images SOnIA shows in chat (markdown ![](data:image/...)). */
.chat-img { display: block; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); margin: 6px 0; }

/* Media players SOnIA shows in chat (markdown ![](…mp4/mp3) auto-embed). */
.chat-media { display: block; max-width: 100%; border-radius: 10px; margin: 6px 0; }
.chat-video { width: 100%; background: #000; border: 1px solid var(--line); }
.chat-audio { width: 100%; min-width: 240px; }

/* Markdown blocks (chat + vault reader): tables, blockquotes, horizontal rules. */
.md-render table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.9rem; margin: 0 0 14px; }
.md-render th, .md-render td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md-render thead th { background: var(--paper); font-weight: 600; white-space: nowrap; }
.md-render blockquote { margin: 0 0 12px; padding: 6px 14px; border-left: 3px solid var(--o); background: var(--o-soft); border-radius: 0 8px 8px 0; color: var(--navy); }
.md-render hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* Obsidian wikilinks [[note]] in the vault reader: resolved = navigable accent
   link; missing = muted plain text. */
.md-render a.wikilink { color: var(--od); text-decoration: none; border-bottom: 1px dotted var(--sl); cursor: pointer; }
.md-render a.wikilink.wikilink-ok:hover { color: var(--o); border-bottom-color: var(--o); }
.md-render a.wikilink-missing { color: var(--slate); border-bottom: none; cursor: default; }

/* Coarse-pointer (touch) devices: enlarge small tap targets toward the ~44px
   comfortable minimum. Desktop (fine pointer) keeps the compact sizing. */
@media (pointer: coarse) {
  .btn.sm { padding: 0.6rem 1rem; }
  .tab-btn { padding: 14px 16px; }
  .icon-btn { padding: 9px; }
  .cadencia-actions button, .seg, .vault-new-btn { padding: 10px 14px; }
}

/* === OS shell ============================================================ */
:root {
  --wall: radial-gradient(60% 50% at 14% 10%, rgba(232,99,45,.14), transparent 60%),
          radial-gradient(55% 55% at 90% 95%, rgba(159,179,214,.30), transparent 60%),
          linear-gradient(135deg, #eef2f9 0%, #e9eef6 55%, #e3e9f3 100%);
  --glass: rgba(255,255,255,.92);
  --glass-bd: rgba(31,42,68,.07);
  --panel-shadow: 0 1px 2px rgba(31,42,68,.05), 0 18px 48px rgba(31,42,68,.12);
}
body.os { background: var(--wall); background-attachment: fixed; }
.os-wall { min-height: 100dvh; padding: 16px; box-sizing: border-box; display: flex; flex-direction: column; }
.os-topbar {
  display: flex; align-items: center; gap: 14px;
  height: 56px; padding: 0 18px; margin-bottom: 18px;
  background: var(--glass); border: 1px solid var(--glass-bd);
  border-radius: 16px; box-shadow: var(--panel-shadow);
  position: sticky; top: 16px; z-index: 50; backdrop-filter: blur(10px);
}
.os-nav { display: flex; align-items: center; gap: 4px; }
.os-nav-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 9px; border: none; background: none;
  color: var(--slate); font: 600 13px/1 var(--font); cursor: pointer;
}
.os-nav-btn:hover { color: var(--navy); background: rgba(31,42,68,.04); }
.os-nav-btn.os-active { color: var(--o); background: rgba(232,99,45,.12); }
.os-search {
  flex: 1; min-width: 0; max-width: 420px; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  background: #f1f4f9; border: 1px solid var(--glass-bd);
  color: var(--sl); font: 400 12.5px/1 var(--font); cursor: text;
}
.os-actions-btn {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--glass-bd); background: #fff;
  color: var(--o); cursor: pointer;
}
.os-actions-btn:hover { background: var(--o-soft); border-color: #f4c9af; }
.os-actions-btn .ic { width: 18px; height: 18px; }
.os-status { margin-left: auto; display: flex; align-items: center; gap: 10px;
  color: var(--slate); font-size: 12.5px; white-space: nowrap; }
.os-topbar { max-width: min(1680px, 88vw); margin-left: auto; margin-right: auto; width: 100%; box-sizing: border-box; }
.os-panel-host { max-width: min(1680px, 88vw); margin: 0 auto; width: 100%; box-sizing: border-box; }
.os-panel {
  background: var(--glass); border: 1px solid var(--glass-bd);
  border-radius: 22px; box-shadow: var(--panel-shadow);
  padding: 24px 28px; animation: osFade .18s ease;
}
@keyframes osFade { from { opacity:0; transform: translateY(6px) } to { opacity:1; transform:none } }

/* ===== General dashboard: "Tus 4 Cs" + "Actividad reciente" =====
   Matches showcase.html: clean white panels, 4-Cs cards with colored bars +
   level badges, activity rows with an orange-soft icon tile + title/sub + ago. */
.dash-row { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; margin-bottom: 4px; }
.dash-panel {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; box-shadow: 0 6px 20px rgba(31,42,68,.06);
}
.dash-h { display: flex; align-items: center; gap: 8px; font: 700 14px/1 var(--font); color: var(--navy); margin-bottom: 14px; }
.dash-h .ic { width: 15px; height: 15px; color: var(--o); }
.dash-cs-hint { margin-left: auto; font: 600 11px/1 var(--font); color: var(--sl); }
.dash-cs-hint code { font: 600 11px ui-monospace,Menlo,monospace; color: var(--slate); }
.dash-cs { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.dc {
  display: block; text-align: left; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; background: #fff; cursor: pointer; font-family: inherit; transition: box-shadow .12s, border-color .12s;
}
.dc:hover { border-color: #d5dce8; box-shadow: 0 8px 22px rgba(31,42,68,.10); }
.dc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dc-sc { font: 800 1.2rem/1 var(--font); }
.dc-sc small { font: 700 .68rem var(--font); color: var(--sl); }
.dc-lv { font: 800 .58rem/1 var(--font); padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.dc-lb { font-size: .78rem; color: var(--slate); margin-top: 7px; }
.dc-bar { height: 5px; border-radius: 3px; background: #eef1f6; margin-top: 8px; overflow: hidden; }
.dc-bar i { display: block; height: 100%; border-radius: 3px; }
.dc-count .dc-bar { visibility: hidden; }  /* counts mode: no fake progress */
.dash-act { display: flex; flex-direction: column; gap: 9px; }
.da-it { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; }
.da-ic { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--o-soft); color: var(--od); display: grid; place-items: center; }
.da-ic .ic { width: 15px; height: 15px; }
.da-tx { min-width: 0; flex: 1 1 auto; }
.da-tt { font: 600 .82rem/1.3 var(--font); color: var(--navy); }
.da-ss { font-size: .7rem; color: var(--sl); margin-top: 1px; }
.da-ago { flex: none; margin-left: auto; font-size: .68rem; color: var(--sl); white-space: nowrap; }
@media (max-width: 760px) {
  .dash-row { grid-template-columns: 1fr; }
}

/* ===== Launchpad command center (replaces spotlight) ===== */
.lp-backdrop {
  display:none; position:fixed; inset:0; z-index:1500;
  background:rgba(31,42,68,.18); backdrop-filter:blur(3px);
}
.lp-backdrop.open { display:block; }
.lp {
  display:none; position:fixed; z-index:1600; left:50%; top:5vh; transform:translateX(-50%);
  width:min(960px,94vw); max-height:88vh; flex-direction:column;
  background:rgba(255,255,255,.97); border:1px solid var(--glass-bd); border-radius:22px;
  box-shadow:0 30px 80px rgba(31,42,68,.30); overflow:hidden; animation: osFade .15s ease;
}
.lp.open { display:flex; }
.lp-top { display:flex; align-items:center; gap:12px; padding:18px 22px 14px; }
.lp-logo { width:30px; height:30px; flex:none; border-radius:8px; background:var(--o-soft);
  color:var(--o); display:grid; place-items:center; }
.lp-logo .ic { width:17px; height:17px; }
.lp-top input { flex:1; border:none; outline:none; background:none; font:600 22px var(--font); color:var(--navy); }
.lp-top input::placeholder { color:var(--sl); }
.lp-x { flex:none; height:30px; padding:0 10px; border-radius:8px; border:1px solid var(--line);
  background:#fff; color:var(--slate); font:600 12px var(--font); cursor:pointer; }
.lp-x:hover { border-color:var(--o); color:var(--o); }
/* flex:none so the chip row never gets shrunk by the flex column when the grid
   below changes height between filters (that shrink was making "Todo" render a
   couple px shorter than the other filters). Hidden scrollbar (like .tab-bar) so
   its gutter never changes the row height either. */
.lp-chips { flex:none; display:flex; gap:8px; padding:0 22px 14px; overflow-x:auto; border-bottom:1px solid var(--line);
  scrollbar-width:none; -webkit-overflow-scrolling:touch; }
.lp-chips::-webkit-scrollbar { display:none; }
/* inline-flex + a fixed line-height makes the chip's box height fully
   determined by padding + border (independent of font glyph metrics / FOUT),
   so the row never changes height between filters. */
.lp-chip { display:inline-flex; align-items:center; height:30px; white-space:nowrap; padding:0 13px;
  border-radius:9px; border:1px solid var(--line);
  background:#fff; font:600 12.5px/1 var(--font); color:var(--slate); cursor:pointer; }
/* keep the active chip's box identical: a 1px (transparent) border so width/height
   never shift between filters; tint only the background/text. */
.lp-chip.on { background:rgba(232,99,45,.12); color:var(--o); border-color:transparent; }
.lp-grid { flex:1; overflow:auto; padding:20px 22px 24px;
  display:grid; grid-template-columns:repeat(auto-fill,minmax(118px,1fr)); gap:18px 10px; }
.lp-gh { grid-column:1/-1; display:flex; align-items:center; gap:10px; margin:10px 2px 0;
  font:800 10.5px var(--font); letter-spacing:.06em; color:var(--sl); text-transform:uppercase; }
.lp-gh::after { content:""; flex:1; height:1px; background:var(--line); }
.lp-gh:first-child { margin-top:0; }
.lp-app { display:flex; flex-direction:column; align-items:center; gap:9px; padding:8px 4px;
  border-radius:14px; cursor:pointer; border:1px solid transparent; text-align:center;
  background:none; font-family:inherit; }
.lp-app:hover { background:#fff; border-color:var(--line); box-shadow:0 8px 20px rgba(31,42,68,.08); }
.lp-tile { position:relative; width:62px; height:62px; border-radius:16px; display:grid; place-items:center;
  box-shadow:inset 0 0 0 1px rgba(31,42,68,.05); }
.lp-tile .ic { width:30px; height:30px; }
.lp-nm { font-size:12px; font-weight:600; line-height:1.25; color:var(--navy); }
.lp-cmd { font:600 9.5px ui-monospace,Menlo,monospace; color:var(--sl); }
.lp-mono { font-weight:800; font-size:24px; line-height:1; }
.lp-empty { grid-column:1/-1; text-align:center; color:var(--sl); padding:30px; }
/* list mode (typing) */
.lp-grid.aslist { display:block; }
.lp-litem { display:flex; align-items:center; gap:12px; padding:10px 12px; border-radius:11px; cursor:pointer; }
.lp-litem:hover, .lp-litem.lp-sel { background:rgba(232,99,45,.08); }
.lp-lt { width:38px; height:38px; flex:none; border-radius:10px; display:grid; place-items:center; }
.lp-lt .ic { width:19px; height:19px; }
.lp-lt .lp-mono { font-size:16px; }
.lp-ltext { display:flex; flex-direction:column; min-width:0; flex:1 1 auto; }
.lp-litem .lp-nm { font-size:14px; }
.lp-ds { font-size:12px; color:var(--slate); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.lp-litem .lp-cmd { margin-left:auto; flex:none; font:600 11px ui-monospace,Menlo,monospace; color:var(--sl);
  background:#f4f6fb; border:1px solid var(--line); border-radius:6px; padding:2px 7px; }
@media (prefers-reduced-motion: reduce) { .os-panel,.lp { animation:none } }

/* ===== Mobile shell: slim top + search pill + bottom tab bar (Option A) =====
   Desktop (≥761px): these mobile-only elements are hidden; the top bar is the
   v2 desktop bar unchanged. ≤760px: the slim top keeps logo + status pill + bell;
   the search pill + 6-tab bottom bar take over navigation; the chat FAB lifts
   above the bar. */
.os-search-pill { display: none; }
.os-bbar { display: none; }
/* mobile */
@media (max-width:760px){
  /* slim top: drop the inline nav, the big search, the sparkle, and the help */
  .os-nav{ display:none; }
  .os-search{ display:none; }
  .os-actions-btn{ display:none; }
  button.topbar-help{ display:none; }  /* beat brand.css `button.btn` specificity */
  .topbar-host{ display:none; }
  .os-status{ gap:8px; }

  /* full-width search pill directly under the slim top bar */
  .os-search-pill{
    display:flex; align-items:center; gap:9px; width:100%;
    margin:0 0 14px; padding:11px 14px; border-radius:999px;
    background:var(--paper); border:1px solid var(--line);
    color:var(--sl); font:400 14px/1 var(--font); cursor:text;
  }
  .os-search-pill .ic{ width:15px; height:15px; color:var(--slate); }

  /* fixed bottom tab bar, safe-area aware */
  .os-bbar{
    display:flex; align-items:stretch; position:fixed; left:0; right:0; bottom:0; z-index:1200;
    background:rgba(255,255,255,.97); backdrop-filter:blur(8px);
    border-top:1px solid var(--line);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .os-bt{
    flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
    padding:9px 2px 11px; border:none; background:none; color:var(--sl);
    font-family:inherit; cursor:pointer; min-width:0;
  }
  .os-bt .ic{ width:20px; height:20px; }
  .os-bt span{ font-size:.58rem; font-weight:600; white-space:nowrap; }
  .os-bt.os-bt-on{ color:var(--o); }
  .os-bt.os-bt-on .ic{ stroke-width:2.4; }

  /* keep content + footer clear of the fixed bottom bar */
  .os-wall{ padding-bottom:calc(64px + env(safe-area-inset-bottom)); }
  .footer{ margin-bottom:8px; }

  /* chat FAB lifts above the bottom bar so it never overlaps */
  .chat-fab{ bottom:calc(78px + env(safe-area-inset-bottom)); }

  .lp{ top:0; left:0; transform:none; width:100vw; max-height:100dvh; border-radius:0; }
  .lp-grid{ grid-template-columns:repeat(auto-fill,minmax(96px,1fr)); }
}

/* ===== Topbar flyouts (Estado del AIOS · Actividad) ===== */
.os-status { position: relative; }
.os-bell {
  position: relative; flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--glass-bd); background: #fff; color: var(--navy); cursor: pointer;
}
.os-bell:hover { border-color: var(--o); color: var(--o); }
.os-bell .ic { width: 18px; height: 18px; }
.os-bell-badge {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 9px; border: 1.5px solid #fff;
  background: var(--o); color: #fff; font: 800 9px/1 var(--font);
}
.os-statuspill { cursor: pointer; }
.os-statuspill[aria-expanded="true"], .os-bell[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--o-soft); }

.os-flyout {
  position: absolute; top: calc(100% + 12px); right: 18px; width: 380px; max-width: calc(100vw - 32px);
  z-index: 60; padding: 16px 16px 14px;
  background: rgba(255,255,255,.97); border: 1px solid var(--glass-bd); border-radius: 16px;
  box-shadow: var(--panel-shadow); backdrop-filter: blur(10px);
  display: none; animation: flyDrop .16s ease;
}
.os-flyout.open { display: block; }
@keyframes flyDrop { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }
.os-flyout::before {
  content: ""; position: absolute; top: -7px; width: 14px; height: 14px;
  background: rgba(255,255,255,.97); border-left: 1px solid var(--glass-bd); border-top: 1px solid var(--glass-bd);
  transform: rotate(45deg);
}
.fly-status::before { right: 118px; }
.fly-act::before { right: 168px; }
@media (prefers-reduced-motion: reduce) { .os-flyout { animation: none } }

.fly-h { display: flex; align-items: center; gap: 8px; font: 700 13.5px/1 var(--font); color: var(--navy); margin-bottom: 12px; }
.fly-h.fly-h-sub { margin: 2px 0 10px; }
.fly-h .ic { width: 16px; height: 16px; color: var(--o); }
.fly-live { margin-left: auto; font: 600 11px/1 var(--font); color: var(--ok); display: inline-flex; align-items: center; gap: 5px; }
.fly-live:empty { display: none; }
.fly-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

/* score banner */
.fly-score {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 13px;
  background: linear-gradient(135deg, rgba(232,99,45,.07), rgba(232,99,45,.02));
}
.fly-score-big { font: 800 30px/1 var(--font); color: var(--o); }
.fly-score-big small { font: 700 13px/1 var(--font); color: var(--sl); }
.fly-score-stage { font: 800 13px/1.2 var(--font); color: var(--navy); }
.fly-trend { font: 600 11.5px/1 var(--font); color: var(--ok); margin-top: 4px; display: inline-flex; align-items: center; gap: 5px; }
.fly-trend .ic { width: 13px; height: 13px; }
.fly-noaudit {
  padding: 12px 14px; margin-bottom: 14px; border: 1px dashed var(--line); border-radius: 13px; background: #fafbfd;
}
.fly-noaudit-t { font: 700 13px/1.2 var(--font); color: var(--navy); }
.fly-noaudit-s { margin-top: 4px; }
.fly-noaudit-s code { font: 600 11px ui-monospace,Menlo,monospace; background: #f4f6fb; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* health mini-pills */
.fly-health { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.fly-hp { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.fly-hp-ico { flex: none; width: 28px; height: 28px; border-radius: 8px; background: rgba(31,42,68,.05); color: var(--navy); display: grid; place-items: center; }
.fly-hp-ico .ic { width: 15px; height: 15px; }
.fly-hp-k { font: 700 10px/1 var(--font); letter-spacing: .03em; color: var(--sl); }
.fly-hp-v { font: 800 13.5px/1.2 var(--font); color: var(--navy); margin-top: 2px; }
.fly-hp-sub { font: 600 10px/1 var(--font); color: var(--sl); margin-top: 2px; }
/* ALMACÉN pill: span the row, value on ONE line + a thin completion bar
   (mirrors the dashboard storage card) so it never wraps to two lines. */
.fly-hp-storage { grid-column: 1 / -1; align-items: flex-start; }
.fly-hp-storebody { flex: 1 1 auto; min-width: 0; }
.fly-hp-v.fly-hp-store { white-space: nowrap; }
.fly-hp-bar { height: 5px; margin-top: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.fly-hp-bar i { display: block; height: 100%; border-radius: 999px; background: var(--o); transition: width 0.4s ease; }

/* AIOS version: faint line under the Instancia pills (preserves the info the
   removed General status strip showed). */
.fly-aios-version { font: 600 10.5px/1 var(--font); color: var(--sl); margin: -8px 2px 14px; }
.fly-aios-version:empty { display: none; }

/* tiny hint that the degrade 4-Cs are COUNTS pending audit, not the score */
.fly-cs-hint { margin-left: 6px; font: 700 9px/1 var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--sl); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 2px 6px; }

/* 4 Cs cards */
.fly-cs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.fly-c { display: flex; flex-direction: column; padding: 11px 11px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.fly-c-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.fly-c-sc { font: 800 20px/1 var(--font); }
.fly-c-sc small { font: 700 11px/1 var(--font); color: var(--sl); }
.fly-c-lvl { font: 800 9.5px/1 var(--font); letter-spacing: .02em; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.fly-c-lbl { font: 600 11px/1.2 var(--font); color: var(--slate); margin-top: 7px; }
.fly-bar { height: 5px; border-radius: 3px; background: #eef1f6; margin-top: 6px; overflow: hidden; }
.fly-bar i { display: block; height: 100%; border-radius: 3px; }
.fly-c-count .fly-c-lbl { margin-top: 5px; }

.fly-remeasure { width: 100%; margin-top: 14px; justify-content: center; }

/* activity list */
.fly-act-list { display: block; }
.fly-act-item { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.fly-act-item:last-child { border-bottom: none; }
.fly-act-ico { flex: none; width: 26px; height: 26px; border-radius: 8px; background: rgba(232,99,45,.1); color: var(--o); display: grid; place-items: center; }
.fly-act-ico .ic { width: 14px; height: 14px; }
.fly-act-body { min-width: 0; flex: 1 1 auto; }
.fly-act-t { font: 600 12.5px/1.3 var(--font); color: var(--navy); }
.fly-act-ago { flex: none; margin-left: auto; font: 400 10.5px/1 var(--font); color: var(--sl); white-space: nowrap; }

@media (max-width: 760px) {
  .os-flyout { right: 8px; left: 8px; width: auto; }
  .fly-status::before, .fly-act::before { right: 28px; }
}

/* ---- sonia:list checklist widget ---- */
.sl-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--bg);
  margin: 6px 0;
}
.sl-title {
  font: 700 0.84rem/1.3 var(--font);
  color: var(--navy);
  margin-bottom: 8px;
}
.sl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.sl-row:last-child { border-bottom: none; }
.sl-row input[type="checkbox"] {
  flex: none;
  width: 15px;
  height: 15px;
  accent-color: var(--ok);
  cursor: pointer;
  margin: 0;
}
.sl-label {
  font: 400 0.875rem/1.4 var(--font);
  color: var(--navy);
  cursor: pointer;
}
.sl-row.done .sl-label {
  text-decoration: line-through;
  color: var(--sl);
}
/* Poll widget (sonia:poll) */
.sl-poll .sl-poll-question { margin-bottom: 10px; }
.sl-poll-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sl-poll-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 0.875rem/1.4 var(--font);
  color: var(--navy);
  cursor: pointer;
}
.sl-poll-opt input[type="radio"],
.sl-poll-opt input[type="checkbox"] {
  flex: none;
  width: 15px;
  height: 15px;
  accent-color: var(--ok);
  cursor: pointer;
  margin: 0;
}
.sl-poll-confirm {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font: 600 0.82rem/1 var(--font);
  color: var(--navy);
  cursor: pointer;
}
.sl-poll-confirm:hover:not(:disabled) { background: var(--line); }
.sl-poll--answered .sl-poll-confirm { opacity: 0.45; cursor: default; }
.sl-poll--answered .sl-poll-opt { opacity: 0.6; cursor: default; }
.sl-poll-summary {
  margin-top: 8px;
  font: 400 0.8rem/1.4 var(--font);
  color: var(--sl);
/* ===== Onboarding spotlight (V5) ===== */
.ob-overlay {
  position: fixed; inset: 0; z-index: 1250;
  background: rgba(0,0,0,0.55);
  pointer-events: auto;
}
.ob-coach {
  position: fixed; bottom: 100px; right: 24px; z-index: 1400;
  width: min(340px, calc(100vw - 48px));
  background: #fff; border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 20px;
}
.ob-dismiss {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; cursor: pointer;
  color: var(--sl); padding: 4px; display: flex; align-items: center;
}
.ob-dismiss .ic { width: 16px; height: 16px; }
.ob-title { font-weight: 700; font-size: 1rem; color: var(--navy); margin-bottom: 6px; }
.ob-body { color: var(--slate); font-size: 0.875rem; margin: 0 0 16px; line-height: 1.5; }
.ob-send { width: 100%; justify-content: center; }
.ob-success {
  text-align: center; padding: 10px 16px; margin: 8px 14px;
  background: #f0fdf4; color: var(--ok);
  border-radius: 10px; font-weight: 600; font-size: 0.9rem;
  border: 1px solid #bbf0cd;
}
@media (max-width: 760px) {
  .ob-coach { bottom: 80px; right: 16px; left: 16px; width: auto; }
}
/* ---- subscription expired overlay ---- */
.sub-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 13, 0.72); /* --navy at 72% */
}
.sub-card {
  background: #fff;
  border-radius: 14px;
  padding: 2rem 2.25rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}
.sub-card h2 {
  font: 700 1.2rem/1.3 var(--font);
  color: var(--navy);
  margin: 0;
}
.sub-card p {
  color: var(--slate);
  margin: 0;
  font-size: 0.95rem;
}
.sub-card .btn {
  align-self: center;
}
.fly-plan-renew { color: var(--o); font-weight: 600; text-decoration: underline; }
