:root {
  --fondo: #0e0e10;
  --fondo-2: #141417;
  --panel: #17171b;
  --tarjeta: #1c1c21;
  --tarjeta-hover: #222228;
  --borde: #2b2b32;
  --borde-fuerte: #3a3a43;
  --texto: #ece8e1;
  --suave: #a39e95;
  --tenue: #77736c;
  --oro: #c9a45c;
  --oro-claro: #e2c58a;
  --oro-fondo: rgba(201, 164, 92, 0.12);
  --peligro: #d46a5f;
  --radio: 14px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --alto-encabezado: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

a { color: var(--oro-claro); }

/* --- Encabezado --- */

.encabezado {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--alto-encabezado);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(14, 14, 16, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borde);
}

.marca { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--texto); }
.marca-icono { width: 30px; height: 30px; color: var(--oro); flex: none; }
.marca-nombre { display: block; font-family: var(--serif); font-weight: 700; font-size: 25px; line-height: 1; letter-spacing: 0.02em; }
.marca-sub { display: block; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--suave); margin-top: 3px; }

/* --- Botones --- */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--oro);
  background: var(--oro);
  color: #17140e;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.boton:hover { background: var(--oro-claro); border-color: var(--oro-claro); }
.boton svg { width: 18px; height: 18px; }
.boton-secundario { background: transparent; color: var(--texto); border-color: var(--borde-fuerte); }
.boton-secundario:hover { background: var(--tarjeta-hover); border-color: var(--oro); color: var(--texto); }
.boton[disabled] { opacity: 0.35; pointer-events: none; }
.boton-chico { min-height: 34px; padding: 0 14px; font-size: 13px; }

/* --- Disposición --- */

.disposicion {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr);
  height: calc(100vh - var(--alto-encabezado));
  height: calc(100dvh - var(--alto-encabezado));
}

.visor {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(ellipse at 50% 42%, #2a2a31 0%, #17171b 55%, #0e0e10 100%);
  border-right: 1px solid var(--borde);
}

.lienzo { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.lienzo canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.lienzo canvas:active { cursor: grabbing; }

.titulo-visor {
  position: absolute;
  left: 24px;
  top: 20px;
  pointer-events: none;
}
.titulo-visor .t1 { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.1; }
.titulo-visor .t2 { color: var(--suave); font-size: 13px; margin-top: 4px; }

.cargando {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--suave);
  font-family: var(--serif);
  font-size: 22px;
  pointer-events: none;
}
.cargando.oculto { display: none; }

/* Etiquetas del despiece */
.etiquetas { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.2s; opacity: 0; }
.etiqueta { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.etiqueta-punto {
  position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--oro); box-shadow: 0 0 0 3px rgba(201, 164, 92, 0.25);
}
.etiqueta-linea { position: absolute; left: -0.5px; bottom: 4px; width: 1px; height: var(--l, 18px); background: rgba(201, 164, 92, 0.7); }
.etiqueta-texto {
  position: absolute; left: 0; bottom: calc(var(--l, 18px) + 4px); transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(14, 14, 16, 0.82); border: 1px solid rgba(201, 164, 92, 0.45); color: var(--texto);
}

/* Controles del visor */
.controles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--borde);
  background: rgba(14, 14, 16, 0.6);
}

.despiece { display: flex; align-items: center; gap: 12px; flex: 1 1 260px; min-width: 0; }
.despiece-nombre { font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--oro-claro); }
.despiece-valor { font-size: 12px; color: var(--suave); width: 70px; text-align: right; font-variant-numeric: tabular-nums; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 80px;
  height: 28px;
  background: transparent;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--oro) var(--p, 0%), var(--borde-fuerte) var(--p, 0%));
}
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: var(--borde-fuerte); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--oro); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
  background: var(--oro-claro); border: 3px solid #17140e; box-shadow: 0 0 0 1px var(--oro);
}
input[type='range']::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--oro-claro); border: 3px solid #17140e; box-shadow: 0 0 0 1px var(--oro);
}

.vistas { display: flex; flex-wrap: wrap; gap: 6px; }
.vistas button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--borde-fuerte); background: transparent; cursor: pointer; font-size: 13px;
}
.vistas button svg { width: 15px; height: 15px; }
.vistas button:hover { border-color: var(--oro); }
.vistas button.activo, .vistas button[aria-pressed='true'] { background: var(--oro-fondo); border-color: var(--oro); color: var(--oro-claro); }

/* --- Panel --- */

.panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }

.pasos {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--borde);
}
.pasos::-webkit-scrollbar { display: none; }
.paso {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 12px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  text-align: left;
  max-width: 150px;
}
.paso-num { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tenue); }
.paso-nombre { font-weight: 600; font-size: 14px; }
.paso-eleccion { font-size: 12px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 126px; }
.paso:hover .paso-nombre { color: var(--oro-claro); }
.paso.activo { border-bottom-color: var(--oro); }
.paso.activo .paso-num, .paso.activo .paso-nombre { color: var(--oro-claro); }

.contenido { flex: 1; overflow-y: auto; padding: 22px 24px 32px; }

.contenido h2 { font-family: var(--serif); font-weight: 600; font-size: 32px; line-height: 1.1; margin: 0 0 6px; }
.contenido h3 { font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--oro-claro); margin: 26px 0 10px; font-weight: 600; }
.intro { color: var(--suave); margin: 0 0 18px; max-width: 60ch; }
.nota {
  font-size: 13px; color: var(--suave); background: var(--fondo-2); border: 1px solid var(--borde);
  border-left: 3px solid var(--oro); border-radius: 8px; padding: 10px 12px; margin: 14px 0;
}

