/* MiCerebro — archivo privado, Telegram primero.
 * Esta capa reduce la web a consulta y administración. Las reglas antiguas
 * permanecen debajo para no romper superficies auxiliares aún enlazadas.
 */

body.nv5 .archive-workspace {
  width: calc(100% - var(--mc-sidebar));
  min-width: 0;
  min-height: 100dvh;
  margin-left: var(--mc-sidebar);
}

body.nv5 .archive-purpose {
  margin: -5px 8px 4px;
  color: var(--mc-subtle);
  font-size: .72rem;
  letter-spacing: .015em;
}

body.nv5 .archive-topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  min-height: 72px;
  padding: 13px clamp(28px, 5vw, 68px);
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-bottom: 1px solid var(--mc-line);
  background: rgba(7, 10, 16, .88);
  backdrop-filter: blur(20px);
}

body.nv5 .archive-global-search {
  display: flex;
  width: min(680px, 100%);
  min-height: 44px;
  margin: 0;
  padding: 0 5px 0 14px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--mc-line-strong);
  border-radius: 13px;
  color: var(--mc-muted);
  background: rgba(17, 24, 36, .86);
}

body.nv5 .archive-global-search > span {
  color: var(--mc-subtle);
  font-size: 1.25rem;
  line-height: 1;
}

body.nv5 .archive-global-search > input[type="search"] {
  min-width: 0;
  min-height: 42px;
  padding: 7px 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.nv5 .archive-global-search > button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  color: var(--mc-text-soft);
  background: var(--mc-surface-3);
  font-size: .74rem;
  font-weight: 650;
  cursor: pointer;
}

body.nv5 .archive-telegram-state {
  display: inline-flex;
  min-height: 34px;
  padding: 0 11px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(105, 200, 158, .18);
  border-radius: 999px;
  color: #a8d7bf;
  background: rgba(105, 200, 158, .07);
  font-size: .7rem;
  font-weight: 650;
}

body.nv5 button.archive-telegram-state { cursor: pointer; }
body.nv5 .archive-telegram-state i,
body.nv5 .pending-telegram-note i,
body.nv5 .telegram-connected i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mc-green);
}

body.nv5 .archive-telegram-state.is-off {
  border-color: var(--mc-line-strong);
  color: var(--mc-muted);
  background: var(--mc-surface);
}

body.nv5 .main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(34px, 5vw, 64px) clamp(28px, 5vw, 68px) 96px;
}

body.nv5 .sidebar-navigation { margin-top: 4px; }
body.nv5 .footer-mark { margin-top: auto; }
body.nv5 .mo-fab,
body.nv5 .uc-fab { display: none !important; }

/* Jerarquía de páginas de archivo */
body.nv5 .pending-page-head,
body.nv5 .memory-page-head,
body.nv5 .settings-page-head {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--mc-line);
}

body.nv5 .pending-telegram-note {
  display: inline-flex;
  min-height: 34px;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(105, 200, 158, .16);
  border-radius: 999px;
  color: #a8d7bf;
  background: rgba(105, 200, 158, .06);
  font-size: .7rem;
  white-space: nowrap;
}

body.nv5 :is(.pending-create, .memory-compose-disclosure) {
  margin-bottom: 18px;
  border: 1px solid var(--mc-line);
  border-radius: var(--mc-r-md);
  background: rgba(12, 17, 27, .68);
  overflow: clip;
}

body.nv5 :is(.pending-create, .memory-compose-disclosure) > summary {
  display: flex;
  min-height: 52px;
  padding: 10px 16px;
  align-items: center;
  gap: 10px;
  color: var(--mc-muted);
  font-size: .8rem;
  font-weight: 620;
  cursor: pointer;
  list-style: none;
}

body.nv5 :is(.pending-create, .memory-compose-disclosure) > summary::-webkit-details-marker { display: none; }
body.nv5 :is(.pending-create, .memory-compose-disclosure) > summary > span { color: var(--mc-accent); font-size: 1.15rem; }
body.nv5 .memory-compose-disclosure > summary > div { display: grid; gap: 1px; }
body.nv5 .memory-compose-disclosure > summary b { color: var(--mc-text-soft); font-size: .8rem; }
body.nv5 .memory-compose-disclosure > summary small { color: var(--mc-subtle); font-size: .68rem; font-weight: 450; }
body.nv5 :is(.pending-create, .memory-compose-disclosure)[open] > summary { border-bottom: 1px solid var(--mc-line); }
body.nv5 .pending-create .card { margin: 0; border: 0; border-radius: 0; background: transparent; }
body.nv5 .memory-compose-disclosure .memory-compose { margin: 0; border: 0; border-radius: 0; }

