:root {
  --bg: #0a0910; --bg2: #13121b; --line: #2a2835; --text: #f3f1f7; --muted: #9b97a8;
  --pink: #ff3d6e; --purple: #7c4dff; --green: #3ddc84; --red: #ff5a5a;
  --grad: linear-gradient(90deg, rgba(255,61,110,.18), rgba(124,77,255,.18));
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: Poppins, system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

/* ---------- genéricos ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 24px 16px calc(40px + var(--safe-b)); }
.logo { font-size: 30px; font-weight: 700; margin: 8px 0 4px; }
.logo span { background: linear-gradient(90deg, var(--pink), var(--purple)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); margin: 0 0 24px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 17px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.input { flex: 1; min-width: 0; background: #1b1a24; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; outline: none; }
.input:focus { border-color: var(--purple); }
.btn { border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 600;
  background: linear-gradient(90deg, var(--pink), var(--purple)); }
.btn.ghost { background: #1f1d29; border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- sala ---------- */
.room { display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; flex-wrap: wrap; background: #0e0d14; }
.room-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; flex: 1; min-width: 90px; }
.room-name .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex: none; }
.icon-btn { height: 46px; min-width: 46px; border-radius: 23px; background: transparent; border: 1.5px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; font-size: 18px; }
.icon-btn.active { border-color: var(--purple); background: rgba(124,77,255,.15); }
.icon-btn.danger { border-color: var(--red); background: rgba(255,90,90,.15); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }

.player { position: relative; background: #000; width: 100%; aspect-ratio: 16/9; max-height: 60vh; flex: none; overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player video::cue { font-size: 1.05em; background: rgba(0,0,0,.6); }
.controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(transparent 50%, rgba(0,0,0,.75)); transition: opacity .25s; }
.player.idle .controls { opacity: 0; }
.center-btns { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 28px; pointer-events: none; }
.center-btns button { pointer-events: auto; width: 62px; height: 62px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.45); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.center-btns button.big { width: 72px; height: 72px; font-size: 26px; }
.bottom-bar { padding: 0 14px 10px; }
.time-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.seek { width: 100%; accent-color: var(--red); margin: 6px 0 0; height: 24px; }
.bottom-right { display: flex; gap: 8px; }
.mini-btn { background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.2); border-radius: 12px; height: 34px; min-width: 34px; padding: 0 9px; font-size: 14px; }
.empty-player { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; padding: 20px; }
.tap-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 5; }
.floating { position: absolute; bottom: 40px; pointer-events: none; z-index: 4; opacity: 0;
  animation: floatUp 2.4s cubic-bezier(.2,.7,.4,1) forwards; will-change: transform, opacity; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
@keyframes floatUp {
  0% { transform: translate(0, 0) scale(.3) rotate(0); opacity: 0; }
  12% { opacity: 1; transform: translate(calc(var(--dx) * .15), -30px) scale(1.15) rotate(calc(var(--rot) * .3)); }
  60% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--rise) * -1)) scale(.9) rotate(var(--rot)); opacity: 0; } }