.navegacion {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--borde);
  background: var(--panel);
}

/* --- Tarjetas de opciones --- */

.grilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.grilla-ancha { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.opcion {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
  background: var(--tarjeta);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.opcion:hover { background: var(--tarjeta-hover); border-color: var(--borde-fuerte); }
.opcion.elegida { border-color: var(--oro); background: linear-gradient(180deg, var(--oro-fondo), var(--tarjeta)); }
.opcion.elegida::after {
  content: '';
  position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--oro) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' fill='none' stroke='%2317140e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.opcion[disabled] { opacity: 0.4; cursor: not-allowed; }
.opcion[disabled]:hover { background: var(--tarjeta); border-color: var(--borde); }

.opcion-imagen {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, #2b2b32, #141417);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.opcion-imagen img, .opcion-imagen canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.opcion-imagen.cargando-img::before {
  content: ''; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--borde-fuerte); border-top-color: var(--oro);
  animation: girar 0.9s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.opcion-nombre { font-weight: 600; font-size: 14px; line-height: 1.3; }
.opcion-sub { font-size: 12px; color: var(--suave); line-height: 1.35; }
.opcion-dato { font-size: 11px; color: var(--tenue); letter-spacing: 0.04em; }

.opcion-fila { flex-direction: row; align-items: center; gap: 14px; padding: 14px; }
.opcion-fila .opcion-texto { flex: 1; padding-right: 26px; }
.opcion-icono {
  width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--borde-fuerte); font-family: var(--serif); font-size: 18px; font-weight: 700; color: var(--oro-claro);
  background: radial-gradient(circle at 40% 35%, #2e2e35, #17171b);
}

/* Chips de color */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 14px 0 6px; border-radius: 999px;
  border: 1px solid var(--borde-fuerte); background: var(--tarjeta); cursor: pointer; font-size: 13px;
}
.chip:hover { border-color: var(--oro); }
.chip.elegida { border-color: var(--oro); background: var(--oro-fondo); color: var(--oro-claro); }
.muestra { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.18); flex: none; }

/* --- Resumen --- */

.resumen-grilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 16px; margin: 0 0 8px; }
.resumen-item { padding: 10px 0; border-bottom: 1px solid var(--borde); }
.resumen-item dt { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tenue); }
.resumen-item dd { margin: 2px 0 0; font-weight: 500; }

.acciones { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }

.partes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.parte {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--tarjeta);
}
.parte-tipo { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--oro-claro); }
.parte-eleccion { font-weight: 600; }
.parte-nota { grid-column: 1 / -1; font-size: 13px; color: var(--suave); }
.parte-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--tenue); }
.parte-meta code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px; color: var(--suave); background: var(--fondo-2); padding: 1px 6px; border-radius: 4px; }
.parte .boton { grid-row: 1 / 3; grid-column: 2; }
.etiqueta-directo { color: #8fc79a; }

.herramientas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.herramientas a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta);
  color: var(--texto); text-decoration: none; font-size: 13px;
}
.herramientas a:hover { border-color: var(--oro); }
.herramientas a span:last-child { color: var(--oro-claro); }

/* --- Aviso flotante --- */

.aviso {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--oro);
  color: #17140e;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s, transform 0.2s;
}
.aviso.visible { opacity: 1; transform: translate(-50%, 0); }

.sin-js { padding: 24px; text-align: center; color: var(--suave); }

/* --- Celular y tablet --- */

@media (max-width: 900px) {
  :root { --alto-encabezado: 56px; }
  .encabezado { padding: 0 16px; }
  .marca-nombre { font-size: 21px; }
  .marca-sub { display: none; }
  #compartir span { display: none; }
  #compartir { padding: 0 12px; }

  .disposicion { display: block; height: auto; }
  .visor {
    position: sticky;
    top: var(--alto-encabezado);
    z-index: 10;
    height: 50vh;
    height: 50svh;
    border-right: 0;
    border-bottom: 1px solid var(--borde);
  }
  .titulo-visor { left: 16px; top: 12px; }
  .titulo-visor .t1 { font-size: 22px; }
  .titulo-visor .t2 { display: none; }
  .controles { padding: 8px 16px 10px; gap: 6px 12px; }
  .despiece-valor { display: none; }
  .etiqueta-texto { font-size: 10px; padding: 2px 6px; }
  .vistas button { min-height: 30px; padding: 0 10px; font-size: 12px; }
  .panel { min-height: 50vh; }
  .pasos { padding: 8px 8px 0; position: sticky; top: calc(var(--alto-encabezado) + 50svh); z-index: 5; background: var(--panel); }
  .contenido { overflow: visible; padding: 18px 16px 24px; }
  .contenido h2 { font-size: 27px; }
  .navegacion { position: sticky; bottom: 0; padding: 10px 16px; z-index: 5; }
  .grilla { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .parte { grid-template-columns: 1fr; }
  .parte .boton { grid-row: auto; grid-column: auto; justify-self: start; }
}

@media (max-width: 900px) and (max-height: 700px) {
  .visor { height: 42vh; height: 42svh; }
  .pasos { top: calc(var(--alto-encabezado) + 42svh); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
