/* JanjaShare: estilos do app. Base visual vem do mockup aprovado (tema escuro/claro automático). */
:root {
  --bg: #0f1320;
  --surface: #171c2c;
  --surface-2: #20263a;
  --line: #2c3450;
  --fg: #e9ecf5;
  --muted: #8e97b1;
  --accent: #f5b83d;
  --accent-ink: #1d1505;
  --accent-text: #f5b83d;
  --live: #ff4d5e;
  --ok: #46d39a;
  --stage: #05070d;
  --shadow: 0 18px 40px -18px rgba(0,0,0,.6);
  --font-display: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f3f8; --surface: #ffffff; --surface-2: #eceef6; --line: #d8dbe8;
    --fg: #141a2b; --muted: #59617e; --accent: #f2ad2a; --accent-ink: #1d1505;
    --accent-text: #8f5d00; --live: #df2a3c; --ok: #0f8a58; --stage: #0b0e17;
    --shadow: 0 18px 40px -22px rgba(20,26,43,.35); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f3f8; --surface: #ffffff; --surface-2: #eceef6; --line: #d8dbe8;
  --fg: #141a2b; --muted: #59617e; --accent: #f2ad2a; --accent-ink: #1d1505;
  --accent-text: #8f5d00; --live: #df2a3c; --ok: #0f8a58; --stage: #0b0e17;
  --shadow: 0 18px 40px -22px rgba(20,26,43,.35); color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; text-wrap: balance; }
p { margin: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 8px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -.01em; color: var(--fg); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }

main { padding-inline: 16px; padding-block: 28px 48px; max-width: 1240px; margin: 0 auto; }
main:focus { outline: none; }
.screen { display: grid; gap: 22px; min-width: 0; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn-danger:hover { border-color: var(--live); filter: brightness(1.06); }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn-discord:hover { filter: brightness(1.08); border-color: #5865f2; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.icon-btn { padding: 10px; }
.icon-btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.icon-btn.off { color: var(--live); }

label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font-size: 15px; min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select.input { appearance: auto; }
.field-hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.note { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--accent-text); }
.note > span { min-width: 0; }

.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--muted); font-size: 14px; }
.banner.error { border-left-color: var(--live); }
.banner.ok { border-left-color: var(--ok); }
.banner > span { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }

.loading { display: flex; align-items: center; gap: 10px; padding: 24px 0; }
.loading::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { display: grid; gap: 12px; justify-items: start; padding: 28px; border: 1.5px dashed var(--line); border-radius: var(--radius); }
.empty h2 { font-size: 20px; }

/* ---------- Início ---------- */
.hero { display: grid; gap: 16px; padding-block: 18px 6px; max-width: 760px; }
.hero h1 { font-size: clamp(34px, 6vw, 58px); font-weight: 800; letter-spacing: -.025em; }
.hero h1 em { font-style: normal; color: var(--accent-text); }
.hero p { font-size: 18px; color: var(--muted); max-width: 58ch; }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.hero-cta small { font-size: 13px; color: var(--muted); max-width: 40ch; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; gap: 4px; padding-top: 14px; border-top: 1px solid var(--line); }
.steps li::before { content: "Passo " counter(s); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.steps strong { font-size: 16px; }

/* ---------- Cabeçalho de tela ---------- */
.roombar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.roombar h1 { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; letter-spacing: -.015em; overflow-wrap: anywhere; }
.roombar > h1 { margin-right: auto; }
.room-head { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.room-head > div { min-width: 0; }
.lock { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.lock svg { width: 14px; height: 14px; flex: none; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; min-width: 0; }
.user-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24ch; }

/* ---------- Avatares e ícones de servidor ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #141a2b; flex: none; overflow: hidden; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.user-chip .avatar { width: 28px; height: 28px; font-size: 12px; }
.gicon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 17px; color: #141a2b; flex: none; overflow: hidden; }
.gicon.sm { width: 42px; height: 42px; border-radius: 13px; font-size: 15px; }
.avatar img, .gicon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-init, .av-img { grid-area: 1 / 1; }
.av-img { opacity: 0; }
.av-img.ok { opacity: 1; }

/* ---------- Servidores ---------- */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; }
.server { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 2px 14px; align-items: center; text-align: left; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); align-content: start; }
.server .gicon { grid-row: span 2; }
.server b { font-size: 16px; overflow-wrap: anywhere; }
.server > span:not(.gicon) { font-size: 13px; color: var(--muted); }
.server-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.server.no-bot { border-style: dashed; background: transparent; }
.server-foot .btn { padding: 7px 12px; font-size: 13px; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.host { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-text); }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.bad { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--live); }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live); }

