/* ---------- Design tokens ----------
   Contrato visual da fase 1 (01-UI-SPEC.md). Os nomes são contrato:
   admin.css e o modal de nome consomem estas variáveis por nome e
   nunca repetem literais hex. Todo CSS novo usa var(--token). */

:root {
  /* Superfícies */
  --page-bg: #fff9ef 0%, #fff 50%, #f9f5ef 100%;
  --surface: #fffdfb;
  --surface-2: #fdf8ee;
  --surface-sunk: #f7f1e9;
  --border: #eadfd6;
  --border-2: #eadcc4;

  /* Tinta */
  --ink: #422b31;
  --ink-body: #2a2e35;
  --ink-muted: #6b5d5a;
  --ink-label: #8a6d73;

  /* Ação */
  --accent: #916455;
  --accent-hover: #7a5346;
  --accent-tint: #f3e7e0;
  --accent-grad: #dbaa98, #b77e90;
  --on-accent: #ffffff;

  /* Festivo: anel de story, botao de gravar e progresso. O dourado abre o
     gradiente e os dois stops seguintes vem do accent do tema (UAT-G2). */
  --story-grad: #e7c988, #d790a5 55%, #b07688;

  /* Foco: o rosa claro de antes dava 1.95:1 contra a superfície e reprovava o
     mínimo de 3:1 da WCAG 1.4.11 para indicador de foco. A base passa a ser
     #b5768a (3.49:1); o tom antigo sobrevive abaixo como --ring-soft, o
     tracejado decorativo do .drop-zone e do .story-ring-add, que não carrega
     informação nenhuma. Mesma classe de correção que a fase 1 fez no accent. */
  --focus-ring: #b5768a;
  --ring-soft: #d7aeb7;

  /* Semântico */
  --danger: #ba3d45;
  --danger-hover: #9e3138;
  --danger-tint: #fbe9ea;
  --success: #2a7a4d;

  /* Marca (não é accent funcional) */
  --brand-grad: linear-gradient(135deg, #d790a5, #b07688);

  /* Espaçamento */
  --sp-xs: 4px;  --sp-sm: 8px;  --sp-md: 16px;
  --sp-lg: 24px; --sp-xl: 32px; --sp-2xl: 48px; --sp-3xl: 64px;
  --touch: 44px;

  /* Raio */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  /* Tipografia */
  --fs-display: 32px; --fs-heading: 20px; --fs-body: 16px; --fs-label: 13px;
  --fw-regular: 400; --fw-bold: 700;
  --lh-tight: 1.2; --lh-body: 1.5;
  --font-ui: Inter, "Segoe UI", Arial, sans-serif;
  --font-display: Georgia, serif;

  /* Elevação */
  --shadow-card: 0 10px 40px rgba(121, 94, 83, 0.07);
  --shadow-overlay: 0 25px 80px rgba(0, 0, 0, 0.35);
  --shadow-bar: 0 -6px 24px rgba(121, 94, 83, 0.12);

  /* Movimento */
  --t-fast: 150ms; --t-base: 190ms; --t-slow: 260ms; --ease: ease;
}

/* ---------- Presets de paleta (02-UI-SPEC.md) ----------
   Aplicados por atributo no <html> das paginas publicas (D-17). admin.html NUNCA
   declara data-theme: a area do casal fica em Rose para sempre. Cada bloco declara
   os MESMOS 21 nomes do :root — nome novo aqui e contrato quebrado, e o
   tests/theme-contrast.test.js reprova. */

[data-theme="rose"] {
  --page-bg: #fff9ef 0%, #fff 50%, #f9f5ef 100%;
  --surface: #fffdfb;      --surface-2: #fdf8ee;   --surface-sunk: #f7f1e9;
  --border: #eadfd6;       --border-2: #eadcc4;
  --ink: #422b31;          --ink-body: #2a2e35;    --ink-muted: #6b5d5a;   --ink-label: #8a6d73;
  --accent: #916455;       --accent-hover: #7a5346; --accent-tint: #f3e7e0;
  --accent-grad: #dbaa98, #b77e90;                 --on-accent: #ffffff;
  --story-grad: #e7c988, #d790a5 55%, #b07688;
  --focus-ring: #b5768a;   --ring-soft: #d7aeb7;
  --danger: #ba3d45;       --danger-tint: #fbe9ea; --success: #2a7a4d;
  --shadow-card: 0 10px 40px rgba(121, 94, 83, 0.07);
}

[data-theme="salvia"] {
  --page-bg: #f6f8f4 0%, #fff 50%, #f2f5ef 100%;
  --surface: #fdfefc;      --surface-2: #f0f4ec;   --surface-sunk: #e8eee3;
  --border: #dbe4d5;       --border-2: #cddcc4;
  --ink: #25332a;          --ink-body: #232a26;    --ink-muted: #586458;   --ink-label: #66755f;
  --accent: #4d6b4f;       --accent-hover: #3b5540; --accent-tint: #e6efe3;
  --accent-grad: #93b394, #4d6b4f;                 --on-accent: #ffffff;
  --story-grad: #e7c988, #93b394 55%, #4d6b4f;
  --focus-ring: #688c69;   --ring-soft: #a9c2a9;
  --danger: #ba3d45;       --danger-tint: #fbe9ea; --success: #2a7a4d;
  --shadow-card: 0 10px 40px rgba(70, 86, 70, 0.08);
}

[data-theme="ceu"] {
  --page-bg: #f2f7fb 0%, #fff 50%, #eef4f9 100%;
  --surface: #fcfdfe;      --surface-2: #eef4f9;   --surface-sunk: #e4edf5;
  --border: #d6e2ec;       --border-2: #c6d8e6;
  --ink: #1f2d3a;          --ink-body: #23303c;    --ink-muted: #54636f;   --ink-label: #62727f;
  --accent: #2f6690;       --accent-hover: #245273; --accent-tint: #e3eef7;
  --accent-grad: #7fb0d0, #2f6690;                 --on-accent: #ffffff;
  --story-grad: #e7c988, #7fb0d0 55%, #2f6690;
  --focus-ring: #5289af;   --ring-soft: #a8c9de;
  --danger: #ba3d45;       --danger-tint: #fbe9ea; --success: #2a7a4d;
  --shadow-card: 0 10px 40px rgba(47, 78, 110, 0.08);
}

/* Noite inverte o par de acao: accent claro, texto escuro sobre ele. E por isso que
   --on-accent existe — nenhum seletor precisa saber qual preset esta ativo. */
[data-theme="noite"] {
  --page-bg: #1d1a22 0%, #16141a 50%, #121016 100%;
  --surface: #211e27;      --surface-2: #2a2632;   --surface-sunk: #191720;
  --border: #332e3d;       --border-2: #3d3749;
  --ink: #f5f0f2;          --ink-body: #ece7ea;    --ink-muted: #b3a9b1;   --ink-label: #a2969f;
  --accent: #e2c08d;       --accent-hover: #efd3a8; --accent-tint: #3a3129;
  --accent-grad: #c9a97a, #e2c08d;                 --on-accent: #1a1720;
  --story-grad: #c9a97a, #e2c08d 55%, #efd3a8;
  --focus-ring: #e8c99b;   --ring-soft: #5f5670;
  --danger: #ff8b93;       --danger-tint: #3a2126; --success: #7ddba4;
  --shadow-card: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink-body);
  background: radial-gradient(circle at top left, var(--page-bg));
  min-height: 100vh;
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent-grad));
  box-shadow: var(--shadow-card);
}