.react-tag { position: absolute; bottom: 14px; z-index: 5; pointer-events: none; font-size: 12px; font-weight: 600; background: rgba(0,0,0,.6);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; animation: tagFade 2s ease forwards; }
@keyframes tagFade { 0% { opacity: 0; transform: translateY(6px); } 15%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.player:fullscreen { max-height: none; aspect-ratio: auto; height: 100%; }

.status-line { text-align: center; padding: 10px 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 10px; border-radius: 999px; padding: 9px 18px; border: 1px solid var(--line); background: #15141d; }
.pill.code { border-color: rgba(255,61,110,.45); background: linear-gradient(90deg, rgba(255,61,110,.15), rgba(124,77,255,.15));
  font-weight: 700; letter-spacing: 5px; font-size: 20px; }
.pill.code b { color: var(--pink); letter-spacing: 0; }
.pill.vis { color: var(--green); border-color: rgba(61,220,132,.45); background: rgba(61,220,132,.08); font-weight: 600; }
.pill.vis.private { color: #ffb84d; border-color: rgba(255,184,77,.45); background: rgba(255,184,77,.08); }
.link-line { color: var(--muted); font-size: 14px; text-decoration: underline; cursor: pointer; word-break: break-all; }
.now-title { font-weight: 600; font-size: 15px; }

.chat { flex: 1; overflow-y: auto; padding: 8px 14px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.msg { max-width: 85%; align-self: flex-start; background: #1b1a24; border-radius: 16px 16px 16px 4px; padding: 8px 12px; font-size: 15px; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: linear-gradient(90deg, rgba(255,61,110,.35), rgba(124,77,255,.35)); border-radius: 16px 16px 4px 16px; }
.msg .who { font-size: 12px; color: var(--pink); font-weight: 600; }
.msg.me .who { color: #ffc2d4; }
.msg .who span { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 4px; }
.msg.only-media { background: transparent !important; padding: 0; }
.msg.only-media .who { padding: 0 4px 2px; }
.chat-media { display: block; max-width: 220px; max-height: 240px; width: auto; border-radius: 14px; margin-top: 4px; }
.chat-media.sticker { max-width: 140px; max-height: 140px; border-radius: 0; }
.msg .txt { margin-top: 2px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 13px; padding: 2px; }

.reactions { display: flex; justify-content: space-around; margin: 6px 12px; padding: 10px; border-radius: 26px;
  background: var(--grad); border: 1px solid rgba(255,61,110,.35); }
.reactions button { background: none; border: 0; font-size: 30px; transition: transform .1s; }
.reactions button:active { transform: scale(1.3); }
.reactions .more { font-size: 22px; color: var(--muted); width: 40px; height: 40px; border: 1.5px dashed rgba(255,255,255,.25) !important; border-radius: 50%; align-self: center; }
.composer { display: flex; gap: 10px; padding: 6px 12px calc(12px + var(--safe-b)); }
.input-wrap { flex: 1; position: relative; display: flex; min-width: 0; }
.composer .input { border-radius: 26px; padding: 14px 64px 14px 18px; width: 100%; }
.gif-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: #3a3846; border: 0; border-radius: 8px;
  font-size: 12px; font-weight: 700; padding: 6px 8px; color: #ddd; }
.send { width: 54px; height: 54px; border-radius: 18px; border: 1px solid var(--line); background: #1b1a24; font-size: 22px; flex: none; }

/* ---------- panel lateral / modal ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg2); width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto; border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(24px + var(--safe-b)); border: 1px solid var(--line); border-bottom: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 9px; border-radius: 12px; border: 1px solid var(--line); background: transparent; }
.tabs button.on { background: rgba(124,77,255,.2); border-color: var(--purple); }
.series-title { font-weight: 700; margin: 14px 0 4px; color: var(--pink); }
.season-title { font-size: 13px; color: var(--muted); margin: 8px 0 2px; }
.progress { height: 6px; background: #2a2835; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); width: 0; transition: width .2s; }

#toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: #24222f; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 14px; font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; }

@media (min-width: 900px) {
  .room { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .room-left { display: flex; flex-direction: column; overflow-y: auto; }
  .player { max-height: none; }
  .room-right { display: flex; flex-direction: column; border-left: 1px solid var(--line); min-height: 0; }
}
@media (max-width: 899px) { .room-left, .room-right { display: contents; } }

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stats b { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 13px; }
.stats .wide { grid-column: 1 / -1; }
details.vid { border-top: 1px solid var(--line); }
details.vid summary { display: flex; gap: 10px; justify-content: space-between; padding: 12px 2px; cursor: pointer; list-style: none; }
details.vid summary::-webkit-details-marker { display: none; }
details.vid[open] summary { color: var(--pink); }
.edit { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 16px; }
.edit label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }
.subs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { background: rgba(124,77,255,.18); border: 1px solid var(--purple); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.chip button { background: none; border: 0; color: var(--muted); }
.upl { margin-bottom: 10px; font-size: 14px; }
a.btn { text-decoration: none; display: inline-block; }
.logo small { font-size: 14px; font-weight: 500; }

/* ---------- selectores ---------- */
.bar-edit { display: flex; gap: 8px; margin-top: 8px; }
.bar-edit button { flex: 1; font-size: 28px; padding: 8px 0; border-radius: 14px; background: #1b1a24; border: 1.5px solid var(--line); }
.bar-edit button.sel { border-color: var(--pink); background: rgba(255,61,110,.15); }
.bar-edit .reset { flex: .6; font-size: 20px; color: var(--muted); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; }
.emoji-grid button { font-size: 28px; background: none; border: 0; padding: 6px 0; border-radius: 10px; }
.emoji-grid button:active { background: #24222f; transform: scale(1.2); }
.media-grid { columns: 3 110px; column-gap: 6px; min-height: 200px; }
.media-grid img { width: 100%; display: block; margin-bottom: 6px; border-radius: 10px; background: #1b1a24; cursor: pointer; break-inside: avoid; }
.upload-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 110px; margin-bottom: 6px;
  border: 1.5px dashed var(--line); border-radius: 10px; font-size: 26px; cursor: pointer; break-inside: avoid; }
.upload-tile span { font-size: 12px; color: var(--muted); }
.giphy-credit { column-span: all; text-align: center; color: var(--muted); font-size: 11px; padding: 8px; }
.sticker-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; margin-top: 10px; }
.sticker-admin div { position: relative; background: #1b1a24; border-radius: 10px; padding: 6px; }
.sticker-admin img { width: 100%; height: 70px; object-fit: contain; }
.sticker-admin button { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.7); border: 0; border-radius: 50%; width: 22px; height: 22px; font-size: 11px; }
