/* =========================================================================
   MiniWasp — hoja de estilos
   Identidad: tinta + caléndula sobre piedra fría. La sala es un "pase"
   temporal: el ID se presenta como un ticket perforado y los códigos usan
   numerales monoespaciados. Sin fuentes externas (CSP): pilas del sistema.
   Secciones:
     1. Tokens            8. Participantes
     2. Base              9. Mensajes
     3. Utilidades       10. Redacción y errores
     4. Controles        11. Videollamada
     5. Marca            12. Aviso de privacidad
     6. Inicio           13. Movimiento
     7. Sala y cabecera  14. Estados ocultos
   ========================================================================= */

/* 1. Tokens --------------------------------------------------------------- */

:root {
  color-scheme: light;

  --font-ui: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", roboto, "Helvetica Neue", arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", menlo, consolas, "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-display: 2.25rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-14: 56px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  --sidebar-width: 320px;
  --control-height: 48px;
  --notch: 9px;

  /* Superficies */
  --ground: #ebedf0;
  --canvas: #f3f4f6;
  --surface: #fff;
  --surface-2: #f6f7f8;
  --surface-hover: #eceef1;
  --line: #dde0e5;
  --line-strong: #c3c8cf;

  /* Texto */
  --ink: #121417;
  --ink-2: #474d56;
  --muted: #5f6670;
  --on-ink: #f4f5f6;

  /* Marca */
  --accent: #ffb224;
  --accent-hover: #ffbf4a;
  --accent-edge: #e39a0f;
  --accent-ink: #1a1306;
  --accent-soft: #fff1d3;
  --accent-icon: #a96a00;

  /* Mensajes propios: impresos en tinta */
  --own-bg: #16191d;
  --own-text: #f4f5f6;
  --own-muted: #a8afb8;

  /* Semántica */
  --danger: #c42b1c;
  --danger-hover: #a92416;
  --danger-text: #a3200f;
  --danger-soft: #fdeceb;
  --success: #18794e;
  --success-hover: #13643f;
  --online: #1f9d5c;

  /* Foco y navegador */
  --focus: #121417;
  --focus-halo: rgb(255 178 36 / 55%);
  --caret: #c47f00;
  --selection: #ffe0a3;

  /* Profundidad */
  --shadow-1: 0 1px 2px rgb(18 20 23 / 6%);
  --shadow-2: 0 1px 2px rgb(18 20 23 / 5%), 0 8px 24px -10px rgb(18 20 23 / 18%);
  --shadow-3: 0 2px 6px rgb(18 20 23 / 6%), 0 30px 60px -24px rgb(18 20 23 / 30%);

  /* Videollamada: siempre oscura */
  --call-bg: #0b0c0e;
  --call-stage: #15171a;
  --call-text: #f4f5f6;
  --call-muted: #b4bac2;
  --call-control: rgb(255 255 255 / 12%);
  --call-control-hover: rgb(255 255 255 / 20%);

  /* Escenario de marca (inicio) */
  --stage-bg: #121417;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --ground: #0b0d0f;
    --canvas: #101215;
    --surface: #16191c;
    --surface-2: #131619;
    --surface-hover: #1f2327;
    --line: #262b30;
    --line-strong: #39404a;

    --ink: #eef0f2;
    --ink-2: #bcc3cb;
    --muted: #949ca6;

    --accent-soft: #33280f;
    --accent-icon: #ffb224;

    --own-bg: #33290f;
    --own-text: #fbe9c2;
    --own-muted: #cbb582;

    --danger: #c42b1c;
    --danger-text: #ff8b7c;
    --danger-soft: #3a1714;
    --online: #3ccf82;

    --focus: #ffb224;
    --focus-halo: rgb(255 178 36 / 35%);
    --caret: #ffb224;
    --selection: #5a4210;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-2: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 28px -12px rgb(0 0 0 / 60%);
    --shadow-3: 0 2px 6px rgb(0 0 0 / 40%), 0 30px 60px -24px rgb(0 0 0 / 70%);

    --stage-bg: #08090b;
  }
}

