/* TeleStore · visor público
 * Fondos cálidos (nunca negro/blanco puro), acento rojo-óxido como glow difuso,
 * colores secundarios SOLO para distinguir tipo de archivo. */

:root {
  color-scheme: dark;
  --bg: #0D0E14;
  --panel: #16141A;
  --panel2: #1E1B23;
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .14);
  --text: #F3F1EC;
  --dim: #A9A7B6;
  --faint: #727082;
  --red: #E8604A;
  --red-soft: rgba(232, 96, 74, .14);
  --red-line: rgba(232, 96, 74, .34);
  --on-red: #1A0F0C;
  --glow: rgba(232, 96, 74, .26);
  --sh: rgba(255, 255, 255, .06);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  /* color semántico del tipo; lo reemplaza cada tarjeta con tint() */
  --c: #8E8B9C;
  --c-soft: rgba(142, 139, 156, .14);
  --c-line: rgba(142, 139, 156, .32);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #F7F5F1;
    --panel: #FFFFFF;
    --panel2: #F1EEE8;
    --line: rgba(30, 24, 20, .09);
    --line2: rgba(30, 24, 20, .17);
    --text: #1C1A20;
    --dim: #5D5B68;
    --faint: #8D8B98;
    --glow: rgba(232, 96, 74, .17);
    --sh: rgba(255, 255, 255, .75);
    --shadow: 0 18px 44px rgba(70, 48, 34, .12);
  }
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; min-height: 100dvh; position: relative; overflow-x: hidden; }
body.noscroll { overflow: hidden; }

/* Glow difuso detrás del contenido: nunca una franja dura */
.glow {
  position: fixed; left: 50%; top: -240px;
  width: 640px; height: 640px; transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none; z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.sr-copy { position: fixed; left: -9999px; top: 0; opacity: 0; }

noscript { display: block; padding: 40px 24px; text-align: center; color: var(--dim); }

/* ───────── estructura ───────── */

.page {
  width: 100%; max-width: 520px; margin: 0 auto; flex: 1;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 18px) 18px calc(env(safe-area-inset-bottom) + 28px);
}
.page.wide { max-width: 620px; }
.page.has-dock { padding-bottom: calc(env(safe-area-inset-bottom) + 124px); }

.top { display: flex; align-items: center; gap: 10px; padding: 2px 2px 22px; }
/* Logo: icono original de la app (se sirve desde telestore.pages.dev) */
.brand-mark {
  flex: none; width: 34px; height: 34px; border-radius: 10px; overflow: hidden;
  background: #16141A url('https://telestore.pages.dev/icon-192.png') center / cover no-repeat;
  box-shadow: 0 6px 18px rgba(232, 96, 74, .28);
}
.brand-mark svg { display: none; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: -.01em; }

.foot { margin-top: auto; padding-top: 30px; text-align: center; font-size: 11.5px; color: var(--faint); }

/* ───────── tarjeta y héroe ───────── */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.hero { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.hero--center { align-items: center; text-align: center; padding: 34px 22px 28px; gap: 14px; }
.hero-head { display: flex; gap: 14px; align-items: center; }
.hero-text { min-width: 0; }

.tile {
  flex: none; width: 60px; height: 60px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--c-soft); border: 1px solid var(--c-line); color: var(--c);
}
.tile svg { width: 28px; height: 28px; }
.tile.sm { width: 44px; height: 44px; border-radius: 13px; }
.tile.sm svg { width: 20px; height: 20px; }
.tile.lg { width: 92px; height: 92px; border-radius: 28px; box-shadow: 0 0 60px var(--c-soft); }
.tile.lg svg { width: 42px; height: 42px; }

.file-title {
  font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.2;
  letter-spacing: -.01em; margin: 0; overflow-wrap: anywhere;
}
.hero--center .file-title { font-size: 24px; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; font-size: 12.5px; color: var(--dim); }
.hero--center .meta { justify-content: center; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.ext {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em; padding: 3px 8px; border-radius: 8px;
  background: var(--c-soft); color: var(--c); border: 1px solid var(--c-line);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hero--center .chips { justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--dim);
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line2);
}
.chip svg { width: 14px; height: 14px; }

