/* ── Fase 2: enlaces internos, etiquetas, embeds, propiedades, panel derecho ── */

/* Enlaces internos y etiquetas */
.cm-wikilink, .markdown .enlace-interno, .consulta .enlace-interno {
  color: var(--accent-text); text-decoration: none; cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.cm-wikilink:hover, .markdown .enlace-interno:hover, .consulta .enlace-interno:hover { border-bottom-color: var(--accent); }
.cm-wikilink.is-rota, .markdown .enlace-interno.is-rota {
  color: color-mix(in srgb, var(--accent-text) 55%, var(--muted)); border-bottom-style: dashed;
}
.tk-hashtag, .cm-hashtag { color: var(--accent-text); }
.modo-vivo .cm-hashtag, .markdown .etiqueta, .consulta .etiqueta {
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: 999px; padding: .05em .55em; font-size: .9em; text-decoration: none; cursor: pointer;
}
.markdown .etiqueta:hover, .modo-vivo .cm-hashtag:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* Embeds ![[Nota]] */
.cm-embed, .markdown .embed {
  display: block; margin: .4em 0; padding: .2em 0 .2em 1em;
  border-left: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 4%, transparent);
  border-radius: 0 6px 6px 0; white-space: normal; cursor: default;
}
.cm-embed-titulo, .markdown .embed-titulo {
  display: inline-block; margin: .2em 0 .1em; font-size: .8em; font-weight: 600; letter-spacing: .02em;
  color: var(--muted); text-transform: uppercase; cursor: pointer; border: 0; text-decoration: none;
}
.cm-embed-titulo:hover, .markdown .embed-titulo:hover { color: var(--accent-text); }
.cm-embed-cuerpo { font-size: .95em; }
.cm-embed-cuerpo > :last-child, .markdown .embed-cuerpo > :last-child { margin-bottom: .3em; }
.cm-embed.is-rota, .markdown .embed.is-rota { border-left-color: var(--border-strong); color: var(--muted); }

/* Autocompletado */
.cm-tooltip.cm-tooltip-autocomplete {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev);
  box-shadow: var(--shadow); padding: 4px; font-family: var(--font-ui);
}
.cm-tooltip.cm-tooltip-autocomplete > ul { max-height: 16em; font-family: var(--font-ui) !important; }
.cm-tooltip.cm-tooltip-autocomplete > ul > li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 10px !important; border-radius: var(--radius-sm); color: var(--text); font-size: 13.5px; line-height: 1.4;
}
.cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--accent-soft) !important; color: var(--text) !important; }
.cm-tooltip-autocomplete .cm-completionLabel { flex: 1; }
.cm-tooltip-autocomplete .cm-completionMatchedText { text-decoration: none; font-weight: 700; color: var(--accent-text); }
.cm-tooltip-autocomplete .cm-completionDetail { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); }