/* 2. Base ----------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--line-strong) transparent;
}

h1,
h2,
p {
  margin: 0;
}

::selection {
  background: var(--selection);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

code {
  font-family: var(--font-mono);
}

svg {
  flex: none;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 3. Utilidades ----------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 4. Controles ------------------------------------------------------------ */

button {
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input {
  width: 100%;
  min-width: 0;
  height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  caret-color: var(--caret);
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:hover {
  border-color: var(--muted);
}

input:focus-visible {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-halo);
}

.input-mono {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  letter-spacing: 0.02em;
}

.input-mono::placeholder {
  font-family: var(--font-ui);
  letter-spacing: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-height);
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 650;
  white-space: nowrap;
}

.button-primary {
  border: 1px solid var(--accent-edge);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-1);
}

.button-primary:hover {
  background: var(--accent-hover);
}

.button-secondary {
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover {
  background: var(--surface-hover);
}

.privacy-link,
.rules-link {
  color: var(--muted);
  font-size: var(--text-sm);
}

.privacy-link:hover,
.rules-link:hover {
  color: var(--ink);
}

/* 5. Marca ---------------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-lg);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-mark {
  width: 30px;
  height: 30px;
}

.brand-mark-cell {
  fill: var(--accent);
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.brand-mark-bubble {
  fill: var(--accent-ink);
}

/* 6. Inicio --------------------------------------------------------------- */

.home {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
  background: var(--surface);
}

.home-stage {
  position: relative;
  display: grid;
  order: -1;
  height: 196px;
  overflow: hidden;
  background: var(--stage-bg);
  place-items: center;
}

.comb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mask-image: radial-gradient(ellipse 70% 80% at 55% 50%, #000 10%, transparent 75%);
}

.comb path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.22;
}

.ticket-art {
  position: relative;
  font-size: 9px;
  filter: drop-shadow(0 24px 30px rgb(0 0 0 / 45%));
  transform: rotate(-6deg);
}

.ticket-art-body {
  display: flex;
  width: 37em;
  border-radius: 1.4em;
  background: var(--accent);
  color: var(--accent-ink);
  mask-image:
    radial-gradient(circle 1.1em at calc(100% - 7.5em) 0, transparent 98%, #000 100%),
    radial-gradient(circle 1.1em at calc(100% - 7.5em) 100%, transparent 98%, #000 100%);
  mask-composite: intersect;
}

.ticket-art-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5em;
  padding: 2.4em 2.6em 2.2em;
}

.ticket-art-brand {
  font-size: 1.2em;
  font-weight: 750;
  letter-spacing: 0.12em;
  opacity: 0.7;
  text-transform: uppercase;
}

.ticket-art-title {
  font-size: 3em;
  font-weight: 780;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.ticket-art-code {
  margin-top: 0.7em;
  font-family: var(--font-mono);
  font-size: 2em;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ticket-art-note {
  font-size: 1.3em;
  opacity: 0.75;
}

.ticket-art-stub {
  display: grid;
  width: 7.5em;
  border-left: 0.2em dashed rgb(26 19 6 / 35%);
  place-items: center;
}

.ticket-art-stub span {
  font-size: 1.2em;
  font-weight: 750;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  transform: rotate(180deg);
  writing-mode: vertical-rl;
}

.home-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-10);
}

.brand-home {
  font-size: var(--text-xl);
}

.brand-home .brand-mark {
  width: 36px;
  height: 36px;
}

.home-headline {
  margin-top: var(--space-8);
  font-size: 1.875rem;
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.home-tagline {
  margin-top: var(--space-3);
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.55;
}

.home-create {
  width: 100%;
  height: 54px;
  margin-top: var(--space-8);
}

.home-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
}

.home-divider::before,
.home-divider::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.join-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--space-2);
}

.home-error {
  margin-top: var(--space-3);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: var(--text-md);
  font-weight: 550;
}

.home-facts {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-8) 0 var(--space-6);
  padding: var(--space-5) 0 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--text-md);
  list-style: none;
}

.home-facts li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.home-facts .icon {
  color: var(--accent-icon);
}

/* 7. Sala y cabecera ------------------------------------------------------ */