.event-kicker {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-label);
}

.app-header h1 {
  margin-top: 4px;
  font-family: Georgia, serif;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1;
  color: var(--ink);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.moments-counter {
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-grad));
  color: var(--on-accent);
  padding: 8px 16px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow-card);
  white-space: nowrap;
}

.tag {
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  padding: 10px 18px;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* Identidade do evento (02-10): capa e mensagem injetadas pelo servidor.
   Slot vazio nao pode reservar espaco: sem capa, o layout tipografico de hoje
   continua exatamente igual (IC-13). */
.event-slot:empty { display: none; }

.event-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border-radius: var(--r-xl);
  background: var(--surface-2);      /* enquanto carrega: cor solida, nunca spinner */
  display: block;
  margin-bottom: var(--sp-lg);
}

/* aspect-ratio + max-height dao altura deterministica antes da imagem carregar: zero CLS. */
.event-cover--hero { max-height: 260px; }
.event-cover--banner { max-height: 180px; }

@media (min-width: 760px) {
  .event-cover--hero { max-height: 360px; }
  .event-cover--banner { max-height: 240px; }
}

/* Capa como fundo translucido do cabecalho (UAT-G1). A foto do casal tem
   luminancia imprevisivel, entao ela nunca segura texto sozinha: a opacidade
   baixa mistura a imagem com a superficie do tema, e o contraste do conteudo
   continua governado pelos tokens — mesma razao de ser do antigo IC-13. */
