:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2b303b;
  --text: #e8eaef;
  --muted: #9aa1ad;
  --accent: #e5a50a;
  --accent-text: #1a1300;
  --danger: #e5484d;
  --ok: #3fb950;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
h1, h2 { margin: 0 0 12px; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

button, .btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
}
button:hover, .btn:hover { border-color: #3c4250; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.primary:hover { border-color: #f7c548; }
.danger { color: var(--danger); }
.icon-btn { padding: 0; width: 40px; min-width: 40px; }
.icon-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.icon-btn.off { color: var(--danger); }

input[type=text], input[type=password] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px; /* 16px — iOS не зумит */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand svg { color: var(--accent); }

/* загрузка */
.drop {
  display: block; border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px 16px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop.drag, .drop:hover { border-color: var(--accent); background: rgba(229,165,10,.05); }
.drop input { display: none; }
.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-row { margin-top: 14px; }
.upload-row .line { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.upload-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* список фильмов */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .info { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.badge.live { color: var(--ok); }
@media (max-width: 560px) {
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; justify-content: flex-start; }
}
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.badge.err { color: var(--danger); }
.empty { color: var(--muted); padding: 10px 0; }

/* вход */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login .form { margin-top: 4px; }

/* формы, вкладки */
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { margin-top: 6px; }
select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 12px; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.segmented { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented label { flex: 1; text-align: center; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--panel-2); color: var(--text); }
.user-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-box span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.invite-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.invite-row code { background: var(--bg); border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; font-size: 16px; letter-spacing: .05em; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; transition: .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; width: min(460px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.vlc-btn { min-width: 40px; padding: 0 10px; font-weight: 700; font-size: 13px; color: #ff8800; }
#vlcBanner { background: rgba(0,0,0,.92); }
.vlc-now { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.error { color: var(--danger); min-height: 1.4em; }

/* комната */
.room { display: grid; grid-template-columns: 1fr 340px; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
.room-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); min-width: 0; }
.room-head .movie-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.stage { position: relative; background: #000; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.player { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; background: #000; }
.player-host { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.player-host video, .player-host iframe { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; border: 0; }
.placeholder { color: var(--muted); padding: 20px; text-align: center; }
/* Встроенные плееры (YouTube, Rutube, VK): у них свои кнопки, наша панель — под видео, а не поверх */
.player.external { flex-direction: column; }
.player.external .player-host { position: relative; inset: auto; flex: 1; width: 100%; min-height: 0; }
.player.external .controls { align-self: stretch; position: static; background: var(--panel); padding: 8px 12px; border-top: 1px solid var(--border); }
.player.external .native-only { display: none; }
.player:fullscreen { width: 100vw; height: 100vh; }
.player:-webkit-full-screen { width: 100vw; height: 100vh; }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); transition: opacity .25s;
  display: grid; gap: 6px;
}
.player.idle .controls { opacity: 0; pointer-events: none; }
.player.idle { cursor: none; }
.controls .row { display: flex; align-items: center; gap: 8px; }
.controls .spacer { flex: 1; }
.controls button { background: rgba(255,255,255,.08); border-color: transparent; }
.controls .time { font-variant-numeric: tabular-nums; font-size: 13px; color: #ddd; white-space: nowrap; }
.seek { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.seek .track { position: absolute; left: 0; right: 0; height: 5px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.seek .buffered { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.3); }
.seek .played { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.seek .knob { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); transform: translateX(-50%); }
.volume { width: 90px; accent-color: var(--accent); }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: rgba(0,0,0,.7); text-align: center; padding: 20px; z-index: 5; }
.overlay .big { font-size: 18px; padding: 14px 24px; }
.status-pill { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: 6px 12px; border-radius: 99px; font-size: 13px; z-index: 4; pointer-events: none; transition: opacity .3s; white-space: nowrap; }

.reactions-fly { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.reactions-fly span { position: absolute; bottom: 70px; font-size: 34px; animation: fly 2.6s ease-out forwards; text-align: center; }
.reactions-fly small { display: block; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; }
@keyframes fly { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-260px); opacity: 0; } }

.side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--panel); }
.people { padding: 10px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.media-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.tile { appearance: none; padding: 0; color: inherit; font: inherit; cursor: zoom-in; min-height: 0; position: relative; aspect-ratio: 4 / 3; background: var(--panel-2); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; border: 2px solid transparent; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.mirror { transform: scaleX(-1); }

/* увеличенное видео участника */
.spotlight { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; padding: 16px 16px 72px; }
.spotlight video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.spot-avatar { width: 160px; height: 160px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 64px; font-weight: 700; color: var(--muted); }
.spot-bar { position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 8px; }
.spot-bar span:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .avatar { font-size: 22px; font-weight: 700; color: var(--muted); }
.tile .label { position: absolute; left: 4px; right: 4px; bottom: 3px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.tile .mic { position: absolute; top: 3px; right: 5px; font-size: 11px; }

.chat { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.msg { word-wrap: break-word; overflow-wrap: anywhere; }
.msg .who { font-weight: 600; margin-right: 6px; }
.msg .at { font-size: 11px; color: var(--muted); margin-left: 4px; cursor: pointer; }
.msg.system { color: var(--muted); font-size: 12px; text-align: center; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.react-bar { display: flex; gap: 4px; padding: 6px 10px 0; flex-wrap: wrap; }
.react-bar button { min-height: 32px; padding: 2px 8px; font-size: 18px; background: transparent; border-color: transparent; }

@media (max-width: 560px) {
  .hide-sm, #online { display: none; }
}
@media (max-width: 860px) {
  .room { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .stage { aspect-ratio: 16 / 9; max-height: 60vh; }
  .side { border-left: 0; border-top: 1px solid var(--border); }
  .volume { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
