/* ============================================================
   CasoTransfer · componentes de aplicación
   ============================================================ */

/* ---------- Marca ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand:hover { color: #fff; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--green-bright), var(--green-dark));
  color: #04120a;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 20px rgba(31, 157, 107, 0.28);
  flex: none;
  overflow: hidden;
}
.brand-mark svg { width: 22px; height: 22px; display: block; }
.brand-name { font-size: 1.02rem; line-height: 1.1; }
.brand-name small {
  display: block;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Autenticación ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px 40px;
}
.auth-card {
  width: min(430px, 100%);
  background: linear-gradient(180deg, var(--surface), #080e0b);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.auth-card .brand { margin-bottom: 20px; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .lead { font-size: 0.88rem; color: var(--muted); margin-bottom: 22px; }
.auth-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.5;
}
.auth-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fca5a5;
  font-size: 0.82rem;
}

/* ---------- Shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 16px;
  background: rgba(6, 10, 8, 0.86);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .nav {
  display: none;
  gap: 4px;
  margin-left: 12px;
}
.topbar .nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}
.topbar .nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.topbar .nav a[aria-current='page'] {
  color: var(--green-bright);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--green-line);
}
.topbar .spacer { flex: 1; }
@media (min-width: 900px) {
  .topbar { padding: 0 24px; }
  .topbar .nav { display: flex; }
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--green-bright);
  font-size: 0.78rem;
  font-weight: 700;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(8, 13, 10, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current='page'] { color: var(--green-bright); }
@media (min-width: 900px) {
  .tabbar { display: none; }
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + 34px);
}
@media (min-width: 900px) {
  .page { padding: 28px 24px 48px; }
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: clamp(1.35rem, 3.6vw, 1.8rem); }
.page-head .sub { font-size: 0.84rem; color: var(--muted); margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-bottom: 22px; }
.section:last-child { margin-bottom: 0; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section-title h2 { font-size: 1rem; margin: 0; }
.section-title .link { font-size: 0.78rem; font-weight: 600; }

/* ---------- Lista de envíos ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .search {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
}
.toolbar .search input { padding-left: 38px; }
.toolbar .search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.toolbar select { width: auto; min-width: 150px; flex: 0 0 auto; }

.tlist { display: flex; flex-direction: column; gap: 10px; }
.trow {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface), #08100c);
  transition: border-color 0.16s ease;
}
.trow:hover { border-color: var(--green-line); }
.trow.is-clickable { cursor: pointer; }
.trow.is-clickable:focus-within { border-color: var(--green-line); }
.trow .thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--green-bright);
  border: 1px solid var(--line);
  overflow: hidden;
  font-size: 1.1rem;
}
.trow .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trow .main { flex: 1 1 auto; min-width: 0; }
.trow .title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 600;
  font-size: 0.94rem;
}
.trow .title a { color: var(--text); }
.trow .title a:hover { color: var(--green-bright); }
.trow .meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}
.trow .row-actions { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 719px) {
  .trow { flex-wrap: wrap; }
  .trow .row-actions {
    width: 100%;
    justify-content: flex-end;
    border-top: 1px solid var(--line-soft);
    padding-top: 10px;
  }
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- Archivo permanente ---------- */
.archive-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  background:
    radial-gradient(600px 180px at 0% 0%, rgba(31, 157, 107, 0.1), transparent 70%),
    linear-gradient(180deg, var(--surface), #08100c);
}
.archive-head h2 { margin: 0 0 4px; font-size: 1.02rem; }
.archive-head p { margin: 0; }

/* ---------- Subida ---------- */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 34px 20px;
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: radial-gradient(600px 200px at 50% 0%, rgba(31, 157, 107, 0.08), transparent 70%), var(--bg-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.dropzone:hover { border-color: var(--green-line); }
.dropzone.is-drag { border-color: var(--green); background: rgba(31, 157, 107, 0.1); }
.dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.dropzone .icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green-bright);
  border: 1px solid var(--green-line);
}
.dropzone b { font-size: 0.98rem; }
.dropzone small { color: var(--muted); font-size: 0.78rem; }

