/* WhatsApp Android (Material) look-alike. Tokens on :root, dark mode via prefers-color-scheme. */
:root {
  color-scheme: light dark;
  --green: #ffffff;
  --green-btn: #008069;
  --link-text: #008069;
  --accent: #1daa61;
  --brand: #1daa61;
  --appbar-text: #111b21;
  --fab: #1daa61;
  --fab-icon: #ffffff;
  --nav-pill: #d8fdd2;
  --search: #f0f2f5;
  --bg: #ffffff;
  --bg-page: #d1d7db;
  --text: #111b21;
  --text-2: #667781;
  --sep: #e9edef;
  --row-press: #f5f6f6;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --chip: #ffffff;
  --composer: #f0f2f5;
  --pill: #ffffff;
  --menu: #ffffff;
  --dialog: #ffffff;
  --snackbar: #323232;
  --skel: #e9edef;
  --fb-bg: #dfe5e7;
  --err: #d93025;
  --shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --doodle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='rgba(11,20,26,0.07)' stroke-width='1.2'><circle cx='20' cy='24' r='5'/><path d='M70 20 l6 -8 l6 8 z'/><rect x='110' y='16' width='12' height='12' rx='3'/><path d='M30 110 q6 -10 12 0 t12 0'/><circle cx='120' cy='120' r='3'/><path d='M80 80 l10 4 l-4 10 z'/><path d='M140 70 l-6 6 m0 -6 l6 6'/></g></svg>");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #0b141a;
    --green-btn: #00a884;
    --link-text: #00a884;
    --accent: #21c063;
    --brand: #ffffff;
    --appbar-text: #e9edef;
    --fab: #21c063;
    --fab-icon: #0b141a;
    --nav-pill: #103529;
    --search: #202c33;
    --bg: #0b141a;
    --bg-page: #0b141a;
    --text: #e9edef;
    --text-2: #8696a0;
    --sep: #1f2a30;
    --row-press: #2a3942;
    --chat-bg: #0b141a;
    --bubble-in: #202c33;
    --bubble-out: #005c4b;
    --chip: #182229;
    --composer: #1f2c34;
    --pill: #2a3942;
    --menu: #233138;
    --dialog: #233138;
    --snackbar: #323232;
    --skel: #2a3942;
    --fb-bg: #6a7175;
    --err: #f28b82;
    --shadow: 0 1px 0.5px rgba(11, 20, 26, 0.4);
    --doodle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='1.2'><circle cx='20' cy='24' r='5'/><path d='M70 20 l6 -8 l6 8 z'/><rect x='110' y='16' width='12' height='12' rx='3'/><path d='M30 110 q6 -10 12 0 t12 0'/><circle cx='120' cy='120' r='3'/><path d='M80 80 l10 4 l-4 10 z'/><path d='M140 70 l-6 6 m0 -6 l6 6'/></g></svg>");
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-page);
  color: var(--text);
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
}
@media (min-width: 481px) {
  .app { box-shadow: 0 0 14px rgba(0, 0, 0, 0.25); }
}

/* Screens and slide transition */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.screen.pre-enter,
.screen.leaving { transform: translateX(100%); }
.screen.leaving { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .screen { transition: none; }
}

/* App bar */
.appbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  padding: 0 4px 0 16px;
  background: var(--green);
  color: var(--appbar-text);
  flex: 0 0 auto;
}
.app-title {
  margin: 0;
  flex: 1;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.appbar-actions { display: flex; align-items: center; }
.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-btn:active { background: rgba(127, 127, 127, 0.18); }
.icon-btn:focus-visible,
.row:focus-visible,
.bubble:focus-visible,
.tab:focus-visible,
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ic { width: 24px; height: 24px; fill: currentColor; }

.chat-bar .icon-btn { color: var(--appbar-text); }
.head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 2px;
}
.head-av { display: flex; flex: 0 0 auto; }
.head-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.head-name {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-sub {
  font-size: 13px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Menus */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 4px;
  top: 44px;
  min-width: 180px;
  padding: 8px 0;
  background: var(--menu);
  color: var(--text);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(11, 20, 26, 0.25);
  z-index: 10;
}
.menu[hidden] { display: none; }
.menu-item {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: 0;
  background: none;
  color: var(--text);
  font: 400 15px Roboto, system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.menu-item:active { background: var(--row-press); }

/* Tabs */
.tabs {
  display: flex;
  flex: 0 0 auto;
  background: var(--green);
  position: relative;
  z-index: 1;
}
.tab {
  position: relative;
  flex: 1;
  padding: 14px 0 12px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.7);
  font: 500 14px Roboto, system-ui, sans-serif;
  cursor: pointer;
}
.tab.active { color: #ffffff; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 32%;
  right: 32%;
  bottom: 0;
  height: 3px;
  background: #ffffff;
  border-radius: 3px 3px 0 0;
}

/* Chat list */
.list-scroll {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 88px;
}
.ptr { display: none; justify-content: center; padding: 8px 0; }
.ptr.on { display: flex; }
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--sep);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.row {
  display: flex;
  align-items: stretch;
  min-height: 72px;
  padding-left: 13px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.row:active { background: var(--row-press); }
.row > .avatar { align-self: center; margin-right: 15px; }
.row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--sep);
}
.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.row-name {
  font-size: 17px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-prev {
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  align-self: stretch;
  justify-content: center;
}
.row-time { font-size: 12px; color: var(--text-2); }
.row-time.unread { color: var(--accent); }
.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
}