.app-header { position: relative; }

.app-header:has(.event-cover) {
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.app-header > .event-slot {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.app-header > :not(.event-slot) {
  position: relative;
  z-index: 1;
}

.app-header .event-cover,
.app-header .event-cover--hero,
.app-header .event-cover--banner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  margin: 0;
  opacity: 0.25;
}

.event-welcome {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-body);
  max-width: 60ch;
  margin-bottom: var(--sp-lg);
}

.upload-panel {
  margin-top: 42px;
}

.hero-card {
  background: var(--surface);
  border-radius: 36px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: clamp(20px, 5vw, 54px);
  display: grid;
  grid-template-columns: minmax(250px, 0.88fr) minmax(310px, 1fr);
  gap: clamp(20px, 4vw, 60px);
  align-items: center;
}

.hero-copy {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Peso 800 -> 700 em todo o arquivo: nenhum webfont é carregado, então a
   fallback real (Segoe UI / Arial) tem uma única face bold e 700 e 800
   renderizam idênticos. A escala do UI-SPEC só permite 400 e 700. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-label);
}

.eyebrow::before {
  content: '';
  width: 38px;
  height: 2px;
  background: var(--ring-soft);
}

.hero-copy h2 {
  margin-top: 24px;
  font-family: Georgia, serif;
  color: var(--ink);
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.95;
}

.subtitle {
  margin-top: 24px;
  color: var(--ink-muted);
  line-height: 1.8;
  font-size: 18px;
}

.upload-card {
  background: var(--surface);
  border-radius: 26px;
  border: 1px solid var(--border);
  padding: 26px;
}

.drop-zone {
  border-radius: 24px;
  border: 2px dashed var(--ring-soft);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Era um gradiente de dois brancos literais. Em Rosé a diferença para o
     --surface é de 3/255 por canal, invisível; em Noite era uma ilha branca de
     15.86:1 no meio do card escuro — o alvo de toque principal do convidado. */
  background: var(--surface);
  transition: all 250ms ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.drop-zone input[type="file"] {
  display: none;
}

.icon-cloud {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--ink);
  font-size: 42px;
  line-height: 1;
  margin-bottom: 10px;
}

.drop-title {
  font-weight: 700;
  color: var(--ink);
}

.drop-subtitle {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 4px;
}

.selected-files-wrap {
  margin-top: 20px;
}

.selected-files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.selected-files-header span {
  color: var(--ink-muted);
  font-size: 13px;
}

.file-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 208px;
  overflow-y: auto;
}

.file-list li.thumb {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-sunk);
  flex-shrink: 0;
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(66, 43, 49, 0.65);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.thumb-remove:hover {
  background: rgba(66, 43, 49, 0.9);
}

.file-list li.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-list li.thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 24px;
}

.file-list li.thumb-fallback::after {
  content: '📷';
}

.progress-section {
  margin-top: 20px;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--ink-muted);
  font-size: 13px;
}

.progress-track {
  height: 15px;
  border-radius: 999px;
  background: var(--surface-sunk);
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-grad));
  transition: width 220ms ease;
}

.secondary-button {
  width: 100%;
  margin-top: 22px;
  border: 1px solid var(--border-2);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink-muted);
  min-height: 46px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 190ms ease;
}

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

.secondary-button + .primary-button {
  margin-top: 12px;
}

/* Contraste: branco sobre #b77f68 dá 3.36:1 e reprova o AA (4.5:1).
   A base passa a ser o antigo hover #916455 (--accent), que dá 5.05:1,
   e o hover desce para #7a5346 (--accent-hover), 6.66:1.
   #b77f68 continua válido como tint decorativo (barra de progresso, bordas). */