.filelist { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fileitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 0.84rem;
}
.fileitem .ftype {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--green-bright);
  flex: none;
  font-size: 0.9rem;
  overflow: hidden;
}
.fileitem .ftype img { width: 100%; height: 100%; object-fit: cover; }
.fileitem .fname { flex: 1 1 auto; min-width: 0; }
.fileitem .fname b { display: block; font-weight: 600; font-size: 0.84rem; }
.fileitem .fname small { color: var(--muted); font-size: 0.72rem; }
.fileitem .remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
}
.fileitem .remove:hover { color: var(--danger); background: var(--danger-soft); }
.upload-total {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ---------- Resultado de subida ---------- */
.result-link {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 6px;
  border: 1px solid var(--green-line);
  border-radius: 12px;
  background: rgba(31, 157, 107, 0.06);
}
.result-link input {
  border: none;
  background: transparent;
  font-size: 0.82rem;
  color: var(--green-bright);
  padding: 8px 10px;
}
.result-link input:focus { box-shadow: none; background: transparent; }
.qr-box {
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #fff;
  width: min(220px, 100%);
  margin: 0 auto;
}
.qr-box img { display: block; width: 100%; height: auto; }
.share-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 700px) {
  .share-grid { grid-template-columns: 1fr 220px; }
}

/* ---------- Ajustes ---------- */
.settings-layout { display: grid; gap: 18px; }
.logo-preview {
  max-height: 56px;
  max-width: 180px;
  object-fit: contain;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.logo-placeholder {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: var(--bg-soft);
  color: var(--green-bright);
  font-weight: 800;
  font-size: 0.9rem;
}
.settings-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav button {
  flex: none;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.settings-nav button:hover { color: var(--text); border-color: var(--green-line); }
.settings-nav button[aria-current='true'] {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-bright);
}
@media (min-width: 900px) {
  .settings-layout { grid-template-columns: 210px minmax(0, 1fr); align-items: start; }
  .settings-nav {
    flex-direction: column;
    position: sticky;
    top: calc(var(--header-h) + 16px);
    overflow: visible;
  }
  .settings-nav button { width: 100%; justify-content: flex-start; }
}
.day-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .day-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.day-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--bg-soft);
  flex-wrap: wrap;
}
.day-row .dname {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 104px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-dim);
}
.day-row .dname input { width: 16px; height: 16px; accent-color: var(--green); }
.day-row input[type='time'] { width: auto; flex: 1 1 88px; padding: 8px 10px; font-size: 0.8rem; }
.day-row .sep { color: var(--muted); font-size: 0.8rem; }
.availability-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--green-line);
  background: linear-gradient(120deg, rgba(31, 157, 107, 0.12), rgba(31, 157, 107, 0.02));
}
.availability-banner.closed {
  border-color: rgba(251, 191, 36, 0.35);
  background: linear-gradient(120deg, rgba(251, 191, 36, 0.1), rgba(251, 191, 36, 0.02));
}
.availability-banner .txt { flex: 1 1 auto; min-width: 0; }
.availability-banner b { display: block; font-size: 0.9rem; }
.availability-banner small { color: var(--muted); font-size: 0.78rem; }

/* ---------- Actividad ---------- */
.loglist { display: flex; flex-direction: column; }
.logitem {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.8rem;
}
.logitem:last-child { border-bottom: none; }
.logitem .lact {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--green-bright);
  font-size: 0.74rem;
}
.logitem .ltxt { flex: 1 1 auto; min-width: 0; }
.logitem .ltxt b { font-weight: 600; }
.logitem time { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }

/* ---------- Detalle ---------- */
.detail-files {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
}
.detail-files .df {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
  font-size: 0.72rem;
}
.detail-files .df .cap { padding: 6px 8px; }
.detail-files .df .cap b { display: block; font-weight: 600; font-size: 0.74rem; }
.detail-files .df .cap small { color: var(--muted); }
.detail-files .df .pv {
  aspect-ratio: 1;
  background: #0a0f0c;
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}
.detail-files .df .pv img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   Página pública de descarga
   ============================================================ */