/* Avatars */
.avatar {
  position: relative;
  width: 49px;
  height: 49px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--fb-bg);
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 40px; height: 40px; }
.avatar.av28 { width: 28px; height: 28px; align-self: flex-end; }
.fb {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--fb-bg);
}
.fb .ic { width: 78%; height: 78%; fill: #ffffff; }

/* Skeletons */
.sk {
  display: block;
  background: var(--skel);
  border-radius: 6px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }
.sk-row {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 16px 12px 13px;
}
.sk-row .sk.circle { width: 49px; height: 49px; border-radius: 50%; flex: 0 0 auto; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.sk-lines .sk:first-child { width: 45%; height: 14px; }
.sk-lines .sk:last-child { width: 75%; height: 12px; }
.sk-chat { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.sk-chat .sk { height: 52px; width: 60%; border-radius: 8px; }
.sk-chat .sk:nth-child(even) { align-self: flex-end; width: 45%; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
  line-height: 20px;
}

/* Floating action button */
.fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 16px;
  background: var(--fab);
  color: var(--fab-icon);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}
.fab .ic { fill: var(--fab-icon); width: 24px; height: 24px; }
.fab { bottom: 92px; }

/* Conversation and thread */
.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px 12px;
  background-color: var(--chat-bg);
  background-image: var(--doodle);
  background-repeat: repeat;
}
.chip-wrap { display: flex; justify-content: center; margin: 8px 0; }
.chip {
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--chip);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 18px;
  box-shadow: var(--shadow);
}
.chat-error {
  margin: auto;
  padding: 24px;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}

.row-msg {
  display: flex;
  align-items: flex-end;
  margin: 2px 0;
}
.row-msg.first { margin-top: 8px; }
.row-msg.out { justify-content: flex-end; }
.row-msg.grp { gap: 6px; }
.av-spacer { flex: 0 0 28px; width: 28px; }

.bubble {
  position: relative;
  max-width: 80%;
  min-width: 96px;
  padding: 6px 7px 8px 9px;
  border-radius: 7.5px;
  background: var(--bubble-in);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.bubble.out { background: var(--bubble-out); cursor: default; }
.bubble.in:not([data-id]) { cursor: default; }
.bubble.tail.in { border-top-left-radius: 0; }
.bubble.tail.out { border-top-right-radius: 0; }
.bubble.tail::before {
  content: "";
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
  background: inherit;
}
.bubble.tail.in::before { left: -8px; clip-path: polygon(100% 0, 100% 100%, 0 0); }
.bubble.tail.out::before { right: -8px; clip-path: polygon(0 0, 0 100%, 100% 0); }

.b-text {
  font-size: 14.2px;
  line-height: 19px;
  white-space: pre-wrap;
  color: var(--text);
}
.fwd {
  margin-bottom: 2px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-2);
}
.media-img {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 6px;
  margin: 2px 0 4px;
}
.gname { margin-bottom: 2px; font-size: 12.8px; font-weight: 500; }
.b-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
  font-size: 11px;
  line-height: 15px;
  color: var(--text-2);
}
.b-replies { margin-right: auto; color: var(--link-text); }
.b-time { white-space: nowrap; }