.primary-button {
  width: 100%;
  margin-top: 22px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  min-height: 46px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 190ms ease, transform 190ms ease;
}

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

.hidden {
  display: none !important;
}

.message {
  min-height: 24px;
  margin-top: 14px;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 13px;
}

.message.success {
  color: var(--success);
}

.message.error {
  color: var(--danger);
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    min-height: auto;
  }

  .hero-copy h2 {
    font-size: 42px;
  }
}

.header-pills {
  display: flex;
  gap: 8px;
}

.tag-link {
  text-decoration: none;
  background: var(--surface);
  transition: background 190ms ease;
}

.tag-link:hover {
  background: var(--surface-2);
}

.album-panel {
  margin-top: 42px;
}

.album-status {
  text-align: center;
  color: var(--ink-muted);
  font-size: 15px;
  padding: 40px 0;
}

.album-status.error {
  color: var(--danger);
  font-weight: 700;
}

.album-grid {
  columns: 4 220px;
  column-gap: 14px;
}

.album-item {
  break-inside: avoid;
  margin: 0 0 14px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.album-item img {
  display: block;
  width: 100%;
  cursor: pointer;
  transition: transform 220ms ease;
}

.album-item img:hover {
  transform: scale(1.02);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(30, 20, 22, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox img {
  max-width: 100%;
  max-height: 92vh;
  border-radius: 12px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.landing-actions {
  margin-top: 34px;
  display: flex;
  gap: 12px;
}

.landing-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0 34px;
  margin-top: 0;
  text-decoration: none;
}

.landing-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 24px;
}

.feature-icon {
  font-size: 26px;
}

.feature-card h3 {
  margin-top: 10px;
  font-family: Georgia, serif;
  color: var(--ink);
  font-size: 19px;
}

.feature-card p {
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.6;
}

.login-panel {
  margin-top: 42px;
  display: flex;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-card);
  padding: 38px 34px;
}

.login-card h2 {
  font-family: Georgia, serif;
  color: var(--ink);
  font-size: 30px;
}

.login-subtitle {
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 14px;
}

.field-label {
  display: block;
  margin-top: 22px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
}

.field-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 46px;
  padding: 0 14px;
  font-size: 16px; /* >= 16px evita o zoom automático do iOS ao focar */
  color: var(--ink-body);
  background: var(--surface);
}

/* Indicador de foco usa --focus-ring (3.49:1), não o --ring-soft decorativo:
   é ele que diz onde o teclado está, então precisa cumprir a WCAG 1.4.11. */
.field-input:focus {
  outline: 2px solid var(--focus-ring);
  border-color: transparent;
}

.admin-panel {
  margin-top: 42px;
}


button.tag-link {
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 760px) {
  .landing-actions {
    flex-direction: column;
  }

  .landing-button {
    width: 100%;
  }
}

/* ---------- Stories ---------- */

.stories-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow-card);
  padding: 18px 20px 14px;
  margin-bottom: 26px;
}

.stories-bar {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.stories-bar::-webkit-scrollbar {
  display: none;
}

.story-item {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.story-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(140deg, var(--story-grad));
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
}

.story-ring-fallback::after {
  content: '🎞️';
  font-size: 24px;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--surface-sunk);
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-ring-add {
  background: var(--surface-2);
  border: 2px dashed var(--ring-soft);
  padding: 0;
}

.story-add-icon {
  font-size: 30px;
  color: var(--accent);
  font-weight: 300;
}

.story-name {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 700;
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Player de stories ---------- */

.story-viewer,
.story-recorder {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #1b1215;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-viewer video,
.story-recorder video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.story-progress {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 60px;
  display: flex;
  gap: 5px;
  z-index: 2;
}

.story-progress-track {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.story-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--story-grad));
}

.story-overlay-close {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 3;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.story-tap {
  position: absolute;
  top: 0;
  bottom: 90px;
  width: 35%;
  z-index: 1;
}

.story-tap-left {
  left: 0;
}

.story-tap-right {
  right: 0;
  width: 65%;
}

/* ---------- Gravador ---------- */

#recorderLive,
#recorderReview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#recorderLive video,
#recorderReview video {
  flex: 1;
  min-height: 0;
}

.recorder-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 22px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, transparent, rgba(27, 18, 21, 0.85));
}

