:root {
  --lima: #90B030;
  --lima-ink: #4A6B15;
  --teal: #2FA58F;
  --izq: #2F6FDB;
  --der: #E0533A;
  --ref: #F2B705;

  --bg: #EEF0EA;
  --bg-edge: #D9DDD2;
  --panel: rgba(252, 253, 250, 0.9);
  --panel-solid: #FCFDFA;
  --ink: #1C211A;
  --ink-2: #5A6155;
  --ink-3: #8A9184;
  --line: rgba(28, 33, 26, 0.12);
  --field: rgba(28, 33, 26, 0.05);
  --field-2: rgba(28, 33, 26, 0.09);
  --lbl-bg: rgba(255, 255, 255, 0.88);
  --shadow: 0 10px 30px rgba(30, 40, 20, 0.12), 0 1px 3px rgba(30, 40, 20, 0.08);
  --radius: 14px;
  --peek: 122px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161916;
    --bg-edge: #0A0B0A;
    --panel: rgba(28, 31, 27, 0.9);
    --panel-solid: #1C1F1B;
    --ink: #EDF0E8;
    --ink-2: #B0B7A9;
    --ink-3: #7D8477;
    --line: rgba(237, 240, 232, 0.12);
    --field: rgba(237, 240, 232, 0.06);
    --field-2: rgba(237, 240, 232, 0.11);
    --lbl-bg: rgba(24, 27, 23, 0.86);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
    --lima-ink: #B6D35A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161916;
  --bg-edge: #0A0B0A;
  --panel: rgba(28, 31, 27, 0.9);
  --panel-solid: #1C1F1B;
  --ink: #EDF0E8;
  --ink-2: #B0B7A9;
  --ink-3: #7D8477;
  --line: rgba(237, 240, 232, 0.12);
  --field: rgba(237, 240, 232, 0.06);
  --field-2: rgba(237, 240, 232, 0.11);
  --lbl-bg: rgba(24, 27, 23, 0.86);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
  --lima-ink: #B6D35A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font: 600 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#stage {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 55% 45%, var(--bg) 45%, var(--bg-edge) 100%);
  touch-action: none;
  /* las etiquetas CSS2D llevan z-index propios: se quedan dentro de este contexto */
  z-index: 0;
  isolation: isolate;
}
#stage canvas { display: block; outline: none; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }

/* ---------- Panel lateral ---------- */
.side {
  position: absolute;
  left: 12px; top: 12px; bottom: 12px;
  width: 316px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 5;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
}
.side.collapsed { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
.sheet-handle { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 16px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font-weight: 750; letter-spacing: -0.01em; }
.brand b::before {
  content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--lima); margin-right: 7px; transform: translateY(-1px);
}
.brand span { color: var(--ink-2); font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--field-2); color: var(--ink); }
.expand {
  position: absolute; left: 12px; top: 12px; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  width: 44px; height: 44px;
}

.search { position: relative; margin: 0 12px 6px; display: flex; align-items: center; gap: 8px;
  background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; color: var(--ink-3); }
.search:focus-within { border-color: var(--lima); box-shadow: 0 0 0 3px rgba(144, 176, 48, 0.2); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 38px; color: var(--ink); }
.search input::-webkit-search-cancel-button { display: none; }
.q-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10;
  margin: 0; padding: 4px; list-style: none;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 260px; overflow: auto;
}
.q-results li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; color: var(--ink); cursor: pointer;
}
.q-results li small { color: var(--ink-3); margin-left: auto; }
.q-results li[aria-selected="true"], .q-results li:hover { background: var(--field-2); }

.side-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 14px; overscroll-behavior: contain; }
.side-body section { padding: 10px 4px; border-top: 1px solid var(--line); }
.side-body section:first-child { border-top: 0; }
h2 { margin: 0 0 8px; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px; background: var(--field); border-radius: 10px; }
.seg button { border: 0; background: transparent; border-radius: 7px; height: 34px; font-weight: 550; font-size: 13px; color: var(--ink-2); }
.seg button[aria-checked="true"] { background: var(--panel-solid); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg button[aria-checked="true"]::after { content: ""; display: block; width: 14px; height: 2px; margin: 1px auto 0; background: var(--lima); border-radius: 2px; }

.views { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.views button {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  height: 34px; padding: 0 8px; border: 1px solid var(--line); background: transparent; border-radius: 8px; font-size: 12.5px;
}
.views button:hover { background: var(--field); }
.views button.on { border-color: var(--lima); background: rgba(144, 176, 48, 0.12); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.tg { display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; font-size: 13px; user-select: none; }
.tg input { appearance: none; margin: 0; flex: none; width: 30px; height: 18px; border-radius: 99px; background: var(--field-2); position: relative; transition: background 0.15s; cursor: pointer; }
.tg input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.tg input:checked { background: var(--lima); }
.tg input:checked::after { transform: translateX(12px); }
.tg input:focus-visible { outline: 2px solid var(--lima); outline-offset: 2px; }
.tg.disabled, .slider.disabled, .tones.disabled { opacity: 0.4; pointer-events: none; }

.slider { margin-top: 8px; display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-2); }
input[type="range"] { width: 100%; accent-color: var(--lima); height: 24px; }
.tones { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; background: var(--c); border: 2px solid var(--panel-solid); box-shadow: 0 0 0 1px var(--line); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--lima); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { min-width: 42px; height: 30px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 12.5px; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--panel-solid); border-color: var(--ink); }
.chips .clear { color: var(--ink-3); font-weight: 500; }

.leg { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); }
.leg li { display: flex; align-items: center; gap: 6px; }
.leg i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.leg i.sq { border-radius: 3px; }
.leg i.sm { width: 7px; height: 7px; }
.leg i.dia { border-radius: 1px; transform: rotate(45deg) scale(0.85); }
.leg i.bar { width: 14px; height: 3px; border-radius: 2px; }