body.nv5 #task-list { padding-block: 6px; }
body.nv5 #task-list .task { padding: 12px 4px; }
body.nv5 #task-list .task.done { opacity: .58; }
body.nv5 #task-list .task.done .t-title { text-decoration: line-through; }
body.nv5 #task-list .task-target {
  margin-inline: -8px;
  padding-inline: 12px;
  border-radius: 11px;
  background: rgba(121, 170, 252, .11);
  box-shadow: inset 3px 0 0 var(--mc-accent);
}

body.nv5 #task-list .t-edit {
  min-height: 34px;
  padding-inline: 10px;
  font-size: .72rem;
}

body.nv5 #task-list .t-del {
  min-width: 34px;
  min-height: 34px;
  padding-inline: 9px;
  font-size: .72rem;
}

body.nv5 .chip.late { border-color: rgba(235, 133, 141, .28); color: var(--mc-red); }

body.nv5 .task-editor-head {
  display: flex;
  margin-bottom: 16px;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

body.nv5 .task-editor-close,
body.nv5 .connections-detail-close {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--mc-line);
  border-radius: 11px;
  color: var(--mc-muted);
  background: var(--mc-bg-raised);
  font-size: 1.3rem;
  cursor: pointer;
}

body.nv5 .task-editor-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 12px; }
body.nv5 .task-editor-grid label { min-width: 0; }
body.nv5 .task-editor-status { min-height: 21px; margin-top: 10px; color: var(--mc-muted); font-size: .76rem; }
body.nv5 .task-editor-actions { display: flex; margin-top: 14px; justify-content: flex-end; gap: 8px; }

/* Recuerdos y fotos */
body.nv5 .memory-entry-actions { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
body.nv5 .memory-entry-actions button {
  min-height: 29px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  color: var(--mc-muted);
  background: transparent;
  font-size: .68rem;
  cursor: pointer;
}

body.nv5 .memory-entry-actions button:hover { color: var(--mc-text-soft); background: rgba(255, 255, 255, .045); }
body.nv5 .memory-entry-actions .memory-delete { color: #d9949a; }
body.nv5 .memory-search { margin-top: 2px; }
body.nv5 .memory-search > input[type="search"] { border: 0 !important; background: transparent !important; }

/* Ajustes: las mejoras históricas de Material 3 todavía marcan Google, la
 * clave y las invitaciones con fondos claros `!important`. En el archivo
 * oscuro esos fondos dejan texto claro casi invisible, así que cerramos el
 * contraste únicamente dentro de Ajustes. */
html[data-premium-page="ajustes"] body.nv5 #page :is(.m3-google-card, .m3-key-card, .m3-invite-card) {
  border-color: var(--mc-line-strong) !important;
  color: var(--mc-text-soft) !important;
  background:
    radial-gradient(circle at 100% 0, rgba(121, 170, 252, .09), transparent 28rem),
    var(--mc-surface) !important;
  box-shadow: none !important;
}

html[data-premium-page="ajustes"] body.nv5 #page .m3-private-badge {
  border: 1px solid rgba(121, 170, 252, .22);
  color: #bed4f8;
  background: rgba(121, 170, 252, .11);
}

html[data-premium-page="ajustes"] body.nv5 #page .security-center .sec-eyebrow { color: var(--mc-accent); }
html[data-premium-page="ajustes"] body.nv5 #page .security-center .sec-shield {
  color: #bed4f8;
  background: rgba(121, 170, 252, .12);
}
html[data-premium-page="ajustes"] body.nv5 #page .security-center :is(.sec-block, .sec-status, .sec-facts span, .sec-copy-summary) {
  border: 1px solid var(--mc-line);
  color: var(--mc-text-soft);
  background: var(--mc-bg-raised);
}