/* Propiedades */
.props { margin: -.2em 0 1.2em; font-size: 14px; }
.props[hidden] { display: none; }
.props-cabecera {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 4px -4px; padding: 2px 6px 2px 2px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); font-size: 13px; font-weight: 600;
}
.props-cabecera:hover { background: var(--bg-hover); color: var(--text); }
.props-cabecera svg.icon { width: 15px; height: 15px; }
.props-tabla { display: grid; gap: 2px; }
.prop-fila { display: grid; grid-template-columns: 26px minmax(90px, 160px) minmax(0, 1fr); align-items: start; gap: 4px; border-radius: var(--radius-sm); }
.prop-fila:hover { background: color-mix(in srgb, var(--bg-hover) 60%, transparent); }
.prop-icono {
  display: grid; place-items: center; width: 26px; height: 30px; padding: 0; border: 0; background: none;
  color: var(--muted); border-radius: var(--radius-sm);
}
.prop-icono:hover { color: var(--text); background: var(--bg-hover); }
.prop-icono svg.icon { width: 15px; height: 15px; }
.prop-clave, .prop-input {
  width: 100%; min-width: 0; height: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font-size: 13.5px;
}
.prop-clave { color: var(--text-2); }
.prop-clave:focus, .prop-input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.prop-clave:read-only:focus, .prop-input:read-only:focus { border-color: transparent; background: transparent; }
.prop-input.es-enlace { color: var(--accent-text); }
.prop-input::placeholder { color: var(--muted); opacity: .7; }
.prop-valor { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 30px; padding: 2px 0; }
.prop-valor .prop-input-lista { flex: 1; min-width: 80px; height: 26px; }
.prop-chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  padding: 1px 4px 1px 9px; border-radius: 999px; background: var(--bg-hover); color: var(--text); font-size: 13px; line-height: 22px;
}
.prop-chip.es-tag { background: var(--accent-soft); }
.prop-chip.es-tag .prop-chip-texto { color: var(--accent-text); text-decoration: none; }
.prop-chip-texto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-chip-texto.enlace-interno { color: var(--accent-text); cursor: pointer; }
.prop-chip-x { display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.prop-chip-x:hover { background: var(--bg-active); color: var(--text); }
.prop-chip-x svg.icon { width: 12px; height: 12px; }
.prop-chip:not(:has(.prop-chip-x)) { padding-right: 9px; }
@media (max-width: 768px) { .prop-fila { grid-template-columns: 26px minmax(70px, 110px) minmax(0, 1fr); } }
.prop-casilla { width: 16px; height: 16px; margin: 7px 6px; accent-color: var(--accent); }
.props-agregar {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 4px 8px 4px 4px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); font-size: 13px;
}
.props-agregar:hover { background: var(--bg-hover); color: var(--text); }
.props-agregar svg.icon { width: 15px; height: 15px; }