.actions .primary {
  width: 100%; height: 40px; border: 0; border-radius: 10px;
  background: var(--lima); color: #1B2408; font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.actions .primary:hover { filter: brightness(1.05); }
.hint { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-3); text-align: center; }

/* ---------- Minimapa ---------- */
.minimap {
  position: absolute; right: 12px; top: 12px; z-index: 4;
  width: 208px; height: 208px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
}
.minimap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.minimap .head { fill: none; stroke: var(--ink-3); stroke-width: 1.4; }
.minimap .ring { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.minimap .axis { stroke: var(--line); stroke-width: 1; }
.minimap .el { cursor: pointer; stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.8; transition: opacity 0.15s; }
.minimap .el.dim { opacity: 0.2; }
.minimap .el.sel { stroke: var(--ink); stroke-width: 2.2; }
.minimap text { font: 600 7.4px system-ui, sans-serif; fill: var(--ink-2); pointer-events: none; text-anchor: middle; }
.minimap text.dim { opacity: 0.25; }
.minimap .cap { font: 600 8px system-ui, sans-serif; fill: var(--ink-3); letter-spacing: 0.06em; }

/* ---------- Panel de electrodo ---------- */
.info {
  position: absolute; right: 12px; bottom: 12px; z-index: 4;
  width: 340px; max-height: calc(100% - 250px); overflow: auto;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.info .close { position: absolute; right: 8px; top: 8px; }
.info-head { display: flex; align-items: baseline; gap: 10px; padding-right: 30px; }
.info h3 { margin: 0; font-size: 30px; line-height: 1; font-weight: 750; letter-spacing: -0.02em; }
.info .old { color: var(--ink-3); font-size: 15px; font-weight: 600; }
.info-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 4px; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--field-2); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tag i { width: 8px; height: 8px; border-radius: 50%; }
.info dl { margin: 8px 0 0; display: grid; grid-template-columns: 104px 1fr; gap: 6px 10px; font-size: 13px; }
.info dt { color: var(--ink-3); font-size: 12px; padding-top: 1px; }
.info dd { margin: 0; }
.tape { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(47, 165, 143, 0.1); border: 1px solid rgba(47, 165, 143, 0.28); }
.tape-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--teal); margin-bottom: 4px; }
.tape p { margin: 0; font-size: 13px; }
.tape p b { font-variant-numeric: tabular-nums; }