.chat {
  display: grid;
  grid-template:
    "header" auto
    "room" auto
    "people" auto
    "messages" 1fr
    "error" auto
    "composer" auto
    / minmax(0, 1fr);
  height: 100dvh;
  background: var(--canvas);
}

.chat-header {
  display: flex;
  grid-area: header;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-header .brand {
  font-size: 1.0625rem;
}

.chat-header .brand-mark {
  width: 28px;
  height: 28px;
}

.status {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 550;
  white-space: nowrap;
}

.privacy-link-header {
  margin-left: auto;
}

.logout {
  display: inline-grid;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-2);
  place-items: center;
}

.logout:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger-text);
}

.logout-label,
.room-bar-button-label,
.composer-send-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Invitación: un ticket perforado de color caléndula. */
.room-bar {
  display: flex;
  grid-area: room;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-ink);
}

.room-bar-label {
  font-size: var(--text-xs);
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.invite-code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-bar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: var(--text-sm);
  font-weight: 650;
}

.room-bar-copy {
  background: var(--accent-ink);
  color: var(--accent);
}

.room-bar-copy:hover {
  background: #33270b;
}

.room-bar-rotate {
  border: 1.5px solid rgb(26 19 6 / 45%);
}

.room-bar-rotate:hover {
  background: rgb(26 19 6 / 8%);
}

.room-bar .room-bar-button:focus-visible {
  outline-color: var(--accent-ink);
}

.copy-status {
  flex-basis: 100%;
  font-size: var(--text-xs);
  font-weight: 650;
}

.copy-status:empty,
.room-bar-hint {
  display: none;
}

/* 8. Participantes -------------------------------------------------------- */

.people {
  display: flex;
  grid-area: people;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: none;
}

.people-title {
  flex: none;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 650;
}

