/* ═══════════════════════════════════════════════════════════
   UNFAMED · VISOR TÉCNICO BIODISCO CBR — v4.0
   Sistema visual: estación de trabajo de ingeniería
   ═══════════════════════════════════════════════════════════ */

:root {
  --void:        #0a0d11;
  --void-2:      #0e1218;
  --surface:     rgba(16, 21, 27, 0.88);
  --surface-sol: #141a21;
  --line:        rgba(255, 255, 255, 0.075);
  --line-2:      rgba(255, 255, 255, 0.16);

  --aqua:        #4dd9c0;
  --aqua-dim:    rgba(77, 217, 192, 0.14);
  --aqua-soft:   rgba(77, 217, 192, 0.45);
  --amber:       #f2a93b;
  --rose:        #e2736b;

  --text:        #e4eaf0;
  --dim:         #8695a4;
  --dim-2:       #5b6975;

  --paper:       #fbfcfd;
  --paper-2:     #f1f4f7;
  --ink:         #0f1821;
  --ink-dim:     #51606e;
  --ink-line:    #dde4ea;

  --f-cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --f-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --r:    8px;
  --r-sm: 5px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select { font: inherit; color: inherit; }

html, body {
  width: 100%; height: 100%;
  background: var(--void);
  font-family: var(--f-sans);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ───────────────────────── ARRANQUE ───────────────────────── */
#boot {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse 80% 55% at 50% 118%, #16222b 0%, transparent 62%),
    var(--void);
  transition: opacity .85s var(--ease);
}
#boot.gone { opacity: 0; pointer-events: none; }

.boot-inner { display: flex; flex-direction: column; align-items: center; }
.boot-mark { width: 72px; height: 72px; color: var(--aqua); }
.boot-arc  { transform-origin: 50% 50%; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.boot-brand {
  font-family: var(--f-cond); font-size: 2.3rem; font-weight: 700;
  letter-spacing: .42em; text-indent: .42em; margin-top: 20px;
}
.boot-sub {
  font-family: var(--f-cond); font-size: .76rem; font-weight: 500;
  letter-spacing: .3em; color: var(--dim); margin-top: 2px;
}
.boot-track {
  width: 300px; height: 2px; background: rgba(255, 255, 255, .08);
  margin-top: 36px; overflow: hidden; border-radius: 2px;
}
#boot-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--aqua-soft), var(--aqua));
  transition: width .5s var(--ease);
}
.boot-row {
  width: 300px; margin-top: 10px;
  display: flex; justify-content: space-between;
  font-family: var(--f-cond); font-size: .68rem;
  letter-spacing: .22em; color: var(--dim); text-transform: uppercase;
}
#boot-pct { letter-spacing: .08em; }

/* ───────────────────────── LIENZO ───────────────────────── */
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }

/* ───────────────────────── BARRA SUPERIOR ───────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 120;
  height: 58px; padding: 0 18px;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to bottom, rgba(10, 13, 17, .94), rgba(10, 13, 17, .55) 70%, transparent);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 11px; pointer-events: auto; }
.brand-mark { width: 30px; height: 30px; color: var(--aqua); flex-shrink: 0; }
.brand-mark ellipse, .brand-mark line { stroke: currentColor; fill: none; }
.brand-name {
  font-family: var(--f-cond); font-size: 1.04rem; font-weight: 700;
  letter-spacing: .3em; line-height: 1;
}
.brand-sub {
  font-size: .66rem; font-weight: 300; color: var(--dim);
  letter-spacing: .04em; margin-top: 3px;
}

.topbar-tools { display: flex; align-items: center; gap: 5px; pointer-events: auto; }
.topbar-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 5px; }

.tool {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--dim); padding: 7px 12px; border-radius: var(--r-sm);
  cursor: pointer; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  font-family: var(--f-cond); font-size: .74rem; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase; white-space: nowrap;
  transition: color .2s, border-color .2s, background .2s;
}
.tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5;
            stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.tool:hover { color: var(--text); border-color: var(--line-2); }
.tool.on { background: var(--aqua-dim); border-color: var(--aqua-soft); color: var(--aqua); }
.tool-accent.on { background: rgba(242, 169, 59, .15); border-color: rgba(242, 169, 59, .5); color: var(--amber); }

/* ───────────────────────── PANELES ───────────────────────── */
.panel {
  position: fixed; z-index: 110;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .4s var(--ease), opacity .3s var(--ease);
}
.panel-left  { top: 70px; left: 18px;  width: 268px; bottom: 128px; }
.panel-right { top: 70px; right: 18px; width: 272px; max-height: calc(100vh - 198px); }

.panel-left.away  { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
.panel-right.away { transform: translateX(calc(100% + 24px));  opacity: 0; pointer-events: none; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px 11px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.panel-head h2 {
  font-family: var(--f-cond); font-size: .76rem; font-weight: 600;
  letter-spacing: .26em; text-transform: uppercase; color: var(--text);
}
.icon-btn {
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--dim-2); cursor: pointer; border-radius: 4px;
  display: grid; place-items: center; transition: color .2s, background .2s;
}
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor;
                stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .07); }