/* ---------- Sala ---------- */
.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.col { display: grid; gap: 14px; min-width: 0; align-content: start; }
.streams { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.stream-card { display: grid; gap: 12px; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; align-content: start; min-width: 0; }
.stream-card:hover { border-color: var(--accent); }
.stream-card .stage-wrap { border-radius: 0; box-shadow: none; display: grid; place-items: center; }
.stream-card .meta { display: flex; align-items: center; gap: 10px; padding: 0 14px 14px; flex-wrap: wrap; }
.stream-card .meta > div { min-width: 0; flex: 1 1 120px; }
.stream-card .meta b { display: block; font-size: 14.5px; overflow-wrap: anywhere; }
.stream-card .meta span { font-size: 12.5px; color: var(--muted); }
.share-card { display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; padding: 24px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: transparent; color: var(--muted); min-height: 220px; font: inherit; }
.share-card:hover:not([disabled]) { border-color: var(--accent); color: var(--fg); }
.share-card[disabled] { cursor: not-allowed; opacity: .7; }
.share-card svg { width: 34px; height: 34px; color: var(--accent-text); }
.share-card b { color: var(--fg); font-size: 16px; }
.share-card span { font-size: 13px; max-width: 34ch; }
.person { display: flex; align-items: center; gap: 10px; padding-block: 8px; }
.person > div { min-width: 0; flex: 1; }
.person b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person span { font-size: 12.5px; color: var(--muted); }
.person .live-dot { font-size: 12px; }

/* ---------- Palco (vídeo) ---------- */
.stage-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--stage); aspect-ratio: 16/9; max-width: 100%; box-shadow: var(--shadow); }
.stage-wrap video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--stage); }
.stage-wrap:fullscreen { aspect-ratio: auto; border-radius: 0; width: 100%; height: 100%; }
.stage-wrap:-webkit-full-screen { aspect-ratio: auto; border-radius: 0; width: 100%; height: 100%; }
.stage-badges { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; background: rgba(5,7,13,.72); color: #e9ecf5; backdrop-filter: blur(6px); }
.badge.live { background: var(--live); color: #fff; letter-spacing: .06em; }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s steps(2) infinite; }
.badge.right { margin-left: auto; }
@keyframes blink { 50% { opacity: .2; } }
.paused-cover { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5,7,13,.82); color: #e9ecf5; text-align: center; font-weight: 600; padding: 16px; }
.paused-cover b { display: block; font-family: var(--font-display); font-size: 24px; margin-bottom: 4px; }
.tap-audio { white-space: nowrap; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 18px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.tap-audio svg { width: 18px; height: 18px; }
.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.stage-col { display: grid; gap: 14px; min-width: 0; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.controls .spacer { flex: 1 1 0; }

.overlay-ctl {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 26px 14px 12px; background: linear-gradient(transparent, rgba(5,7,13,.85)); color: #e9ecf5;
}
.overlay-ctl button { background: transparent; border: 0; color: inherit; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.overlay-ctl button:hover { background: rgba(255,255,255,.12); }
.overlay-ctl svg { width: 20px; height: 20px; }
.overlay-ctl input[type="range"] { width: 110px; accent-color: #f5b83d; }
.overlay-ctl select { background: rgba(5,7,13,.6); border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 4px 8px; font-size: 12.5px; color: #e9ecf5; max-width: 100%; }
.overlay-ctl option { color: #141a2b; background: #fff; }
.overlay-ctl .grow { flex: 1 1 0; }
.reactions-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater { position: absolute; bottom: 60px; font-size: 30px; animation: floatUp 2.4s ease-out forwards; }
@keyframes floatUp { from { transform: translateY(0) scale(.7); opacity: 0; } 15% { opacity: 1; transform: translateY(-20px) scale(1); } to { transform: translateY(-260px) scale(1.1); opacity: 0; } }
.react-row { display: flex; flex-wrap: wrap; gap: 6px; }
.react-row button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 18px; line-height: 1; }
.react-row button:hover { border-color: var(--accent); }

/* ---------- Painel lateral (chat / pessoas) ---------- */
.side { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; overflow: hidden; height: 100%; min-height: 420px; max-height: 640px; }
.side-body { display: grid; min-height: 0; overflow: hidden; }
.side-body > .tab-body { min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 13px 10px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--fg); box-shadow: inset 0 -2px 0 var(--accent); }
.tab-body { overflow-y: auto; padding: 14px 16px; min-height: 0; }
.msg { display: grid; gap: 1px; padding-block: 6px; }
.msg b { font-size: 13px; overflow-wrap: anywhere; }
.msg.self b { color: var(--accent-text); }
.msg p { font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.sys p { font-size: 12.5px; color: var(--muted); font-style: italic; }
.chat-empty { font-size: 13.5px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form .input { padding: 9px 12px; font-size: 14px; }

/* ---------- Configurar transmissão / opções ---------- */
.setup { display: grid; gap: 16px; align-content: start; max-width: 640px; }
.opts { display: grid; gap: 16px; align-content: start; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt > div { min-width: 0; }
.opt b { display: block; font-size: 14.5px; }
.opt span { font-size: 13px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px; border: 0; background: var(--line); padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; }
.seg button { flex: 1 1 auto; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface-2); color: var(--fg); box-shadow: 0 1px 0 var(--line); }
.seg-block { display: grid; gap: 8px; }
.seg-block > b { font-size: 14.5px; }
.bot-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.checks { display: grid; gap: 4px; max-height: 280px; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.check { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; font-size: 14px; cursor: pointer; min-width: 0; }
.check:hover { background: var(--surface-2); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.check i { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.check span { overflow-wrap: anywhere; min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Modal e toast ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(5,7,13,.6); }
.modal { max-width: 420px; width: 100%; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal h2 { font-size: 24px; }
.modal p { color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; }

/* ---------- Responsivo ---------- */
@media (max-width: 960px) {
  .live-layout, .room-layout, .bot-layout { grid-template-columns: minmax(0, 1fr); }
  .side { max-height: 520px; min-height: 380px; }
}
@media (max-width: 560px) {
  main { padding-block: 20px 40px; }
  .panel { padding: 16px; }
  .overlay-ctl { padding: 18px 8px 6px; gap: 4px; flex-wrap: nowrap; }
  .overlay-ctl input[type="range"] { width: 70px; }
  .overlay-ctl select { max-width: 112px; }
  .tap-audio { top: 40%; font-size: 13px; padding: 8px 14px; }
  .stage-badges { top: 8px; left: 8px; right: 8px; gap: 5px; }
  .badge { font-size: 10.5px; padding: 3px 7px; }
  .paused-cover { font-size: 13px; padding: 12px; }
  .paused-cover b { font-size: 18px; }
  .controls .btn .lbl { display: none; }
  .user-chip > span:last-child { max-width: 12ch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
