/* Mostrador — lenguaje visual de iOS: materiales translúcidos que flotan sobre el contenido,
   tipografía del sistema, añil como color de la marca y ámbar solo para las notas internas. */
html { font-size: 106.25%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }   /* respeta el tamaño de texto del iPhone */

:root {
  --bg: #ffffff; --bg-group: #f2f2f7; --card: #ffffff;
  --ink: #000000; --ink-2: #6c6c70; --ink-3: #8e8e93;
  --sep: rgba(60, 60, 67, .2); --fill: rgba(120, 120, 128, .12); --fill-2: rgba(120, 120, 128, .2);
  --accent: #3d4edb; --on-accent: #ffffff; --accent-soft: rgba(61, 78, 219, .12);
  --bubble: #3d4edb; --in: #e9e9eb;
  --note: #ffe9a6; --note-ink: #463600; --note-edge: #dfae2c;
  --danger: #d93a4f; --ok: #1fa97e; --warn: #e08a1e;
  --glass: rgba(255, 255, 255, .72); --glass-thick: rgba(250, 250, 252, .9); --glass-edge: rgba(255, 255, 255, .7); --glass-line: rgba(0, 0, 0, .07);
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .06);
  --scrim: rgba(0, 0, 0, .32);

  /* escala tipográfica de iOS, en rem para crecer con el texto del usuario */
  --t-large: 2rem; --t-title: 1.294rem; --t-title3: 1.176rem; --t-body: 1rem; --t-sub: .882rem;
  --t-foot: .765rem; --t-cap: .706rem; --t-cap2: .647rem;

  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --vh: 100dvh;
  --safe-t: max(env(safe-area-inset-top, 0px), 6px); --safe-b: env(safe-area-inset-bottom, 0px);
  --bar: 44px; --tab: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --bg-group: #000000; --card: #1c1c1e;
    --ink: #ffffff; --ink-2: #a1a1a8; --ink-3: #74747a;
    --sep: rgba(84, 84, 88, .6); --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36);
    --accent: #8c99ff; --on-accent: #ffffff; --accent-soft: rgba(140, 153, 255, .2);
    --bubble: #4353e4; --in: #262629;
    --note: #4a3e12; --note-ink: #ffe9a6; --note-edge: #b8902a;
    --danger: #ff6b7f; --ok: #46cfa9; --warn: #f0a85a;
    --glass: rgba(40, 40, 44, .7); --glass-thick: rgba(38, 38, 42, .9); --glass-edge: rgba(255, 255, 255, .14); --glass-line: rgba(255, 255, 255, .06);
    --glass-shadow: 0 8px 28px rgba(0, 0, 0, .5);
    --scrim: rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; overscroll-behavior: none; }
body { font-size: var(--t-body); line-height: 1.3; color: var(--ink); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; touch-action: manipulation; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
svg { width: 24px; height: 24px; display: block; flex: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.muted { color: var(--ink-2); font-size: var(--t-sub); }
.small { font-size: var(--t-foot); }
.grow { flex: 1; min-width: 0; }
.pad { padding: 12px 16px; }
.error { color: var(--danger); font-size: var(--t-sub); margin-top: 10px; }

#root { position: fixed; inset: 0 0 auto 0; height: var(--vh); overflow: hidden; background: #000; }
#stage { position: absolute; inset: 0; background: var(--bg); overflow: hidden; transform-origin: 50% 0; will-change: transform; }
#stage > section { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ----- material: una capa translúcida que flota, con borde claro donde "le da la luz" ----- */
.glass, .glass-btn {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%);
  box-shadow: inset 0 .5px 0 var(--glass-edge), 0 0 0 .5px var(--glass-line), var(--glass-shadow);
}
.quick-pop.glass, .ctx-menu.glass, .toast-in.glass { background: var(--glass-thick); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%); }
.glass-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); flex: none; position: relative;
  box-shadow: inset 0 .5px 0 var(--glass-edge), 0 0 0 .5px var(--glass-line), 0 3px 12px rgba(0, 0, 0, .1); }

/* ----- respuesta al toque: en el instante de presionar, no al soltar ----- */
.btn, .glass-btn, .send-btn, .in-btn, .chips button, .tabbar button, .pick button, .days button, .swatches button, .chat-who, .banner, .audio .play {
  transition: transform .24s var(--ease-out), opacity .24s var(--ease-out), background-color .2s ease; }
