/* ============================================================
   ETIQUETADORA - CSS
   Diseño responsive con glassmorphism.
   ============================================================ */

:root {
  --bg: #eef2f8;
  --bg-secondary: #dfe6f2;
  --text: #141824;
  --muted: #5e6678;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.72);
  --shadow: 0 20px 55px rgba(30, 42, 70, 0.16);
  --accent: #287fff;
  --danger: #e83f4f;
  --success: #20a64a;
  --radius: 24px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-size: 16px;
}

:root[data-theme="dark"] {
  --bg: #090b12;
  --bg-secondary: #151927;
  --text: #f5f7fb;
  --muted: #aeb6c9;
  --glass: rgba(26, 30, 43, 0.62);
  --glass-strong: rgba(25, 29, 42, 0.9);
  --glass-border: rgba(255, 255, 255, 0.13);
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
}


* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  height: auto;
  margin: 0;
  overscroll-behavior: none;
  overflow-x: hidden;
  font-family: var(--font-family);
  font-size: var(--font-size);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(40,127,255,.18), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(247,57,142,.16), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(126,73,255,.15), transparent 38%),
    var(--bg);
}

body {
  min-height: 100dvh;
  height: auto;
  overflow-y: auto;
  overscroll-behavior-y: none;
  touch-action: pan-y;
}

.main-content {
  overflow: visible;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="color"] {
  touch-action: manipulation;
}

button {
  color: inherit;
  border: 0;
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(40,127,255,.65);
  outline-offset: 2px;
}

input,
select {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text);
  padding: 9px 12px;
}

