/* 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; grid-template-columns: 1fr auto auto; align-items: center; gap: 1rem 1.5rem; 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; }
.last-room .muted { font-size: .9rem; }
.last-code { margin: 0; font: 700 1.6rem/1 var(--display); letter-spacing: .18em; }
.last-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.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); }

#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 ---------- */
.room { display: grid; grid-template-columns: minmax(290px, 370px) 1fr; gap: 1.5rem; padding: 1rem var(--gutter) 3rem; align-items: start; max-width: 1240px; margin: 0 auto; }
body:not(.is-host) .host-only, body.is-host .guest-only { display: none !important; }

/* o bilhete acompanha a rolagem, mas nunca fica mais alto que a tela: se não couber (pedidos + QR), rola por dentro */
.ticket { position: sticky; top: 1rem; max-height: calc(100dvh - 2rem); background: linear-gradient(160deg, var(--ticket-start), var(--surface) 60%); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.6rem; display: grid; gap: 1.25rem; align-content: start; box-shadow: var(--shadow); }
.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: .4rem; }
.tiles span { font: 700 clamp(1.6rem, 3.4vw, 2.2rem)/1 var(--display); text-align: center; padding: .7rem 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: 1rem; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; justify-self: start; }
.qr svg { display: block; width: clamp(128px, 22dvh, 164px); height: clamp(128px, 22dvh, 164px); }
.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); }

.files { min-width: 0; }
.files-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.files-head h2 { font-size: 1.4rem; }

.drop { display: grid; justify-items: center; gap: .2rem; border: 1.5px dashed var(--line); border-radius: var(--r-lg); padding: clamp(1.25rem, 4dvh, 2.25rem) 1rem; text-align: center; margin-bottom: 1rem; transition: background .15s, border-color .15s; }
.drop svg { width: 30px; height: 30px; color: var(--accent); margin-bottom: .4rem; }
.drop p { margin: 0; font-weight: 700; }
.drop .muted { font-weight: 500; font-size: .9rem; }
.drop.over { background: var(--selected); border-color: var(--accent); }

/* lista de arquivos e chat rolam por dentro, com altura proporcional à tela */
.file-list { list-style: none; margin: 0; padding: .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); max-height: clamp(220px, 45dvh, 640px); box-shadow: var(--shadow); }
.file-list:empty { display: none; }
.file { display: grid; grid-template-columns: 56px 1fr auto; gap: 1rem; align-items: center; padding: .8rem .9rem; position: relative; border-radius: var(--r-md); overflow: hidden; }
.file:hover { background: var(--surface-2); }
.thumb { width: 56px; height: 56px; border-radius: 12px; background: var(--bg) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; font: 700 .7rem var(--display); color: var(--accent); text-transform: lowercase; overflow: hidden; }
.file-name { font-weight: 700; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: .85rem; }
.file-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: end; }
.progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--accent); transition: width .2s; }
.file.done .progress { background: var(--ok); }
.empty { color: var(--muted); text-align: center; padding: 2.5rem 1rem; margin: 0; }
.empty:empty { display: none; }

.chat { margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; display: grid; gap: .9rem; box-shadow: var(--shadow); }
.chat-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; }
.chat-head h2 { font-size: 1.15rem; }
.chat-head .muted { font-size: .85rem; }
.chat-list { list-style: none; margin: 0; padding: 0 .35rem 0 0; display: grid; gap: .6rem; max-height: clamp(200px, 40dvh, 560px); }
.chat-list:empty { display: none; }
.msg { max-width: min(80%, 520px); justify-self: start; background: var(--surface-2); border-radius: 4px 16px 16px 16px; padding: .55rem .85rem; }
.msg.mine { justify-self: end; background: var(--accent); color: var(--on-accent); border-radius: 16px 4px 16px 16px; }
.msg p { margin: 0; }
.msg-who { font-size: .78rem; color: var(--muted); }
.msg.mine .msg-who { color: var(--mine-who); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-empty { margin: 0; color: var(--muted); font-size: .9rem; }
.chat-form { display: flex; gap: .5rem; align-items: end; }
.chat-form textarea { flex: 1; min-width: 0; width: 100%; resize: none; min-height: 46px; max-height: min(140px, 25dvh); padding: .7rem 1rem; border-radius: 22px; border: 1px solid var(--line); background: var(--bg); field-sizing: content; }
.chat-form textarea::placeholder { color: var(--muted); }
.chat-form textarea:focus { border-color: var(--ok); outline: none; box-shadow: 0 0 0 3px var(--ring); }
.chat-form textarea:disabled { opacity: .5; }

.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; 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); }

@media (max-width: 900px) {
  .hero, .actions, .room { grid-template-columns: 1fr; }
  .link-art { max-width: 340px; justify-self: center; order: -1; }
  /* empilhado, o bilhete rola junto com a página */
  .ticket { position: static; max-height: none; overflow: visible; }
  .bar-note { display: none; }
  .last-room { grid-template-columns: 1fr auto; }
  .last-actions { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .kind { grid-template-columns: 1fr; }
  .last-room { grid-template-columns: 1fr; }
  .file { grid-template-columns: 44px 1fr; }
  .thumb { width: 44px; height: 44px; }
  .file-actions { grid-column: 1 / -1; justify-content: start; }
  .chat-list { max-height: 55dvh; }
}
/* telas baixas (notebook pequeno, celular deitado) */
@media (max-height: 560px) {
  .ticket { position: static; max-height: none; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
