/* Canal privado — interfaz de chat */

.tgcb-body { margin: 0; background: #dde5e1; }
@media (prefers-color-scheme: dark) { .tgcb-body { background: #0e1513; } }

#tgcb-app {
  --ink: #15211d;
  --muted: #5b6a64;
  --bg: #dde5e1;
  --surface: #ffffff;
  --chip: rgba(21, 33, 29, .07);
  --line: rgba(21, 33, 29, .11);
  --line-strong: rgba(21, 33, 29, .22);
  --mine: #1e4a3f;
  --mine-ink: #eef5f1;
  --accent: #1e4a3f;
  --focus: rgba(30, 74, 63, .22);
  --warn: #b3261e;
  --rec: #d13b2e;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Onest", system-ui, sans-serif;

  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font: 400 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
@media (prefers-color-scheme: dark) {
  #tgcb-app {
    --ink: #e2ebe7;
    --muted: #92a39c;
    --bg: #0e1513;
    --surface: #18221f;
    --chip: rgba(226, 235, 231, .08);
    --line: rgba(226, 235, 231, .1);
    --line-strong: rgba(226, 235, 231, .22);
    --mine: #2c6a5a;
    --mine-ink: #f2f8f5;
    --accent: #3a8a74;
    --focus: rgba(58, 138, 116, .35);
    --warn: #ff8a80;
  }
}
#tgcb-app *, #tgcb-app *::before, #tgcb-app *::after { box-sizing: border-box; }
#tgcb-app button { font: inherit; }
#tgcb-app button:focus-visible,
#tgcb-app a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tgcb-standalone { width: 100%; height: 100vh; height: var(--tgcb-vh, 100dvh); }
.tgcb-embed { width: 100%; height: min(720px, 85vh); border: 1px solid var(--line); border-radius: 20px; }

.tgcb-ico { display: inline-grid; place-items: center; line-height: 0; }
.tgcb-ico svg { width: 22px; height: 22px; display: block; }

/* ---------- Acceso ---------- */

.tgcb-login-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.tgcb-login {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
/* Sello: el elemento que da identidad al acceso */
.tgcb-seal {
  width: 92px;
  height: 92px;
  margin-bottom: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--mine-ink);
  background:
    radial-gradient(circle at 50% 50%, var(--mine) 0 58%, transparent 59%),
    repeating-conic-gradient(var(--mine) 0 6deg, transparent 6deg 12deg);
  box-shadow: inset 0 0 0 1px transparent;
}
.tgcb-seal .tgcb-ico svg { width: 32px; height: 32px; }
.tgcb-login-title {
  margin: 0 0 8px;
  font: 700 clamp(28px, 8vw, 38px)/1.08 var(--font-display);
  letter-spacing: -.02em;
  color: var(--ink);
}
.tgcb-login-sub { margin: 0 0 28px; max-width: 30ch; color: var(--muted); }
.tgcb-code-input {
  width: 100%;
  padding: 18px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 600 24px/1.1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-align: center;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.tgcb-code-input::placeholder {
  font: 400 17px/1.1 var(--font-body);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
.tgcb-code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }
.tgcb-login-error { min-height: 1.45em; margin: 10px 0 8px; color: var(--warn); font-size: 14px; }
.tgcb-btn-primary {
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--mine-ink);
  font-weight: 600 !important;
  cursor: pointer;
}
.tgcb-btn-primary:disabled { opacity: .65; cursor: default; }

/* ---------- Cabecera ---------- */

.tgcb-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 8px 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.tgcb-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--mine);
  color: var(--mine-ink);
  font: 700 18px/1 var(--font-display);
}
.tgcb-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tgcb-head-text strong {
  font: 600 17px/1.2 var(--font-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tgcb-head-sub {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tgcb-head-sub.is-offline { color: var(--warn); }

/* ---------- Lista ---------- */

.tgcb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px 10px;
}
.tgcb-list > :first-child { margin-top: auto; }
.tgcb-empty { margin: auto; padding: 24px; max-width: 30ch; text-align: center; color: var(--muted); }
.tgcb-empty strong { display: block; margin-bottom: 4px; color: var(--ink); font: 600 18px/1.3 var(--font-display); }
.tgcb-day {
  align-self: center;
  margin: 14px 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.tgcb-msg { display: flex; flex-direction: column; max-width: min(80%, 520px); }
.tgcb-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.tgcb-msg.is-theirs { align-self: flex-start; align-items: flex-start; }
.tgcb-msg.is-mine + .tgcb-msg.is-theirs,
.tgcb-msg.is-theirs + .tgcb-msg.is-mine { margin-top: 10px; }

.tgcb-bubble {
  position: relative;
  padding: 8px 12px 5px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.is-theirs .tgcb-bubble { border-bottom-left-radius: 6px; }
.is-mine .tgcb-bubble { background: var(--mine); color: var(--mine-ink); border-bottom-right-radius: 6px; }
.is-pending .tgcb-bubble { opacity: .7; }

.tgcb-text { margin: 0; white-space: pre-wrap; }
.tgcb-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.tgcb-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 3px;
  margin-top: 1px;
  font-size: 11.5px;
  opacity: .68;
  font-variant-numeric: tabular-nums;
}
.tgcb-meta .tgcb-ico svg { width: 14px; height: 14px; }

/* Fotos */
.tgcb-bubble.tgcb-t-photo { padding: 4px; }
.tgcb-photo {
  display: block;
  width: min(280px, 64vw);
  min-height: 140px;
  max-height: 380px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--chip);
  cursor: zoom-in;
}
.tgcb-photo.is-loaded { min-height: 0; }
.tgcb-t-photo .tgcb-text { padding: 6px 8px 0; }
.tgcb-t-photo .tgcb-meta { padding: 0 8px 2px; }

/* Notas de voz */
.tgcb-voice { display: flex; align-items: center; gap: 10px; width: min(250px, 62vw); padding: 2px 0 0; }
.tgcb-play {
  flex: none;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--mine-ink);
  cursor: pointer;
}
.is-mine .tgcb-play { background: var(--mine-ink); color: var(--mine); }
.tgcb-play:disabled { opacity: .6; }
.tgcb-play .tgcb-ico svg { width: 20px; height: 20px; }
.tgcb-wave { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.tgcb-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .28; }
.tgcb-wave i.on { opacity: 1; }
.tgcb-vtime { min-width: 32px; font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }

/* Archivos */
.tgcb-filelink {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; border: 0; background: none; color: inherit;
  text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}

.tgcb-failed {
  margin-top: 4px; padding: 2px; border: 0; background: none;
  color: var(--warn); font-size: 13px; cursor: pointer;
}

/* ---------- Redactor ---------- */

.tgcb-composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tgcb-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 16px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.4 var(--font-body);
  outline: none;
}
.tgcb-input::placeholder { color: var(--muted); }
.tgcb-input:focus { border-color: var(--accent); }
.tgcb-icon-btn {
  flex: none;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.tgcb-icon-btn:hover { background: var(--chip); color: var(--ink); }
.tgcb-action {
  flex: none;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--mine-ink);
  cursor: pointer;
  transition: transform .12s;
}
.tgcb-action:active { transform: scale(.9); }
.tgcb-action.is-rec { background: var(--rec); }