.people-empty {
  color: var(--muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.people-list {
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.person {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 3px 3px 3px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.person::before {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--online) 18%, transparent);
  content: "";
  grid-area: dot;
}

.person-name {
  min-width: 0;
  max-width: 14ch;
  overflow: hidden;
  font-size: var(--text-md);
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
  grid-area: name;
}

.person-badge {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 0.6875rem;
  font-weight: 650;
  white-space: nowrap;
  grid-area: badge;
}

.person-call {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0;
  grid-area: call;
}

.person-call::after {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  background: currentcolor;
  content: "";
  mask: url("icon-camera.svg") center / contain no-repeat;
}

.person-call:hover {
  background: var(--accent-hover);
}

.person-expel {
  height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--danger-text);
  font-size: var(--text-sm);
  font-weight: 600;
  grid-area: expel;
}

.person-expel:hover {
  background: var(--danger-soft);
}

/* 9. Mensajes ------------------------------------------------------------- */

.messages,
.messages-empty {
  grid-area: messages;
}

.messages {
  min-height: 0;
  margin: 0;
  padding: var(--space-4) max(var(--space-4), calc((100% - 820px) / 2));
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.messages-empty {
  display: none;
  align-content: center;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-6);
  color: var(--muted);
  font-size: var(--text-md);
  text-align: center;
  pointer-events: none;
}

.chat:has(.messages:empty) .messages-empty {
  display: grid;
}

.messages-empty-mark {
  width: 52px;
  height: 52px;
  margin-bottom: var(--space-2);
}

.messages-empty-title {
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 700;
}

.messages-empty-text {
  max-width: 34ch;
}

.message {
  width: fit-content;
  max-width: min(82%, 560px);
  margin-bottom: 6px;
  padding: 8px 12px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 6px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.message-own {
  margin-left: auto;
  border-color: var(--own-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
  background: var(--own-bg);
  color: var(--own-text);
}

.message-name {
  display: block;
  margin-bottom: 1px;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 700;
}

.message-own .message-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.message-text {
  font-size: var(--text-base);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.message-own .message-time {
  color: var(--own-muted);
}

/* 10. Redacción y errores ------------------------------------------------- */

.error {
  grid-area: error;
  margin: 0 var(--space-4) var(--space-2);
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: var(--text-md);
  font-weight: 550;
}

.composer {
  display: grid;
  grid-area: composer;
  grid-template:
    "chip chip chip chip" auto
    "recording recording recording recording" auto
    "name name name name" auto
    "attach text mic send" auto
    / auto minmax(0, 1fr) auto auto;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) max(var(--space-3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.field-name {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 4px 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  grid-area: name;
}

.field-name:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-halo);
}

.field-name .field-label {
  flex: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
}

.field-name input {
  height: 100%;
  padding: 0 var(--space-2);
  border: 0;
  background: transparent;
  font-weight: 600;
}

.field-name input:focus-visible {
  box-shadow: none;
}

.field-text {
  grid-area: text;
}

.field-text input {
  background: var(--surface-2);
}

.composer-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--control-height);
  height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  grid-area: send;
}

.composer-send:hover {
  background: var(--accent-hover);
}

.composer-send .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

/* Escritorio: barra lateral con la invitación y la lista de participantes. */
@media (width >= 900px) {
  .chat {
    grid-template:
      "header header" auto
      "room messages" auto
      "people messages" 1fr
      "people error" auto
      "people composer" auto
      / var(--sidebar-width) minmax(0, 1fr);
  }

  .chat-header {
    min-height: 64px;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
  }

  .logout {
    display: inline-flex;
    gap: var(--space-2);
    width: auto;
    padding: 0 var(--space-3);
    font-size: var(--text-md);
    font-weight: 600;
  }

  .logout-label,
  .room-bar-button-label,
  .composer-send-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }

  /* La barra lateral se pinta en el fondo del grid: así cubre todas sus filas. */
  .chat {
    background: linear-gradient(
      to right,
      var(--surface-2) calc(var(--sidebar-width) - 1px),
      var(--line) calc(var(--sidebar-width) - 1px) var(--sidebar-width),
      var(--canvas) var(--sidebar-width)
    );
  }

  /* El ticket: muescas a la altura de la línea perforada. */
  .room-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
    margin: var(--space-4) var(--space-4) var(--space-2);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    mask-image:
      radial-gradient(circle var(--notch) at 0 82px, transparent 98%, #000 100%),
      radial-gradient(circle var(--notch) at 100% 82px, transparent 98%, #000 100%);
    mask-composite: intersect;
  }

  .room-bar-label,
  .invite-code,
  .copy-status,
  .room-bar-hint {
    grid-column: 1 / -1;
  }

  .invite-code {
    padding-bottom: 14px;
    border-bottom: 1.5px dashed rgb(26 19 6 / 40%);
    font-size: var(--text-base);
    white-space: normal;
    word-break: break-all;
  }

  .room-bar-button {
    width: auto;
    height: 38px;
    padding: 0 var(--space-3);
  }

  .room-bar-rotate {
    grid-column: 2;
  }

  .copy-status {
    flex-basis: auto;
  }

  .room-bar-hint {
    display: block;
    color: rgb(26 19 6 / 80%);
    font-size: var(--text-sm);
    line-height: 1.45;
  }

  .people {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3) var(--space-4);
    overflow: hidden auto;
    border-bottom: 0;
    background: none;
  }

  .people-title {
    padding: var(--space-3) var(--space-2) 0;
  }

  .people-empty {
    padding: 0 var(--space-2);
    white-space: normal;
  }

  .people-list {
    flex-direction: column;
    gap: 2px;
  }

  .person {
    display: grid;
    grid-template:
      "dot name call expel" auto
      "dot badge call expel" auto
      / 8px minmax(0, 1fr) auto auto;
    align-content: center;
    gap: 0 var(--space-3);
    min-height: 52px;
    padding: 6px 8px 6px 12px;
    border: 0;
    border-radius: var(--radius-md);
    background: none;
  }

  .person:hover {
    background: var(--surface-hover);
  }

  .person-name {
    align-self: end;
    max-width: none;
    font-size: var(--text-base);
  }

  .person:not(:has(.person-badge)) .person-name {
    grid-row: 1 / -1;
    align-self: center;
  }

  .person-badge {
    justify-self: start;
    margin-top: 2px;
  }

  .person-call {
    width: 36px;
    height: 36px;
  }

  .messages {
    padding-block: var(--space-6);
  }

  .error {
    margin-inline: var(--space-6);
  }

  .composer {
    grid-template:
      "chip chip chip chip chip" auto
      "recording recording recording recording recording" auto
      "name attach text mic send" auto
      / minmax(170px, 230px) auto minmax(0, 1fr) auto auto;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6) var(--space-5);
  }

  .field-name {
    height: var(--control-height);
  }

  .composer-send {
    padding: 0 var(--space-5) 0 var(--space-4);
  }

  .home {
    grid-template-columns: minmax(420px, 520px) minmax(0, 1fr);
    grid-template-rows: none;
  }

  .home-stage {
    order: 0;
    height: auto;
  }

  .ticket-art {
    font-size: clamp(11px, 1.15vw, 15px);
  }

  .home-panel {
    justify-content: center;
    max-width: 520px;
    padding: var(--space-14);
  }

  .home-headline {
    margin-top: var(--space-10);
    font-size: var(--text-display);
  }
}

