:root {
  --bg: #0b0b10;
  --bg-2: #111118;
  --glass: rgba(30, 30, 38, 0.62);
  --glass-strong: rgba(24, 24, 32, 0.9);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f4f4f6;
  --muted: #9b9ba8;
  --faint: #6b6b78;
  --accent: #8b5cf6;
  --accent-2: #a855f7;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --ok: #22c55e;
  --warn: #f5b942;
  --err: #f0526a;
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.23, 1, .32, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(900px 500px at 15% -10%, rgba(124, 58, 237, .18), transparent 60%),
              radial-gradient(700px 400px at 100% 0%, rgba(168, 85, 247, .10), transparent 60%);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
img, video { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
#app { position: relative; z-index: 1; }
.topbar {
  position: sticky; top: 0; z-index: 20; padding: calc(12px + var(--safe-t)) 20px 12px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(to bottom, rgba(11, 11, 16, .92), rgba(11, 11, 16, .75));
  backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .08em; font-size: 16px; }
.brand-dot { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #7c3aed, #c084fc); display: grid; place-items: center; box-shadow: 0 6px 20px rgba(124, 58, 237, .45); }
.brand-dot svg { width: 15px; height: 15px; }
.topbar .spacer { flex: 1; }
.page { padding: 18px 20px calc(120px + var(--safe-b)); max-width: 1500px; margin: 0 auto; }
.page-title { font-size: 26px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin: 0 0 18px; }

/* ---------- Chips / segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); color: #d9d9e0; font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .2s, color .2s, transform .15s var(--ease);
}
.chip:hover { background: rgba(255, 255, 255, .1); }
.chip:active { transform: scale(.96); }
.chip.on { background: #fff; color: #0b0b10; border-color: #fff; }
.chip.dashed { border-style: dashed; color: var(--muted); background: transparent; }
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

.seg { display: flex; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 650; font-size: 14px; transition: all .2s var(--ease); }
.seg button.on { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }

/* ---------- Buttons ---------- */
.btn {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px;
  border-radius: 14px; font-weight: 700; background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
  transition: transform .15s var(--ease), background .2s, opacity .2s; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .13); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, #7c3aed, #a855f7); border-color: transparent; box-shadow: 0 8px 28px rgba(124, 58, 237, .35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ffb3bf; background: rgba(240, 82, 106, .12); border-color: rgba(240, 82, 106, .25); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; padding: 15px; font-size: 16px; border-radius: 18px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); }
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Reel grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  position: relative; aspect-ratio: 9 / 16; border-radius: var(--radius); overflow: hidden; background: #16161d;
  border: 1px solid var(--line); cursor: pointer; transition: transform .25s var(--ease), box-shadow .25s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.card img, .card video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .shade { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0, 0, 0, .45) 0%, transparent 22%, transparent 60%, rgba(0, 0, 0, .8) 100%); pointer-events: none; }
.card .top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; align-items: center; }
.card .bottom { position: absolute; bottom: 10px; left: 12px; right: 12px; }
.card .author { font-weight: 750; font-size: 14px; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: flex; gap: 10px; align-items: center; margin-top: 6px; font-size: 12px; font-weight: 650; color: #e6e6ea; }
.stats span { display: inline-flex; align-items: center; gap: 4px; }
.stats svg.i { width: 13px; height: 13px; }
.stats .dur { margin-left: auto; }
.badge { white-space: nowrap; padding: 4px 8px; border-radius: 8px; font-size: 11.5px; font-weight: 700; background: rgba(0, 0, 0, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.badge.accent { background: rgba(139, 92, 246, .85); }
.badge.ok { background: rgba(34, 197, 94, .85); color: #04110a; }
.badge.err { background: rgba(240, 82, 106, .9); }
.plat { margin-left: auto; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: rgba(0, 0, 0, .5); }
.plat svg { width: 15px; height: 15px; }
.card.pending { display: grid; place-items: center; text-align: center; padding: 18px; cursor: default; background: linear-gradient(160deg, #1a1a24, #111118); }
.card.pending .msg { color: var(--muted); font-size: 13px; line-height: 1.4; }
.card.pending .url { font-size: 11px; color: var(--faint); word-break: break-all; margin-top: 8px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--accent-2); animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 70px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty h3 { color: var(--text); margin: 0 0 6px; }

/* ---------- Dock ---------- */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); z-index: 30;
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 26px;
  background: var(--glass); border: 1px solid var(--line-2);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.dock a { text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 74px; padding: 8px 0 6px; border-radius: 20px; color: var(--muted); font-size: 11px; font-weight: 650; transition: all .2s var(--ease); }
.dock a svg.i { width: 21px; height: 21px; }
.dock a.on { color: #fff; background: rgba(255, 255, 255, .1); }
.dock .plus { width: 58px; height: 46px; border-radius: 18px; margin: 0 6px; display: grid; place-items: center; background: #fff; color: #0b0b10; box-shadow: 0 0 0 6px rgba(139, 92, 246, .18), 0 10px 30px rgba(139, 92, 246, .45); transition: transform .2s var(--ease); }
.dock .plus:active { transform: scale(.94); }
.dock .plus svg.i { width: 24px; height: 24px; stroke-width: 2.4; }

/* ---------- Sheets (modales) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .2s ease; display: flex; align-items: flex-end; justify-content: center; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--glass-strong); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5); animation: up .35s var(--ease);
}
.sheet.wide { max-width: 880px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 760px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 26px; border-bottom: 1px solid var(--line-2); margin: 20px; }
  .backdrop.side { justify-content: flex-end; align-items: stretch; }
  .backdrop.side .sheet { max-height: none; height: calc(100dvh - 24px); margin: 12px; max-width: 480px; animation: side .35s var(--ease); }
  @keyframes side { from { transform: translateX(40px); opacity: 0; } }
}
.grabber { width: 42px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .2); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin: 0 -18px 14px; position: sticky; top: -10px; z-index: 5; padding: 8px 18px; background: rgba(23, 23, 30, .97); border-bottom: 1px solid transparent; }
.sheet-head h2 { flex: 1; text-align: center; margin: 0; font-size: 18px; font-weight: 800; }
.sheet-head .icon-btn { width: 34px; height: 34px; border-radius: 50%; }
.sheet-head .back { color: #c4b5fd; font-weight: 700; display: flex; align-items: center; gap: 2px; }

.section-label { font-size: 12px; letter-spacing: .08em; font-weight: 800; color: var(--muted); margin: 18px 4px 8px; text-transform: uppercase; }
.panel { background: rgba(255, 255, 255, .045); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel + .hint, .hint { color: var(--faint); font-size: 12.5px; margin: 7px 4px 0; line-height: 1.45; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row + .row { margin-top: 12px; }
.divider { height: 1px; background: var(--line); margin: 12px -14px; }
.row-title { font-weight: 650; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* Toggle */
.toggle { position: relative; width: 52px; height: 31px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, .14); transition: background .25s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .3s cubic-bezier(.3, 1.35, .45, 1); }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(21px); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 650; }
.input, textarea.input, select.input {
  width: 100%; padding: 12px 14px; border-radius: 14px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line-2);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: rgba(168, 85, 247, .7); box-shadow: 0 0 0 4px rgba(139, 92, 246, .15); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.45; }
.counter { text-align: right; font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }

/* Dropzone / archivo */
.drop { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; border: 1px dashed var(--line-2); background: rgba(0, 0, 0, .25); cursor: pointer; transition: border-color .2s, background .2s; }
.drop:hover, .drop.drag { border-color: rgba(168, 85, 247, .7); background: rgba(139, 92, 246, .08); }
.drop .thumb { width: 58px; height: 58px; border-radius: 12px; background: rgba(255, 255, 255, .06); display: grid; place-items: center; overflow: hidden; flex: none; }
.drop .thumb img { width: 100%; height: 100%; object-fit: cover; }
.drop .meta { flex: 1; min-width: 0; }
.drop .meta b { display: block; font-size: 14px; }
.drop .meta small { color: var(--muted); }
.drop input { display: none; }

/* Avatares */
.avatar-pick { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
.avatar-pick button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 650; color: var(--muted); flex: none; width: 70px; }
.avatar-pick img, .avatar-pick .ph { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; border: 2px solid transparent; background: rgba(255, 255, 255, .06); display: grid; place-items: center; }
.avatar-pick button.on { color: #fff; }
.avatar-pick button.on img { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(168, 85, 247, .22); }
.traits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.traits span { font-size: 12px; padding: 5px 9px; border-radius: 9px; background: rgba(255, 255, 255, .06); color: #d6d6de; }
.traits span b { color: var(--muted); font-weight: 600; }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.a-card { display: flex; gap: 14px; padding: 14px; border-radius: var(--radius); background: rgba(255, 255, 255, .045); border: 1px solid var(--line); }
.a-card img.face { width: 78px; height: 78px; border-radius: 16px; object-fit: cover; flex: none; }
.a-card .body { flex: 1; min-width: 0; }
.a-card h3 { margin: 2px 0 6px; font-size: 17px; }
.a-card .actions { display: flex; gap: 6px; margin-top: 10px; }

/* Clones */
.c-card .status { position: absolute; left: 10px; right: 10px; bottom: 10px; }
.progress { height: 4px; border-radius: 9px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #7c3aed, #c084fc); width: 30%; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.c-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Viewer */
.viewer { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 18px; }
.viewer video { width: 100%; aspect-ratio: 9 / 16; object-fit: contain; background: #000; border-radius: var(--radius); }
.viewer .info h3 { margin: 0 0 4px; font-size: 20px; }
.viewer .caption { color: var(--muted); font-size: 13.5px; line-height: 1.5; max-height: 140px; overflow: auto; margin: 10px 0; white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (max-width: 759px) { .viewer { grid-template-columns: 1fr; } .viewer video { max-height: 62dvh; } }

textarea.prompt-box { min-height: 46dvh; }
.prompt-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; min-height: 260px; }
.refs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.refs span { font-size: 12px; padding: 5px 9px; border-radius: 9px; background: var(--accent-soft); color: #d8c8ff; font-weight: 650; }

.provider { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.provider button { padding: 14px 10px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 750; }
.provider button small { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.provider button.on { border-color: rgba(168, 85, 247, .8); background: rgba(139, 92, 246, .12); box-shadow: 0 0 0 3px rgba(139, 92, 246, .15); }
.provider button:disabled { opacity: .45; cursor: not-allowed; }
.logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 900; font-size: 15px; }

/* Ajustes */
.key-row { display: flex; align-items: center; gap: 12px; }
.key-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); margin-left: auto; }
.key-row .dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(34, 197, 94, .7); }
.settings { max-width: 640px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 380px; padding: 28px 22px; border-radius: 26px; background: var(--glass); border: 1px solid var(--line-2); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.login .brand { justify-content: center; font-size: 22px; margin-bottom: 6px; }
.login .brand-dot { width: 34px; height: 34px; border-radius: 11px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 22px; }

/* Toasts */
#toasts { position: fixed; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 16px; background: rgba(28, 28, 36, .95); border: 1px solid var(--line-2); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); font-weight: 600; font-size: 14px; animation: drop .35s var(--ease); pointer-events: auto; }
.toast.err { border-color: rgba(240, 82, 106, .5); }
.toast.ok { border-color: rgba(34, 197, 94, .45); }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

@media (max-width: 600px) {
  .topbar { padding: calc(10px + var(--safe-t)) 14px 10px; }
  .page { padding: 14px 12px calc(110px + var(--safe-b)); }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .card { border-radius: 14px; }
  .card .author { font-size: 12.5px; }
  .stats { gap: 7px; font-size: 11px; }
  .dock a { width: 60px; font-size: 10.5px; }
  .dock .plus { width: 52px; margin: 0 3px; }
  .page-title { font-size: 22px; }
  .topbar .add-txt { display: none; }
}
@media (hover: none) { .card:hover { transform: none; box-shadow: none; } }