.panel-reveal {
  position: fixed; top: 70px; left: 18px; z-index: 109;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--dim); cursor: pointer; display: none; place-items: center;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.panel-reveal svg { width: 16px; height: 16px; fill: none; stroke: currentColor;
                    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.panel-reveal.show { display: grid; }
.panel-reveal:hover { color: var(--text); border-color: var(--line-2); }

/* ───────────────────────── BUSCADOR ───────────────────────── */
.search-wrap { position: relative; padding: 11px 12px 9px; flex-shrink: 0; }
.search-ico {
  position: absolute; left: 21px; top: 50%; transform: translateY(-40%);
  width: 13px; height: 13px; fill: none; stroke: var(--dim-2);
  stroke-width: 1.8; stroke-linecap: round; pointer-events: none;
}
#tree-search {
  width: 100%; background: rgba(0, 0, 0, .3); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 10px 7px 29px;
  font-size: .78rem; color: var(--text); outline: none;
  transition: border-color .2s;
}
#tree-search::placeholder { color: var(--dim-2); }
#tree-search:focus { border-color: var(--aqua-soft); }
#tree-search::-webkit-search-cancel-button { filter: invert(.6); cursor: pointer; }

/* ───────────────────────── ÁRBOL ───────────────────────── */
.tree { flex: 1; overflow-y: auto; padding: 2px 6px 10px; min-height: 0; }

.tg { margin-bottom: 2px; }
.tg-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--r-sm);
  cursor: pointer; user-select: none; transition: background .18s;
}
.tg-head:hover { background: rgba(255, 255, 255, .045); }
.tg-caret {
  width: 11px; height: 11px; flex-shrink: 0; color: var(--dim-2);
  transition: transform .22s var(--ease);
}
.tg-caret svg { width: 100%; height: 100%; fill: none; stroke: currentColor;
                stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tg.open .tg-caret { transform: rotate(90deg); }

.tg-swatch { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
.tg-name {
  flex: 1; font-family: var(--f-cond); font-size: .82rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-count {
  font-family: var(--f-mono); font-size: .64rem; color: var(--dim-2);
  font-variant-numeric: tabular-nums;
}
.tg-eye {
  width: 20px; height: 20px; border: none; background: transparent; padding: 0;
  color: var(--dim-2); cursor: pointer; border-radius: 3px;
  display: grid; place-items: center; flex-shrink: 0;
}
.tg-eye svg { width: 13px; height: 13px; fill: none; stroke: currentColor;
              stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tg-eye:hover { color: var(--text); }
.tg-eye.off { color: var(--dim-2); opacity: .4; }

.tg-items { display: none; padding: 1px 0 5px 24px; }
.tg.open .tg-items { display: block; }

.ti {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px; border-radius: 4px; cursor: pointer;
  font-size: .74rem; color: var(--dim);
  white-space: nowrap; overflow: hidden;
  transition: background .15s, color .15s;
}
.ti:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.ti.sel { background: var(--aqua-dim); color: var(--aqua); }
.ti.off { opacity: .35; text-decoration: line-through; }
.ti-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ti-tris { font-family: var(--f-mono); font-size: .6rem; color: var(--dim-2); }

.panel-foot {
  display: flex; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--line); flex-shrink: 0;
}
.mini-btn {
  flex: 1; background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line); color: var(--dim);
  padding: 6px 9px; border-radius: var(--r-sm); cursor: pointer;
  font-family: var(--f-cond); font-size: .7rem; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase; white-space: nowrap;
  transition: all .2s;
}
.mini-btn:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); background: rgba(255, 255, 255, .08); }
.mini-btn:disabled { opacity: .35; cursor: default; }

/* ───────────────────────── INSPECTOR ───────────────────────── */
.insp-body { padding: 14px; overflow-y: auto; }
.insp-eyebrow {
  font-size: .62rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--aqua); margin-bottom: 6px;
}
.insp-title {
  font-family: var(--f-cond); font-size: 1.16rem; font-weight: 600;
  line-height: 1.2; letter-spacing: .02em; margin-bottom: 14px;
}

.spec-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r-sm); overflow: hidden;
}
.spec {
  background: rgba(0, 0, 0, .25); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.spec-k {
  font-family: var(--f-cond); font-size: .62rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--dim-2);
}
.spec-v { font-size: .78rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; }

.insp-actions { display: flex; gap: 6px; margin-top: 12px; }
.insp-note {
  margin-top: 12px; font-size: .74rem; line-height: 1.6; color: var(--dim);
  padding-top: 11px; border-top: 1px solid var(--line);
}
.insp-note:empty { display: none; }
.insp-note b { color: var(--aqua); font-weight: 500; }

/* ───────────────────────── DOCK INFERIOR ───────────────────────── */
.dock {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 110; display: flex; align-items: center; gap: 16px;
  padding: 9px 16px; max-width: calc(100vw - 36px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  overflow-x: auto; scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock-group { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.dock-group + .dock-group { padding-left: 16px; border-left: 1px solid var(--line); }
.dock-label {
  font-family: var(--f-cond); font-size: .64rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--dim-2); white-space: nowrap;
}
.dock-val { font-size: .68rem; color: var(--dim); min-width: 34px; text-align: right; }

.chip {
  background: transparent; border: 1px solid transparent; color: var(--dim);
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font-family: var(--f-cond); font-size: .74rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  transition: all .2s;
}
.chip:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.chip.on { background: var(--aqua-dim); border-color: var(--aqua-soft); color: var(--aqua); }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg-b {
  background: transparent; border: none; color: var(--dim-2);
  padding: 5px 10px; cursor: pointer;
  font-family: var(--f-mono); font-size: .66rem; font-weight: 500;
  transition: all .18s;
}
.seg-b + .seg-b { border-left: 1px solid var(--line); }
.seg-b:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.seg-b.active { background: var(--aqua-dim); color: var(--aqua); }

.slider {
  -webkit-appearance: none; appearance: none;
  width: 118px; height: 3px; border-radius: 2px;
  background: rgba(255, 255, 255, .14); outline: none; cursor: pointer;
}
.slider-sm { width: 84px; }
.slider:disabled { opacity: .35; cursor: default; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--aqua); cursor: pointer; border: 2px solid var(--void-2);
  box-shadow: 0 0 0 1px var(--aqua-soft);
}
.slider::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; background: var(--aqua);
  cursor: pointer; border: 2px solid var(--void-2);
}