/* Pantallas grandes: la app flota como una ventana sobre la piedra. */
@media (width >= 1280px) and (height >= 720px) {
  .chat {
    max-width: 1240px;
    height: calc(100dvh - 48px);
    margin: 24px auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-3);
  }
}

/* 11. Videollamada -------------------------------------------------------- */

.call {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--call-bg);
  color: var(--call-text);
  color-scheme: dark;
}

.call-header {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-4) var(--space-4);
  text-align: center;
}

.call-peer {
  font-size: var(--text-xl);
  font-weight: 720;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.call-status {
  color: var(--call-muted);
  font-size: var(--text-md);
}

.call-security-code {
  max-width: 34rem;
  margin-top: var(--space-2);
  padding: 6px 14px;
  border: 1px solid rgb(255 178 36 / 40%);
  border-radius: var(--radius-pill);
  background: rgb(255 178 36 / 12%);
  color: #ffd68a;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  font-weight: 550;
}

.call-stage {
  position: relative;
  margin: 0 var(--space-3);
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--call-stage);
}

.call-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.call-placeholder-mark {
  position: relative;
  width: 96px;
  height: 96px;
}

.call:has(.call-security-code:not([hidden])) .call-placeholder {
  display: none;
}

.call-video-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.call-video-local {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  width: min(32%, 220px);
  aspect-ratio: 3 / 4;
  border: 2px solid rgb(255 255 255 / 18%);
  border-radius: var(--radius-lg);
  background: #22252a;
  box-shadow: 0 12px 30px rgb(0 0 0 / 45%);
  object-fit: cover;
  transform: scaleX(-1);
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom));
}

.call-button {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: var(--space-2);
  width: 88px;
  padding: 0;
  border-radius: var(--radius-lg);
  color: var(--call-text);
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.25;
  text-align: center;
}

.call-button::before {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--call-control);
  content: "";
}

.call-button::after {
  position: absolute;
  top: 17px;
  left: calc(50% - 13px);
  width: 26px;
  height: 26px;
  background: var(--call-text);
  content: "";
  mask: var(--call-icon) center / contain no-repeat;
}

.call-button:hover::before {
  background: var(--call-control-hover);
}

.call-button:focus-visible {
  outline: none;
}

.call-button:focus-visible::before {
  box-shadow: 0 0 0 3px var(--call-bg), 0 0 0 5px var(--accent);
}

.call-button-accept {
  --call-icon: url("icon-camera.svg");
}

.call-button-accept::before {
  background: var(--success);
}

.call-button-accept:hover::before {
  background: var(--success-hover);
}

.call-button-reject,
.call-button-hangup {
  --call-icon: url("icon-hangup.svg");
}

.call-button-danger::before {
  background: var(--danger);
}

.call-button-danger:hover::before {
  background: var(--danger-hover);
}

.call-button-mic {
  --call-icon: url("icon-mic.svg");
}

.call-button-camera {
  --call-icon: url("icon-camera.svg");
}

.call-button-mic[aria-pressed="true"] {
  --call-icon: url("icon-mic-off.svg");
}

