/* Octi View en la web: la misma cara que la app de Mac, medida sobre sus
   capturas (`OctiView --pantallas`). Barra de 48 con el ícono sobre el
   nombre; el lienzo casi negro; el panel de 318 con tarjetas gris oscuro de
   esquinas de 10; el verde del ícono como único acento: lo elegido lleva
   borde verde sobre verde muy hondo, y Exportar es el único botón macizo.
   En el teléfono, las herramientas van al pie y el panel sube como hoja. */

:root {
  --barra: #1d1d21;
  --lienzo: #0f0f12;
  --panel: #19191d;
  --tarjeta: #232328;
  --control: #2a2a30;
  --borde: #38383f;
  --elegido: #3d3d44;
  --texto: #f2f2f4;
  --suave: #c9c9ce;
  --tenue: #8e8e95;
  --acento: #63c695;
  --acento-texto: #0d2a1d;
  --acento-hondo: #1f3a2f;
  --rojo: #ee6a5a;
  --amarillo: #f4b94a;
  --verde: #5fc28f;
  --azul: #5aa2f5;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--lienzo); color: var(--texto); overflow: hidden; }
button { font: inherit; color: inherit; cursor: default; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: 0.32; }
[hidden] { display: none !important; }
svg { display: block; flex: none; }
i[data-ic] { display: contents; }

/* MARK: La barra */

#barra {
  height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex; align-items: center; gap: 6px;
  background: var(--barra);
  border-bottom: 1px solid #000;
  user-select: none; -webkit-user-select: none;
}
.grupo { display: flex; align-items: center; gap: 4px; }
.archivo { flex: 1 1 0; min-width: 0; gap: 2px; }
.salida { flex: 1 1 0; justify-content: flex-end; gap: 2px; }
.sep { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.11); margin: 0 12px; flex: none; }

.b-barra {
  height: 30px; display: flex; align-items: center; gap: 6px;
  background: none; border: 0; border-radius: 7px; padding: 0 8px;
  color: var(--suave); font-size: 13.5px; white-space: nowrap;
}
.b-barra svg { width: 17px; height: 17px; }
.b-barra:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); }
.b-barra.elegido { background: rgba(255, 255, 255, 0.11); color: var(--texto); }
.b-panel { margin-left: 8px; }
.b-panel.elegido { background: rgba(255, 255, 255, 0.13); }
.chico svg, svg.chico { width: 9px; height: 9px; }

#cual { display: flex; flex-direction: column; min-width: 0; margin-left: 14px; line-height: 1.2; }
#cual b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cual small { color: var(--tenue); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.herr {
  height: 40px; min-width: 54px; padding: 0 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; border-radius: 8px;
  color: var(--suave); font-size: 11px; font-weight: 600; white-space: nowrap;
}
.herr > svg { width: 19px; height: 19px; }
.herr span { display: flex; align-items: center; gap: 2px; }
.herr:hover { background: rgba(255, 255, 255, 0.06); }
.herr.elegido { color: var(--acento); background: rgba(255, 255, 255, 0.09); }