/* Telegram es la superficie principal. */
html[data-premium-page="ajustes"] body.nv5 #page .telegram-settings-primary {
  padding: clamp(20px, 4vw, 28px);
  border-color: rgba(121, 170, 252, .23) !important;
  background:
    radial-gradient(circle at 100% 0, rgba(121, 170, 252, .09), transparent 24rem),
    var(--mc-surface) !important;
}

body.nv5 .telegram-settings-head {
  display: flex;
  margin-bottom: 14px;
  align-items: center;
  gap: 12px;
}

body.nv5 .telegram-settings-head > span { font-size: 1.3rem; }
body.nv5 .telegram-settings-head > div { min-width: 0; flex: 1; }
body.nv5 .telegram-settings-head h2 { margin: 0; }
body.nv5 .telegram-connected {
  display: inline-flex;
  padding: 6px 9px;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  color: #a8d7bf;
  background: rgba(105, 200, 158, .08);
  font-size: .68rem;
}

body.nv5 .telegram-command-list { display: flex; margin: 17px 0 13px; gap: 7px; flex-wrap: wrap; }
body.nv5 .telegram-command-list span,
body.nv5 .telegram-link-code {
  padding: 6px 9px;
  border: 1px solid var(--mc-line);
  border-radius: 9px;
  color: #b8cef2;
  background: var(--mc-bg-raised);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .72rem;
}

/* Conexiones: vista completa que se calcula una sola vez al abrir. */
body.connections-open { overflow: hidden !important; }
body.nv5 .connections-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  color: var(--mc-text);
  background:
    radial-gradient(circle at 52% 45%, rgba(95, 130, 188, .08), transparent 38rem),
    #060910;
}

body.nv5 .connections-header {
  display: flex;
  min-height: 86px;
  padding: 16px clamp(18px, 4vw, 44px) 14px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--mc-line);
  background: rgba(7, 10, 16, .86);
}

body.nv5 .connections-header > div { min-width: 0; }
body.nv5 .connections-header h1 { font-size: clamp(1.35rem, 2.5vw, 1.9rem); }
body.nv5 .connections-header p { margin-top: 4px; color: var(--mc-muted); font-size: .76rem; }
body.nv5 .connections-close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--mc-line-strong);
  border-radius: 12px;
  color: var(--mc-text-soft);
  background: var(--mc-surface);
  font-size: 1.5rem;
  cursor: pointer;
}

body.nv5 .connections-toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  min-height: 58px;
  padding: 8px clamp(18px, 4vw, 44px);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--mc-line);
  background: rgba(9, 13, 21, .78);
}

body.nv5 .connections-toolbar > label {
  display: flex;
  width: min(430px, 100%);
  min-height: 40px;
  margin: 0;
  padding: 0 12px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--mc-line-strong);
  border-radius: 11px;
  color: var(--mc-subtle);
  background: var(--mc-surface);
}

body.nv5 .connections-toolbar input[type="search"] {
  min-width: 0;
  min-height: 38px;
  padding: 6px 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.nv5 .connections-zoom { display: flex; gap: 5px; }
body.nv5 .connections-zoom button {
  min-width: 39px;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid var(--mc-line);
  border-radius: 10px;
  color: var(--mc-muted);
  background: var(--mc-surface);
  font-size: .74rem;
  cursor: pointer;
}

body.nv5 .connections-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
body.nv5 .connections-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
body.nv5 .connections-stage canvas:active { cursor: grabbing; }

body.nv5 .connections-loading {
  position: absolute;
  inset: 0;
  display: grid;
  padding: 28px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--mc-muted);
  background: rgba(6, 9, 16, .35);
  text-align: center;
}

body.nv5 .connections-loading > span:first-child {
  width: 22px;
  height: 22px;
  border: 2px solid var(--mc-line-strong);
  border-top-color: var(--mc-accent);
  border-radius: 50%;
  animation: connections-spin .8s linear infinite;
}

body.nv5 .connections-loading b { color: var(--mc-text-soft); }
body.nv5 .connections-loading b + span { max-width: 440px; }
@keyframes connections-spin { to { transform: rotate(1turn); } }