.call-button-camera[aria-pressed="true"] {
  --call-icon: url("icon-camera-off.svg");
}

.call-button[aria-pressed="true"]::before {
  background: var(--call-text);
}

.call-button[aria-pressed="true"]::after {
  background: var(--call-bg);
}

@media (width >= 900px) {
  .call-stage {
    width: min(100% - 48px, 1200px);
    margin: 0 auto;
  }

  .call-video-local {
    right: var(--space-5);
    bottom: var(--space-5);
    width: min(24%, 260px);
    aspect-ratio: 4 / 3;
  }

  .call-controls {
    gap: var(--space-6);
  }
}

/* 12. Aviso de privacidad ------------------------------------------------- */

.notice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) 0;
}

.notice-header .brand {
  text-decoration: none;
}

.notice-back {
  color: var(--ink-2);
  font-size: var(--text-md);
  font-weight: 600;
}

.notice {
  max-width: 760px;
  margin: var(--space-6) auto var(--space-14);
  padding: var(--space-8) var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 1rem;
  line-height: 1.6;
}

.notice h1 {
  font-size: 2rem;
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.notice-lead {
  max-width: 62ch;
  margin-top: var(--space-3);
  color: var(--ink-2);
  font-size: 1.0625rem;
}

.notice h2 {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.notice p,
.notice ul {
  max-width: 68ch;
}

.notice h2 + p,
.notice h2 + ul {
  margin-top: var(--space-3);
}

.notice ul {
  display: grid;
  gap: var(--space-3);
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.notice li {
  position: relative;
  padding-left: var(--space-6);
}

.notice li::before {
  position: absolute;
  top: 0.62em;
  left: 4px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
  transform: rotate(45deg);
}

.notice strong {
  font-weight: 700;
}

@media (width >= 900px) {
  .notice {
    padding: var(--space-14);
  }

  .notice h1 {
    font-size: 2.5rem;
  }
}

/* 13. Movimiento ---------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  button,
  input,
  a,
  .person,
  .field-name {
    transition:
      background-color 160ms var(--ease-out),
      border-color 160ms var(--ease-out),
      box-shadow 160ms var(--ease-out),
      color 160ms var(--ease-out);
  }

  .button:active,
  .composer-send:active,
  .room-bar-button:active,
  .person-call:active {
    transform: scale(0.97);
  }

  .call-button::before {
    transition:
      background-color 160ms var(--ease-out),
      transform 160ms var(--ease-out);
  }

  .call-button:active::before {
    transform: scale(0.94);
  }

  .message {
    animation: message-in 240ms var(--ease-out);
  }

  .ticket-art {
    animation: ticket-in 700ms var(--ease-out);
  }

  /* Llamada en curso de conectar: la celda late como un timbre. */
  .call-placeholder::before,
  .call-placeholder::after {
    grid-area: 1 / 1;
    width: 96px;
    height: 96px;
    border: 2px solid rgb(255 178 36 / 55%);
    border-radius: 50%;
    content: "";
    animation: ring 2.4s var(--ease-out) infinite;
  }

  .call-placeholder::after {
    animation-delay: 1.2s;
  }

  .call-placeholder-mark {
    grid-area: 1 / 1;
  }
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes ticket-in {
  from {
    opacity: 0;
    transform: translateY(16px) rotate(-11deg);
  }
}

@keyframes ring {
  from {
    opacity: 1;
    transform: scale(0.9);
  }

  to {
    opacity: 0;
    transform: scale(2.2);
  }
}

/* 15. Adjuntos, acciones y normas -------------------------------------- */

.composer-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink-2);
}

.composer-tool:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.composer-tool:disabled {
  cursor: progress;
  opacity: 0.55;
}

.composer-tool .icon {
  width: 20px;
  height: 20px;
}

.composer-attach {
  grid-area: attach;
}

.composer-voice {
  grid-area: mic;
}

.composer-voice[aria-pressed="true"] {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: 6px 6px 6px var(--space-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: var(--text-sm);
  grid-area: chip;
}

.attachment-chip-busy {
  opacity: 0.7;
}

.attachment-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  display: inline-flex;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
}

.attachment-remove:hover {
  background: var(--surface-hover);
}

.voice-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--danger-text);
  font-size: var(--text-sm);
  font-weight: 650;
  grid-area: recording;
}