.tgcb-recbar {
  flex: 1; min-width: 0; height: 44px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-radius: 22px;
  background: var(--bg);
}
.tgcb-recdot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: tgcb-pulse 1.2s ease-in-out infinite; }
.tgcb-rectime { font-weight: 500; font-variant-numeric: tabular-nums; }
.tgcb-rechint { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes tgcb-pulse { 50% { opacity: .25; } }

/* ---------- Avisos y visor ---------- */

.tgcb-toast {
  position: absolute;
  top: 76px; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.tgcb-lightbox {
  position: fixed; inset: 0; z-index: 99999;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(6, 10, 9, .93);
  cursor: zoom-out;
}
.tgcb-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  .tgcb-recdot { animation: none; }
  .tgcb-action, .tgcb-code-input { transition: none; }
}

/* ---------- Editar y eliminar ---------- */

.tgcb-msg { position: relative; }
.tgcb-msg .tgcb-bubble.tgcb-t-deleted {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
}
.tgcb-t-deleted .tgcb-text { display: flex; align-items: center; gap: 6px; font-style: italic; }
.tgcb-t-deleted .tgcb-ico svg { width: 16px; height: 16px; }

.tgcb-more {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s;
}
.is-mine .tgcb-more { right: 100%; margin-right: 6px; }
.is-theirs .tgcb-more { left: 100%; margin-left: 6px; }
.tgcb-msg:hover .tgcb-more, .tgcb-more:focus-visible { opacity: 1; }
.tgcb-more .tgcb-ico svg { width: 18px; height: 18px; }
@media (pointer: coarse) {
  .tgcb-more { display: none; }
  .tgcb-bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

.tgcb-menu {
  position: absolute;
  z-index: 6;
  min-width: 200px;
  padding: 6px;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .2);
}
.tgcb-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: 0; border-radius: 9px;
  background: none; color: var(--ink);
  font-size: 15px; text-align: left;
  cursor: pointer;
}
.tgcb-menu button:hover, .tgcb-menu button:focus-visible { background: var(--chip); outline: none; }
.tgcb-menu button.is-danger { color: var(--warn); }
.tgcb-menu .tgcb-ico svg { width: 18px; height: 18px; }