body.nv5 .connections-detail {
  position: absolute;
  inset: 18px 18px 18px auto;
  z-index: 6;
  width: min(340px, calc(100% - 36px));
  padding: 22px;
  overflow-y: auto;
  border: 1px solid var(--mc-line-strong);
  border-radius: 18px;
  color: var(--mc-text-soft);
  background: rgba(17, 24, 36, .96);
  box-shadow: var(--mc-shadow);
  backdrop-filter: blur(18px);
}

body.nv5 .connections-detail[hidden] { display: none; }
body.nv5 .connections-detail-close { float: right; margin: -5px -5px 6px 12px; }
body.nv5 .connections-detail h2 { margin: 3px 0 16px; font-size: 1.45rem; overflow-wrap: anywhere; }
body.nv5 .connections-stats { display: grid; margin-bottom: 18px; grid-template-columns: 1fr 1fr; gap: 8px; }
body.nv5 .connections-stats span { display: grid; padding: 11px; border: 1px solid var(--mc-line); border-radius: 11px; color: var(--mc-muted); font-size: .69rem; }
body.nv5 .connections-stats b { color: var(--mc-text); font-family: Sora, sans-serif; font-size: 1.05rem; }
body.nv5 .connections-neighbours { display: grid; gap: 5px; }
body.nv5 .connections-neighbours > b { margin-bottom: 3px; color: var(--mc-muted); font-size: .72rem; }
body.nv5 .connections-neighbours button {
  display: grid;
  min-height: 38px;
  padding: 5px 8px;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  color: var(--mc-text-soft);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

body.nv5 .connections-neighbours button:hover { background: rgba(255, 255, 255, .045); }
body.nv5 .connections-neighbours button > span { width: 8px; height: 8px; border-radius: 50%; background: var(--node-color); }
body.nv5 .connections-neighbours small { color: var(--mc-subtle); }
body.nv5 .connections-detail-actions { display: grid; margin-top: 20px; gap: 7px; }

body.nv5 .connections-suggestions {
  position: absolute;
  z-index: 9;
  top: 10px;
  left: clamp(18px, 4vw, 44px);
  display: grid;
  width: min(430px, calc(100% - 36px));
  max-height: min(54dvh, 420px);
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--mc-line-strong);
  border-radius: 12px;
  background: rgba(17, 24, 36, .98);
  box-shadow: var(--mc-shadow);
}