input[type="text"],
input[type="search"],
input[type="color"],
select {
  font-size: 16px;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.topbar {
  position: sticky;
  top: max(8px, env(safe-area-inset-top));
  z-index: 30;
  height: 64px;
  min-height: 64px;
  border-radius: 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 5px 10px;
}

.brand {
  border: 0;
  background: transparent;
  height: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  font-size: 32pt;
  line-height: 1;
  font-weight: 800;
}

.icon-button {
  min-width: 46px;
  min-height: 46px;
  border-radius: 15px;
  background: rgba(255,255,255,.14);
  border: 1px solid var(--glass-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.labeled-action {
  justify-self: start;
  padding: 0 13px;
}

.svg-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: inline-grid;
  place-items: center;
}

.svg-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.menu-nav .svg-icon,
.menu-section .svg-icon {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.view-header-spacer {
  width: 46px;
  min-height: 46px;
}

#menuButton {
  justify-self: end;
  font-size: 23px;
}

/* En tema claro los botones principales de la cabecera destacan con un gris suave. */
:root[data-theme="light"] .topbar .icon-button {
  background: rgba(92, 101, 116, 0.14);
  border-color: rgba(92, 101, 116, 0.22);
}

:root[data-theme="dark"] .topbar .icon-button {
  background: rgba(255, 255, 255, 0.10);
}

.main-content {
  width: min(980px, 100%);
  margin: 0 auto;
}

.view {
  display: none;
  min-height: calc(100dvh - 100px);
  padding: 26px 0 90px;
  overflow: visible;
}

.active-view {
  display: block;
}

.hero-copy {
  text-align: center;
  padding: 18px 10px 22px;
}

.hero-copy h1,
.view-header h2 {
  margin: 0 0 7px;
  font-size: clamp(1.45rem, 4vw, 2.15rem);
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  touch-action: pan-y;
}

/* ============================================================
   BOTÓN DE ETIQUETA (tag-card)
   - ALTO: +30% respecto al original (44px / 1.3em → 57.2px / 1.69em)
   - ESQUINAS: poco redondeadas (6px)
   - LAYOUT: [icono editar] [nombre] [icono galería]
   ------------------------------------------------------------
   👇 SI QUIERES CAMBIAR EL ALTO DE LOS BOTONES DE ETIQUETA,
      modifica las DOS propiedades siguientes a la vez:
        · min-height
        · height
      Mantén la misma fórmula en ambas para que no haya saltos.
      Ejemplos:
        max(70px, 2em)   → más altas
        max(50px, 1.5em) → más bajas
   ============================================================ */
.tag-card {
  position: relative;
  min-height: max(57.2px, 1.69em);
  height:     max(57.2px, 1.69em);
  border-radius: 6px;          /* esquinas poco redondeadas */
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
  font-size: clamp(1.35rem, 4.5vw, 2rem);
  box-shadow: 0 14px 30px rgba(0,0,0,.16);
  border: 1px solid rgba(255,255,255,.38);
  user-select: none;
  touch-action: pan-y;
  transition: transform .18s ease, filter .18s ease;
}

.tag-card:active {
  transform: scale(.985);
}

.tag-card.dragging {
  opacity: .58;
  transform: scale(.98) rotate(-1deg);
}

/* Nombre central de la etiqueta. No intercepta toques: así los gestos
   de swipe/arrastre siguen funcionando sobre toda la superficie. */
.tag-label {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* Iconos circulares dentro del botón.
   El círculo y el SVG comparten color con el texto de la etiqueta
   (currentColor), por lo que se adaptan automáticamente al textColor
   configurado por el usuario.
   ------------------------------------------------------------
   Tamaño base original: clamp(32px, 4.8vw, 44px).
   Tamaño actual (−25 %):  clamp(24px, 3.6vw, 33px).
   👇 Si quieres volver a cambiarlo, multiplica los TRES valores
      por el mismo factor (24 → 100 %, 30 → 125 %, 36 → 150 %...).
   ============================================================ */
.tag-icon {
  flex: 0 0 auto;
  width: clamp(24px, 3.6vw, 33px);
  height: clamp(24px, 3.6vw, 33px);
  border-radius: 50%;
  border: 2px solid currentColor;
  background: transparent;
  color: inherit;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
  transition: transform .12s ease, background .12s ease;
}

.tag-icon:hover {
  background: rgba(255, 255, 255, .18);
}

.tag-icon:active {
  transform: scale(.9);
}

.tag-icon svg {
  width: 58%;
  height: 58%;
  display: block;
  fill: currentColor;
}

.tag-icon svg path {
  fill: currentColor;
}

/* Botón "Añadir etiqueta": mantiene su alto original,
   sólo se han redondeado menos las esquinas. */
.add-tag-button {
  width: 100%;
  min-height: max(44px, 1.1em);
  height: max(44px, 1.1em);
  margin-top: 18px;
  border-radius: 6px;          /* esquinas poco redondeadas */
  border-style: dashed;
  font-weight: 700;
}

.install-area {
  margin: 28px 0 max(18px, env(safe-area-inset-bottom));
  padding-top: 22px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: center;
  width: 100%;
}

.install-button,
.primary-button {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 17px;
  background: linear-gradient(135deg, #287fff, #7e49ff);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(40,127,255,.32);
}

.secondary-button {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 17px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.view-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.view-header h2 {
  text-align: center;
  margin: 0;
}

.view-header select {
  min-width: 0;
  width: 100%;
}

/* Cabecera específica de Configuración: título centrado
   y sin botón X (ahora hay un botón "Cerrar" al final). */
.view-header.settings-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

.settings-header h2 {
  text-align: center;
  margin: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.month-heading {
  grid-column: 1 / -1;
  padding: 18px 4px 5px;
  font-size: 1.05rem;
  font-weight: 800;
}

.photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 2px solid transparent;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-tile.selected {
  border-color: #287fff;
}

.photo-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,.48);
  color: #fff;
  border: 1px solid rgba(255,255,255,.8);
}

.photo-tile.selected .photo-check {
  background: #287fff;
}

.selection-bar {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(940px, calc(100% - 20px));
  border-radius: 22px;
  padding: 12px;
}

.selection-summary {
  text-align: center;
  margin-bottom: 7px;
}

.selection-bar > button {
  background: transparent;
  color: var(--accent);
  display: block;
  margin: 0 auto 8px;
  font-weight: 700;
}

.selection-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.selection-actions button {
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: #fff;
  font-weight: 800;
}

.selection-actions .action-retag {
  background: #20a64a;
}

.selection-actions .action-share {
  background: #287fff;
  font-size: 1.55rem;
}

.selection-actions .action-delete {
  background: #d93445;
  font-size: 1.45rem;
}

.side-menu {
  position: fixed;
  z-index: 100;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: min(360px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  padding: 70px 18px 18px;
  border-radius: 28px;
  transform: translateX(calc(100% + 30px));
  transition: transform .25s ease;
}

.side-menu.open {
  transform: translateX(0);
}

.menu-close {
  position: absolute;
  top: 14px;
  right: 14px;
  left: auto;
}

.svg-cross-button {
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: #000;
}

:root[data-theme="dark"] .svg-cross-button {
  color: #fff;
}

.svg-cross-button svg {
  width: 28px;
  height: 28px;
  display: block;
  fill: currentColor;
}

.svg-cross-button svg path {
  fill: currentColor;
}

.view-header {
  position: relative;
}

.view-header > .svg-cross-button {
  position: absolute;
  top: 0;
  right: 0;
  justify-self: auto;
}

.menu-nav,
.menu-section {
  display: grid;
  gap: 7px;
}

.menu-nav button,
.menu-section button,
.by-dama {
  min-height: 56px;
  padding: 0 14px;
  border-radius: 15px;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  text-align: left;
  gap: 10px;
  background: transparent;
  text-decoration: none;
  color: inherit;
}

.menu-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}

.menu-section h3 {
  margin: 0 8px 6px;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.by-dama {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
  grid-template-columns: 32px 1fr 30px;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 30px);
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  padding: 24px;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0,0,0,.52);
  backdrop-filter: blur(4px);
}

.modal form,
.modal > div {
  display: grid;
  gap: 16px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  font-size: 26px;
}


.modal label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.tag-preview {
  min-height: 78px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  font-size: 1.45rem;
  font-weight: 800;
}

.dialog-actions,
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-button,
.success-button,
.cancel-soft-button {
  min-height: 52px;
  border-radius: 16px;
  font-weight: 800;
}

.danger-button {
  background: #d93445;
  color: #fff;
}

.success-button {
  background: #20a64a;
  color: #fff;
}

.cancel-soft-button {
  background: #A6A19D;
  color: #111;
}

.settings-list {
  border-radius: 24px;
  padding: 6px 16px 18px;
  overflow: visible;
}

/* Botón verde "Cerrar" al final de la pantalla de Configuración */
.settings-close-button {
  width: 100%;
  min-height: 54px;
  margin-top: 22px;
  border-radius: 16px;
  background: #20a64a;
  color: #ffffff;
  border: 1px solid var(--glass-border);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}

.setting-row {
  min-height: 66px;
  padding: 9px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid var(--glass-border);
}

.setting-row.stack {
  grid-template-columns: 1fr;
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-fieldset {
  border: 0;
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 0 18px;
  margin: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 8px;
}

.segmented-control button {
  min-height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
}

.segmented-control button.active {
  background: var(--accent);
  color: #fff;
}

.toggle {
  appearance: none;
  width: 54px;
  height: 32px;
  min-height: 32px;
  border-radius: 999px;
  padding: 3px;
  background: #858b99;
  position: relative;
  cursor: pointer;
}

.toggle::after {
  content: "";
  width: 26px;
  height: 26px;
  display: block;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}

.toggle:checked {
  background: #20a64a;
}

.toggle:checked::after {
  transform: translateX(22px);
}

.settings-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.settings-section h3 {
  margin: 0 0 6px;
}

.settings-section p {
  color: var(--muted);
  margin: 0 0 14px;
}


.viewer-modal {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #05070d;
  color: #fff;
  overflow-y: auto;
  overflow-x: hidden;
}

.viewer-modal::backdrop {
  background: #05070d;
}

.viewer-topbar {
  position: absolute;
  z-index: 5;
  top: max(10px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
}

.viewer-topbar button {
  min-width: 46px;
  min-height: 46px;
  border-radius: 14px;
  background: rgba(0,0,0,.35);
  color: #fff;
}

.viewer-image-wrap {
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  padding: max(66px, calc(env(safe-area-inset-top) + 58px)) 0 max(12px, env(safe-area-inset-bottom));
}

.viewer-image-wrap img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-options-panel {
  position: absolute;
  z-index: 6;
  top: max(68px, calc(env(safe-area-inset-top) + 62px));
  right: 12px;
  width: min(430px, calc(100vw - 24px));
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 22px;
  background: rgba(10, 12, 22, .92);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 18px 50px rgba(0,0,0,.42);
  backdrop-filter: blur(18px);
  display: none;
}

.viewer-options-open .viewer-options-panel {
  display: block;
}

.viewer-info {
  display: grid;
  gap: 7px;
  padding: 4px 6px 12px;
  text-align: left;
  word-break: break-word;
}

.viewer-info strong,
.viewer-info span {
  line-height: 1.35;
}

.viewer-info span {
  color: #c3c8d4;
}

.viewer-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.viewer-actions button {
  min-height: 58px;
  border-radius: 15px;
  color: #fff;
  font-size: .82rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 5px;
  line-height: 1.15;
  text-align: center;
}

.viewer-actions .action-rename {
  background: #5b6475;
}

.viewer-actions .action-retag {
  background: #20a64a;
}

.viewer-actions .action-crop {
  background: #7e49ff;
}

.viewer-actions .action-share {
  background: #287fff;
}

.viewer-actions .action-delete {
  background: #d93445;
}

.viewer-actions .svg-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 21px;
}

.viewer-hint {
  display: none;
}

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 18px;
  border-radius: 15px;
  background: rgba(15,18,28,.92);
  color: #fff;
  transition: .2s ease;
  max-width: min(90vw, 560px);
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Tablet: aprovechamos el ancho con dos columnas. */
@media (min-width: 700px) {
  .app-shell {
    padding-left: 24px;
    padding-right: 24px;
  }

  .tag-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 9px;
  }
}

/* Escritorio: más densidad y más controles visibles. */
@media (min-width: 1100px) {
  .topbar {
    height: 72px;
    min-height: 72px;
  }

  .tag-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .gallery-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .view {
    padding-top: 34px;
  }
}

/* Horizontal en dispositivos pequeños: usamos dos columnas para las etiquetas. */
@media (orientation: landscape) and (max-height: 600px) {
  .tag-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tag-card {
    min-height: 86px;
  }

  .hero-copy {
    padding: 10px;
  }
}

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


/* La aplicación mantiene el scroll vertical disponible en todas las pantallas. */
#homeView, #galleryView, #settingsView {
  overflow: visible;
}

@media (max-width: 520px) {
  .view-header {
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  }

  .view-header .icon-button {
    min-width: 44px;
  }

  .viewer-options-panel {
    left: 12px;
    right: 12px;
    width: auto;
  }
}

/* ============================================================
   Correcciones v1.0.4: scroll móvil, feedback de swipe y compartir.
   ============================================================ */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  touch-action: pan-y;
}

.app-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.main-content {
  min-height: auto;
}

.view {
  min-height: auto;
  overflow: visible;
}

#homeView,
#galleryView,
#settingsView {
  min-height: calc(100dvh - 100px);
  overflow: visible;
  touch-action: pan-y;
}