.btn:active, .chips button:active, .pick button:active, .days button:active, .chat-who:active, .banner:active { transform: scale(.97); transition-duration: .1s; }
.glass-btn:active, .send-btn:active, .in-btn:active, .swatches button:active, .audio .play:active { transform: scale(.9); transition-duration: .1s; }
.tabbar button:active .tab-ic { transform: scale(.88); transition-duration: .1s; }
.row, .cell, .menu button, .quick-pop button, .ctx-menu button { transition: background-color .35s ease; }
.row:active, button.cell:active, .menu button:active, .quick-pop button:active, .ctx-menu button:active { background-color: var(--fill-2); transition-duration: 0s; }

/* ----- botones y campos ----- */
.btn { display: flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 20px; border-radius: 25px;
  background: var(--fill); color: var(--accent); font-weight: 600; width: 100%; margin-top: 10px; }
.btn.primary { background: var(--bubble); color: #fff; }
.btn.text { background: none; }
.btn.danger, .danger { color: var(--danger); }
.btn.small { width: auto; min-height: 34px; padding: 0 14px; margin: 0; font-size: var(--t-sub); background: var(--accent-soft); }
.btn:disabled { opacity: .5; }
.field { display: block; margin-top: 14px; }
.field > span, .field-label { display: block; font-size: var(--t-foot); color: var(--ink-2); margin: 14px 0 6px 14px; }
.field > span { margin-top: 0; }
.field input, .field select, .area { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 0;
  background: var(--card); outline: none; -webkit-appearance: none; appearance: none; box-shadow: 0 0 0 0 var(--accent); transition: box-shadow .2s ease; }
#login .field input, .view:not(.grouped) .field input { background: var(--fill); }
.field select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.area { resize: none; line-height: 1.3; display: block; }
.field input:focus, .field select:focus, .area:focus { box-shadow: 0 0 0 2px var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ----- entrada y vinculación ----- */
.center-screen { overflow-y: auto; padding: calc(var(--safe-t) + 24px) 24px calc(var(--safe-b) + 24px); align-items: center; background: var(--bg); }
.card-form, .link-box { width: 100%; max-width: 380px; margin: auto; }
.brand-mark { width: 68px; height: 68px; border-radius: 16px; display: block; margin-bottom: 20px; }
.card-form h1, .link-box h1 { font-size: var(--t-large); line-height: 1.1; letter-spacing: -.015em; margin-bottom: 8px; }
.qr-card { background: #fff; border-radius: 28px; padding: 16px; margin: 20px 0; aspect-ratio: 1; display: grid; place-items: center; box-shadow: 0 0 0 .5px var(--sep), 0 12px 40px rgba(0, 0, 0, .08); }
.qr-card img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.steps { margin: 0 0 12px; padding-left: 24px; }
.steps li { margin: 7px 0; padding-left: 4px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.link-box .small { margin-top: 18px; }
.pair-code { font-size: 2rem; font-weight: 700; letter-spacing: .12em; text-align: center; margin: 18px 0 10px; font-variant-numeric: tabular-nums; }

/* ----- pantallas con título grande que se recoge al desplazar ----- */
#main { background: var(--bg); will-change: transform; }
#main-dim { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 9; }
.view { position: absolute; inset: 0; background: var(--bg); }
.view.grouped { background: var(--bg-group); }
.navbar { position: absolute; inset: 0 0 auto 0; height: calc(var(--safe-t) + var(--bar)); padding-top: var(--safe-t); z-index: 4; display: grid; place-items: center; pointer-events: none; }
/* borde de desplazamiento: el contenido se desvanece bajo la barra en vez de chocar con una línea */
.navbar::before { content: ""; position: absolute; inset: 0 0 -22px 0; background: var(--bg);
  -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent);
  opacity: 0; transition: opacity .25s ease; }
.grouped .navbar::before { background: var(--bg-group); }
.nav-title { position: relative; font-weight: 600; opacity: 0; transform: translateY(5px); transition: opacity .2s ease, transform .3s var(--ease-out); }
.scrolled .navbar::before, .scrolled .nav-title { opacity: 1; }
.scrolled .nav-title { transform: none; }
.nav-action { position: absolute; right: 12px; top: var(--safe-t); pointer-events: auto; color: var(--accent); }
.scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: calc(var(--safe-t) + var(--bar)) 0 calc(var(--tab) + var(--safe-b) + 34px); }
.large-title { font-size: var(--t-large); font-weight: 700; letter-spacing: -.015em; line-height: 1.12; padding: 2px 16px 6px; }
.grouped .scroll { padding-left: 16px; padding-right: 16px; }
.grouped .large-title { padding-left: 4px; }

.search { margin: 4px 16px 0; position: relative; }
.search-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search-ic svg { width: 18px; height: 18px; }
.search input { width: 100%; height: 38px; border-radius: 19px; border: 0; background: var(--fill); padding: 0 14px 0 35px; outline: none; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-decoration { display: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--fill); color: var(--ink); font-size: var(--t-sub); display: flex; align-items: center; gap: 6px;
  transition: transform .24s var(--ease-out), background-color .2s ease, color .2s ease; }
.chips button.has-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chips button[aria-selected="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
.list-head { padding: 18px 20px 6px; font-size: var(--t-foot); font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .02em; }
.empty { color: var(--ink-2); text-align: center; padding: 56px 36px; font-size: var(--t-sub); }

/* ----- fila de chat ----- */
.row { display: flex; gap: 12px; width: 100%; padding: 9px 16px 0; align-items: flex-start; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-bottom: 10px; box-shadow: 0 .5px 0 var(--sep); min-height: 62px; }
.row-top, .row-sub { display: flex; align-items: baseline; gap: 8px; }
.row-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.row time { font-size: var(--t-sub); color: var(--ink-3); flex: none; }
.row.unread time { color: var(--accent); }
.row-sub { align-items: center; min-height: 22px; }
.row-prev { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); font-size: var(--t-sub); }
.row-marks { display: flex; align-items: center; gap: 6px; flex: none; color: var(--ink-3); }
.mark svg { width: 16px; height: 16px; }
.mark.note { color: var(--note-edge); }
.count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--bubble); color: #fff; font-size: var(--t-foot); font-weight: 600; display: grid; place-items: center; }
.row-labels { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.label { font-size: var(--t-cap); font-weight: 600; padding: 2px 8px; border-radius: 7px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
@media (prefers-color-scheme: dark) { .label { color: color-mix(in srgb, var(--c) 50%, #fff); background: color-mix(in srgb, var(--c) 28%, transparent); } }
.tick { display: inline-block; vertical-align: -3px; margin-right: 3px; color: var(--ink-3); }
.tick svg { width: 18px; height: 15px; display: inline; }
.tick.read { color: var(--accent); }
.list.stagger .row { animation: rise .45s var(--ease-out) backwards; }
.list.stagger .row:nth-child(2) { animation-delay: 35ms; } .list.stagger .row:nth-child(3) { animation-delay: 70ms; }
.list.stagger .row:nth-child(4) { animation-delay: 105ms; } .list.stagger .row:nth-child(5) { animation-delay: 140ms; }
.list.stagger .row:nth-child(6) { animation-delay: 175ms; } .list.stagger .row:nth-child(n+7) { animation-delay: 210ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative; overflow: hidden; font-weight: 600; font-size: 1.1rem; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 55%; height: 55%; }
.avatar.sm { width: 32px; height: 32px; font-size: .76rem; }
.avatar.lg { width: 96px; height: 96px; font-size: 2rem; }
.tint0 { background: linear-gradient(#e6e9ff, #cfd5ff); color: #2f3db3; } .tint1 { background: linear-gradient(#dff5ee, #c4eadc); color: #0b6e55; }
.tint2 { background: linear-gradient(#fdebd7, #f8d9b8); color: #96500e; } .tint3 { background: linear-gradient(#fbe1e7, #f5c9d3); color: #96233a; }
.tint4 { background: linear-gradient(#efe4fb, #decdf5); color: #6730a0; } .tint5 { background: linear-gradient(#e0f0fa, #c7e2f4); color: #165f8f; }
@media (prefers-color-scheme: dark) {
  .tint0 { background: linear-gradient(#343d85, #262d66); color: #cdd3ff; } .tint1 { background: linear-gradient(#185444, #103a2f); color: #a6ead6; }
  .tint2 { background: linear-gradient(#69441f, #4a3016); color: #f8d6ae; } .tint3 { background: linear-gradient(#6b2a39, #4b1d28); color: #f9c2cd; }
  .tint4 { background: linear-gradient(#503276, #382353); color: #dfc9f8; } .tint5 { background: linear-gradient(#215273, #173a52); color: #bfe1f6; }
}

/* ----- barra de pestañas flotante ----- */
.tabbar { position: absolute; left: 50%; bottom: max(calc(var(--safe-b) - 14px), 10px); transform: translateX(-50%); width: min(calc(100% - 44px), 340px);
  height: var(--tab); border-radius: 31px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; z-index: 5; }
.tab-thumb { position: absolute; top: 4px; left: 4px; bottom: 4px; width: calc((100% - 8px) / 3); border-radius: 27px; background: var(--fill-2); will-change: transform; }
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: var(--t-cap2); font-weight: 600; color: var(--ink); border-radius: 27px;
  transition: color .2s ease; }
.tabbar button.on { color: var(--accent); }
.tab-ic { transition: transform .3s var(--ease-out); }
.tabbar i, #back-count { position: absolute; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bubble); color: #fff; font-size: var(--t-cap2); font-weight: 600; font-style: normal; display: grid; place-items: center; }
.tabbar i { top: 5px; left: calc(50% + 7px); }
.banner { position: absolute; left: 50%; bottom: calc(var(--tab) + max(calc(var(--safe-b) - 14px), 10px) + 10px); transform: translateX(-50%); z-index: 5; white-space: nowrap;
  height: 36px; padding: 0 16px; border-radius: 18px; font-size: var(--t-foot); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.banner:active { transform: translateX(-50%) scale(.97); }
.banner::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }

/* ----- Negocio y Ajustes: listas agrupadas ----- */
.group { margin-top: 26px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px 2px; min-height: 34px; }
.group h2 { font-size: var(--t-title3); font-weight: 600; letter-spacing: -.005em; }
.group > .muted { margin: 0 4px; }
.cells { background: var(--card); border-radius: 22px; margin-top: 10px; overflow: hidden; }
.cell { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px; box-shadow: 0 .5px 0 var(--sep); }
.cell:last-child { box-shadow: none; }
button.cell::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-top: 2px solid var(--ink-3); transform: rotate(45deg); flex: none; opacity: .7; }
.cell.col { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; row-gap: 2px; }
.cell.col b, .cell.col .clamp { grid-column: 1; }
.cell.col::after { grid-column: 2; grid-row: 1 / 3; }
.cell small { color: var(--ink-3); font-size: var(--t-sub); }
.cell b { font-weight: 600; }
.clamp { color: var(--ink-2); font-size: var(--t-sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--ink-3)); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }
.switch { position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 1; }
.switch i { display: block; width: 51px; height: 31px; border-radius: 16px; background: var(--fill-2); transition: background-color .25s ease; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 14px; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .22); transition: transform .32s var(--ease-out), width .32s var(--ease-out); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:active + i::after { width: 33px; }                         /* la perilla se estira al presionar, como en iOS */
.switch input:checked:active + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--fill); border-radius: 12px; padding: 2px; margin-top: 14px; position: relative; }
.seg::before { content: ""; position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc(50% - 2px); border-radius: 10px; background: var(--card); box-shadow: 0 2px 6px rgba(0, 0, 0, .12), 0 0 0 .5px var(--glass-line); transition: transform .34s var(--ease-out); }
.seg[data-i="1"]::before { transform: translateX(100%); }
@media (prefers-color-scheme: dark) { .seg::before { background: #5b5b60; } }
.seg button { position: relative; height: 34px; border-radius: 10px; text-align: center; font-size: var(--t-sub); font-weight: 500; }
.seg button[aria-pressed="true"] { font-weight: 600; }
.days { display: flex; gap: 6px; }
.days button { flex: 1; height: 44px; border-radius: 22px; background: var(--card); text-align: center; font-weight: 600; color: var(--ink-2); }
.days button[aria-pressed="true"] { background: var(--bubble); color: #fff; }

/* ----- conversación ----- */
.over { background: var(--bg); z-index: 10; will-change: transform; box-shadow: -1px 0 0 var(--sep); touch-action: pan-y; }
.chat-top { position: absolute; inset: 0 0 auto 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-t) + 2px) 10px 0; height: calc(var(--safe-t) + 50px); pointer-events: none; }
.chat-top > * { pointer-events: auto; }
.chat-top::before, .composer::before { content: ""; position: absolute; left: 0; right: 0; pointer-events: none; background: var(--bg); z-index: -1; }
.chat-top::before { top: 0; bottom: -26px; -webkit-mask-image: linear-gradient(#000 45%, transparent); mask-image: linear-gradient(#000 45%, transparent); opacity: .92; }
.composer::before { bottom: 0; top: -22px; -webkit-mask-image: linear-gradient(transparent, #000 60%); mask-image: linear-gradient(transparent, #000 60%); opacity: .92; }
#chat-back { color: var(--accent); }
#chat-back svg { margin-left: -2px; }
#back-count { top: -4px; right: -6px; }
.chat-top-space { width: 44px; flex: none; }
.chat-who { display: flex; align-items: center; gap: 8px; min-width: 0; height: 44px; padding: 0 16px 0 6px; border-radius: 22px; }
.who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.who-text b { font-weight: 600; font-size: var(--t-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { font-size: var(--t-cap2); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s ease; }
.who-text small.live { color: var(--accent); font-weight: 600; }

.msgs { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  padding: calc(var(--safe-t) + 58px) 12px var(--ch, 70px); }
.msgs-col { display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
#msgs-inner { display: flex; flex-direction: column; }
.day, .older { text-align: center; margin: 16px 0 8px; font-size: var(--t-cap); font-weight: 600; color: var(--ink-3); }
.older { font-weight: 400; margin: 4px 0; }
.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; max-width: 100%; position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; will-change: transform; }
.msg.cont { margin-top: 2px; }
.msg.me { align-items: flex-end; }
.bubble { --b-ink: var(--ink); --b-sub: var(--ink-2); --b-acc: var(--accent); --b-fill: rgba(120, 120, 128, .14);
  max-width: min(78%, 520px); padding: 7px 12px; border-radius: 19px; background: var(--in); color: var(--b-ink); position: relative;
  display: flex; flex-direction: column; gap: 4px; min-width: 48px; overflow-wrap: anywhere; transition: transform .3s var(--ease-out); transform-origin: 0 100%; }
.msg.me .bubble { --b-ink: #fff; --b-sub: rgba(255, 255, 255, .74); --b-acc: #fff; --b-fill: rgba(255, 255, 255, .2); background: var(--bubble); transform-origin: 100% 100%; }
.msg.them:not(.cont) .bubble { border-top-left-radius: 19px; } .msg.them .bubble { border-bottom-left-radius: 6px; }
.msg.me .bubble { border-bottom-right-radius: 6px; }
.msg.them.cont .bubble { border-top-left-radius: 6px; } .msg.me.cont .bubble { border-top-right-radius: 6px; }
.msg.pressing .bubble, .note-item.pressing { transform: scale(.96); }
.msg.flash .bubble { animation: flash 1.1s ease; }
@keyframes flash { 30% { filter: brightness(.82); } }
.text { white-space: pre-wrap; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.sender { font-size: var(--t-foot); font-weight: 600; color: var(--b-acc); }
.meta { align-self: flex-end; font-size: var(--t-cap2); color: var(--b-sub); display: flex; align-items: center; gap: 3px; margin: -1px -2px 0 0; }
.meta .tick { margin: 0; vertical-align: 0; color: inherit; }
.msg.me .meta .tick.read { color: #8fe6ff; }
.meta .tick svg { width: 17px; height: 14px; display: block; }
.sys { font-style: italic; color: var(--b-sub); font-size: var(--t-sub); }
.quoted { display: flex; flex-direction: column; font-size: var(--t-foot); padding: 5px 9px; border-radius: 10px; border-left: 3px solid var(--b-acc); background: var(--b-fill); color: var(--b-sub); max-height: 62px; overflow: hidden; margin: 1px -4px 0; }
.quoted b { color: var(--b-acc); font-weight: 600; }
.media { display: block; width: 264px; max-width: 100%; max-height: 340px; min-height: 90px; object-fit: cover; border-radius: 15px; background: var(--b-fill); }
.bubble:has(.media) { padding: 4px; }
.bubble:has(.media) > :not(.media) { margin-left: 8px; margin-right: 8px; }
.bubble:has(.media) > .meta { margin-bottom: 3px; }
.bubble.bare > .meta { position: absolute; right: 10px; bottom: 9px; margin: 0; padding: 2px 7px; border-radius: 10px; background: rgba(0, 0, 0, .45); color: #fff; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.t-sticker .bubble, .jumbo .bubble { background: none !important; padding: 0; --b-sub: var(--ink-3); }
.sticker { width: 140px; height: 140px; object-fit: contain; }
.jumbo .text { font-size: 2.9rem; line-height: 1.15; }
.msg.me.jumbo .meta .tick.read { color: var(--accent); }
.file { display: flex; align-items: center; gap: 10px; text-decoration: none !important; color: inherit; padding: 4px 0; min-width: 190px; }
.file svg { width: 30px; height: 30px; color: var(--b-acc); }
.file span { display: flex; flex-direction: column; min-width: 0; }
.file b { font-weight: 600; font-size: var(--t-sub); overflow-wrap: anywhere; }
.file small { font-size: var(--t-foot); color: var(--b-sub); }
.audio { display: flex; align-items: center; gap: 10px; width: min(230px, 60vw); padding: 3px 0 0; }
.audio .play { width: 38px; height: 38px; border-radius: 50%; background: var(--b-acc); color: var(--in); display: grid; place-items: center; flex: none; }
.msg.me .audio .play { color: var(--bubble); }
.audio .play svg { width: 20px; height: 20px; }
.audio .bar { flex: 1; height: 30px; display: flex; align-items: center; position: relative; }
.audio .bar::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--b-fill); }
.audio .bar i { position: relative; height: 4px; border-radius: 2px; background: var(--b-acc); width: 100%; transform-origin: 0 50%; transform: scaleX(0); }
.audio .dur { font-size: var(--t-cap); color: var(--b-sub); font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
.reacts { font-size: var(--t-sub); background: var(--bg); box-shadow: 0 0 0 .5px var(--sep), 0 1px 4px rgba(0, 0, 0, .1); border-radius: 13px; padding: 1px 8px; margin: -7px 10px 0; z-index: 1; }
.swipe-ic { position: absolute; left: -34px; top: 50%; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%; background: var(--fill-2); color: var(--ink-2); display: grid; place-items: center; pointer-events: none; }
.swipe-ic svg { width: 17px; height: 17px; }
.dots { flex-direction: row !important; gap: 4px !important; padding: 13px 14px !important; min-width: 0 !important; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); animation: dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .16s; } .dots i:nth-child(3) { animation-delay: .32s; }
@keyframes dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* notas internas: papel ámbar con la esquina doblada, fuera del hilo de burbujas */
.note-item { align-self: center; width: min(88%, 480px); background: var(--note); color: var(--note-ink); border-radius: 6px 16px 6px 6px; padding: 9px 13px 8px; margin: 12px 0 4px; display: flex; flex-direction: column; gap: 3px; position: relative;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: transform .3s var(--ease-out);
  background-image: linear-gradient(225deg, var(--bg) 0 11px, var(--note-edge) 11px 12.5px, transparent 12.5px); }
.note-head { display: flex; align-items: center; gap: 5px; font-size: var(--t-cap); font-weight: 600; opacity: .78; }
.note-head svg { width: 14px; height: 14px; }
.note-text { white-space: pre-wrap; font-size: var(--t-sub); overflow-wrap: anywhere; }
.note-item time { font-size: var(--t-cap2); opacity: .7; align-self: flex-end; }
.sheet .note-item { width: 100%; margin: 8px 0 0; background-image: linear-gradient(225deg, var(--bg-group) 0 11px, var(--note-edge) 11px 12.5px, transparent 12.5px); }
@media (prefers-color-scheme: dark) { .sheet .note-item { background-image: linear-gradient(225deg, #1c1c1e 0 11px, var(--note-edge) 11px 12.5px, transparent 12.5px); } }

.to-bottom { position: absolute; right: 12px; bottom: calc(var(--ch, 70px) + 6px); width: 40px; height: 40px; color: var(--accent); z-index: 2;
  opacity: 0; transform: scale(.8); pointer-events: none; transition: opacity .2s ease, transform .3s var(--ease-out); }
.to-bottom.show { opacity: 1; transform: none; pointer-events: auto; }
.to-bottom.show:active { transform: scale(.9); }
.quick-pop { position: absolute; left: 10px; right: 10px; bottom: calc(var(--ch, 70px) + 2px); max-height: 46%; overflow-y: auto; border-radius: 22px; z-index: 3; transform-origin: 30px 100%;
  transition: opacity .2s ease, transform .3s var(--ease-out), filter .2s ease, display .3s allow-discrete; }
.quick-pop[hidden] { display: none !important; }
@starting-style { .quick-pop { opacity: 0; transform: scale(.94) translateY(8px); filter: blur(6px); } }
.quick-pop button { display: flex; flex-direction: column; width: 100%; padding: 11px 16px; box-shadow: 0 .5px 0 var(--sep); gap: 1px; }
.quick-pop button:last-child { box-shadow: none; }
.quick-pop b { color: var(--accent); font-size: var(--t-sub); font-weight: 600; }
.quick-pop span { color: var(--ink-2); font-size: var(--t-sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.composer { position: absolute; inset: auto 0 0 0; z-index: 3; padding: 6px 10px max(calc(var(--safe-b) - 14px), 8px); }
/* Con el teclado abierto el borde inferior del iPhone queda tapado: la barra de mensaje se pega al teclado
   y la barra de pestañas se esconde detrás, como en las apps nativas. */
.kb .composer { padding-bottom: 8px; }
.kb .tabbar, .kb .banner { visibility: hidden; }
.c-row { display: flex; align-items: flex-end; gap: 8px; }
#attach { width: 42px; height: 42px; color: var(--ink-2); transition: transform .24s var(--ease-out), opacity .2s ease; }
.c-pill { flex: 1; min-width: 0; border-radius: 21px; overflow: hidden; transition: background-color .25s ease; }
.c-input { display: flex; align-items: flex-end; min-height: 42px; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; background: none; padding: 10px 4px 10px 15px; outline: none; line-height: 1.3; min-height: 42px; max-height: 130px; }
.composer textarea::placeholder { color: var(--ink-3); }
.in-btn { width: 34px; height: 34px; margin: 4px 0; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.in-btn svg { width: 22px; height: 22px; }
.send-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--bubble); color: #fff; display: grid; place-items: center; flex: none; margin: 4px; position: relative; }
.send-btn svg { width: 20px; height: 20px; }
/* micrófono y flecha comparten botón: se relevan con un fundido desenfocado en vez de un corte */
.send-btn span { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .2s ease, transform .3s var(--ease-out), filter .2s ease; }
.send-btn[data-mode="mic"] .ic-send, .send-btn[data-mode="send"] .ic-mic { opacity: 0; transform: scale(.5); filter: blur(3px); }
.note-toggle[aria-pressed="true"] { color: var(--note-ink); background: var(--note-edge); }
.composer.noting .c-pill { background: var(--note); }
.composer.noting textarea { color: var(--note-ink); }
.composer.noting textarea::placeholder { color: color-mix(in srgb, var(--note-ink) 60%, transparent); }
.composer.noting .send-btn { background: var(--note-ink); color: var(--note); }
.composer.noting #attach { display: none; }
.reply-bar { display: flex; align-items: center; gap: 6px; margin: 6px 6px 0; padding: 4px 2px 4px 10px; border-left: 3px solid var(--accent); background: var(--fill); border-radius: 10px; }
.reply-bar span { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--t-foot); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar b { color: var(--accent); font-weight: 600; }
.rec { align-items: center; gap: 8px; padding-left: 4px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes pulse { 50% { opacity: .25; } }

/* ----- hojas: suben desde abajo, se arrastran con el dedo y empujan el fondo hacia atrás ----- */
.sheet-wrap { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.sheet-bg { position: absolute; inset: 0; background: var(--scrim); opacity: 0; }
.sheet { position: relative; width: 100%; max-width: 560px; margin: 0 auto; max-height: calc(100% - var(--safe-t) - 12px); overflow-y: auto; overscroll-behavior: contain; background: var(--bg-group);
  border-radius: 30px 30px 0 0; padding: 6px 16px calc(var(--safe-b) + 20px); will-change: transform; transform: translateY(100%); }
@media (prefers-color-scheme: dark) { .sheet { background: #1c1c1e; } .sheet .field input, .sheet .area, .sheet .field select, .sheet .menu, .sheet .days button { background: #2c2c2e; } }
.sheet::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 200px; background: inherit; }   /* para que un rebote no deje ver el fondo */
.sheet.tall { min-height: 62%; }
.sheet.bare { background: none; padding-left: 10px; padding-right: 10px; }
.sheet.bare::after, .sheet.bare .grab-zone { display: none; }
.grab-zone { position: sticky; top: 0; z-index: 2; height: 22px; margin: 0 -16px 4px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.grab { width: 36px; height: 5px; border-radius: 3px; background: var(--fill-2); }
.sheet h2 { font-size: var(--t-title); font-weight: 700; letter-spacing: -.01em; margin-bottom: 6px; padding: 0 4px; }
.sheet > .muted { padding: 0 4px; }
.sheet h3 { font-size: var(--t-foot); font-weight: 400; color: var(--ink-2); margin: 24px 0 8px 14px; }
.sheet-title { text-align: center; color: var(--ink-2); font-size: var(--t-foot); padding: 14px 16px; box-shadow: 0 .5px 0 var(--sep); }
.sheet-title b { color: var(--ink); font-size: var(--t-sub); }
.menu { background: var(--card); border-radius: 22px; overflow: hidden; margin-top: 8px; }
.sheet.bare .menu { background: var(--card); box-shadow: 0 10px 40px rgba(0, 0, 0, .18); }   /* sólido: dentro de una hoja en movimiento el desenfoque no alcanza el fondo */
@media (prefers-color-scheme: dark) { .sheet.bare .menu { background: #2c2c2e; } }
.menu button { display: block; width: 100%; min-height: 56px; padding: 0 18px; text-align: center; box-shadow: 0 .5px 0 var(--sep); color: var(--accent); font-size: var(--t-title3); }
.menu.left button { text-align: left; color: var(--ink); font-size: var(--t-body); min-height: 52px; }
.menu button.danger { color: var(--danger); }
.menu button:last-child { box-shadow: none; }
.info-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 4px 0 0; }
.info-head h2 { margin: 8px 0 0; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { height: 38px; padding: 0 14px; border-radius: 19px; font-size: var(--t-sub); font-weight: 500; color: var(--ink); background: var(--card); display: flex; align-items: center; gap: 7px;
  transition: transform .24s var(--ease-out), background-color .2s ease, color .2s ease; }
@media (prefers-color-scheme: dark) { .sheet .pick button { background: #2c2c2e; } }
.pick button::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); transition: background-color .2s ease; }
.pick button[aria-pressed="true"] { background: var(--c) !important; color: #fff; font-weight: 600; }
.pick button[aria-pressed="true"]::before { background: #fff; }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; padding: 2px 4px; }
.swatches button { width: 38px; height: 38px; border-radius: 50%; background: var(--c); transition: transform .24s var(--ease-out), box-shadow .2s ease; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg-group), 0 0 0 5.5px var(--c); }
.file-prev { display: grid; place-items: center; background: var(--fill); border-radius: 22px; overflow: hidden; min-height: 120px; }
.file-prev img, .file-prev video { max-width: 100%; max-height: 42vh; display: block; }

/* ----- menú contextual: nace del elemento que se mantuvo presionado ----- */
#ctx { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.ctx-wrap { position: absolute; inset: 0; pointer-events: auto; }
.ctx-bg { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); opacity: 0; transition: opacity .28s ease; }
.ctx-clone { position: absolute; margin: 0 !important; max-width: none !important; pointer-events: none; transition: transform .36s var(--ease-out); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.ctx-clone.row { background: var(--bg); border-radius: 22px; padding-bottom: 0; overflow: hidden; }
.ctx-clone.row .row-main { box-shadow: none; }
.ctx-menu { position: absolute; min-width: 230px; border-radius: 20px; overflow: hidden; opacity: 0; transform: scale(.82); filter: blur(8px);
  transition: opacity .2s ease, transform .34s var(--ease-out), filter .22s ease; }
.ctx-menu button { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; min-height: 46px; padding: 0 16px; box-shadow: 0 .5px 0 var(--sep); }
.ctx-menu button:last-child { box-shadow: none; }
.ctx-menu button svg { width: 20px; height: 20px; }
.ctx-menu button.danger { color: var(--danger); }
.ctx-wrap.in .ctx-bg { opacity: 1; }
.ctx-wrap.in .ctx-menu { opacity: 1; transform: none; filter: none; }
.ctx-wrap.out .ctx-bg, .ctx-wrap.out .ctx-menu { transition-duration: .16s; }
.ctx-wrap.out .ctx-clone { transition-duration: .2s; box-shadow: none; }

/* ----- visor de fotos: la foto sale de su miniatura y vuelve a ella ----- */
.viewer { position: fixed; inset: 0; z-index: 40; touch-action: none; }
.viewer-bg { position: absolute; inset: 0; background: #000; opacity: 0; }
.viewer img { position: absolute; left: 50%; top: 50%; will-change: transform; border-radius: 4px; -webkit-user-drag: none; user-select: none; }
.viewer .glass-btn { position: absolute; top: calc(var(--safe-t) + 8px); right: 12px; color: #fff; background: rgba(60, 60, 64, .6); transition: opacity .2s ease, transform .24s var(--ease-out); }

/* ----- aviso superior: entra y sale por arriba ----- */
#toast { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: center; z-index: 50; pointer-events: none; padding: calc(var(--safe-t) + 8px) 12px 0; }
.toast-in { padding: 11px 18px; border-radius: 24px; font-size: var(--t-sub); max-width: 440px; pointer-events: auto; touch-action: none; will-change: transform; line-height: 1.25; }
.toast-in b { font-weight: 600; }

/* pantallas anchas: lista a la izquierda y conversación a la derecha */
@media (min-width: 820px) {
  #main { right: auto; width: 380px; box-shadow: .5px 0 0 var(--sep); transform: none !important; }
  #main-dim { display: none; }
  #chat.over { left: 380px; transform: none !important; box-shadow: none; }
  #chat-back, .chat-top-space { display: none; }
  .chat-top { justify-content: center; }
}

/* ----- accesibilidad: menos movimiento, menos transparencia, más contraste ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-property: opacity, background-color, color, box-shadow !important; }
  .over, .sheet-wrap, .ctx-menu { animation: fade .2s ease !important; }
  @keyframes fade { from { opacity: 0; } }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--card); --glass-thick: var(--card); }
  .glass, .glass-btn, .ctx-bg { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .ctx-bg { background: rgba(0, 0, 0, .6); }
}
@media (prefers-contrast: more) {
  :root { --glass: var(--card); --glass-thick: var(--card); --sep: var(--ink-2); --ink-2: var(--ink); --ink-3: var(--ink); }
  .glass, .glass-btn { -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 0 0 1.5px var(--ink); }
  .bubble { box-shadow: 0 0 0 1px var(--ink); }
}
