/* fontes servidas pelo próprio site (Fontsource, licença OFL): nenhum pedido sai para o Google */
@font-face { font-family: "Unbounded"; src: url("fonts/unbounded-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 200 800; font-display: swap; }

/* ---------- temas: só cores mudam; layout é o mesmo ---------- */
:root {                       /* claro (padrão) */
  color-scheme: light;
  --bg: #eef0f9;
  --surface: #ffffff;
  --surface-2: #f2f1fc;
  --panel-end: #fbfbff;
  --line: #dddbf0;
  --text: #17143a;
  --muted: #5d5984;
  --accent: #5b47f0;          /* ação / quem envia */
  --accent-hover: #4a36e0;
  --on-accent: #ffffff;
  --ok: #0c9e7c;              /* sucesso / quem recebe */
  --warn: #ffc65c;            /* pedido de entrada */
  --on-warn: #2a1d00;
  --danger: #cf2f53;
  --selected: #ece9ff;
  --chip-bg: #ece9ff;
  --chip-text: #4433c9;
  --chip-ok-bg: #dcf6ef;
  --placeholder: #b9b5d9;
  --mine-who: #dcd6ff;
  --ticket-start: #e7e3ff;
  --glow-1: #d9d3ff;
  --glow-2: #cdeff0;
  --backdrop: rgb(23 20 58 / .55);
  --shadow: 0 10px 30px rgb(23 20 58 / .12);
  --ring: rgb(12 158 124 / .25);
  --dev-a: #5b47f0;           /* arte do topo */
  --dev-b: #0c9e7c;
  --dev-bar: #dcd8f5;
  --packet: #17143a;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15122e;
  --surface: #1c1840;
  --surface-2: #252055;
  --panel-end: #1a1638;
  --line: #332d6b;
  --text: #f3f1ff;
  --muted: #a9a4d0;
  --accent: #8c7cff;
  --accent-hover: #a294ff;
  --on-accent: #120f2a;
  --ok: #4fe3c1;
  --warn: #ffc65c;
  --on-warn: #2a1d00;
  --danger: #ff8aa1;
  --selected: #2a2360;
  --chip-bg: rgb(140 124 255 / .18);
  --chip-text: #c9c1ff;
  --chip-ok-bg: rgb(79 227 193 / .15);
  --placeholder: #403a78;
  --mine-who: #2b2370;
  --ticket-start: #2a2363;
  --glow-1: #2b2370;
  --glow-2: #123c4a;
  --backdrop: rgb(10 8 25 / .75);
  --shadow: 0 10px 30px rgb(0 0 0 / .35);
  --ring: rgb(79 227 193 / .25);
  --dev-a: #8c7cff;
  --dev-b: #4fe3c1;
  --dev-bar: #3a3470;
  --packet: #ffffff;
}
:root {
  --display: "Unbounded", system-ui, sans-serif;
  --body: "Manrope", system-ui, sans-serif;
  --r-lg: 28px;
  --r-md: 16px;
  --gutter: clamp(1rem, 4vw, 3rem);
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--line) transparent; }
body {
  margin: 0; min-height: 100dvh; color: var(--text); font: 500 1rem/1.6 var(--body);
  background:
    radial-gradient(900px 600px at 85% -10%, var(--glow-1) 0%, transparent 60%),
    radial-gradient(700px 500px at -10% 110%, var(--glow-2) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2 { font-family: var(--display); margin: 0; font-weight: 700; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); margin: 0; }
:focus-visible { outline: 3px solid var(--ok); outline-offset: 3px; }

/* áreas com rolagem própria: barra fina na cor do tema, sem "arrastar" a página junto */
.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* barra */
.bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; padding: 1.25rem var(--gutter); max-width: 1240px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font: 700 1.05rem var(--display); color: var(--text); text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.bar-right { display: flex; align-items: center; gap: 1rem; }
.bar-note { margin: 0; color: var(--muted); font-size: .875rem; }
.btn.theme-toggle { width: 42px; height: 42px; padding: 0; flex: none; }
.theme-toggle svg { width: 20px; height: 20px; flex: none; }
.theme-toggle .moon, [data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .7rem 1.15rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s, transform .08s; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.big { padding: .95rem 1.4rem; font-size: 1.05rem; }
.btn.small { padding: .45rem .85rem; font-size: .85rem; }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); padding-inline: 0; justify-self: start; }
.btn.danger:hover { text-decoration: underline; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* início */
.home { max-width: 1240px; margin: 0 auto; padding: clamp(1.5rem, 5vw, 4rem) var(--gutter) 5rem; }
.hero { display: grid; grid-template-columns: 1.25fr 1fr; align-items: center; gap: 2rem; margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.hero h1 { font-size: clamp(2rem, 4.4vw, 3.7rem); line-height: 1.06; letter-spacing: -0.03em; max-width: 17ch; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 46ch; margin: 1.5rem 0 0; }
.link-art { width: 100%; max-width: 460px; justify-self: end; overflow: visible; }
.link-art .stop-a { stop-color: var(--dev-a); }
.link-art .stop-b { stop-color: var(--dev-b); }
.link-art .dev { fill: var(--surface); stroke-width: 2; }
.link-art .dev-a { stroke: var(--dev-a); }
.link-art .dev-b { stroke: var(--dev-b); }
.link-art .bar-a { fill: var(--dev-a); }
.link-art .bar-b { fill: var(--dev-b); }
.link-art .bar-dim { fill: var(--dev-bar); }
.link-art .pk { fill: var(--packet); }
.link-art .pk-a { fill: var(--dev-a); }
.link-art .pk-b { fill: var(--dev-b); }

/* card "Sua última sala": volta rápida depois de recarregar ou sair sem querer */
.last-room { display: grid; gap: .75rem; margin-bottom: 1.25rem; padding: 1.1rem 1.4rem; border-radius: var(--r-lg); background: linear-gradient(120deg, var(--ticket-start), var(--surface) 70%); border: 1px solid var(--accent); box-shadow: var(--shadow); }
.last-room h2 { font-size: 1.05rem; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; max-height: min(320px, 40dvh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.history-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .5rem 1.25rem; padding: .6rem .8rem; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.history-item .muted { font-size: .9rem; }
.last-code { margin: 0; font: 700 1.3rem/1 var(--display); letter-spacing: .16em; }


.actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.25rem; align-items: start; }
.panel { background: linear-gradient(180deg, var(--surface), var(--panel-end)); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(1.4rem, 3vw, 2rem); display: grid; gap: 1.4rem; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.3rem; }
.join { gap: 1rem; }

.choice { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice legend { color: var(--muted); font-size: .9rem; margin-bottom: .7rem; padding: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }

.kind { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.kind span { display: grid; gap: .2rem; height: 100%; padding: .95rem 1rem; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.kind strong { font-size: 1rem; }
.kind small { color: var(--muted); font-size: .85rem; line-height: 1.4; }
.kind input:checked + span { border-color: var(--accent); background: var(--selected); box-shadow: inset 0 0 0 1px var(--accent); }
.kind input:focus-visible + span, .pills input:focus-visible + span { outline: 3px solid var(--ok); outline-offset: 2px; }

.pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.pills span { display: block; padding: .5rem 1rem; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-weight: 600; }
.pills input:checked + span { background: var(--text); border-color: var(--text); color: var(--bg); }

.field { display: grid; gap: .45rem; }
.field label { font-weight: 700; }
.field label .muted { font-weight: 500; }
.text-input { width: 100%; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
.text-input::placeholder { color: var(--muted); }
.text-input:focus { border-color: var(--ok); outline: none; box-shadow: 0 0 0 3px var(--ring); }
.room-title { font-size: 1.2rem; line-height: 1.25; overflow-wrap: anywhere; }
.history-name { font-weight: 700; overflow-wrap: anywhere; }

#join-form { display: grid; gap: .9rem; }
.code-input { font: 700 clamp(1.6rem, 3vw, 2rem) var(--display); letter-spacing: .3em; text-transform: uppercase; text-align: center; padding: .8rem .5rem; border: 1px solid var(--line); border-radius: var(--r-md); width: 100%; background: var(--bg); }
.code-input::placeholder { color: var(--placeholder); }
.code-input:focus { border-color: var(--ok); outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* ---------- sala: chat ocupando a tela, dados da sala ao lado ---------- */
body:not(.is-host) .host-only, body.is-host .guest-only { display: none !important; }
/* na sala a página não rola: só as mensagens e o painel de dados rolam por dentro */
body.in-room { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.in-room .bar { flex: none; padding-block: .8rem; max-width: 1320px; width: 100%; }
.room { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px 1fr; gap: 1rem; padding: 0 var(--gutter) 1rem; max-width: 1320px; width: 100%; margin: 0 auto; }

.info { min-height: 0; background: linear-gradient(160deg, var(--ticket-start), var(--surface) 55%); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.4rem; display: grid; gap: 1.1rem; align-content: start; box-shadow: var(--shadow); }
.info-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.room-title { font-size: 1.1rem; line-height: 1.25; overflow-wrap: anywhere; }
.info-note { font-size: .85rem; line-height: 1.45; }
.info-backdrop { display: none; }
.only-mobile { display: none !important; }

.ticket-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.ticket-label { margin: 0; color: var(--muted); font-size: .9rem; }
.chip { font-size: .8rem; font-weight: 700; padding: .25rem .7rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-text); }
.chip.public { background: var(--chip-ok-bg); color: var(--ok); }

.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
.tiles span { font: 700 1.6rem/1 var(--display); text-align: center; padding: .6rem 0; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; animation: drop .45s cubic-bezier(.2, .9, .3, 1.3) both; }
.tiles span:nth-child(2) { animation-delay: .05s } .tiles span:nth-child(3) { animation-delay: .1s }
.tiles span:nth-child(4) { animation-delay: .15s } .tiles span:nth-child(5) { animation-delay: .2s }
.tiles span:nth-child(6) { animation-delay: .25s }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

.timer-track { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.timer-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); border-radius: 99px; transition: width 1s linear; }
.timer-text { margin: .5rem 0 0; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }

.share { display: grid; gap: .9rem; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; justify-self: start; }
.qr svg { display: block; width: clamp(120px, 20dvh, 150px); height: clamp(120px, 20dvh, 150px); }
.share-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.status { margin: 0; color: var(--text); }

.knocks { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.knocks:empty { display: none; }
.knock { background: var(--warn); color: var(--on-warn); border-radius: var(--r-md); padding: .9rem 1rem; display: grid; gap: .65rem; animation: drop .35s cubic-bezier(.2, .9, .3, 1.3) both; }
.knock p { margin: 0; }
.knock-actions { display: flex; gap: .4rem; }
.knock .btn { background: transparent; color: var(--on-warn); border-color: rgb(42 29 0 / .35); }
.knock .btn.accept { background: var(--on-warn); color: var(--warn); border-color: var(--on-warn); }

/* painel do chat */
.chat-panel { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.chat-header { flex: none; display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--panel-end); }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--selected); color: var(--text); }
.avatar svg { width: 26px; height: 26px; }
.avatar .av-a { fill: var(--accent); } .avatar .av-b { fill: var(--ok); }
.chat-header-text { min-width: 0; }
.chat-header h2 { font-size: 1rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .muted { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-status { flex: none; margin: 0; padding: .55rem 1.1rem; font-size: .88rem; font-weight: 600; background: var(--selected); border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--text); }
.chat-status:empty { display: none; }
.chat-status.warn, .knock-banner { background: var(--warn); color: var(--on-warn); }
.knock-banner { cursor: pointer; font: inherit; font-weight: 700; }

/* mensagens: fundo com trama de pontos, balões à esquerda (outros) e à direita (você) */
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent; list-style: none; margin: 0; padding: 1.1rem clamp(.75rem, 3vw, 1.5rem); display: flex; flex-direction: column; gap: .35rem;
  background: radial-gradient(var(--line) 1px, transparent 1.2px) 0 0 / 22px 22px, var(--bg); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 30ch; padding: 2rem 1rem; display: grid; gap: .6rem; justify-items: center; }
.chat-empty svg { width: 42px; height: 42px; color: var(--accent); }

.msg { position: relative; max-width: min(78%, 520px); align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 18px 18px 18px; padding: .5rem .75rem .35rem; box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.msg.mine { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: var(--on-accent); border-radius: 18px 4px 18px 18px; }
.msg + .msg.same { margin-top: -.15rem; }
.msg p { margin: 0; }
.msg-who { font-size: .78rem; font-weight: 800; color: var(--accent); margin-bottom: .1rem !important; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-time { display: block; text-align: right; font-size: .7rem; color: var(--muted); margin-top: .15rem; font-variant-numeric: tabular-nums; }
.msg.mine .msg-time { color: var(--mine-who); }

/* arquivo dentro do balão */
.file-card { position: relative; display: grid; gap: .45rem; min-width: min(240px, 60vw); overflow: hidden; border-radius: 12px; }
.file-img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; background: var(--bg); }
.file-row { display: flex; align-items: center; gap: .7rem; padding: .45rem .55rem; border-radius: 12px; background: var(--bg); color: var(--text); }
.msg.mine .file-row { background: rgb(255 255 255 / .16); color: inherit; }
.file-icon { flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font: 700 .68rem var(--display); text-transform: lowercase; background: var(--selected); color: var(--accent); }
.msg.mine .file-icon { background: rgb(255 255 255 / .22); color: inherit; }
.file-info { min-width: 0; }
.file-name { font-weight: 700; font-size: .92rem; overflow-wrap: anywhere; }
.file-meta { font-size: .78rem; opacity: .75; }
.file-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.msg.mine .file-actions .btn { background: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .35); color: inherit; }
.msg.mine .file-actions .btn.primary { background: var(--on-accent); color: var(--accent); }
.file-card.gone .file-row { opacity: .6; }
.progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--ok); transition: width .2s; }
.msg.mine .progress { background: var(--on-accent); }

/* barra de digitação */
.composer { flex: none; display: flex; align-items: flex-end; gap: .5rem; padding: .7rem clamp(.6rem, 2vw, 1rem); padding-bottom: max(.7rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel-end); }
.composer textarea { flex: 1; min-width: 0; width: 100%; resize: none; min-height: 46px; max-height: min(140px, 25dvh); padding: .7rem 1rem; border-radius: 23px; border: 1px solid var(--line); background: var(--bg); field-sizing: content; }
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus { border-color: var(--ok); outline: none; box-shadow: 0 0 0 3px var(--ring); }
.composer textarea:disabled { opacity: .5; }
.btn.icon { width: 46px; height: 46px; padding: 0; flex: none; }
.btn.icon svg { width: 21px; height: 21px; }
.attach { cursor: pointer; }
.attach:has(input:disabled) { opacity: .4; cursor: not-allowed; }
.attach:focus-within { outline: 3px solid var(--ok); outline-offset: 2px; }

.drop-overlay { position: absolute; inset: .6rem; z-index: 5; display: grid; place-content: center; justify-items: center; gap: .5rem; border: 2px dashed var(--accent); border-radius: calc(var(--r-lg) - 6px); background: color-mix(in srgb, var(--selected) 92%, transparent); font-weight: 800; pointer-events: none; }
.drop-overlay svg { width: 40px; height: 40px; color: var(--accent); }
.drop-overlay p { margin: 0; }

.preview { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem; max-width: min(92vw, 1000px); max-height: 92dvh; background: var(--surface); color: var(--text); }
.preview::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.preview img, .preview video { display: block; max-width: 100%; max-height: calc(92dvh - 6rem); border-radius: var(--r-md); margin: 0 auto; }
.preview .close { margin-bottom: .75rem; }

.toast { position: fixed; left: 50%; bottom: max(1.5rem, env(safe-area-inset-bottom)); transform: translate(-50%, 2rem); opacity: 0; z-index: 30; background: var(--text); color: var(--bg); font-weight: 700; padding: .8rem 1.25rem; border-radius: 999px; pointer-events: none; transition: .25s; max-width: 90vw; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.in-room .toast { bottom: 6.5rem; }

@media (max-width: 900px) {
  .hero, .actions { grid-template-columns: 1fr; }
  .link-art { max-width: 340px; justify-self: center; order: -1; }
  .bar-note { display: none; }
  .only-mobile { display: inline-flex !important; }
  .knock-banner.only-mobile { display: block !important; }
  .knock-banner[hidden] { display: none !important; }
  /* celular: o chat ocupa a tela toda; os dados da sala abrem por cima, deslizando da esquerda */
  .room { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .chat-panel { border-radius: 0; border-inline: 0; border-bottom: 0; box-shadow: none; }
  .info { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(88vw, 360px); border-radius: 0 var(--r-lg) var(--r-lg) 0; overflow-y: auto; transform: translateX(-105%); transition: transform .25s ease; visibility: hidden; }
  .info.open { transform: none; visibility: visible; }
  .info-backdrop { display: block; position: fixed; inset: 0; z-index: 19; background: var(--backdrop); }
  .info-backdrop[hidden] { display: none; }
  .msg { max-width: 86%; }
}
@media (max-width: 520px) {
  .kind { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 1fr auto; }
  .history-item .muted { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