.home-hint {
  padding: 16px 10px 28px;
  cursor: pointer;
}

.home-hint p {
  max-width: 900px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Animaciones breves que acompañan los dos gestos de las etiquetas. */
.tag-card.swipe-right {
  animation: tagSwipeRight .18s ease-out;
}

.tag-card.swipe-left {
  animation: tagSwipeLeft .18s ease-out;
}

@keyframes tagSwipeRight {
  0% { transform: translateX(0); }
  55% { transform: translateX(28px) scale(.985); }
  100% { transform: translateX(0); }
}

@keyframes tagSwipeLeft {
  0% { transform: translateX(0); }
  55% { transform: translateX(-28px) scale(.985); }
  100% { transform: translateX(0); }
}

.share-action-icon {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
  color: #fff;
}

.selection-actions .action-share .share-action-icon,
.viewer-actions .action-share .share-action-icon {
  color: #fff;
}

/* El popup de ⋮ muestra etiqueta, nombre, fecha y tamaño. */
.viewer-info #viewerFilename {
  display: block;
}

/* En móvil, los controles de Galería permanecen en una sola fila. */
@media (max-width: 520px) {
  .view-header {
    grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .view-header select {
    min-width: 0;
    padding-left: 8px;
    padding-right: 22px;
  }
}


/* Acciones de edición y confirmación de etiquetas */
.delete-tag-button {
  width: 100%;
  min-height: 50px;
  margin-top: 14px;
  border: 0;
  border-radius: 16px;
  background: #d93445;
  color: #ffffff;
  font-weight: 800;
}

.cancel-soft-button {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  background: #A6A19D;
  color: #111;
  font-weight: 800;
}


/* ============================================================
   v1.0.13 - Exportación avanzada y modo recorte
   ============================================================ */
.export-dialog {
  width: min(560px, calc(100vw - 24px));
}

.export-message {
  white-space: pre-line;
  color: var(--muted);
  line-height: 1.55;
}

.export-progress-label {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

#exportProgress {
  width: 100%;
  height: 18px;
  accent-color: var(--accent);
}

.export-status {
  min-height: 24px;
  color: var(--muted);
  line-height: 1.35;
}

.export-dialog-actions {
  grid-template-columns: 1fr 1fr;
}

.export-dialog-actions button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.reset-warnings-button {
  width: 100%;
  min-height: 52px;
  background: #A6A19D;
  color: #111;
  font-weight: 800;
}

.viewer-actions .action-crop {
  background: #7e49ff;
}

.viewer-actions .action-crop .svg-icon {
  width: 22px;
  height: 22px;
}

.crop-dialog {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(4,6,12,.96);
  color: #fff;
}

.crop-dialog::backdrop {
  background: rgba(0,0,0,.70);
}

.crop-dialog-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 10px;
}

