/* jotas.tv — tema escuro azulado, cor-chave azul claro.
   O vídeo é a estrela: a interface fica quieta, em tons de ardósia,
   e o azul aparece só onde há ação (botões, foco, nomes no chat). */
:root {
  --bg: #0f1318;
  --panel: #151a21;
  --panel-2: #1c232c;
  --line: #27303b;
  --line-strong: #344050;
  --text: #e4e9f0;
  --muted: #8a95a5;
  --accent: #7cc8ff;        /* azul claro */
  --accent-hover: #a6d9ff;
  --accent-ink: #062338;    /* texto sobre o azul */
  --accent-soft: rgba(124, 200, 255, .12);
  --danger: #f2555a;
  --live: #ff4d58;
  --ok: #4fd69c;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.015em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); }
h4 { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ---------- topo e logo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  flex: none;
}
.logo {
  display: inline-flex; align-items: baseline;
  font-size: 21px; font-weight: 700; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; line-height: 1;
}
/* "jotas" desenhado com traço único arredondado (3px, pontas redondas).
   O pingo do j é o único toque de azul. O ".tv" fica em texto normal. */
.logo-word {
  width: 53px; height: 22px; flex: none;
  position: relative; top: 5px; /* a linha de base do desenho (y=16) encosta na do texto */
  overflow: visible;
}
.logo-stroke { fill: none; stroke: var(--text); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.logo-dot { fill: var(--accent); }
.logo-tld { margin-left: 0; }
.logo-tld { color: var(--muted); font-weight: 600; letter-spacing: 0; }
.logo:hover .logo-tld { color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.me { font-weight: 600; margin-right: 4px; }
.traffic { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.traffic.warn { color: #ffd27a; border-color: #5c4a1e; }

/* ---------- controles ---------- */
button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background-color .12s, border-color .12s, color .12s;
}
button:hover { border-color: var(--line-strong); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: transparent; border-color: #5a2428; color: #ff9a9d; }
button.danger:hover { background: #2a1518; }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.small { padding: 5px 10px; font-size: 13px; }
button.sharing { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 650; }
button.sharing:hover { background: #ff6d72; }
.icon-btn { padding: 5px; border-color: transparent; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; min-width: 0;
}
input::placeholder { color: #5f6a79; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); cursor: pointer; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row input { flex: 1; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.error { color: #ff9a9d; min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.notice { margin: 0; padding: 8px 12px; background: #2a2414; color: #ffd27a; border-radius: var(--r-md); font-size: 13px; }

/* ---------- login ---------- */
.view { flex: 1; min-height: 0; }
.view.center { display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(380px, 100%); }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; background: var(--bg); padding: 4px; border-radius: var(--r-md); }
.tab { flex: 1; background: transparent; border: none; color: var(--muted); border-radius: var(--r-sm); }
.tab.active { background: var(--panel-2); color: var(--text); }

/* ---------- salas ---------- */
.lobby { max-width: 760px; margin: 0 auto; padding: 32px 18px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.rooms { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rooms li a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line);
  color: var(--text); text-decoration: none;
}
.rooms li a:hover { border-color: var(--accent); }
.room-name { font-weight: 650; }
.room-meta { color: var(--muted); font-size: 13px; text-align: right; }
.live {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 10px;
  color: var(--live); font-weight: 650; font-size: 13px;
}
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live); }

/* ---------- sala ---------- */
.room { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.room.chat-hidden { grid-template-columns: minmax(0, 1fr); }
.room.chat-hidden .side { display: none; }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px; gap: 10px; }
.stage-bar { display: flex; align-items: center; gap: 12px; min-height: 32px; }
.conn { font-size: 12px; color: var(--muted); }
.conn.ok { color: var(--ok); }
.chat-toggle[aria-pressed="false"] { color: var(--muted); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
}

.screens-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.screens {
  flex: 1; min-height: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); grid-auto-rows: minmax(220px, 1fr);
  overflow-y: auto;
}
.screens.focus { grid-template-columns: 1fr; }
.screens.focus .tile:not(.focused) { display: none; }
.empty-stage {
  display: grid; place-content: center; text-align: center; gap: 2px; border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg); grid-column: 1 / -1;
}
.empty-stage p { margin: 0; }

.tile {
  position: relative; background: #000; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line); min-height: 200px;
}
.tile .media { position: absolute; inset: 0; display: flex; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile:fullscreen { border: none; border-radius: 0; }
.no-share .share-only { display: none !important; }
.tile-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px;
  padding: 26px 10px 10px; background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-bar, .tile:focus-within .tile-bar { opacity: 1; }
.tile-name { font-weight: 650; font-size: 14px; text-shadow: 0 1px 2px #000; }
.tile-bar .spacer { flex: 1; }
.tile-bar input[type=range] { width: 110px; padding: 0; accent-color: var(--accent); }
.tile-bar button { background: rgba(15, 19, 24, .72); border-color: rgba(255, 255, 255, .12); }
.tile-bar button:hover { background: rgba(28, 35, 44, .9); }
.tile-bar .icon-btn { padding: 6px; }
.tile.idle { background: var(--panel); }
.tile.idle .media { display: none; }
.tile.idle .tile-ui {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: 12px; text-align: center; padding: 16px;
}
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* mensagens sobre o vídeo (quando o chat está oculto ou em tela cheia) */
.chat-overlay {
  position: absolute; right: 18px; bottom: 64px; z-index: 5;
  width: min(380px, calc(100% - 36px));
  list-style: none; margin: 0; padding: 0;
  display: none; flex-direction: column; gap: 6px; align-items: flex-end;
  pointer-events: none;
}
.chat-overlay.active { display: flex; }
.chat-overlay li {
  max-width: 100%; text-align: right; font-size: 15px; line-height: 1.35;
  color: #fff; overflow-wrap: anywhere;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .95), 0 0 10px rgba(0, 0, 0, .75);
  transition: opacity .4s, transform .4s;
  animation: overlay-in .2s ease-out;
}
.chat-overlay li.out { opacity: 0; transform: translateY(-4px); }
.chat-overlay .who { font-weight: 700; color: var(--accent); margin-right: 6px; }
@keyframes overlay-in { from { opacity: 0; transform: translateY(6px); } }
.tile:fullscreen .chat-overlay { bottom: 72px; right: 28px; font-size: 17px; }

.controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.controls .ctl { font-size: 12px; }
.controls .ctl.check { padding-bottom: 9px; font-size: 13px; }

.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.people { padding: 14px; border-bottom: 1px solid var(--line); }
.people ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.people li { display: flex; align-items: center; gap: 8px; }
.count { color: var(--muted); font-weight: 400; margin-left: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 10px 14px 14px; gap: 8px; }
#chat-log { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#chat-log li { overflow-wrap: anywhere; font-size: 14px; }
#chat-log .who { font-weight: 650; color: var(--accent); margin-right: 6px; }
#chat-log .sys { color: var(--muted); font-size: 12px; }

/* ---------- modais ---------- */
dialog { color: var(--text); width: min(420px, calc(100% - 32px)); }
dialog.wide { width: min(620px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(5, 8, 12, .65); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--bg); border-radius: var(--r-sm); font-size: 14px; }
.list code { font-size: 12px; color: var(--muted); }
.invite-box { background: var(--bg); padding: 12px; border-radius: var(--r-md); }

@media (max-width: 900px) {
  /* no celular a sala vira uma página que rola: telas em 16:9, chat embaixo */
  .room, .room.chat-hidden { display: block; overflow-y: auto; }
  .stage { min-height: 0; }
  .screens-wrap { flex: none; }
  .screens { grid-template-columns: 1fr; grid-auto-rows: auto; overflow: visible; }
  .tile { aspect-ratio: 16 / 9; min-height: 0; }
  .tile.idle { aspect-ratio: auto; min-height: 140px; }
  .empty-stage { padding: 40px 16px; }
  .side { border-left: none; border-top: 1px solid var(--line); min-height: 320px; }
  .tile-bar { opacity: 1; }
  .focus-btn { display: none; }
  .topbar-right .traffic, .topbar-right .me { display: none; }
  .stage-bar #overlay-option { display: none; }
}

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