.record-button {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(140deg, var(--story-grad));
  cursor: pointer;
  transition: transform 150ms ease;
}

.record-button.recording {
  transform: scale(0.82);
  border-radius: 18px;
  background: #d9534f;
}

.record-timer {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
}

.recorder-hint {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  text-align: center;
}

.review-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 420px;
}

.review-actions .secondary-button,
.review-actions .primary-button {
  margin-top: 0;
}

.recorder-message {
  color: #fff;
  text-align: center;
}

.recorder-message.error {
  color: #ffb3b8;
}

.stories-counter {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border-2);
  box-shadow: none;
}

/* ---------- Mobile first: refinamentos para smartphones ---------- */

.recorder-controls {
  padding-bottom: calc(30px + env(safe-area-inset-bottom));
}

.story-progress {
  top: calc(14px + env(safe-area-inset-top));
}

.story-overlay-close {
  top: calc(10px + env(safe-area-inset-top));
}

button,
.tag-link {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 16px 12px calc(24px + env(safe-area-inset-bottom));
  }

  .header-right {
    align-items: flex-start;
    width: 100%;
  }

  .header-pills {
    flex-wrap: wrap;
  }

  .tag {
    padding: 9px 14px;
  }

  .moments-counter {
    font-size: 12px;
    padding: 7px 14px;
  }

  .upload-panel,
  .album-panel,
  .admin-panel,
  .login-panel {
    margin-top: 22px;
  }

  .hero-card {
    border-radius: 22px;
    padding: 18px;
  }

  .upload-card {
    padding: 16px;
    border-radius: 20px;
  }

  .subtitle {
    font-size: 16px;
    margin-top: 14px;
  }

  .hero-copy h2 {
    margin-top: 14px;
  }

  .stories-section {
    padding: 12px 14px 10px;
    border-radius: 18px;
    margin-bottom: 16px;
  }

  .story-ring {
    width: 62px;
    height: 62px;
  }

  .album-grid {
    columns: 2;
    column-gap: 10px;
  }

  .album-item {
    margin-bottom: 10px;
    border-radius: 14px;
  }

  .thumb-remove {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .file-list li.thumb {
    width: 84px;
    height: 84px;
  }

  .login-card {
    padding: 26px 20px;
    border-radius: 22px;
  }

  .lightbox {
    padding: 10px;
  }

  .lightbox img {
    border-radius: 8px;
  }
}

/* ---------- QR Code ---------- */

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-muted);
}

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(30, 20, 22, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.qr-card {
  position: relative;
  background: var(--surface);
  border-radius: 28px;
  padding: 34px 30px 26px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
}

.qr-card h3 {
  font-family: Georgia, serif;
  color: var(--ink);
  font-size: 22px;
}

.qr-card img {
  width: 100%;
  max-width: 240px;
  margin: 18px auto 0;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* O card de QR abre em upload.html e album.html, que são tematizadas: com o
   texto em literal, o hint sumiria sobre o --surface escuro do preset Noite. */
.qr-hint {
  margin-top: 14px;
  color: var(--ink-muted);
  font-size: 14px;
}

.qr-url {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  word-break: break-all;
}

.qr-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#storyVideo {
  transition: opacity 280ms ease, transform 280ms ease;
  opacity: 1;
  transform: scale(1);
}

#storyVideo.story-switching {
  opacity: 0;
  transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
  #storyVideo {
    transition: none;
  }
}

/* ---------- Stories: foto, legenda e câmera ---------- */

#storyImage {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 280ms ease, transform 280ms ease;
  opacity: 1;
  transform: scale(1);
}

#storyImage.story-switching {
  opacity: 0;
  transform: scale(0.96);
}

.story-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 46px 20px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(27, 18, 21, 0.82));
  color: rgba(255, 255, 255, 0.94);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.story-caption.expanded {
  -webkit-line-clamp: unset;
  max-height: 60vh;
  overflow-y: auto;
}