.b-exportar {
  height: 28px; display: flex; align-items: center; gap: 7px;
  border: 0; border-radius: 7px; padding: 0 13px;
  background: var(--acento); color: var(--acento-texto);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.b-exportar svg { width: 16px; height: 16px; stroke-width: 1.9; }
.b-exportar.elegido { box-shadow: 0 0 0 1.5px var(--barra), 0 0 0 3px rgba(99, 198, 149, 0.55); }
.b-exportar:active { filter: brightness(0.9); }

.menu { position: relative; }
.desplegable {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  min-width: 220px; max-height: 62vh; overflow: auto; padding: 5px;
  background: rgba(44, 44, 50, 0.97);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 9px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
}
.desplegable.derecha { left: auto; right: 0; }
.desplegable button {
  display: flex; align-items: center; gap: 6px; width: 100%;
  background: none; border: 0; border-radius: 5px; padding: 4px 10px 4px 6px;
  text-align: left; font-size: 13px; white-space: nowrap;
}
.desplegable button::before { content: ""; width: 14px; flex: none; font-size: 12px; }
.desplegable button.actual::before { content: "✓"; }
.desplegable button:hover:not(:disabled) { background: #3474e0; color: #fff; }
.desplegable hr { border: 0; border-top: 1px solid rgba(255, 255, 255, 0.1); margin: 5px 6px; }

/* MARK: El lienzo */

#principal { display: flex; height: calc(100% - 48px - env(safe-area-inset-top)); }
#escena {
  flex: 1; min-width: 0; position: relative;
  background: var(--lienzo);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
#marco { position: relative; }
#vista { display: block; width: 100%; height: 100%; }
#marco.cuadritos {
  background-color: #3a3a3e;
  background-image: linear-gradient(45deg, #4b4b50 25%, transparent 25%, transparent 75%, #4b4b50 75%),
                    linear-gradient(45deg, #4b4b50 25%, transparent 25%, transparent 75%, #4b4b50 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
#capa { position: absolute; inset: 0; }
#capa.jalar { cursor: grab; }
#capa.jalar:active { cursor: grabbing; }
#capa.marcar { cursor: crosshair; }

#inicio { text-align: center; color: var(--tenue); padding: 24px; user-select: none; -webkit-user-select: none; }
#inicio p { margin: 4px 0; font-size: 13px; }
#inicio .grande { font-size: 15px; font-weight: 600; color: #9d9da4; }
#inicio .privado { margin-top: 22px; display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 12px; color: #6f6f76; }
#inicio .privado svg { width: 14px; height: 14px; }
.enlace { background: none; border: 0; padding: 0; color: var(--acento); cursor: pointer; }
body.soltando #escena::after {
  content: ""; position: absolute; inset: 12px; pointer-events: none;
  border: 2px dashed var(--acento); border-radius: 14px; background: rgba(99, 198, 149, 0.05);
}

/* MARK: El panel */

#panel {
  width: 318px; flex: none; overflow-y: auto;
  padding: 13px 13px 24px;
  background: var(--panel);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}
#panel > :first-child { margin-top: 0; }

.titulo { font-size: 15px; font-weight: 700; margin: 2px 0 12px; }
.rotulo { color: var(--tenue); font-size: 11.5px; font-weight: 500; margin: 18px 0 8px; }
.tarjeta { background: var(--tarjeta); border-radius: 10px; padding: 11px 10px; margin-bottom: 10px; }
.tarjeta > :first-child { margin-top: 0; }
.tarjeta > :last-child { margin-bottom: 0; }
.dice { font-size: 13px; line-height: 1.35; margin: 10px 0; }
.nota { color: var(--tenue); font-size: 11.5px; line-height: 1.4; margin: 8px 0; }
.aviso-ojo { display: flex; gap: 8px; color: var(--tenue); font-size: 11.5px; line-height: 1.4; margin: 12px 0; }
.aviso-ojo svg { color: var(--amarillo); width: 15px; height: 15px; margin-top: 1px; }

/* «Sale de 1080 × 1920 / Original: …», con el botón de volver. */
.sale { display: flex; align-items: center; gap: 12px; padding: 11px 10px 11px 12px; }
.sale > svg { color: var(--tenue); width: 17px; height: 17px; }
.sale div { flex: 1; min-width: 0; }
.sale b { display: block; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sale small { display: block; color: var(--tenue); font-size: 11.5px; margin-top: 1px; font-variant-numeric: tabular-nums; }
.redondo {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--control); border: 1px solid var(--borde); padding: 0;
}
.redondo svg { width: 14px; height: 14px; }

.segmentos { display: flex; gap: 2px; padding: 2px; background: #1c1c20; border-radius: 7px; }
.tarjeta .segmentos { background: #1c1c20; }
.segmentos button {
  flex: 1; height: 22px; border: 0; background: none; border-radius: 5px;
  font-size: 11.5px; font-weight: 500; color: var(--tenue); white-space: nowrap;
}
.segmentos button.elegido { background: var(--elegido); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.segmentos + .segmentos { margin-top: 8px; }

/* Botones de a tres (Entera · Llenar · Centrar) y los formatos. */
.botones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.boton {
  height: 26px; border: 1px solid var(--borde); border-radius: 7px;
  background: var(--control); font-size: 12.5px; color: var(--texto); white-space: nowrap;
}
.boton:hover { filter: brightness(1.12); }
.boton.elegido, .mosaico.elegido { background: var(--acento-hondo); border-color: var(--acento); }
.formatos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.formatos .boton { height: 27px; border-color: transparent; font-weight: 600; font-size: 11.5px; }

.mosaicos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mosaicos.tres { grid-template-columns: repeat(3, 1fr); }
.mosaico {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 42px; padding: 8px 6px;
  border: 1px solid transparent; border-radius: 9px; background: var(--tarjeta);
  text-align: center;
}
.mosaico:hover { filter: brightness(1.1); }
.mosaico b { font-size: 11.5px; font-weight: 600; line-height: 1.25; }
.mosaico small { font-size: 11px; color: var(--tenue); font-variant-numeric: tabular-nums; }
.mosaico > svg { width: 18px; height: 18px; color: var(--suave); }
.mosaicos.tres .mosaico { min-height: 48px; gap: 5px; }
.mosaicos.tres .mosaico b { font-weight: 600; }
.mosaico.ancho { grid-column: 1 / -1; padding: 12px; min-height: 64px; }

.ancho-entero {
  width: 100%; height: 26px; margin-top: 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--borde); border-radius: 7px; background: transparent; font-size: 13px;
}
.ancho-entero svg { width: 15px; height: 15px; }
.ancho-entero.elegido { background: var(--acento-hondo); border-color: var(--acento); }

.b-principal {
  width: 100%; height: 31px; border: 0; border-radius: 7px;
  background: var(--acento); color: var(--acento-texto); font-size: 13.5px; font-weight: 600;
}
.b-principal:active { filter: brightness(0.9); }
.b-suave {
  height: 26px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--borde); border-radius: 7px; background: transparent; font-size: 13px; white-space: nowrap;
}
.b-suave svg { width: 15px; height: 15px; }
.b-suave.lleno { width: 100%; height: 26px; }
.b-suave:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); }
.fila { display: flex; gap: 8px; align-items: center; }
.fila > .crece { flex: 1; }
.pila { display: flex; flex-direction: column; gap: 8px; }

/* Deslizadores como los de la Mac: riel fino, perilla blanca. */
.deslizador { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; margin: 4px 0 12px; }
.deslizador:last-child { margin-bottom: 2px; }
.deslizador label { font-size: 13px; }
.deslizador output { color: var(--tenue); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.deslizador output.cambiado { color: var(--acento); }
.deslizador .riel { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.deslizador .riel svg { width: 14px; height: 14px; color: var(--tenue); }
.deslizador .riel svg.grande { width: 18px; height: 18px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; width: 100%; height: 22px; margin: 0;
  background: transparent; touch-action: none;
}
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: #3d3d44; }
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: #3d3d44; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 19px; height: 19px; margin-top: -8px; border-radius: 50%;
  background: #f4f4f6; box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(0, 0, 0, 0.2);
}
input[type=range]::-moz-range-thumb { width: 19px; height: 19px; border: 0; border-radius: 50%; background: #f4f4f6; }

.colores { display: flex; gap: 7px; align-items: center; margin-top: 12px; }
.colores button, .colores label {
  width: 22px; height: 22px; border-radius: 50%; padding: 0; flex: none;
  border: 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.colores button.elegido, .colores label.elegido { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--acento); }
.colores label { position: relative; overflow: hidden; background: conic-gradient(#ff4d4d, #ffd24d, #5dde6a, #4dd8ff, #5b6bff, #e64dff, #ff4d4d); }
.colores input[type=color] { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; }
.colores .redondo { margin-left: auto; width: 26px; height: 26px; border-radius: 7px; }
.colores .redondo.elegido { background: var(--acento-hondo); border-color: var(--acento); }

/* Info: cada cosa que la foto dice, con su ícono de color. */
.hallazgo { display: flex; gap: 12px; align-items: center; padding: 10px; margin-bottom: 9px; background: var(--tarjeta); border-radius: 10px; }
.hallazgo .icono {
  width: 27px; height: 27px; border-radius: 7px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--amarillo); background: rgba(244, 185, 74, 0.16);
}
.hallazgo .icono svg { width: 15px; height: 15px; }
.hallazgo.rojo .icono { color: var(--rojo); background: rgba(238, 106, 90, 0.16); }
.hallazgo.verde .icono { color: var(--verde); background: rgba(95, 194, 143, 0.16); }
.hallazgo.azul .icono { color: var(--azul); background: rgba(90, 162, 245, 0.16); }
.hallazgo div { min-width: 0; }
.hallazgo b { display: block; font-size: 13px; font-weight: 600; }
.hallazgo small { display: block; color: var(--suave); font-size: 11.5px; margin-top: 2px; overflow-wrap: anywhere; }
.limpia { display: flex; gap: 10px; align-items: center; }
.limpia > svg { color: var(--acento); width: 22px; height: 22px; }
.limpia b { display: block; font-size: 13px; }
.cabeza { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; margin-bottom: 10px; }
.cabeza svg { width: 16px; height: 16px; color: var(--tenue); }
.cabeza small { color: var(--tenue); font-weight: 400; font-size: 11.5px; }
.dato { margin: 8px 0 0; }
.dato small { display: block; color: var(--tenue); font-size: 11px; }
.dato span { display: block; font-size: 13px; margin-top: 1px; overflow-wrap: anywhere; }

.paso {
  display: flex; gap: 10px; align-items: center; width: 100%;
  border: 1px solid transparent; border-radius: 9px; background: none;
  padding: 5px; text-align: left; font-size: 13px;
}
.paso:hover { background: rgba(255, 255, 255, 0.04); }
.paso.actual { background: var(--acento-hondo); border-color: var(--acento); }
.paso.adelante { opacity: 0.42; }
.paso canvas, .paso .mini { width: 52px; height: 38px; border-radius: 5px; background: var(--control); object-fit: contain; flex: none; }

/* MARK: Lo de encima de la imagen */

.zona { position: absolute; border: 1.5px dashed var(--acento); pointer-events: none; }
.zona.ovalo { border-radius: 50%; }
.zona.pincel { border-color: rgba(99, 198, 149, 0.45); }
.zona.elegida { border-width: 2px; }
.manija, .esquina {
  position: absolute; width: 13px; height: 13px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%); cursor: nwse-resize; touch-action: none;
}
.esquina::after, .manija::after { content: ""; position: absolute; inset: -12px; }
.esquina.ne, .esquina.so { cursor: nesw-resize; }
.quitar {
  position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 0; padding: 0;
  background: var(--acento); color: var(--acento-texto); transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.quitar svg { width: 10px; height: 10px; stroke-width: 3; }
.dibujando { position: absolute; background: rgba(99, 198, 149, 0.16); border: 1.5px dashed var(--acento); pointer-events: none; }
.dibujando.ovalo { border-radius: 50%; }
#capa svg.trazo { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.franja {
  position: absolute; left: 0; right: 0; pointer-events: none;
  background: rgba(150, 150, 155, 0.42);
  color: rgba(255, 255, 255, 0.8); font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.franja.arriba { border-bottom: 1px dashed rgba(255, 255, 255, 0.55); }
.franja.abajo { border-top: 1px dashed rgba(255, 255, 255, 0.55); }
.guia { position: absolute; background: rgba(99, 198, 149, 0.9); pointer-events: none; }

#aviso {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50;
  display: flex; gap: 10px; align-items: center;
  max-width: min(92vw, 620px); padding: 9px 16px;
  background: rgba(30, 30, 34, 0.94);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5); font-size: 13px;
}
#aviso svg { width: 16px; height: 16px; color: var(--acento); }
#aviso.falla svg { color: var(--rojo); }

/* MARK: Ventana angosta: primero se van los nombres de archivo; nunca deshacer ni Exportar. */
@media (max-width: 1060px) {
  #cual { display: none !important; }
}
@media (max-width: 900px) {
  .b-barra .nombre { display: none; }
  .sep { margin: 0 6px; }
}

/* MARK: El teléfono: herramientas al pie, panel como hoja encima de ellas. */
@media (max-width: 760px) {
  #barra { padding: env(safe-area-inset-top) 8px 0; }
  #exportar span { display: none; }
  #exportar { padding: 0 10px; }
  .herramientas {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--barra); border-top: 1px solid #000;
  }
  .herramientas .sep { display: none; }
  .herramientas .herr { height: 44px; }
  .herramientas .desplegable { top: auto; bottom: calc(100% + 8px); }
  #principal { flex-direction: column; height: calc(100% - 48px - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  #panel {
    width: auto; max-height: 48vh; flex: none;
    border-left: 0; border-top: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  }
  #aviso { bottom: calc(72px + env(safe-area-inset-bottom)); border-radius: 14px; }
  input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -10.5px; }
}