/* ───────────────────────── LECTURA TÉCNICA ───────────────────────── */
.readout {
  /* Encima del dock: con solo dos filas (rotor y cámara) ya no asoma por
     arriba de él como cuando llevaba también las cifras del modelo */
  position: fixed; right: 18px; bottom: 84px; z-index: 105;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 14px; min-width: 186px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.ro-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 2.5px 0; }
.ro-k {
  font-family: var(--f-cond); font-size: .66rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--dim-2);
}
.ro-v { font-size: .68rem; color: var(--text); }
.ro-v.on  { color: var(--aqua); }
.ro-v.off { color: var(--dim-2); }
.ro-sep { height: 1px; background: var(--line); margin: 7px 0; }

/* ───────────────────────── DOCK DE EDICIÓN ───────────────────────── */
.edit-dock {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-14px);
  z-index: 115; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(36, 26, 10, .9); border: 1px solid rgba(242, 169, 59, .4);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.edit-dock.on { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.edit-dock .dock-label { color: var(--amber); }
.edit-dock .mini-btn { flex: none; border-color: rgba(242, 169, 59, .3); color: #f0cf9a; }
.edit-dock .mini-btn:hover { background: rgba(242, 169, 59, .16); color: #fff; }
.edit-hint { font-size: .68rem; color: rgba(240, 207, 154, .6); white-space: nowrap; }

/* ───────────────────────── ASISTENTE IA ───────────────────────── */
.ai-panel {
  position: fixed; left: 18px; bottom: 18px; z-index: 130;
  width: 326px; max-height: 420px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.ai-panel.on { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.ai-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 8px 11px 14px; border-bottom: 1px solid var(--line);
}
.ai-head h2 {
  flex: 1; font-family: var(--f-cond); font-size: .98rem; font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase; color: var(--text);
}
.ai-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--aqua);
  box-shadow: 0 0 0 3px var(--aqua-dim); flex-shrink: 0;
}
.ai-msgs {
  flex: 1; min-height: 120px; max-height: 280px; overflow-y: auto;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 9px;
}
.ai-msg {
  font-size: .82rem; line-height: 1.5; padding: 8px 11px; border-radius: var(--r-sm);
  max-width: 92%; white-space: pre-wrap;
}
.ai-msg.bot  { align-self: flex-start; background: rgba(255,255,255,.055); color: var(--text); border: 1px solid var(--line); }
.ai-msg.user { align-self: flex-end;   background: var(--aqua-dim); color: var(--aqua); border: 1px solid var(--aqua-soft); }
.ai-msg.error { align-self: flex-start; background: rgba(194, 95, 87, .14); color: #e39b94; border: 1px solid rgba(194, 95, 87, .4); }
.ai-msg.loading { align-self: flex-start; color: var(--dim); font-style: italic; }
.ai-input-row {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line);
}
.ai-input {
  flex: 1; background: rgba(255,255,255,.05); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); font-family: var(--f-sans);
  font-size: .82rem; padding: 8px 10px;
}
.ai-input:focus { outline: none; border-color: var(--aqua-soft); }
.ai-input::placeholder { color: var(--dim-2); }
.ai-send {
  display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  background: var(--aqua-dim); border: 1px solid var(--aqua-soft); color: var(--aqua);
  border-radius: var(--r-sm); cursor: pointer; transition: background .15s;
}
.ai-send:hover { background: var(--aqua); color: var(--void); }
.ai-send:disabled { opacity: .45; cursor: default; }
.ai-send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 920px) {
  .ai-panel { left: 12px; right: 12px; width: auto; bottom: 12px; }
}

/* ───────────────────────── MARCADORES ───────────────────────── */
.tag {
  position: fixed; z-index: 60; pointer-events: none;
  transform: translate(-50%, calc(-100% - 18px));
  background: rgba(10, 14, 18, .9); border: 1px solid var(--line-2);
  border-left: 2px solid var(--aqua);
  border-radius: 4px; padding: 4px 9px;
  font-family: var(--f-cond); font-size: .7rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  color: var(--text); opacity: 0;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity .3s ease;
}
.tag.show { opacity: 1; }

.dim-label {
  position: fixed; z-index: 55; pointer-events: none;
  transform: translate(-50%, -50%);
  font-family: var(--f-mono); font-size: .62rem; font-weight: 500;
  color: var(--aqua); background: rgba(10, 14, 18, .82);
  padding: 2px 6px; border-radius: 3px; white-space: nowrap;
  border: 1px solid rgba(77, 217, 192, .28);
  opacity: 0; transition: opacity .25s ease;
}
.dim-label.show { opacity: 1; }

/* ───────────────────── FICHA ACOPLADA AL COSTADO ─────────────────────
   La ficha ya no tapa la pantalla: entra por la derecha mientras la pieza
   del punto queda aislada y enfocada a la izquierda. */
.sheet {
  position: fixed; top: 70px; right: 18px; z-index: 1000;
  width: 384px; max-width: calc(100vw - 36px);
  max-height: calc(100vh - 198px);
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--paper); border-radius: 12px; overflow: hidden;
  transform: translateX(calc(100% + 26px));
  opacity: 0; pointer-events: none;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
  transition: transform .44s var(--ease), opacity .3s var(--ease);
}
.sheet.on { opacity: 1; pointer-events: auto; transform: none; }
.sheet.editing { max-height: calc(100vh - 110px); }