/* Composer (decorative) */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 5px 6px 6px;
  background: var(--composer);
  flex: 0 0 auto;
}
.pill {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px 0 4px;
  border-radius: 24px;
  background: var(--pill);
  box-shadow: var(--shadow);
}
.pill input {
  flex: 1;
  min-width: 0;
  padding: 0 6px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px Roboto, system-ui, sans-serif;
}
.pill input::placeholder { color: var(--text-2); }
.pill .icon-btn { width: 36px; height: 36px; color: var(--text-2); }
.mic {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--green-btn);
  color: #ffffff;
  cursor: pointer;
}
.mic .ic { fill: #ffffff; }

/* Material dialog */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}
.dialog {
  width: 100%;
  max-width: 328px;
  padding: 24px 24px 12px;
  border-radius: 28px;
  background: var(--dialog);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.dlg-title { margin: 0 0 16px; font-size: 24px; font-weight: 400; line-height: 32px; }
.dlg-body { font-size: 14px; line-height: 20px; color: var(--text-2); }
.dlg-body p { margin: 0 0 4px; }
.dlg-body b { color: var(--text); font-weight: 500; }
.dlg-input {
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 2px solid var(--green-btn);
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px Roboto, system-ui, sans-serif;
}
.dlg-error { min-height: 18px; margin: 6px 0 0; font-size: 13px; color: var(--err); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-btn {
  padding: 10px 12px;
  border: 0;
  border-radius: 20px;
  background: none;
  color: var(--link-text);
  font: 500 14px Roboto, system-ui, sans-serif;
  cursor: pointer;
}

/* Snackbar */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  width: max-content;
  max-width: min(440px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 4px;
  background: var(--snackbar);
  color: #ffffff;
  font-size: 14px;
  line-height: 20px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- WhatsApp 2025: cabecera, buscador y barra inferior ---------- */
.home-bar { height: 64px; padding-left: 16px; }
.home-bar .app-title { font-size: 24px; font-weight: 500; }
.home-bar .app-title.brand { color: var(--brand); font-weight: 700; letter-spacing: 0; }
.home-bar .icon-btn { color: var(--appbar-text); }
.chat-bar { border-bottom: 1px solid var(--sep); }

.search {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 2px 12px 8px;
  padding: 0 18px;
  height: 46px;
  border-radius: 24px;
  background: var(--search);
  color: var(--text-2);
  cursor: text;
}
.search .ic { width: 22px; height: 22px; flex: 0 0 auto; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 16px Roboto, system-ui, sans-serif;
}
.search input::placeholder { color: var(--text-2); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.list-scroll { padding-bottom: 96px; }
.row[hidden] { display: none; }

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  height: 80px;
  padding: 10px 4px 8px;
  background: var(--bg);
  border-top: 1px solid var(--sep);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  color: var(--text);
  font: 500 13px Roboto, system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-ic {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 32px;
  border-radius: 16px;
}
.nav-item.active .nav-ic { background: var(--nav-pill); }
.nav-item.active .nav-label { font-weight: 700; }
.nav-dot {
  position: absolute;
  top: 1px;
  right: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.section-label { padding: 8px 16px 4px; font-size: 14px; color: var(--text-2); }
.muted-ic { color: var(--text-2); display: grid; place-items: center; }
.muted-ic .ic { width: 22px; height: 22px; }
.empty-ic { display: block; margin: 0 auto 12px; width: 48px; opacity: 0.5; }
.empty-ic .ic { width: 48px; height: 48px; }

.about-hero { text-align: center; padding: 20px 24px 24px; border-bottom: 1px solid var(--sep); }
.about-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fab);
  color: var(--fab-icon);
}
.about-logo .ic { width: 36px; height: 36px; }
.about-name { font-size: 22px; font-weight: 500; }
.about-sub { margin-top: 6px; font-size: 14px; line-height: 20px; color: var(--text-2); }
.about-item { display: flex; gap: 20px; padding: 16px 20px; }
.about-ic { color: var(--text-2); flex: 0 0 auto; padding-top: 2px; }
.about-title { font-size: 16px; margin-bottom: 4px; }
.about-text { font-size: 14px; line-height: 20px; color: var(--text-2); }
.about-foot { padding: 16px 20px 24px; text-align: center; font-size: 13px; color: var(--text-2); }

.row-body { border-bottom: 0; }
.row { min-height: 76px; }

/* Tweet citado (como la cita de un mensaje en WhatsApp) */
.quote {
  display: flex;
  margin: 2px 0 6px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.12);
  border-left: 4px solid var(--qc, var(--accent));
}
.q-main { flex: 1; min-width: 0; padding: 6px 8px; }
.q-name { font-size: 13px; font-weight: 500; color: var(--qc, var(--accent)); margin-bottom: 2px; }
.q-text {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-2);
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.q-thumb { width: 64px; flex: 0 0 64px; object-fit: cover; align-self: stretch; min-height: 64px; }

/* Vídeo: miniatura con botón de play */
.media { position: relative; }
.media.video::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='white' d='M8 5v14l11-7z'/></svg>") center / 28px no-repeat;
}

/* Enlaces, multimedia tocable y visor a pantalla completa */
.lnk { color: #027eb5; text-decoration: none; word-break: break-all; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lnk { color: #53bdeb; } }
.media, .quote { cursor: pointer; }
a.menu-item { display: block; color: inherit; text-decoration: none; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: #000;
}
.viewer img, .viewer video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 8px;
  color: #fff;
  background: linear-gradient(rgba(0, 0, 0, 0.6), transparent);
}

/* Badge de un hilo ya leído: gris, como un chat silenciado en WhatsApp */
.badge.read { background: var(--text-2); color: var(--bg); }