.pub-wrap {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px 16px 40px;
}
.pub-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.pub-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  background:
    radial-gradient(700px 240px at 0% 0%, rgba(31, 157, 107, 0.13), transparent 70%),
    linear-gradient(180deg, var(--surface), #0a110d);
  box-shadow: var(--shadow-soft);
}
.pub-hero h1 { margin: 0 0 6px; font-size: clamp(1.35rem, 4.6vw, 1.9rem); }
.pub-hero .from { color: var(--muted); font-size: 0.85rem; }
.pub-hero .msg {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--green);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0 10px 10px 0;
  font-size: 0.88rem;
  color: var(--text-dim);
  white-space: pre-wrap;
}
.pub-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pub-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.gallery {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-top: 20px;
}
@media (min-width: 760px) {
  .gallery { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
}
.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: #080d0a;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  font-family: inherit;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.04); }
.tile .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.4rem;
  pointer-events: none;
}
.tile .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  font-size: 0.7rem;
  line-height: 1.3;
  text-align: left;
}
.tile .cap b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .cap small { color: #b9c6bf; font-size: 0.66rem; }
.tile .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.12);
}
.tile .play span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 0.95rem;
  padding-left: 3px;
}
.files-list {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
}
.files-list .fhead {
  padding: 12px 16px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.frow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.85rem;
}
.frow:last-child { border-bottom: none; }
.frow .ico {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--green-bright);
  flex: none;
  overflow: hidden;
}
.frow .ico img { width: 100%; height: 100%; object-fit: cover; }
.frow .nm { flex: 1 1 auto; min-width: 0; }
.frow .nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .nm small { color: var(--muted); font-size: 0.74rem; }
.frow .dl {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.frow .dl:hover { border-color: var(--green); color: var(--green-bright); }
.pub-foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}

/* ---------- Candado / estados ---------- */
.lock-card {
  width: min(430px, 100%);
  margin: 8vh auto 0;
  padding: 26px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), #080e0b);
  box-shadow: var(--shadow);
  text-align: center;
}
.lock-card .lockicon {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  color: var(--green-bright);
  font-size: 1.4rem;
}
.lock-card h1 { font-size: 1.25rem; margin-bottom: 4px; }
.lock-card .sub { font-size: 0.82rem; color: var(--muted); margin-bottom: 18px; }
.lock-card form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.state-card {
  width: min(460px, 100%);
  margin: 10vh auto 0;
  text-align: center;
  padding: 30px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), #080e0b);
}
.state-card .big { font-size: 2.2rem; margin-bottom: 10px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: rgba(3, 7, 5, 0.96);
  backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }
.lightbox .lb-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.lightbox .lb-bar .t { flex: 1 1 auto; min-width: 0; font-size: 0.84rem; }
.lightbox .lb-bar .t b {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lightbox .lb-bar .t small { color: var(--muted); font-size: 0.72rem; }
.lightbox .lb-stage {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 10px;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
}
.lightbox .lb-stage img,
.lightbox .lb-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  background: #000;
}
.lightbox .lb-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: var(--muted);
}
.lightbox .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.lightbox .nav.prev { left: 10px; }
.lightbox .nav.next { right: 10px; }
.lightbox .nav[disabled] { opacity: 0.25; pointer-events: none; }
@media (max-width: 560px) {
  .lightbox .nav.prev { left: 6px; }
  .lightbox .nav.next { right: 6px; }
}

/* ---------- Offline / 404 ---------- */
.offline-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.offline-card {
  width: min(480px, 100%);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  background: linear-gradient(180deg, var(--surface), #080e0b);
  box-shadow: var(--shadow);
}
.offline-card .moon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  color: var(--green-bright);
  font-size: 1.5rem;
}
.offline-card h1 { font-size: 1.4rem; }
.offline-card .next {
  margin: 16px 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 0.88rem;
}
.offline-card .next b { display: block; color: var(--green-bright); font-size: 1rem; }
.offline-card .hint { font-size: 0.76rem; color: var(--muted); margin-top: 14px; }

/* ---------- Utilidades finales ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 180px; }
.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;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   Arranque, esqueleto de carga y detalles para móvil
   ============================================================ */