.sheet-visual {
  position: relative; background: var(--paper-2); height: 168px;
  display: grid; place-items: center; overflow: hidden;
  border-bottom: 1px solid var(--ink-line);
}
.sheet-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-img.none { display: none; }
.sheet-img-empty {
  display: none; flex-direction: column; align-items: center; gap: 9px;
  color: #b5c0ca; font-family: var(--f-cond); font-size: .74rem;
  letter-spacing: .2em; text-transform: uppercase;
}
.sheet-img-empty.show { display: flex; }
.sheet-img-empty svg { width: 34px; height: 34px; fill: none; stroke: currentColor;
                       stroke-width: 1.3; stroke-linejoin: round; }
.sheet-img-btn {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; border: none;
  padding: 8px 15px; border-radius: 999px; cursor: pointer;
  font-family: var(--f-cond); font-size: .7rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; white-space: nowrap;
}
.sheet-img-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor;
                     stroke-width: 2.2; stroke-linecap: round; }
.sheet.editing .sheet-img-btn { display: inline-flex; }

.sheet-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sheet-close {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--paper-2); border: 1px solid var(--ink-line);
  color: var(--ink-dim); cursor: pointer; display: grid; place-items: center;
  transition: all .25s var(--ease);
}
.sheet-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor;
                   stroke-width: 1.9; stroke-linecap: round; }
.sheet-close:hover { background: var(--ink); border-color: var(--ink); color: #fff; transform: rotate(90deg); }

.sheet-head { padding: 19px 22px 0; }
.sheet-tag {
  font-size: .6rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 11px;
}
.sheet-title-row { display: flex; align-items: center; gap: 13px; }
.sheet-icon {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: var(--r-sm);
  background: var(--paper-2); border: 1px solid var(--ink-line);
  display: grid; place-items: center; color: var(--ink);
}
.sheet-icon svg { width: 21px; height: 21px; }
.sheet-head h3 {
  font-family: var(--f-cond); font-size: 1.46rem; font-weight: 700;
  letter-spacing: .01em; color: var(--ink); line-height: 1.15;
}
.sheet-rule { height: 3px; width: 54px; border-radius: 2px; background: var(--ink); margin-top: 17px; }

.rt-bar {
  display: none; align-items: center; gap: 6px;
  padding: 12px 22px 0;
}
.sheet.editing .rt-bar { display: flex; }
.rt {
  width: 27px; height: 27px; border-radius: 4px;
  background: var(--paper-2); border: 1px solid var(--ink-line);
  color: var(--ink); cursor: pointer; display: grid; place-items: center;
  font-size: .86rem; transition: background .18s;
}
.rt:hover { background: var(--ink-line); }
#rt-color {
  width: 27px; height: 27px; padding: 1px; cursor: pointer;
  border: 1px solid var(--ink-line); border-radius: 4px; background: none;
}
.rt-hint { font-size: .68rem; color: #9aa7b3; margin-left: auto; }

.sheet-body { flex: 1; padding: 14px 22px 18px; overflow-y: auto; min-height: 0; }
#sheet-desc { font-size: .88rem; line-height: 1.75; color: var(--ink-dim); }
#sheet-desc p { margin-bottom: 11px; }
#sheet-desc h4 {
  font-family: var(--f-cond); font-size: .68rem; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink); margin: 17px 0 7px;
}
#sheet-desc h4:first-child { margin-top: 0; }
#sheet-desc ul { list-style: none; margin-bottom: 13px; }
#sheet-desc li { position: relative; padding: 6px 0 6px 19px; border-bottom: 1px solid var(--paper-2); }
#sheet-desc li::before {
  content: ''; position: absolute; left: 2px; top: 15px;
  width: 7px; height: 2px; background: var(--ink);
}
#sheet-desc strong { color: var(--ink); font-weight: 600; }
.sheet.editing [contenteditable="true"] {
  outline: 1px dashed #9fc9c0; outline-offset: 4px;
  border-radius: 3px; cursor: text;
}