.crop-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 1.15rem;
}

.crop-hint {
  margin: 0;
  color: #c3c8d4;
  text-align: center;
  line-height: 1.4;
}

.crop-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: none;
  background: #020307;
  border-radius: 20px;
}

.crop-stage > img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-selection {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.52);
  touch-action: none;
  cursor: move;
}

.crop-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 6px;
  background: #287fff;
  touch-action: none;
}

.crop-handle.nw { left: -11px; top: -11px; cursor: nwse-resize; }
.crop-handle.ne { right: -11px; top: -11px; cursor: nesw-resize; }
.crop-handle.sw { left: -11px; bottom: -11px; cursor: nesw-resize; }
.crop-handle.se { right: -11px; bottom: -11px; cursor: nwse-resize; }

.crop-dialog-actions {
  grid-template-columns: 1fr 1.4fr;
}

@media (max-width: 520px) {
  .export-dialog-actions {
    grid-template-columns: 1fr 1fr;
  }


  .viewer-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.viewer-options-panel .viewer-actions { align-items: stretch; }
.viewer-options-panel .viewer-actions button { min-width: 0; }
@media (max-width: 380px) { .viewer-actions button { font-size: .82rem; gap: 5px; } .viewer-actions .svg-icon { width: 19px; height: 19px; flex-basis: 19px; } }


/* v1.0.21 - Protección de almacenamiento */
.storage-protection-status {
  width: 100%;
  min-height: 52px;
  margin: 8px 0 10px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: #f0f2f5;
  color: #111;
  font-weight: 800;
  text-align: left;
  padding: 0 14px;
}
.storage-protection-status[data-state="ok"] { background: #dff3e5; color: #176b34; }
.storage-protection-status[data-state="warning"] { background: #fff0dc; color: #7a3f00; }
.storage-warning-help {
  width: 42px; height: 42px; min-height: 42px; border-radius: 50%;
  background: #d93445; color: #fff; font-size: 1.15rem;
  display: inline-grid; place-items: center;
}

#appVersionLabel {
  font-size: 12px;
  color: #D5D7CF;
}

:root[data-theme="light"] #appVersionLabel {
  color: #6f6f6f;
}

.share-tag-options {
  display: grid;
  gap: 10px;
}

.share-tag-option {
  width: 100%;
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.08);
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(0,0,0,.10);
}

.share-tag-message {
  margin: 0;
  color: var(--muted);
}

/* ============================================================
   v1.1.0 - Diálogo de compartir: botón "+ Nueva etiqueta"
   y formulario en línea para crear etiquetas con fondo blanco
   y letras negras durante la recepción de imágenes compartidas.
   ============================================================ */
.share-tag-new-button {
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  border-radius: 14px;
  background: #ffffff;
  color: #000000;
  border: 2px dashed rgba(0,0,0,.35);
  font-weight: 800;
  cursor: pointer;
}

.share-tag-new-form {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0,0,0,.04);
}

.share-tag-new-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.share-tag-cancel-row {
  margin-top: 12px;
}