:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dcdfe5;
  --text: #1b1d21;
  --muted: #63676f;
  --accent: #2f6df6;
  --accent-text: #ffffff;
  --ok: #1a7f45;
  --ok-bg: #e4f5ea;
  --bad: #b3261e;
  --bad-bg: #fbe6e5;
  --wait: #8a5a00;
  --wait-bg: #fdf1dc;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2027;
    --border: #333844;
    --text: #eceef2;
    --muted: #a0a6b2;
    --accent: #6f9bff;
    --accent-text: #10131a;
    --ok: #7ddba4;
    --ok-bg: #1c3628;
    --bad: #ff9f99;
    --bad-bg: #3a1f1e;
    --wait: #f0c777;
    --wait-bg: #3a2f18;
  }
}

* { box-sizing: border-box; }

/* El navegador oculta [hidden] con display:none, pero cualquier regla nuestra
   que fije display le gana: .button lo hacia visible aunque el JS lo ocultara. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 24px 16px; flex: 1; }
.container.narrow { max-width: 640px; }

.site-header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 14px; }
.site-footer { padding: 20px 16px; text-align: center; color: var(--muted); font-size: 13px; }

h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
.lead { font-size: 18px; color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
small.muted { display: block; font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card.center { text-align: center; }

.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

.button {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
  text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.button.small { padding: 5px 10px; font-size: 13px; }
.button.danger:hover { border-color: var(--bad); color: var(--bad); }
.link-button { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.inline { display: inline; }

.hero { text-align: center; padding: 32px 0; }
.steps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.step span {
  display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700;
}
.step p { margin-bottom: 0; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat strong { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 13px; }

.form { display: grid; gap: 16px; }
.form label, .share-box { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-weight: 400;
}
textarea { resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
legend { padding: 0 6px; font-size: 14px; font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

.link-list { list-style: none; margin: 0; padding: 0; }
.link-card { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; }
.link-card.inactive { opacity: .65; }
.link-card h2 { margin: 0 0 4px; font-size: 18px; }
.link-main { min-width: 0; flex: 1 1 260px; }
.link-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-url {
  display: block; margin: 8px 0; padding: 6px 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px; overflow-wrap: anywhere;
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.wait { background: var(--wait-bg); color: var(--wait); border-color: transparent; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 15px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }

.drop-page { text-align: center; }
.name-field { display: grid; gap: 6px; text-align: left; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.dropzone {
  display: grid; gap: 6px; place-items: center; padding: 40px 20px; cursor: pointer;
  background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--ok-bg); }
.dropzone-icon { font-size: 40px; }

.file-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.file-item {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.file-info { display: grid; gap: 6px; min-width: 0; flex: 1; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-item .badge { flex: none; }
.progress { display: block; height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-bar { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .2s ease; }
.dropzone.disabled { opacity: .6; cursor: progress; }
.done-note { margin-top: 20px; font-weight: 600; color: var(--ok); }

@media (max-width: 560px) {
  .link-actions { width: 100%; }
  .table thead { display: none; }
  .table tr { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table td { border: none; padding: 2px 0; }
}

/* --- Galeria del enlace ---------------------------------------------------
   Movil primero: la cuadricula arranca en tres columnas en un telefono y
   crece sola con la pantalla, sin una sola media query. */

.album { margin-top: 40px; text-align: left; }
.album h2 { font-size: 18px; margin: 0 0 12px; }
.album-status { margin: 0 0 12px; }
.album-more { margin-top: 16px; width: 100%; }

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 2px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  background: var(--border);
  cursor: pointer;
  overflow: hidden;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile-video {
  position: absolute; right: 6px; bottom: 4px;
  color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  pointer-events: none;
}

/* En pantallas grandes la galeria se sale del contenedor estrecho: una
   cuadricula de 640 px de ancho no se parece en nada a Google Photos. */
@media (min-width: 720px) {
  .album { width: min(1100px, 92vw); margin-inline: calc(50% - min(550px, 46vw)); }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .album-more { width: auto; }
}

/* --- Visor a pantalla completa -------------------------------------------- */

body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
.viewer[hidden] { display: none; }

.viewer-stage {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  /* Deja respirar los controles y la barra del sistema en el movil. */
  padding: 56px 8px calc(56px + env(safe-area-inset-bottom));
}
.viewer-stage img,
.viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }

.viewer-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  margin: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  color: #fff; font-size: 13px; text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  pointer-events: none;
}

/* 44 px de lado: lo minimo para acertar con el dedo sin pelearse con los
   gestos del borde de la pantalla. */
.viewer-button {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: none; border-radius: 999px;
  background: rgba(0, 0, 0, .5); color: #fff;
  font-size: 22px; line-height: 1; text-decoration: none;
  cursor: pointer;
}
.viewer-button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.viewer-close { top: calc(8px + env(safe-area-inset-top)); right: 8px; }
.viewer-download { top: calc(8px + env(safe-area-inset-top)); left: 8px; }
.viewer-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.viewer-next { right: 8px; top: 50%; transform: translateY(-50%); }

/* Con raton los controles laterales estorban hasta que hacen falta. */
@media (hover: hover) {
  .viewer-prev, .viewer-next { opacity: .35; transition: opacity .15s ease; }
  .viewer:hover .viewer-prev, .viewer:hover .viewer-next { opacity: 1; }
}

.viewer:focus { outline: none; }

/* Cabecera del album: refleja el nombre y la destacada de Google Photos. */
.album-head { margin-bottom: 12px; }
.album-cover {
  display: block; width: 100%; aspect-ratio: 3 / 1; object-fit: cover;
  border-radius: var(--radius); margin-bottom: 10px; background: var(--border);
}
.album-title { margin: 0; font-size: 18px; }
.album-count { margin: 2px 0 0; font-size: 14px; }
.tip { margin: 14px 0 0; font-size: 13px; text-align: left; }
