/* ================= Variables ================= */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f5f5f7;
  --text: #1d1d1f;
  --text2: #6e6e73;
  --sep: rgba(0, 0, 0, .08);
  --dash: rgba(0, 0, 0, .22);
  --accent: #0071e3;
  --success: #34c759;
  --error: #ff3b30;
  --nav-bg: rgba(245, 245, 247, .72);
  --card-shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --seg-bg: rgba(120, 120, 128, .16);
  --seg-sel: #ffffff;
  --btn2: rgba(120, 120, 128, .16);
  --toast-bg: rgba(250, 250, 252, .85);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface2: #2c2c2e;
    --text: #f5f5f7;
    --text2: #98989d;
    --sep: rgba(255, 255, 255, .1);
    --dash: rgba(255, 255, 255, .28);
    --accent: #0a84ff;
    --nav-bg: rgba(20, 20, 22, .7);
    --card-shadow: none;
    --seg-bg: rgba(120, 120, 128, .22);
    --seg-sel: #636366;
    --btn2: rgba(120, 120, 128, .22);
    --toast-bg: rgba(44, 44, 46, .82);
  }
}

/* ================= Base ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: calc(52px + env(safe-area-inset-top));
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.mt {
  margin-top: 14px;
}

.w100 {
  width: 100%;
}

/* ================= Barra superior ================= */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(52px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
}

.nav-in {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1200px;
  margin: 0 auto;
  height: 52px;
}

.nav-in svg {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.nav-in .name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.nav-open {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.nav-open[hidden] {
  display: none;
}

.nav-open .short {
  display: none;
}

@media (max-width: 480px) {
  .nav-open .full {
    display: none;
  }

  .nav-open .short {
    display: inline;
  }
}

/* ================= Hero ================= */
.hero {
  text-align: center;
  padding: 60px 20px 36px;
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.08;
}

.hero p {
  margin-top: 12px;
  color: var(--text2);
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  letter-spacing: -.01em;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px calc(48px + env(safe-area-inset-bottom));
}

/* ================= Zona de soltar ================= */
.drop {
  border: 2px dashed var(--dash);
  border-radius: 24px;
  background: var(--surface);
  padding: 70px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .25s cubic-bezier(.25, .1, .25, 1), background .25s, transform .2s;
}

.drop:hover {
  border-color: var(--accent);
}

.drop.over {
  border-color: var(--accent);
  background: var(--surface2);
}

.drop svg {
  width: 52px;
  height: 52px;
  color: var(--accent);
  margin-bottom: 16px;
}

.drop .t1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.drop .t2 {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text2);
}

/* ================= Tarjetas ================= */
.card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
  padding: 20px;
}

@media (prefers-color-scheme: dark) {
  .card {
    border: 1px solid var(--sep);
  }
}

/* ================= Layout principal ================= */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}

.grid > * {
  min-width: 0;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }

  .panel {
    position: sticky;
    top: calc(52px + env(safe-area-inset-top) + 16px);
  }
}

#ws {
  animation: fadeUp .35s cubic-bezier(.25, .1, .25, 1);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ================= Comparador ================= */
.zbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.zbar .seg {
  width: 236px;
}

.seg.sm button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12.5px;
}

.compare {
  position: relative;
  overflow: hidden;
  background: #000;
  padding: 0;
  border-radius: 20px;
  touch-action: none;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
}

.compare.zoom {
  height: min(70vh, 720px);
  cursor: grab;
}

.compare.zoom:active {
  cursor: grabbing;
}

.layer {
  position: absolute;
  inset: 0;
}

.stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.stage canvas {
  display: block;
}

.lbefore {
  clip-path: inset(0 50% 0 0);
}

.divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 44px;
  margin-left: -22px;
  pointer-events: none;
}

.dline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, .95);
}

.handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: #5a5a5e;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
}

.handle::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.tag {
  position: absolute;
  top: 12px;
  padding: 5px 13px;
  border-radius: 980px;
  background: rgba(20, 20, 22, .4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  pointer-events: none;
}

.tag.l {
  left: 12px;
}

.tag.r {
  right: 12px;
}

.info {
  margin: 12px 4px 0;
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  overflow-wrap: anywhere;
}

/* ================= Panel ================= */
.frow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.fname {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group {
  padding: 14px 0;
  border-top: 1px solid var(--sep);
}

.glabel {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 10px;
}

.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text2);
}

.note {
  font-size: 12px;
  color: var(--text2);
  background: var(--surface2);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 4px 0 14px;
}

/* ================= Segmentado ================= */
.seg {
  position: relative;
  display: flex;
  background: var(--seg-bg);
  border-radius: 12px;
  padding: 2px;
}

.seg button {
  flex: 1;
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  min-height: 36px;
  padding: 7px 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .2s;
}

.seg .ind {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 10px;
  border-radius: 10px;
  background: var(--seg-sel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
  transition: transform .25s cubic-bezier(.25, .1, .25, 1), width .25s cubic-bezier(.25, .1, .25, 1);
}

.seg.dis {
  opacity: .45;
  pointer-events: none;
}

/* ================= Sliders ================= */
.ctl {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 0;
}

.ctl label {
  width: 118px;
  flex: none;
  font-size: 14px;
  color: var(--text);
}

.ctl input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  height: 24px;
  min-width: 0;
}

.ctl .val {
  width: 40px;
  flex: none;
  text-align: right;
  font-size: 14px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ================= Botones ================= */
.btn {
  border: 0;
  border-radius: 980px;
  min-height: 44px;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.25, .1, .25, 1), opacity .2s, background .2s;
}

.btn:active {
  transform: scale(.97);
}

.btn[disabled] {
  opacity: .4;
  pointer-events: none;
}

.btn-p {
  background: var(--accent);
  color: #fff;
}

.btn-s {
  background: var(--btn2);
  color: var(--text);
}

.btn.sm {
  min-height: 34px;
  padding: 0 16px;
  font-size: 13px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn-row .btn {
  flex: 1;
}

.link {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
}

/* ================= Progreso ================= */
#progWrap {
  margin: 14px 0 4px;
}

.prog {
  height: 4px;
  border-radius: 2px;
  background: var(--sep);
  overflow: hidden;
}

.prog i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width .2s;
}

.prog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.prog-row span {
  font-size: 13px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ================= Historial ================= */
.hist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}

.hist {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
}

.hist button {
  flex: none;
  border: 1px solid var(--sep);
  border-radius: 12px;
  padding: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
  line-height: 0;
}

.hist img {
  width: 110px;
  display: block;
}

/* ================= Overlay de soltar ================= */
#dropOverlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  pointer-events: none;
}

#dropOverlay[hidden] {
  display: none;
}

/* ================= Toasts ================= */
#toasts {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 520px);
}

.toast {
  background: var(--toast-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .18);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .25s cubic-bezier(.25, .1, .25, 1), transform .25s cubic-bezier(.25, .1, .25, 1);
}

.toast.on {
  opacity: 1;
  transform: none;
}

.toast.ok {
  color: var(--success);
}

.toast.err {
  color: var(--error);
}

/* ================= Pie / video oculto ================= */
.foot {
  text-align: center;
  font-size: 12px;
  color: var(--text2);
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
}

.foot a {
  color: inherit;
}

#vid {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

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