.tgcb-editbar {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--accent);
}
.tgcb-editbar-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}
.tgcb-editbar-text strong { font-size: 13px; font-weight: 600; }
.tgcb-editbar-text span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tgcb-editbar + .tgcb-composer { border-top: 0; }
.tgcb-icon-btn:disabled { opacity: .35; cursor: default; }
@media (prefers-reduced-motion: reduce) { .tgcb-more { transition: none; } }

/* ---------- Historial ---------- */

.tgcb-history-top {
  align-self: center;
  padding: 6px 0 4px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.tgcb-history-top:empty { padding: 0; }
.tgcb-older {
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-size: 13px !important;
  cursor: pointer;
}

/* ---------- Ajustes ---------- */

.tgcb-sheet {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.tgcb-sheet-head {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.tgcb-sheet-head h2 { margin: 0; color: var(--ink); font: 600 19px/1.2 var(--font-display); }
.tgcb-sheet-body {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
}
.tgcb-section {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
}
.tgcb-section h3 { margin: 0; color: var(--ink); font: 600 17px/1.25 var(--font-display); }
.tgcb-section-desc { margin: -6px 0 0; color: var(--muted); font-size: 14px; }
.tgcb-field { display: flex; flex-direction: column; gap: 6px; }
.tgcb-field-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.tgcb-field-hint { color: var(--muted); font-size: 12.5px; }
.tgcb-in {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.3 var(--font-body);
  outline: none;
}
.tgcb-in:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }
.tgcb-in-code { font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.tgcb-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--mine-ink);
  font-weight: 600 !important;
  cursor: pointer;
}
.tgcb-btn:disabled { opacity: .6; cursor: default; }
.tgcb-btn.is-danger { background: var(--warn); color: var(--surface); }
.tgcb-btn.is-quiet { background: var(--chip); color: var(--ink); }
.tgcb-btn .tgcb-ico svg { width: 18px; height: 18px; }
.tgcb-status { margin: 0; font-size: 14px; }
.tgcb-status:empty { display: none; }
.tgcb-status.is-ok { color: var(--accent); }
.tgcb-status.is-error { color: var(--warn); }

/* Oculta la conversación mientras la página está en segundo plano */
.tgcb-covered > * { visibility: hidden; }

/* ---------- Imágenes incógnito ---------- */

.tgcb-bubble.tgcb-t-ephemeral { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }
.tgcb-t-ephemeral .tgcb-text { display: flex; align-items: center; gap: 8px; font-style: italic; }
.tgcb-t-ephemeral .tgcb-ico svg { width: 17px; height: 17px; }

.tgcb-once {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: min(240px, 60vw);
  padding: 22px 16px;
  border: 0; border-radius: 14px;
  background: var(--chip);
  color: var(--ink);
  cursor: pointer;
}
.is-mine .tgcb-once { background: rgba(255,255,255,.16); color: var(--mine-ink); }
.tgcb-once:disabled { opacity: .7; cursor: default; }
.tgcb-once-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 6px; border-radius: 50%; background: var(--accent); color: var(--mine-ink); }
.tgcb-once-icon .tgcb-ico svg { width: 24px; height: 24px; }
.tgcb-once-label { font: 600 15px/1.2 var(--font-display); }
.tgcb-once-sub { font-size: 12px; opacity: .75; }

.tgcb-once-viewer {
  position: fixed; inset: 0; z-index: 99999;
  display: grid; place-items: center;
  padding: 20px;
  background: #05070a;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.tgcb-once-img {
  max-width: 100%; max-height: 82vh; object-fit: contain; border-radius: 8px;
  -webkit-user-drag: none; pointer-events: none;
}
.tgcb-once-timer {
  position: absolute; top: max(18px, env(safe-area-inset-top)); right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.14); color: #fff;
  font: 700 17px/1 var(--font-display); font-variant-numeric: tabular-nums;
}
.tgcb-once-hint {
  position: absolute; bottom: max(22px, env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center; color: rgba(255,255,255,.75); font-size: 13px; padding: 0 20px;
}
