@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('/fonts/ahn-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('/fonts/ahn-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --noite: #1d1a24;
  --veludo: #27232f;
  --borda: #3a3445;
  --papel: #ece6f5;
  --tinta: #2a2238;
  --tinta-suave: #6d6380;
  --propria: #3a3250;
  --lilas: #b8a6e6;
  --lacre: #e2557a;
  --nevoa: #9a91a8;
  --texto: #ece6f5;
  --ok: #8fd4b4;

  --fs-small: 0.8125rem;
  --fs-body: 1.0625rem;
  --fs-lede: 1.25rem;
  --fs-logo: 4.5rem;
  --radius: 16px;
  --gutter: 16px;
  font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  font-size: 100%;
  line-height: 1.45;
}

:root:lang(ar) {
  font-family: 'Atkinson Hyperlegible Next', 'SF Arabic', 'Geeza Pro', 'Noto Naskh Arabic', 'Noto Sans Arabic', 'Segoe UI', Tahoma, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--noite);
  color: var(--texto);
  font-size: var(--fs-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lilas); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Logo: "shııı" com os pingos sumindo, como um sussurro. */
.logo { font-weight: 700; letter-spacing: -0.02em; line-height: 1; margin: 0; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.logo .i { position: relative; display: inline-block; }
.logo .i::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0.02em;
  width: 0.2em;
  height: 0.2em;
  margin-left: -0.1em;
  border-radius: 50%;
  background: var(--lilas);
}
.logo .i:nth-child(1)::before { opacity: 1; }
.logo .i:nth-child(2)::before { opacity: 0.55; }
.logo .i:nth-child(3)::before { opacity: 0.2; }
.logo-big { font-size: var(--fs-logo); padding-top: 0.15em; }
.logo-small { font-size: 1.375rem; padding-top: 0.15em; }

/* Páginas soltas (início, encerrada) */
.page {
  height: 100dvh;
  overflow-y: auto;
  max-width: 34rem;
  margin: 0 auto;
  padding: max(12vh, 48px) var(--gutter) 48px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}
.lede { font-size: var(--fs-lede); margin: 0; max-width: 28ch; color: var(--texto); }
.facts { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 14px; color: var(--nevoa); max-width: 60ch; }
.facts li { padding-inline-start: 18px; position: relative; }
.facts li::before {
  content: '';
  position: absolute; inset-inline-start: 0; top: 0.55em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--borda);
}
.hint { margin: 0; font-size: var(--fs-small); color: var(--nevoa); max-width: 60ch; }
.landing-links { margin-top: 8px; display: flex; gap: 18px; flex-wrap: wrap; }
.landing-links a { color: var(--nevoa); font-size: var(--fs-small); font-weight: 700; text-decoration: none; }
.landing-links a:hover { color: var(--texto); }
.error { margin: 0; color: var(--lacre); }
.ended-title { font-size: 1.75rem; margin: 8px 0 0; line-height: 1.2; }

.btn {
  appearance: none;
  border: 1px solid var(--borda);
  background: transparent;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 700;
}
.btn:hover { border-color: var(--nevoa); }
.btn-primary { background: var(--lilas); border-color: var(--lilas); color: var(--tinta); }
.btn-primary:hover { background: #c8b9ee; border-color: #c8b9ee; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Chat */
.chat { height: 100dvh; display: flex; flex-direction: column; }
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--veludo);
  border-bottom: 1px solid var(--borda);
}
.status { flex: 1; margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-small); color: var(--nevoa); min-width: 0; }
.status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--nevoa); }
.dot.is-ready { background: var(--ok); }
.dot.is-busy { background: var(--lilas); animation: pulse 1.4s ease-in-out infinite; }
.dot.is-bad { background: var(--lacre); }
@keyframes pulse { 50% { opacity: 0.3; } }
.btn-panic {
  appearance: none;
  flex: none;
  border: 1px solid var(--lacre);
  color: var(--lacre);
  background: transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: var(--fs-small);
  font-weight: 700;
  cursor: pointer;
}
.btn-panic:hover { background: var(--lacre); color: var(--noite); }
.code {
  margin: 0;
  padding: 6px var(--gutter);
  font-size: var(--fs-small);
  color: var(--nevoa);
  border-bottom: 1px solid var(--borda);
  font-variant-numeric: tabular-nums;
}
.code strong { color: var(--texto); letter-spacing: 0.04em; margin-inline-start: 4px; unicode-bidi: isolate; }