.voice-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--danger);
}

.voice-timer {
  font-variant-numeric: tabular-nums;
}

.voice-cancel {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-xs);
}

.message-image-link {
  display: block;
  margin: 4px 0 2px;
}

.message-image {
  display: block;
  max-width: min(100%, 320px);
  max-height: 320px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.message-audio {
  display: block;
  width: min(280px, 100%);
  margin: 4px 0 2px;
}

.message-file {
  display: grid;
  gap: 2px;
  margin: 4px 0 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.message-own .message-file {
  border-color: rgb(255 255 255 / 18%);
  background: rgb(255 255 255 / 8%);
  color: var(--own-text);
}

.message-file-name {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.message-file-size {
  color: var(--muted);
  font-size: var(--text-xs);
}

.message-own .message-file-size {
  color: var(--own-muted);
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: 2px;
}

.message-action {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-decoration: underline;
}

.message-own .message-action {
  color: var(--own-muted);
}

.message-action:hover {
  color: var(--danger-text);
}

/* "Borrar" solo en los mensajes propios, o en todos para quien creó la sala;
   "Reportar" solo en los mensajes de otras personas. */
.message-delete,
.message-own .message-report {
  display: none;
}

.message-own .message-delete,
.messages-owner .message-delete {
  display: inline;
}

.message-reported {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message-reported::after {
  content: "Reportado (" attr(data-reports) ")";
  display: block;
  margin-top: 2px;
  color: var(--accent-icon);
  font-size: 0.6875rem;
  font-weight: 700;
}

.rules-consent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--ink-2);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.rules-consent input,
.whisper-preference input {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--accent-edge);
}

.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* 16. Salas públicas y susurros ----------------------------------------- */

.public-rooms {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.public-rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.public-rooms-heading {
  font-size: var(--text-lg);
  font-weight: 700;
}

.public-rooms-refresh {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

.public-rooms-hint,
.public-rooms-empty {
  color: var(--muted);
  font-size: var(--text-sm);
}

.public-room-list {
  display: grid;
  gap: var(--space-2);
  max-height: 260px;
  overflow-y: auto;
  list-style: none;
}

.public-room {
  display: grid;
  grid-template: "title join" auto "members join" auto / minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-3);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.public-room-title {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
  grid-area: title;
}

.public-room-members {
  color: var(--muted);
  font-size: var(--text-xs);
  grid-area: members;
}

.public-room-join {
  grid-area: join;
}

.public-room-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2);
}

.room-kind {
  grid-column: 1 / -1;
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 700;
}

/* Un susurro no tiene invitación que compartir. */
.room-bar[data-visibility="whisper"] > :not(.room-kind) {
  display: none;
}

/* Las salas estrictas no admiten notas de voz. */
.chat[data-visibility="public"] .composer-voice,
.chat[data-visibility="whisper"] .composer-voice {
  display: none;
}

.person-whisper {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

.whisper-preference {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.whisper-dialog {
  position: fixed;
  z-index: 20;
  right: var(--space-4);
  bottom: 96px;
  left: var(--space-4);
  max-width: 420px;
  margin-inline: auto;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-3);
}

.whisper-from {
  margin-bottom: var(--space-3);
  font-weight: 600;
  line-height: 1.45;
}

.whisper-actions {
  display: flex;
  gap: var(--space-2);
}

/* 14. Estados ocultos ------------------------------------------------------
   Los scripts muestran y ocultan con el atributo hidden; estas reglas ganan
   en especificidad a los display de cada componente. */

.home[hidden],
.chat[hidden],
.call[hidden],
.home-error[hidden],
.people-empty[hidden],
.error[hidden],
.room-bar-button[hidden],
.call-button[hidden],
.call-security-code[hidden],
.call-video-local[hidden],
.attachment-chip[hidden],
.voice-status[hidden],
.public-rooms-empty[hidden],
.whisper-preference[hidden],
.whisper-dialog[hidden] {
  display: none;
}