body.nv5 .connections-suggestions[hidden] { display: none; }
body.nv5 .connections-suggestions button {
  display: grid;
  min-height: 46px;
  padding: 7px 9px;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 9px;
  color: var(--mc-text-soft);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

body.nv5 .connections-suggestions button:hover { background: rgba(255, 255, 255, .045); }
body.nv5 .connections-suggestions i { width: 9px; height: 9px; border-radius: 50%; background: var(--node-color); }
body.nv5 .connections-suggestions b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.nv5 .connections-suggestions small { color: var(--mc-subtle); font-size: .66rem; }
body.nv5 .connections-suggestions p { padding: 13px; color: var(--mc-muted); font-size: .78rem; }

body.nv5 .connections-legend {
  display: flex;
  min-height: 48px;
  padding: 9px clamp(18px, 4vw, 44px);
  align-items: center;
  gap: 15px;
  border-top: 1px solid var(--mc-line);
  color: var(--mc-muted);
  background: rgba(7, 10, 16, .9);
  font-size: .68rem;
}

body.nv5 .connections-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
body.nv5 .connections-legend i { width: 8px; height: 8px; border-radius: 50%; }
body.nv5 .connections-legend i.persona { background: #79aafc; }
body.nv5 .connections-legend i.tema { background: #b497f5; }
body.nv5 .connections-legend i.lugar { background: #63c7ae; }
body.nv5 .connections-legend i.proyecto { background: #efad62; }
body.nv5 .connections-legend small { margin-left: auto; color: var(--mc-subtle); }

@media (max-width: 760px) {
  body.nv5 .archive-workspace { width: 100%; min-height: var(--mobile-vh, 100dvh); margin-left: 0; }
  body.nv5 .archive-topbar {
    min-height: calc(60px + env(safe-area-inset-top));
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    gap: 8px;
  }
  body.nv5 .archive-global-search { min-height: 42px; padding-left: 12px; }
  body.nv5 .archive-global-search > button { display: none; }
  body.nv5 .archive-global-search > input[type="search"] { font-size: 16px; }
  body.nv5 .archive-telegram-state { display: none; }
  body.nv5 .main {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 26px 14px calc(var(--mc-dock) + 34px + env(safe-area-inset-bottom));
  }
  body.nv5 .bottom-nav { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  body.nv5 .mc-page-head { align-items: flex-start; }
  body.nv5 .pending-page-head,
  body.nv5 .memory-page-head { display: grid; gap: 13px; }
  body.nv5 .pending-telegram-note { width: fit-content; }
  body.nv5 .memory-page-head > .btn { width: fit-content; }
  body.nv5 :is(.pending-create, .memory-compose-disclosure) > summary { min-height: 56px; }
  body.nv5 .pending-create .row { align-items: stretch; }
  body.nv5 .pending-create :is(input, select, .btn) { width: 100% !important; }
  body.nv5 #task-list { padding-inline: 12px; }
  body.nv5 #task-list .task { align-items: flex-start; flex-wrap: wrap; }
  body.nv5 #task-list .task > input[type="checkbox"] { margin-top: 8px; }
  body.nv5 #task-list .t-title { min-width: calc(100% - 38px); padding-top: 5px; }
  body.nv5 #task-list .chip:first-of-type { margin-left: 29px; }
  body.nv5 #task-list .t-edit { margin-left: auto; }
  body.nv5 .task-editor-grid { grid-template-columns: 1fr; gap: 0; }
  body.nv5 .task-editor-actions .btn { min-width: 0; flex: 1; }
  body.nv5 .memory-entry-meta { display: grid; }
  body.nv5 .memory-entry-actions { justify-content: flex-start; }
  body.nv5 .memory-entry-actions button { padding-inline: 6px; }
  body.nv5 .telegram-settings-head { align-items: flex-start; flex-wrap: wrap; }
  body.nv5 .telegram-connected { margin-left: 43px; }

  body.nv5 .connections-overlay { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  body.nv5 .connections-header {
    min-height: calc(70px + env(safe-area-inset-top));
    padding: max(11px, env(safe-area-inset-top)) 13px 10px;
    gap: 10px;
  }
  body.nv5 .connections-header p { display: none; }
  body.nv5 .connections-header .mc-eyebrow { margin-bottom: 3px; font-size: .58rem; }
  body.nv5 .connections-header h1 { font-size: 1.25rem; }
  body.nv5 .connections-close { width: 42px; height: 42px; flex-basis: 42px; }
  body.nv5 .connections-toolbar { min-height: 56px; padding: 7px 11px; }
  body.nv5 .connections-toolbar > label { min-width: 0; }
  body.nv5 .connections-toolbar input[type="search"] { font-size: 16px; }
  body.nv5 .connections-zoom [data-zoom="out"],
  body.nv5 .connections-zoom [data-zoom="in"] { display: none; }
  body.nv5 .connections-zoom button { min-width: 58px; padding-inline: 8px; }
  body.nv5 .connections-detail {
    inset: auto 8px 8px;
    width: auto;
    max-height: min(58%, 440px);
    padding: 18px;
    border-radius: 18px;
  }
  body.nv5 .connections-detail h2 { font-size: 1.25rem; }
  body.nv5 .connections-suggestions { top: 8px; left: 8px; width: calc(100% - 16px); }
  body.nv5 .connections-legend { min-height: 42px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 11px; overflow-x: auto; scrollbar-width: none; }
  body.nv5 .connections-legend small { display: none; }
}

@media (max-width: 390px) {
  body.nv5 .main { padding-inline: 12px; }
  body.nv5 .archive-global-search > span { display: none; }
  body.nv5 .archive-global-search { padding-left: 10px; }
  body.nv5 .memory-entry { grid-template-columns: 43px minmax(0, 1fr); gap: 8px; }
  body.nv5 .memory-entry-date { width: 43px; }
  body.nv5 .connections-legend { gap: 9px; font-size: .61rem; }
}

@media (prefers-reduced-motion: reduce) {
  body.nv5 .connections-loading > span:first-child { animation: none; border-color: var(--mc-accent); }
}