.boot-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
}
.boot-brand .brand-mark { width: 54px; height: 54px; border-radius: 17px; }
.boot-brand .brand-mark svg { width: 28px; height: 28px; }
.boot-brand .boot-name {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1;
}
.boot-brand .boot-role {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Esqueleto: ocupa el sitio del contenido mientras llega la respuesta. */
.view-loading { display: grid; gap: 14px; padding-top: 4px; }
.skel {
  border-radius: 12px;
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0.035) 20%,
    rgba(255, 255, 255, 0.08) 40%,
    rgba(255, 255, 255, 0.035) 60%
  );
  background-size: 200% 100%;
  animation: ct-skel 1.25s ease-in-out infinite;
}
.skel-head { height: 26px; width: min(260px, 55%); }
.skel-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.skel-card { height: 112px; }
.skel-block { height: 210px; }
@media (min-width: 700px) {
  .skel-grid { grid-template-columns: repeat(3, 1fr); }
}
@keyframes ct-skel {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
}

@media (max-width: 899px) {
  /* El notch del iPhone no debe tapar la cabecera. */
  .topbar {
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
  /* Seis secciones caben sin cortes incluso en 360 px. */
  .tabbar { grid-auto-columns: minmax(0, 1fr); }
  .tabbar a { min-height: 48px; padding: 4px 2px; font-size: 0.62rem; }
  .tabbar a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .page { padding: 16px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 26px); }
  .page-head { align-items: flex-start; margin-bottom: 16px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }

  /* Objetivos táctiles cómodos. */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }

  /* Los avisos no pueden quedar escondidos detrás de la barra inferior. */
  .toast-host { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); }

  /* Página pública: botón de descarga a lo ancho y sin zoom al enfocar campos. */
  .pub-wrap { padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px)); }
  .pub-actions .btn { flex: 1 1 100%; min-height: 48px; font-size: 0.95rem; }
  .pub-hero { padding: 18px; border-radius: var(--radius); }
  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='number'],
  input[type='search'],
  input[type='url'],
  input[type='time'],
  select,
  textarea { font-size: 16px; }
}

/* El nombre de un archivo largo no puede partir el botón en dos líneas. */
.pub-actions .btn { min-width: 0; max-width: 100%; overflow: hidden; }
.pub-actions .btn .btn-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  /* Cabecera en una sola línea: la marca no se parte en tres renglones. */
  .pub-top { flex-wrap: nowrap; align-items: flex-start; gap: 10px; }
  .pub-top .brand { flex: 1 1 auto; min-width: 0; }
  .pub-top .brand-name { min-width: 0; }
  .pub-top .brand-name small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* «1 archivo · 880 KB» ya se repite dentro de la cabecera del envío. */
  .pub-top #top-badge { display: none; }
}

/* ============================================================
   Escritorio (≥ 900 px)
   ------------------------------------------------------------
   La app nació pensada para el móvil. En pantalla grande se
   aprovecha el ancho: más aire, filas más altas y un panel de
   descarga con jerarquía, sin tocar la estructura del móvil.
   ============================================================ */
@media (min-width: 900px) {
  body { font-size: 15.5px; }

  .topbar { padding: 0 28px; gap: 18px; }
  .topbar .nav a { padding: 9px 16px; }

  .page { padding: 34px 32px 72px; }
  .page-head { margin-bottom: 26px; align-items: center; }
  .page-head h1 { font-size: 1.9rem; letter-spacing: -0.035em; }
  .page-head .sub { font-size: 0.86rem; }

  .card { padding: 22px 24px; }
  .tlist { gap: 12px; }
  .trow {
    padding: 16px 20px;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  }
  .trow:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
  .trow .thumb { width: 56px; height: 56px; border-radius: 14px; }
  .trow .title { font-size: 0.98rem; }
  .trow .meta { gap: 14px; }

  .toolbar { gap: 12px; }
  .dropzone { padding: 52px 28px; }
  .detail-files { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  dialog.modal { width: min(840px, calc(100vw - 56px)); }

  /* Página pública: el enlace que recibe el cliente. */
  .pub-wrap { padding: 32px 24px 64px; }
  .pub-hero { padding: 32px 34px; border-radius: 24px; }
  .pub-hero h1 { font-size: 2.1rem; }
  .pub-actions { margin-top: 22px; }
  .pub-actions .btn { padding: 13px 22px; }
  .gallery { margin-top: 24px; gap: 12px; }
  .tile { border-radius: 14px; }
  .files-list { margin-top: 24px; }
}

@media (min-width: 1280px) {
  .page { padding-left: 40px; padding-right: 40px; }
}