.nopreview { margin: 2px 0 0; font-size: 13px; color: var(--faint); max-width: 260px; line-height: 1.5; }
.note { margin: 16px 8px 0; text-align: center; font-size: 12.5px; color: var(--faint); line-height: 1.5; }

/* ───────── vista previa ───────── */

.media {
  position: relative; display: grid; place-items: center; min-height: 180px;
  border-radius: 18px; overflow: hidden; background: var(--panel2); border: 1px solid var(--line);
}
.media img, .media video { display: block; width: 100%; max-height: min(62vh, 560px); object-fit: contain; opacity: 0; transition: opacity .3s; }
.media img.loaded, .media video.loaded { opacity: 1; }
.media img { cursor: zoom-in; }
.media iframe { display: block; width: 100%; height: 62vh; border: 0; background: #fff; }
.media--audio { min-height: 0; }
.media-fail { margin: 0; padding: 36px 22px; text-align: center; font-size: 13px; color: var(--faint); line-height: 1.5; }

.shimmer, .skel {
  background:
    linear-gradient(100deg, transparent 20%, var(--sh) 40%, transparent 60%) 0 0 / 220% 100%,
    var(--panel2);
  animation: sh 1.5s linear infinite;
}
.shimmer { position: absolute; inset: 0; }
.skel { border-radius: 24px; border: 1px solid var(--line); }
.skel-hero { height: 340px; }
.skel-row { height: 76px; border-radius: 20px; margin-bottom: 10px; }
@keyframes sh { to { background-position: -220% 0, 0 0; } }

.hint { margin: 18px 0 0; text-align: center; font-size: 12.5px; color: var(--faint); min-height: 18px; opacity: 0; transition: opacity .35s; }
.hint.on { opacity: 1; }

/* ───────── botones ───────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 54px; padding: 0 20px; border-radius: 17px; border: 1px solid transparent;
  font: 600 15px var(--sans); color: inherit; text-decoration: none; cursor: pointer;
  transition: transform .12s, opacity .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 19px; height: 19px; flex: none; }
.btn-primary { flex: 1; background: var(--red); color: var(--on-red); box-shadow: 0 10px 30px rgba(232, 96, 74, .34); }
.btn-primary:hover { background: #EE6D57; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: var(--panel); border-color: var(--line2); color: var(--text); }
.btn-icon { width: 54px; padding: 0; flex: none; }
.btn-block { width: 100%; }
.btn.busy { opacity: .78; pointer-events: none; }
.btn-sub { font-weight: 500; font-size: 12.5px; opacity: .72; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 26px 18px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 58%, transparent);
}
.dock-in { max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ───────── estados (error, vacío, landing) ───────── */

.state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 24px 8px 70px;
}
.state-ic {
  width: 80px; height: 80px; border-radius: 26px; display: grid; place-items: center;
  background: var(--c-soft); border: 1px solid var(--c-line); color: var(--c); box-shadow: 0 0 60px var(--c-soft);
}
.state-ic svg { width: 36px; height: 36px; }
.state h1 { font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; margin: 8px 0 0; }
.state p { margin: 0; max-width: 310px; color: var(--dim); font-size: 14.5px; line-height: 1.55; }
.state .btn { margin-top: 10px; }

/* ───────── puerta de código ───────── */