.invite {
  margin: 16px var(--gutter) 0;
  padding: 16px;
  border: 1px dashed var(--borda);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
}
.invite-title { margin: 0; font-weight: 700; }
.invite-link {
  width: 100%;
  background: var(--noite);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: var(--fs-small);
  color: var(--lilas);
  text-align: left;
}
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.timeline {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  margin: 0;
  padding: 16px var(--gutter) 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timeline > li { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.25s ease, margin 0.25s ease; }
.timeline > li > * { min-height: 0; }
.timeline > li.collapsing { grid-template-rows: 0fr; margin-top: -10px; }
.timeline > li.collapsing > * { overflow: hidden; }
.notice { align-self: center; text-align: center; font-size: var(--fs-small); color: var(--nevoa); max-width: 36ch; padding: 4px 0; }

.msg { max-width: min(78%, 26rem); }
.theirs { align-self: flex-start; }
.mine { align-self: flex-end; }

/* Bilhete recebido: papel dobrado com lacre. */
.note {
  position: relative;
  display: block;
  width: 100%;
  min-width: 11rem;
  text-align: left;
  background: var(--papel);
  color: var(--tinta);
  border-radius: var(--radius);
  border-start-start-radius: 4px;
  padding: 12px 16px 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow-wrap: anywhere;
}
.note.is-sealed {
  background:
    linear-gradient(225deg, var(--noite) 0 14px, #cfc6df 14px 20px, transparent 20px),
    var(--papel);
  padding-inline-end: 32px;
}
[dir='rtl'] .note.is-sealed {
  background:
    linear-gradient(135deg, var(--noite) 0 14px, #cfc6df 14px 20px, transparent 20px),
    var(--papel);
}
.note-row { display: flex; align-items: center; gap: 10px; }
.seal {
  flex: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--lacre);
  box-shadow: inset 0 0 0 3px #f07d9b, inset 0 0 0 5px var(--lacre);
}
.note-kind { font-weight: 700; }
.note-hint { display: block; margin-top: 2px; font-size: var(--fs-small); color: var(--tinta-suave); }
.note-text { margin: 0; white-space: pre-wrap; }
.note.is-open .note-hint { margin-top: 8px; }

.bubble {
  background: var(--propria);
  border-radius: var(--radius);
  border-start-end-radius: 4px;
  padding: 10px 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.bubble.is-ghost {
  background: transparent;
  border: 1px dashed var(--borda);
  color: var(--nevoa);
  font-size: var(--fs-small);
  white-space: normal;
}
.meta { display: block; text-align: end; font-size: var(--fs-small); color: var(--nevoa); margin-top: 3px; }

.pic { display: block; width: 100%; max-width: 18rem; height: auto; border-radius: 8px; margin: 2px 0; pointer-events: none; }
.bubble .pic { margin: -4px -8px; width: calc(100% + 16px); max-width: calc(18rem + 16px); }

.player { display: flex; align-items: center; gap: 10px; min-width: 12rem; }
.player-btn {
  appearance: none;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--tinta);
  color: var(--papel);
  display: grid; place-items: center;
  cursor: pointer;
}
.bubble .player-btn { background: var(--lilas); color: var(--tinta); }
.player-btn svg { width: 16px; height: 16px; fill: currentColor; }
.player-track { flex: 1; height: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 22%, transparent); overflow: hidden; }
.player-fill { height: 100%; width: 0; background: currentColor; }
.player-time { font-size: var(--fs-small); font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: end; direction: ltr; }

/* O momento: o bilhete se desfaz como fumaça. */
.note.is-dissolving { animation: dissolve 0.55s ease-in forwards; pointer-events: none; }
@keyframes dissolve {
  0% { opacity: 1; filter: blur(0); transform: none; letter-spacing: 0; }
  55% { opacity: 0.55; filter: blur(5px); transform: translateY(-4px) scale(1.02); letter-spacing: 0.06em; }
  100% { opacity: 0; filter: blur(16px); transform: translateY(-16px) scale(1.07); letter-spacing: 0.14em; }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px var(--gutter) max(10px, env(safe-area-inset-bottom));
  background: var(--veludo);
  border-top: 1px solid var(--borda);
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 9rem;
  background: var(--noite);
  border: 1px solid var(--borda);
  border-radius: 20px;
  padding: 9px 14px;
  line-height: 1.35;
}
.composer textarea:disabled { opacity: 0.6; }
.icon-btn {
  appearance: none;
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--borda);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--texto);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-send { background: var(--lilas); border-color: var(--lilas); color: var(--tinta); }
[dir='rtl'] .icon-send svg { transform: scaleX(-1); }
.icon-btn[aria-disabled='true'], .icon-btn:disabled { opacity: 0.4; cursor: default; }

.recorder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter) max(10px, env(safe-area-inset-bottom));
  background: var(--veludo);
  border-top: 1px solid var(--borda);
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lacre); animation: pulse 1s ease-in-out infinite; }
.rec-time { flex: 1; font-variant-numeric: tabular-nums; }

/* Seletor de idioma: um chip; o <select> nativo transparente por cima abre
   a lista do sistema (no celular, a roleta/lista nativa). */
.corner { position: fixed; top: max(16px, env(safe-area-inset-top)); inset-inline-end: var(--gutter); z-index: 5; }
.lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding-inline: 12px 10px;
  border: 1px solid var(--borda);
  border-radius: 999px;
  background: var(--veludo);
  color: var(--texto);
  font-size: var(--fs-small);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.lang:hover { border-color: var(--nevoa); background: #2e2938; }
.lang:focus-within { outline: 2px solid var(--lilas); outline-offset: 2px; }
.lang svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lang-globe { width: 17px; height: 17px; color: var(--lilas); }
.lang-chev { width: 14px; height: 14px; color: var(--nevoa); }
.lang-current { white-space: nowrap; }
.lang-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* evita o zoom automático do iOS */
  appearance: none;
}
.lang-select option { background: var(--veludo); color: var(--texto); font-weight: 400; }
.lang.is-compact { height: 32px; padding-inline: 9px 7px; gap: 5px; }
.lang.is-compact .lang-globe { width: 15px; height: 15px; }
#bar-lang { display: contents; }

.cover {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--noite);
  display: grid;
  place-items: center;
}

@media (min-width: 720px) {
  .chat { max-width: 46rem; margin: 0 auto; border-inline: 1px solid var(--borda); }
  :root { --fs-logo: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .note.is-dissolving { animation: fade 0.15s linear forwards; }
  .timeline > li { transition: none; }
  .dot.is-busy, .rec-dot { animation: none; }
  @keyframes fade { to { opacity: 0; } }
}