/* Panel derecho */
#panel-der { padding: 6px 8px 16px; }
.pd-seccion { margin-bottom: 14px; }
.pd-titulo {
  display: flex; align-items: center; justify-content: space-between; margin: 6px 4px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.pd-cuenta { font: 500 11px var(--font-mono); color: var(--muted); padding: 0 6px; border-radius: 999px; background: var(--bg-hover); }
.pd-nada { margin: 2px 6px; color: var(--muted); font-size: 12.5px; }
.pd-item { margin-bottom: 6px; border-radius: var(--radius-sm); }
.pd-item-simple { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 0; }
.pd-nota {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.pd-nota:hover { background: var(--bg-hover); }
.pd-nota svg.icon { width: 14px; height: 14px; color: var(--muted); flex: none; }
.pd-item.is-rota .pd-nota { color: var(--muted); }
.pd-etiqueta-roto { font-size: 11px; color: var(--muted); padding-right: 6px; flex: none; }
.pd-contexto {
  display: flex; align-items: flex-start; gap: 6px; margin: 2px 0 4px 26px; padding: 6px 8px;
  border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.45; color: var(--text-2); cursor: pointer; overflow-wrap: anywhere;
}
.pd-contexto { display: block; }
.pd-contexto:hover { border-color: var(--border-strong); }
.pd-contexto mark { background: var(--accent-soft); color: var(--accent-text); border-radius: 3px; padding: 0 2px; }
.pd-enlazar { display: flex; margin: 6px 0 0 auto; height: 24px; padding: 0 8px; font-size: 12px; }
.pd-esquema { display: grid; gap: 1px; }
.pd-esquema-item {
  display: block; padding: 4px 8px 4px calc(8px + var(--nivel) * 14px); border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; text-decoration: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.pd-esquema-item:hover { background: var(--bg-hover); color: var(--text); }
.pd-filtro {
  width: 100%; height: 30px; margin: 2px 0 8px; padding: 0 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 13px;
}
.pd-filtro:focus { outline: none; border-color: var(--accent); }
.pd-tag {
  display: flex; align-items: center; gap: 2px; height: 28px; padding: 0 6px 0 calc(var(--nivel) * 14px);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; color: var(--text-2);
}
.pd-tag:hover { background: var(--bg-hover); color: var(--text); }
.pd-tag.is-active { background: var(--accent-soft); color: var(--accent-text); }
.pd-tag-chev { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; background: none; color: var(--muted); flex: none; }
.pd-tag-chev svg.icon { width: 14px; height: 14px; }
.pd-tag-nombre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-tag-notas { margin: 0 0 6px calc(var(--nivel) * 14px + 18px); }

/* Bloques ```consulta */
.consulta, .cm-consulta {
  display: block; position: relative; margin: .5em 0; padding: .5em .8em .4em;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-side);
  font-family: var(--font-ui); white-space: normal; cursor: default;
}
.cm-consulta > .consulta { margin: 0; padding: 0; border: 0; background: none; }
/* En el editor es un widget de bloque: su margin no se mide y corre el margen de pliegues */
.cm-consulta { margin: 0; }
.cm-consulta-editar { position: absolute; top: 4px; right: 4px; opacity: 0; transition: opacity .12s; }
.cm-consulta:hover .cm-consulta-editar, .cm-consulta-editar:focus-visible { opacity: 1; }
.consulta-estado { color: var(--muted); font-size: .9em; padding: .2em 0; }
.consulta-estado.is-error { color: var(--danger); }
.consulta-lista, .consulta-lista-tareas { margin: .2em 0; padding-left: 1.2em; }
.consulta-lista li, .consulta-lista-tareas li { margin: .15em 0; }
.consulta-sep { color: var(--muted); }
.consulta-valor.es-vacio { color: var(--muted); }
.consulta-tabla-envoltura { overflow-x: auto; margin: .2em 0; }
.consulta-tabla { border-collapse: collapse; width: 100%; font-size: .92em; }
.consulta-tabla th, .consulta-tabla td { border-bottom: 1px solid var(--border); padding: .35em .7em .35em 0; text-align: left; vertical-align: top; }
.consulta-tabla th { color: var(--muted); font-weight: 600; font-size: .85em; text-transform: uppercase; letter-spacing: .02em; }
.consulta-tabla tr:last-child td { border-bottom: 0; }
.consulta-nota { margin-top: .4em; font-size: .85em; font-weight: 600; }
.consulta-lista-tareas { list-style: none; padding-left: 0; }
.consulta-tarea { display: flex; align-items: baseline; gap: .5em; }
.consulta-casilla { flex: none; margin: 0; accent-color: var(--accent); }
.consulta-tarea-texto { flex: 1; cursor: pointer; }
.consulta-tarea.tarea-hecha .consulta-tarea-texto { text-decoration: line-through; color: var(--muted); }
.consulta-fecha { flex: none; color: var(--muted); font-size: .85em; }
.consulta-pie { display: flex; align-items: center; gap: .35em; margin-top: .3em; color: var(--muted); font-size: .78em; }
.consulta-pie .icon { width: 12px; height: 12px; }

/* Vista previa de un [[enlace]] al pasar el mouse */
.vista-previa {
  position: fixed; z-index: 60; width: min(460px, calc(100vw - 16px)); max-height: min(380px, 60vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: calc(var(--editor-font-size) * .88); animation: vp-entra .12s var(--ease);
}
@keyframes vp-entra { from { opacity: 0; transform: translateY(-3px); } }
.vp-cabecera { flex: none; padding: 8px 12px 6px; border-bottom: 1px solid var(--border); font-family: var(--font-ui); font-size: 12.5px; }
.vista-previa .vp-titulo { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; color: var(--text-2); font-weight: 600; border: 0; }
.vista-previa .vp-titulo:hover { color: var(--accent-text); }
.vp-titulo svg.icon { width: 14px; height: 14px; flex: none; }
.vp-cuerpo { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px 12px; font-family: var(--font-texto); }
.vp-cuerpo > :last-child { margin-bottom: 0; }
.vista-previa.is-rota .vp-cuerpo { color: var(--muted); font-family: var(--font-ui); font-size: 13px; }
.vp-adjunto { padding: 8px; }
.vp-adjunto img { display: block; max-width: 100%; max-height: 300px; margin: 0 auto; border-radius: 6px; }
/* [texto](Nota.md) en el editor: como un enlace interno */
.modo-vivo .cm-enlace-interno { color: var(--accent-text); }
.modo-vivo .cm-enlace-interno.is-rota { color: color-mix(in srgb, var(--accent-text) 55%, var(--muted)); text-decoration-style: dashed; }