.gate-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding-bottom: 30px; }
.gate { width: 100%; max-width: 380px; padding: 30px 24px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate .tile.lg { --c: #E8604A; }
.gate h1 { font-family: var(--serif); font-weight: 600; font-size: 24px; letter-spacing: -.01em; margin: 4px 0 0; }
.gate p { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.55; }
.gate form { width: 100%; margin-top: 10px; }
.gate .fine { font-size: 12px; color: var(--faint); margin-top: 6px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); max-width: 100%; overflow-wrap: anywhere; }

.code {
  width: 100%; height: 58px; border-radius: 16px; border: 1px solid var(--line2);
  background: var(--bg); color: var(--text); text-align: center;
  font: 600 22px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .14em;
  margin-bottom: 12px;
}
.code::placeholder { color: var(--faint); font-weight: 500; }
.code:focus { outline: none; border-color: var(--red-line); box-shadow: 0 0 0 4px var(--red-soft); }
.err {
  min-height: 0; margin: -2px 0 12px; font-size: 12.5px; line-height: 1.45; color: #F0A594;
  background: rgba(232, 96, 74, .1); border: 1px solid rgba(232, 96, 74, .28); border-radius: 12px; padding: 0 12px;
  max-height: 0; overflow: hidden; opacity: 0; transition: max-height .2s, opacity .2s, padding .2s;
}
.err:not(:empty) { max-height: 90px; opacity: 1; padding: 10px 12px; }
@media (prefers-color-scheme: light) { .err { color: #B8402B; } }

/* ───────── proyecto ───────── */

.proj-head { display: flex; flex-direction: column; gap: 12px; padding: 0 2px 18px; }
.proj-top { display: flex; gap: 14px; align-items: center; }
.proj-top .file-title { font-size: 26px; }
.desc { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.55; }

.search { position: relative; margin: 0 0 12px; }
.search svg { position: absolute; left: 15px; top: 15px; width: 19px; height: 19px; color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; height: 49px; border-radius: 15px; border: 1px solid var(--line2);
  background: var(--panel); color: var(--text); font: 400 16px var(--sans); padding: 0 14px 0 43px;
}
.search input:focus { outline: none; border-color: var(--red-line); box-shadow: 0 0 0 4px var(--red-soft); }

.filters {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -18px 14px; padding: 2px 18px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 37px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line2); background: var(--panel); color: var(--dim);
  font: 500 13px var(--sans); cursor: pointer;
}
.fchip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.fchip[aria-pressed="true"] { border-color: var(--red-line); background: var(--red-soft); color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 20px; background: var(--panel); border: 1px solid var(--line);
}
.row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  background: none; border: 0; padding: 0; margin: 0; color: inherit; text-align: left; font: inherit; cursor: default;
}
.row-main.clickable { cursor: pointer; }
.row-text { min-width: 0; }
.row-name {
  font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-meta { margin-top: 3px; font-size: 12px; color: var(--faint); }
.row-actions { display: flex; gap: 8px; flex: none; }

.ibtn {
  width: 42px; height: 42px; border-radius: 13px; border: 1px solid var(--line2); background: transparent;
  color: var(--text); display: grid; place-items: center; cursor: pointer; text-decoration: none; padding: 0;
}
.ibtn svg { width: 19px; height: 19px; }
.ibtn.primary { background: var(--red); border-color: transparent; color: var(--on-red); }

.empty { list-style: none; text-align: center; padding: 50px 20px; color: var(--faint); }
.empty svg { width: 34px; height: 34px; }
.empty p { margin: 12px 0 0; font-size: 13.5px; line-height: 1.5; }

/* ───────── reproductor de audio ───────── */

.ap { display: flex; align-items: center; gap: 14px; padding: 16px; width: 100%; }
.ap-btn {
  flex: none; width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--red); color: var(--on-red); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(232, 96, 74, .34);
}
.ap-btn svg { width: 22px; height: 22px; }
.ap-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ap-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 99px; margin: 0; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--c) var(--p, 0%), var(--line2) var(--p, 0%));
}
.ap-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }
.ap-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }
.ap-times { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ───────── lightbox ───────── */

.lb {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  background: rgba(8, 8, 12, .93); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fade .2s ease both;
}
.lb-top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 12px) 14px 12px; }
.lb-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: #F3F1EC; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .ibtn { color: #F3F1EC; border-color: rgba(255, 255, 255, .2); }
.lb-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 14px calc(env(safe-area-inset-bottom) + 18px); }
.lb-body img, .lb-body video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; }
.lb-body iframe { width: 100%; height: 100%; border: 0; border-radius: 12px; background: #fff; }
.lb-audio { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; color: var(--text); }
.lb-fail { color: #A9A7B6; font-size: 14px; }

/* ───────── aviso ───────── */

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); z-index: 200;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 17px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; transition: opacity .22s, transform .22s;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ───────── movimiento ───────── */

.rise { animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; }
.d1 { animation-delay: .05s; }
.d2 { animation-delay: .12s; }
.d3 { animation-delay: .19s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

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

@media (min-width: 700px) {
  .page { padding-top: 40px; }
}