.recorder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.toolbar-spacer {
  width: 44px;
  flex-shrink: 0;
}

.flip-button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

#recorderPreview.mirrored {
  transform: scaleX(-1);
}

.mode-toggle {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px;
}

.mode-chip {
  border: 0;
  border-radius: 999px;
  padding: 7px 18px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.mode-chip.active {
  background: var(--surface);
  color: var(--ink);
}

.record-button.photo-mode {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.5);
}

#recorderReview img {
  flex: 1;
  min-height: 0;
  object-fit: contain;
  width: 100%;
}

.caption-input {
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  background: rgba(27, 18, 21, 0.6);
  color: #fff;
  padding: 12px 14px;
  font-size: 16px; /* >= 16px evita o zoom automático do iOS ao focar */
  font-family: inherit;
  resize: none;
}

.caption-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.caption-input:focus {
  outline: 2px solid var(--focus-ring);
  border-color: transparent;
}

/* ---------- Componentes compartilhados (fase 1) ----------
   Só consomem var(--token); nenhum hex literal novo entra daqui para baixo.
   Consumidos por public/identity.js (modal de nome, linha de identidade)
   e pela área do casal (botão de perigo). */

/* Mesma estrutura do .primary-button, com a cor semântica de perigo.
   Branco sobre #ba3d45 dá 5.47:1 — AA. Sem margin-top: quem posiciona
   é o container (.name-modal-actions ou a barra de ações do sheet). */
.danger-button {
  width: 100%;
  border: none;
  border-radius: var(--r-md);
  background: var(--danger);
  color: #fff;
  min-height: 46px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background var(--t-base) var(--ease);
}

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

/* z-index 100: o modal dispara ao publicar um story, então precisa ficar
   acima do recorder (80) e do overlay de QR (90). Visibilidade é sempre
   pela classe .hidden — nunca style.display. */
.name-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(30, 20, 22, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
}

.name-modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  max-width: 340px;
  width: 100%;
  text-align: left;
  box-shadow: var(--shadow-overlay);
}

/* font-weight explícito anula o bold padrão do browser em heading:
   o display em Georgia já carrega o peso visual em 400. */
.name-modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-heading);
  font-weight: var(--fw-regular);
  color: var(--ink);
  line-height: var(--lh-tight);
}

.name-modal-body {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-muted);
  margin-top: var(--sp-sm);
}

.name-modal-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: var(--touch);
  padding: 0 14px;
  font-size: var(--fs-body); /* >= 16px evita o zoom automático do iOS ao focar */
  color: var(--ink-body);
  background: var(--surface);
  margin-top: var(--sp-md);
}

.name-modal-field:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: transparent;
}

/* min-height reserva a linha do erro: a mensagem aparecer não pode
   empurrar os botões para baixo enquanto o dedo já está indo neles. */
.name-modal-error {
  font-size: var(--fs-label);
  font-weight: var(--fw-bold);
  color: var(--danger);
  margin-top: var(--sp-sm);
  min-height: 18px;
}

.name-modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-top: var(--sp-md);
}

/* Zera o margin-top: 22px herdado de .primary-button/.secondary-button —
   o espaçamento aqui é do gap do flex. */
.name-modal-actions button {
  margin-top: 0;
}

.name-modal-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.identity-line {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  min-height: var(--touch);
  font-size: var(--fs-label);
  color: var(--ink-muted);
}

.identity-action {
  min-height: var(--touch);
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: var(--fw-bold);
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.name-modal-card button:focus-visible,
.identity-action:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .name-modal *,
  .danger-button {
    transition: none;
    animation: none;
  }
}

/* ---------- Faixa de envio de stories (topo da página) ---------- */

/* z-index 70: acima do conteúdo, mas abaixo do recorder (80) — gravar outro
   story cobre a faixa, e o envio continua correndo por trás */
.story-upload-strip {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  padding: 10px 16px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-2);
  box-shadow: 0 6px 18px rgba(27, 18, 21, 0.12);
}

.story-upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-muted);
}

.story-upload-track {
  height: 6px;
  margin-top: 8px;
}

.story-upload-retry {
  border: 1px solid var(--border-2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
}