.sheet-foot {
  display: none; flex-direction: column; gap: 12px;
  padding: 13px 22px; border-top: 1px solid var(--ink-line); background: var(--paper-2);
}
.sheet.editing .sheet-foot { display: flex; }
.sheet-foot .color-field { justify-content: space-between; }
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field span {
  font-family: var(--f-cond); font-size: .62rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-dim);
}
.color-field input {
  width: 32px; height: 25px; padding: 1px; cursor: pointer;
  border: 1px solid var(--ink-line); border-radius: 4px; background: none;
}
.sheet-foot-actions { display: flex; gap: 9px; }
.btn-danger, .btn-primary {
  padding: 7px 16px; border-radius: var(--r-sm); cursor: pointer;
  font-family: var(--f-cond); font-size: .7rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  transition: all .22s;
}
.btn-danger  { background: transparent; color: #c25f57; border: 1px solid rgba(194, 95, 87, .4); }
.btn-danger:hover { background: #c25f57; border-color: #c25f57; color: #fff; }
.btn-primary { background: var(--ink); color: #fff; border: 1px solid var(--ink); }
.btn-primary:hover { background: #22323f; }

/* ───────────────────────── AVISOS ───────────────────────── */
.toast {
  position: fixed; bottom: 92px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 9998; padding: 10px 20px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 2px solid var(--aqua); color: var(--text);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  font-family: var(--f-cond); font-size: .76rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { border-left-color: var(--amber); }

.hint-bar {
  position: fixed; bottom: 18px; left: 18px; z-index: 104;
  display: flex; gap: 14px; align-items: center;
  font-size: .66rem; color: var(--dim-2);
  opacity: .85; transition: opacity .3s;
}
.hint-bar kbd {
  font-family: var(--f-mono); font-size: .6rem;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line);
  border-radius: 3px; padding: 1.5px 5px; margin-right: 3px; color: var(--dim);
}

/* ───────────────────────── SCROLLBARS ───────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .13); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); }

/* ───────────────────────── RESPONSIVE ───────────────────────── */
@media (max-width: 1180px) {
  .hint-bar { display: none; }
  .panel-left { bottom: 150px; }
  /* En tablet las lecturas de abajo chocan con el dock: el dato vive en el Inspector */
  .readout { display: none; }
  /* Las capas no deben meterse bajo los paneles laterales */
  .layers { max-width: calc(100vw - 640px); }
}

/* Aviso de que el dock y las capas siguen hacia el lado */
.dock, .layers { scroll-behavior: smooth; }
.dock::after, .layers::after {
  content: ''; position: sticky; right: -1px; flex: 0 0 18px; align-self: stretch;
  background: linear-gradient(to right, transparent, var(--surface-sol));
  pointer-events: none; margin-left: -18px;
}

@media (max-width: 920px) {
  .topbar { height: 52px; padding: 0 12px; }
  .brand-sub { display: none; }
  .tool span { display: none; }
  .tool { padding: 7px 9px; }
  .panel-left  { width: 232px; top: 62px; bottom: 170px; }
  .panel-right { width: 232px; top: 62px; }
  .readout { display: none; }
  .dock { bottom: 12px; gap: 11px; padding: 8px 12px; border-radius: var(--r); }
  .dock-group + .dock-group { padding-left: 11px; }
  .sheet { top: auto; bottom: 0; right: 0; width: 100%; max-width: 100%;
           max-height: 62vh; border-radius: 12px 12px 0 0;
           transform: translateY(calc(100% + 26px)); }
  .sheet.editing { max-height: 78vh; }
  .sheet-visual { height: 120px; }
  .sheet-head { padding: 20px 22px 0; }
  .sheet-body { padding: 14px 22px 16px; }
  .rt-bar, .sheet-foot { padding-left: 22px; padding-right: 22px; }
  .edit-dock { font-size: .9em; }
  .edit-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════════════════════════════════════════════════════
   v5 · CAPAS · ENFOQUE · ASISTENTE
   ═══════════════════════════════════════════════════════════ */

/* ───────────────────────── CAPAS ───────────────────────── */
.layers {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 108; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 14px; max-width: calc(100vw - 620px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.layers::-webkit-scrollbar { display: none; }
.layers .dock-label { margin-right: 4px; }
.layers .chip { flex-shrink: 0; }

/* ───────────────────────── ENFOQUE ───────────────────────── */
.focus-bar {
  position: fixed; top: 118px; left: 50%; z-index: 112;
  transform: translateX(-50%) translateY(-10px);
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 14px; border-radius: 999px;
  background: rgba(9, 28, 27, .92); border: 1px solid var(--aqua-soft);
  box-shadow: var(--shadow); max-width: calc(100vw - 36px);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.focus-bar.on { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.focus-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--aqua);
  box-shadow: 0 0 0 3px var(--aqua-dim); flex-shrink: 0;
}
.focus-k {
  font-family: var(--f-cond); font-size: .68rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--aqua);
}
.focus-title {
  font-size: .8rem; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
}
.focus-exit {
  font-family: var(--f-cond); font-size: .7rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  background: rgba(255, 255, 255, .07); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; transition: background .15s;
}
.focus-exit:hover { background: var(--aqua); color: var(--void); border-color: var(--aqua); }
.edit-dock { top: 118px; }
.focus-bar.on ~ .edit-dock.on, .edit-dock.on { z-index: 116; }

/* ───────────────────────── ÁRBOL ───────────────────────── */
.tg-focus { opacity: 0; transition: opacity .15s; }
.tg-head:hover .tg-focus, .tg-focus:focus-visible { opacity: 1; }
.tg-focus:hover { color: var(--aqua); }
.ti-tris { white-space: nowrap; }
.ti.off { opacity: .38; }

/* ───────────────────────── INSPECTOR ───────────────────────── */
.insp-note p { margin: 0 0 7px; }
.insp-note p:last-child { margin-bottom: 0; }
.insp-note .insp-link:hover b { text-decoration: underline; }

/* ───────────────────────── ASISTENTE ───────────────────────── */
.ai-panel { max-height: min(520px, calc(100vh - 110px)); width: 340px; }
.ai-msgs { max-height: none; }
.ai-suggest { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ai-suggest button {
  font-family: var(--f-sans); font-size: .76rem; text-align: left;
  background: transparent; color: var(--dim); cursor: pointer;
  border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  padding: 6px 10px; transition: color .15s, border-color .15s, background .15s;
}
.ai-suggest button:hover { color: var(--aqua); border-color: var(--aqua-soft); background: var(--aqua-dim); }
.ai-msg.action {
  align-self: flex-start; padding: 2px 4px; background: none; border: none;
  font-family: var(--f-mono); font-size: .68rem; color: var(--aqua); letter-spacing: .02em;
}

button:focus-visible, input:focus-visible { outline: 2px solid var(--aqua-soft); outline-offset: 2px; }

@media (max-width: 1180px) {
  .layers { max-width: calc(100vw - 36px); top: 64px; }
}
@media (max-width: 920px) {
  .layers { top: 58px; padding: 5px 8px 5px 12px; }
  .layers .dock-label { display: none; }
  .focus-bar, .edit-dock { top: 104px; }
  .ai-panel { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* La guía de atajos vive entre el panel de despiece y la barra inferior */
.hint-bar { bottom: 92px; gap: 10px; flex-wrap: wrap; max-width: 268px; row-gap: 5px; }
.panel-left { bottom: 152px; }
.tg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   v6 · OPERACIÓN · MONTAJE · MODELADOR
   ═══════════════════════════════════════════════════════════ */

/* El dock principal se aparta cuando entra el de operación o el de montaje */
.dock { transition: opacity .25s var(--ease), transform .25s var(--ease); }
.dock.away {
  opacity: 0; pointer-events: none;
  transform: translateX(-50%) translateY(14px);
}
.dock-alt {
  opacity: 0; pointer-events: none;
  transform: translateX(-50%) translateY(14px);
}
.dock-alt.on { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.dock-montaje { border-color: rgba(242, 169, 59, .45); background: rgba(32, 25, 13, .9); }
.dock-montaje .dock-label { color: var(--amber); }
.dock-montaje .seg-b.active { background: rgba(242, 169, 59, .18); color: var(--amber); }
.mt-pieza {
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text) !important; text-transform: none; letter-spacing: 0;
}

.mini-primary { background: var(--aqua-dim); border-color: var(--aqua-soft); color: var(--aqua); }
.mini-primary:hover:not(:disabled) { background: var(--aqua); color: var(--void); border-color: var(--aqua); }
#mt-estado { color: var(--dim-2); min-width: 86px; text-align: right; }
#mt-estado.dirty { color: var(--amber); }

/* Lecturas de proceso dentro del panel de operación */
.op-read { gap: 14px; }
.op-read span { display: flex; flex-direction: column; line-height: 1.25; }
.op-read i {
  font-style: normal; font-family: var(--f-cond); font-size: .6rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim-2);
}
.op-read b { font-size: .78rem; font-weight: 500; color: var(--aqua); }

/* Campos numéricos de la pieza en montaje */
.mt-form { display: none; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
#inspector.montando .mt-form { display: block; }
.mt-k {
  font-family: var(--f-cond); font-size: .64rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--amber); margin: 6px 0 4px;
}
.mt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mt-grid-1 { grid-template-columns: 1fr; }
.mt-grid label {
  display: flex; align-items: center; gap: 5px;
  font-size: .62rem; color: var(--dim-2); text-transform: uppercase; letter-spacing: .08em;
}
.mt-num {
  width: 100%; min-width: 0; background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--text); font-size: .74rem; padding: 4px 6px;
  -moz-appearance: textfield;
}
.mt-num::-webkit-outer-spin-button, .mt-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mt-num:focus { outline: none; border-color: rgba(242, 169, 59, .55); }

/* Enlace al modelador, con su distintivo de versión beta */
a.tool { text-decoration: none; }
.tool .beta {
  font-style: normal; font-family: var(--f-mono); font-size: .52rem;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--void); background: var(--aqua);
  border-radius: 3px; padding: 1px 3px; margin-left: 4px;
}
.topbar-tools { overflow-x: auto; scrollbar-width: none; }
.topbar-tools::-webkit-scrollbar { display: none; }

@media (max-width: 1180px) {
  .tool span { display: none; }
  .tool .beta { display: none; }
  .op-read { display: none; }
}
@media (max-width: 920px) {
  .dock-alt { max-width: calc(100vw - 24px); }
}

/* ───────────── PIEZA ASOCIADA A UN PUNTO DE MANTENIMIENTO ───────────── */
/* Lectura: debajo del título de la ficha, lleva de vuelta a la pieza */
.sheet-pieza-ro {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 14px; padding: 6px 11px 6px 9px;
  background: var(--paper-2); border: 1px solid var(--ink-line);
  border-radius: 999px; cursor: pointer; max-width: 100%;
  color: var(--ink-dim); font-family: var(--f-cond); font-size: .72rem;
  font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
  transition: border-color .2s, color .2s;
}
.sheet-pieza-ro:hover { border-color: #b9c6d0; color: var(--ink); }
.sheet-pieza-ro svg {
  width: 14px; height: 14px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round;
}
.sheet-pieza-ro span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-pieza-ro[hidden] { display: none; }

/* Edición: qué pieza tiene asignada y cómo cambiarla */
.pieza-field { display: flex; flex-direction: column; gap: 5px; }
.pieza-k {
  font-family: var(--f-cond); font-size: .62rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-dim);
}
.pieza-v {
  font-size: .84rem; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Deducida por cercanía, aún sin confirmar */
.pieza-v.auto { color: #a07a28; }
.pieza-v.auto::after {
  content: 'deducida'; margin-left: 7px; padding: 1px 6px;
  font-family: var(--f-cond); font-size: .58rem; letter-spacing: .14em;
  text-transform: uppercase; vertical-align: 1px;
  border: 1px solid #e0cb9a; border-radius: 999px; background: #fbf3e0;
}
.pieza-acc { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 3px; }
.mini-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: #1f7d6d; font-size: .74rem; font-weight: 500;
  border-bottom: 1px solid rgba(31, 125, 109, .35);
}
.mini-link:hover { color: #0f5a4e; border-bottom-color: #0f5a4e; }

/* Mientras se espera el clic que asocia el punto a su pieza */
body.ligando { cursor: crosshair !important; }
body.ligando #stage { box-shadow: inset 0 0 0 2px var(--aqua-soft); }

/* La franja de imagen desaparece cuando no hay foto y no se está editando */
.sheet-visual[hidden] { display: none; }
/* Aviso de que el texto sigue más abajo */
.sheet-body { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent); 
              mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent); }
.sheet-body:not([data-desbordado]) { -webkit-mask-image: none; mask-image: none; }

/* ───────────── FOTOGRAFÍA REAL DE LA PIEZA ───────────── */
.insp-foto {
  position: relative; margin: 14px 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; background: rgba(255, 255, 255, .03);
}
.insp-foto[hidden] { display: none; }
.insp-foto img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.insp-foto figcaption {
  padding: 7px 10px; font-family: var(--f-cond); font-size: .64rem;
  letter-spacing: .18em; text-transform: uppercase; color: var(--dim-2);
  border-top: 1px solid var(--line);
}
.insp-foto-quitar {
  position: absolute; top: 7px; right: 7px; width: 24px; height: 24px;
  display: grid; place-items: center; cursor: pointer; border-radius: 4px;
  background: rgba(10, 13, 17, .72); border: 1px solid var(--line-2); color: var(--text);
  backdrop-filter: blur(8px);
}
.insp-foto-quitar[hidden] { display: none; }
.insp-foto-quitar svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.insp-foto-quitar:hover { background: rgba(226, 115, 107, .9); border-color: transparent; }
.mini-btn-wide { width: 100%; margin-top: 10px; }
.mini-btn-wide[hidden] { display: none; }

/* ───────────── BASE DE CONOCIMIENTO DEL ASISTENTE ───────────── */
.saber {
  position: fixed; inset: 0; z-index: 1100;
  display: grid; place-items: center; padding: 24px;
  background: rgba(6, 8, 11, .72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s var(--ease);
}
.saber.on { opacity: 1; }
.saber[hidden] { display: none; }

.saber-caja {
  width: min(560px, 100%); max-height: min(78vh, 720px);
  display: flex; flex-direction: column;
  background: var(--surface-sol); border: 1px solid var(--line-2);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
  transform: translateY(12px); transition: transform .34s var(--ease);
}
.saber.on .saber-caja { transform: none; }

.saber-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 13px; border-bottom: 1px solid var(--line);
}
.saber-head h2 {
  font-family: var(--f-cond); font-size: .82rem; font-weight: 600;
  letter-spacing: .24em; text-transform: uppercase; color: var(--text);
}
.saber-intro {
  padding: 15px 18px 4px; font-size: .82rem; line-height: 1.6; color: var(--dim);
}
.saber-lista { flex: 1; overflow-y: auto; padding: 13px 18px; min-height: 90px; }
.saber-vacio { font-size: .8rem; color: var(--dim-2); line-height: 1.6; padding: 12px 0; }

.saber-doc {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.saber-doc:last-child { border-bottom: none; }
.saber-doc-txt { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.saber-doc-t {
  font-size: .86rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.saber-doc-m { font-size: .68rem; color: var(--dim-2); }
.saber-del {
  width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 5px; background: none;
  color: var(--dim-2); cursor: pointer;
}
.saber-del svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.saber-del:hover { color: var(--rose); border-color: rgba(226, 115, 107, .5); }

.saber-acc {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 18px; border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
}
.saber-nota { font-size: .68rem; color: var(--dim-2); margin-left: auto; }
.saber-pegar { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 9px; }
.saber-pegar[hidden] { display: none; }
.saber-pegar input, .saber-pegar textarea {
  width: 100%; padding: 9px 11px; font-size: .84rem;
  background: rgba(255, 255, 255, .04); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm); resize: vertical;
}
.saber-pegar input:focus, .saber-pegar textarea:focus { outline: none; border-color: var(--aqua-soft); }
.saber-pegar-acc { display: flex; justify-content: flex-end; gap: 9px; }

/* ───────────── TÁCTIL: tablet y pantallas sin ratón ───────────── */
@media (hover: none) and (pointer: coarse) {
  /* Objetivos de pulsación cómodos: el dedo no apunta como el ratón */
  .tool { padding: 11px 13px; }
  .icon-btn { width: 34px; height: 34px; }
  .chip, .seg-b, .mini-btn { padding: 10px 14px; min-height: 40px; }
  .ti { padding-top: 9px; padding-bottom: 9px; }
  .saber-del, .insp-foto-quitar { width: 34px; height: 34px; }
  .slider { height: 26px; }
  /* Las ayudas de teclado no significan nada sin teclado */
  .hint-bar, .edit-hint, .rt-hint { display: none !important; }
  /* Las etiquetas flotantes de los puntos estorban al arrastrar */
  .tag { font-size: .74rem; }
}

/* ───────────── MONTAJE v9: historial, imán y piezas ocultas ───────────── */
.mini-icono { padding: 7px 9px; display: inline-grid; place-items: center; }
.mini-icono svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.mini-btn:disabled { opacity: .38; cursor: default; }

.seg-iman {
  border-radius: var(--r-sm); padding: 7px 13px;
  border: 1px solid var(--line); background: var(--surface);
}
.seg-iman.active { background: var(--aqua-dim); border-color: var(--aqua-soft); color: var(--aqua); }

/* Lectura del desplazamiento mientras se arrastra */
.mt-delta {
  font-family: var(--f-mono); font-variant-numeric: tabular-nums;
  font-size: .72rem; color: var(--dim-2); white-space: nowrap;
  min-width: 142px; transition: color .2s;
}
.mt-delta.on { color: var(--aqua); }

/* Aviso de que el imán encajó */
#mt-iman-txt.on { color: var(--aqua); }

/* Botón con piezas fuera de la vista */
#mt-ocultas.con-ocultas {
  border-color: rgba(242, 169, 59, .5); color: var(--amber);
  background: rgba(242, 169, 59, .12);
}

/* Panel desplegable con la lista de ocultas */
.oc-panel {
  position: fixed; right: 18px; bottom: 96px; z-index: 118;
  width: 300px; max-height: 42vh; overflow-y: auto;
  background: var(--surface-sol); border: 1px solid var(--line-2);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 4px 0;
}
.oc-panel[hidden] { display: none; }
.oc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px 8px; border-bottom: 1px solid var(--line);
  font-family: var(--f-cond); font-size: .7rem; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
}
.oc-fila {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 13px; font-size: .8rem; color: var(--text);
}
.oc-fila + .oc-fila { border-top: 1px solid var(--line); }
.oc-fila span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-fila .mini-link, .oc-head .mini-link {
  background: none; border: none; padding: 0; cursor: pointer; flex-shrink: 0;
  color: var(--aqua); font-size: .74rem;
  border-bottom: 1px solid var(--aqua-soft);
}
.oc-fila .mini-link:hover, .oc-head .mini-link:hover { color: #9ff0e0; }

/* El dock del montaje es largo y en pantallas de portátil se desborda. Guardar
   y Salir se quedan pegados al borde derecho: son los dos botones que nunca
   pueden quedar fuera de la vista, por mucho que haya que desplazar el resto. */
.dock-cola {
  position: sticky; right: -16px; margin-left: auto; z-index: 2;
  padding-left: 26px !important; padding-right: 16px;
  border-left: none !important;
  background: linear-gradient(90deg, rgba(20, 26, 33, 0) 0, var(--surface-sol) 22px);
}

@media (max-width: 1180px) {
  .oc-panel { right: 12px; width: 260px; }
  .mt-delta { min-width: 0; }
  .dock-cola { padding-left: 20px !important; }
}

/* ───────────────────────── IDIOMA (ES / EN) ───────────────────────── */
.lang-sw {
  display: inline-flex; margin-left: 14px; pointer-events: auto;
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.lang-sw button {
  background: transparent; border: 0; cursor: pointer;
  color: var(--dim); padding: 6px 9px;
  font-family: var(--f-cond); font-size: .72rem; font-weight: 600; letter-spacing: .16em;
  transition: color .2s, background .2s;
}
.lang-sw button + button { border-left: 1px solid var(--line); }
.lang-sw button:hover { color: var(--text); }
.lang-sw button.on { background: var(--aqua-dim); color: var(--aqua); }
@media (max-width: 920px) {
  .lang-sw { margin-left: 8px; }
  .lang-sw button { padding: 5px 7px; }
}

/* ───────────── MARCA: Unfamed | Technology & Provisions ───────────── */
.marca-uf { white-space: nowrap; }
.marca-uf .mk-sep { color: var(--aqua); font-weight: 400; margin: 0 .12em; }
.marca-uf .mk-b { font-weight: 500; }
.brand-name.marca-uf { letter-spacing: .07em; font-size: 1.02rem; }
.boot-brand.marca-uf { letter-spacing: .06em; text-indent: 0; font-size: 2.05rem; text-align: center; white-space: normal; line-height: 1.15; }
.boot-brand.marca-uf .mk-b { color: var(--text); }
@media (max-width: 1180px) { .brand-name.marca-uf { font-size: .92rem; letter-spacing: .05em; } }
@media (max-width: 640px) {
  .brand { flex-shrink: 0; gap: 8px; }
  .brand-mark { width: 24px; height: 24px; }
  .brand-name.marca-uf { line-height: 1.1; font-size: .84rem; }
  .brand-name.marca-uf .mk-sep { display: none; }
  .brand-name.marca-uf .mk-b { display: block; font-size: .6rem; letter-spacing: .04em; color: var(--dim); margin-top: 1px; }
  .lang-sw { margin-left: 6px; }
  .topbar-tools { min-width: 0; flex: 1 1 auto; justify-content: flex-start; margin-left: 10px; }
  .boot-brand.marca-uf { font-size: 1.6rem; }
  .boot-brand.marca-uf .mk-sep { display: none; }
  .boot-brand.marca-uf .mk-b { display: block; font-size: .62em; color: var(--dim); }
}
/* Con el nombre completo de la marca, las herramientas se compactan un poco
   para que quepan con su texto en pantallas de 1280–1600 px. */
@media (min-width: 1181px) and (max-width: 1600px) {
  .topbar { padding: 0 14px; }
  .topbar-tools { gap: 4px; }
  .topbar-sep { margin: 0 3px; }
  .tool { padding: 7px 9px; gap: 6px; letter-spacing: .1em; }
  .lang-sw { margin-left: 10px; }
}
@media (min-width: 1181px) and (max-width: 1360px) {
  .tool span { display: none; }
  .tool .beta { display: none; }
}

/* ───────────── FICHA: más ancha y con la foto entera ───────────── */
@media (min-width: 921px) {
  .sheet { width: 470px; max-height: calc(100vh - 150px); }
  #sheet-desc { font-size: .93rem; }
}
.sheet-visual { height: 250px; background: #0e1217; isolation: isolate; }
.sheet-visual::before {
  content: ''; position: absolute; inset: -24px; z-index: -1;
  background: var(--foto, none) center / cover no-repeat;
  filter: blur(18px) brightness(.55) saturate(1.1);
}
.sheet-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.sheet-img-empty, .sheet-img-btn { z-index: 1; }
.sheet.editing .sheet-img { cursor: default; }
@media (max-width: 920px) { .sheet-visual { height: 200px; } }

.foto-velo {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(5, 7, 10, .92); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 40px 24px; cursor: zoom-out;
  opacity: 0; transition: opacity .25s var(--ease);
}
.foto-velo.on { opacity: 1; }
.foto-velo img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; border-radius: 8px;
                 box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.foto-pie { font-family: var(--f-cond); font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
.foto-cerrar {
  position: absolute; top: 18px; right: 20px; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