/* ---------- Etiquetas 3D ---------- */
.lbl {
  pointer-events: auto; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 4px;
  font: 650 11px/1 system-ui, sans-serif; color: var(--ink);
  background: var(--lbl-bg); border: 1px solid var(--line);
  padding: 3px 6px 3px 5px; border-radius: 99px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.lbl i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.lbl.s1010 { font-size: 9.5px; font-weight: 600; padding: 2px 5px 2px 4px; opacity: 0.9; }
.lbl.s1010 i { width: 5px; height: 5px; }
.lbl.dim { opacity: 0.22; }
.lbl.sel { background: var(--ink); color: var(--panel-solid); border-color: var(--ink); font-size: 12.5px; z-index: 2; }
.lbl.lm { background: var(--ref); color: #231C00; border-color: rgba(0, 0, 0, 0.2); font-size: 10px; }
.tick { pointer-events: none; font: 700 9.5px/1 system-ui, sans-serif; color: #fff; background: var(--teal); padding: 2px 4px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.tick.total { background: transparent; color: var(--teal); font-size: 11px; text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg); }

/* ---------- Colocación y medidas ---------- */
.field { margin-bottom: 9px; }
.flabel { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.seg.seg3 { grid-template-columns: repeat(3, 1fr); }
.seg.seg2 { grid-template-columns: repeat(2, 1fr); }
.seg button small { margin-left: 4px; font-size: 10.5px; color: var(--ink-3); font-weight: 600; }
.seg.locked { opacity: 0.45; pointer-events: none; }
.note { margin: 4px 0 0; font-size: 11.5px; color: var(--ink-3); }
.field.disabled { opacity: 0.4; pointer-events: none; }
select {
  width: 100%; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--field);
  color: var(--ink); padding: 0 10px; font-size: 13px;
}
select option { background: var(--panel-solid); color: var(--ink); }
.secondary, .ghost {
  width: 100%; height: 38px; border-radius: 10px; font-weight: 620; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.secondary { border: 1px solid var(--lima); background: rgba(144, 176, 48, 0.14); color: var(--ink); }
.secondary:hover { background: rgba(144, 176, 48, 0.24); }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--ink-2); }
.ghost:hover { background: var(--field); }
.ghost:disabled { opacity: 0.4; cursor: default; }
.measures { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.unit { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-3); font-size: 12px; }
.unit input {
  width: 64px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--field);
  color: var(--ink); text-align: right; padding: 0 8px; font-variant-numeric: tabular-nums;
}
.unit input:focus { outline: none; border-color: var(--lima); box-shadow: 0 0 0 3px rgba(144, 176, 48, 0.2); }
.row2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 6px; margin-top: 10px; }
.error { color: #C4412E; font-size: 12px; margin: 8px 0 0; }
.hint.left { text-align: left; margin-top: 8px; }
.hint b { color: var(--ink-2); }

/* ---------- Métodos alternativos en el panel ---------- */
.variants { margin-top: 12px; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; }
.var-title { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.variants ul { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.variants li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; color: var(--ink-2); }
.variants li b { font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.variants li.here b { color: var(--lima-ink); }
.ghost-lbl { pointer-events: none; font: 700 9.5px/1 system-ui, sans-serif; color: #fff; background: #5A6155; padding: 2px 5px; border-radius: 4px; }
.leg i.ring { background: transparent; box-shadow: inset 0 0 0 2px #5A6155; }

/* ---------- Guía paso a paso ---------- */
.guide {
  position: absolute; left: calc(316px + 24px); bottom: 12px; z-index: 4;
  width: 380px; max-height: calc(100% - 24px); overflow: auto;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px 14px; animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.side.collapsed ~ .guide { left: 12px; }
.guide-top { display: flex; align-items: center; justify-content: space-between; }
.guide-count { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lima-ink); }
.guide-progress { height: 3px; background: var(--field-2); border-radius: 3px; margin: 6px 0 10px; overflow: hidden; }
.guide-progress span { display: block; height: 100%; background: var(--lima); transition: width 0.25s; }
.guide h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.guide-text { font-size: 13.5px; line-height: 1.5; }
.guide-text ul { margin: 4px 0; padding-left: 18px; }
.guide-text li { margin: 3px 0; }
.guide-text table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.guide-text td { padding: 4px 6px; border-top: 1px solid var(--line); }
.guide-text td:first-child { font-weight: 650; }
.guide-text td:last-child { text-align: right; }
.guide-text .muted { color: var(--ink-3); font-size: 12.5px; }
.guide-nav { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.guide-nav .primary { height: 38px; border: 0; border-radius: 10px; background: var(--lima); color: #1B2408; font-weight: 650; }

/* ---------- Carga ---------- */
.loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: 99px; padding: 10px 16px; font-size: 13px; color: var(--ink-2);
  transition: opacity 0.2s;
}
.loading.done { opacity: 0; pointer-events: none; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--field-2); border-top-color: var(--lima); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------- Móvil ---------- */
.mtop, .msearch, .mtabs { display: none; }

@media (max-width: 760px) {
  :root { --mtop: calc(58px + env(safe-area-inset-top)); --mtabs: calc(62px + env(safe-area-inset-bottom)); }

  /* barra superior: modelo + buscar + mapa */
  .mtop {
    display: flex; gap: 6px; align-items: center;
    position: absolute; z-index: 7; left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top));
  }
  .mseg {
    flex: 1; min-width: 0; grid-template-columns: repeat(4, 1fr);
    background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 12px;
  }
  .mseg button { height: 40px; font-size: 13px; padding: 0; }
  .mbtn {
    flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
    background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink);
  }
  .mbtn[aria-pressed="true"] { border-color: var(--lima); color: var(--lima-ink); }

  /* buscador desplegable */
  .msearch:not([hidden]) {
    display: block; position: absolute; z-index: 8; left: 8px; right: 8px; top: calc(var(--mtop) + 2px);
  }
  .msearch-row {
    display: flex; gap: 6px; align-items: center; padding: 6px;
    background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  }
  .msearch input {
    flex: 1; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--field); color: var(--ink); padding: 0 12px; font-size: 16px; outline: none;
  }
  .msearch input:focus { border-color: var(--lima); }
  .mlink { border: 0; background: transparent; color: var(--ink-2); font-weight: 600; height: 44px; padding: 0 10px; }
  .msearch .q-results { position: static; margin-top: 6px; max-height: 50vh; }
  .msearch .q-results li { min-height: 46px; font-size: 15px; }

  /* pestañas inferiores */
  .mtabs {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: absolute; z-index: 7; left: 0; right: 0; bottom: 0; height: var(--mtabs);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel-solid); border-top: 1px solid var(--line);
  }
  .mtabs button {
    border: 0; background: transparent; color: var(--ink-2);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 600; position: relative;
  }
  .mtabs svg { width: 23px; height: 23px; }
  .mtabs button[aria-pressed="true"] { color: var(--ink); }
  .mtabs button[aria-pressed="true"]::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--lima);
  }

  /* hoja: solo la sección de la pestaña activa */
  .side {
    left: 0; right: 0; top: auto; bottom: var(--mtabs);
    width: auto; height: auto; max-height: min(52vh, calc(100% - var(--mtop) - var(--mtabs) - 160px));
    border-radius: 18px 18px 0 0; border-bottom: 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
    transform: translateY(calc(100% + var(--mtabs) + 20px)); opacity: 1; z-index: 6;
    background: var(--panel-solid);
  }
  .side.open { transform: translateY(0); }
  .side.collapsed { transform: translateY(calc(100% + var(--mtabs) + 20px)); opacity: 1; pointer-events: auto; }
  .side.open.collapsed { transform: translateY(0); }
  .sheet-handle { display: grid; place-items: center; width: 100%; height: 26px; border: 0; background: transparent; flex: none; }
  .sheet-handle span { width: 40px; height: 5px; border-radius: 99px; background: var(--ink-3); opacity: 0.5; }
  .side-head, .side > .search, #collapse, .expand { display: none !important; }
  .side-body { padding: 0 14px calc(14px + env(safe-area-inset-bottom)); }
  .side-body section { border-top: 0; padding: 4px 2px 12px; }
  .side-body section.m-off { display: none; }
  .side-body section + section:not(.m-off) { border-top: 1px solid var(--line); padding-top: 12px; }
  #guide-open, .side-body .hint:not(.left) { display: none; }

  /* controles grandes para el dedo */
  .seg button, .views button { height: 46px; }
  .views { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .views kbd { display: none; }
  .views button { justify-content: center; font-size: 13.5px; }
  .toggles { grid-template-columns: 1fr 1fr; gap: 4px 10px; }
  .tg { min-height: 44px; font-size: 14px; }
  .chips button { height: 44px; min-width: 50px; }
  .swatches button { width: 38px; height: 38px; }
  .actions .primary { height: 48px; }
  .guide-nav button, .secondary, .ghost { height: 46px; }
  .unit input { height: 44px; width: 80px; font-size: 16px; }
  select { height: 46px; font-size: 16px; }
  .measures { gap: 8px 10px; font-size: 14px; }

  /* minimapa: plegado por defecto, se abre con el botón */
  .minimap { display: none; }
  .minimap.m-show { display: block; top: calc(var(--mtop) + 4px); right: 8px; width: 132px; height: 132px; padding: 4px; }
  .minimap text { display: none; }

  /* tarjetas sobre las pestañas */
  .info, .guide {
    left: 8px; right: 8px; width: auto; bottom: calc(var(--mtabs) + 8px);
    max-height: calc(50% - 40px); padding: 12px 14px 14px; z-index: 5;
  }
  .side.open ~ .info, .side.open ~ .guide { visibility: hidden; }
  .info h3 { font-size: 26px; }
  .info dl { grid-template-columns: 88px 1fr; font-size: 13.5px; }
  .info .close { width: 44px; height: 44px; right: 4px; top: 4px; }
  .guide h3 { font-size: 16.5px; }
  .guide-text { font-size: 13.5px; }
  .guide-text td { padding: 5px 6px; }
  .guide-top .icon-btn { width: 44px; height: 44px; }

  /* etiquetas 3D un poco mayores y pulsables */
  .lbl { font-size: 12px; padding: 4px 7px 4px 6px; }
  .lbl.s1010 { font-size: 10px; }
  .lbl.lm span { display: none; }

  .loading { top: 42%; }
}

/* móvil en horizontal: hoja y tarjetas más bajas */
@media (max-width: 900px) and (max-height: 500px) {
  .info, .guide { max-height: calc(100% - 90px); width: 46%; left: auto; }
}
