/* ============================================================
   Canal QC — Estilos (dark theme, Telegram-inspired)
   ============================================================ */

:root {
  --bg:          #0e1117;
  --surface:     #1c2333;
  --surface2:    #242f3d;
  --surface3:    #2d3748;
  --primary:     #7c3aed;
  --primary-dim: rgba(124,58,237,0.15);
  --text:        #e2e8f0;
  --subtext:     #94a3b8;
  --border:      #2d3748;
  --danger:      #ef4444;
  --success:     #22c55e;
  --header-h:    60px;
  --bar-h:       60px;
  --nav-h:       56px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ─────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a      { color: var(--primary); text-decoration: none; }
img, video { display: block; max-width: 100%; }

.hidden { display: none !important; }

/* ── Loading ───────────────────────────────────────────────── */

#screen-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100dvh; flex-direction: column; gap: 1rem;
}
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--surface3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App shell ─────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: -webkit-fill-available;
}

/* ── Header ────────────────────────────────────────────────── */

#app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left  { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

.header-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-dim);
  border: 2px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}

.header-info { min-width: 0; }
.header-info h1 {
  font-size: 1rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#casino-tagline, #member-count { font-size: 0.72rem; color: var(--subtext); }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-user  { font-size: 0.75rem; color: var(--subtext); }
.admin-badge  {
  font-size: 0.55rem; font-weight: 700; letter-spacing: 0.05em;
  background: var(--primary); color: #fff;
  padding: 1px 5px; border-radius: 4px; vertical-align: middle;
}

#btn-notify {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#btn-notify:hover { background: var(--surface3); }
#btn-notify[data-status="granted"] { color: var(--primary); }

/* ── Feed ──────────────────────────────────────────────────── */

#feed-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding-bottom: calc(var(--bar-h) + var(--nav-h) + var(--safe-bottom));
}

#feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px 8px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.feed-empty {
  text-align: center; color: var(--subtext);
  padding: 3rem 1rem; font-size: 0.9rem;
}

#feed-sentinel { height: 1px; }

/* ── Bottom bar ────────────────────────────────────────────── */

#app { position: relative; }

#bottom-bar {
  position: fixed;
  bottom: var(--nav-h); left: 0; right: 0;
  z-index: 60;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#bottom-input-row {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

#reply-context {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--primary-dim);
  border-radius: 6px;
  border-left: 3px solid var(--primary);
  font-size: 0.75rem;
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
}

.reply-icon { color: var(--primary); flex-shrink: 0; }

#reply-to-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#comment-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
#comment-input:focus { border-color: var(--primary); }
#comment-input::placeholder { color: var(--subtext); }
#comment-input:disabled { opacity: 0.5; }

#btn-send-comment {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
#btn-send-comment:hover  { opacity: 0.85; }
#btn-send-comment:active { transform: scale(0.92); }
#btn-send-comment:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Post ──────────────────────────────────────────────────── */

.post-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 3px 0;
}

.post-pinned-wrap .post-bubble {
  border-left: 3px solid var(--primary);
}

.pin-badge {
  font-size: 0.7rem; color: var(--primary);
  font-weight: 600; padding: 0 4px;
  letter-spacing: 0.02em;
}

.post-bubble {
  background: var(--surface);
  border-radius: 14px 14px 4px 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.post-tipo {
  display: inline-block;
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--primary); background: var(--primary-dim);
  padding: 4px 10px;
  border-radius: 0 0 8px 0;
}

.post-media-wrap { width: 100%; }
.post-media {
  width: 100%; max-height: 400px;
  object-fit: cover; display: block;
}
video.post-media { max-height: 360px; background: #000; }

.post-titulo {
  font-size: 0.97rem; font-weight: 600;
  color: var(--text);
  padding: 10px 12px 4px;
  line-height: 1.4;
}

.post-contenido {
  font-size: 0.875rem; color: var(--subtext);
  padding: 0 12px 10px;
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}

/* ── Post meta row (reactions + views + time) ─────────────── */

.post-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 8px;
  gap: 8px;
}

.post-reactions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 12px;
  background: var(--surface2);
  font-size: 0.8rem;
  color: var(--subtext);
  transition: background 0.15s, transform 0.1s;
  border: 1px solid transparent;
  line-height: 1;
}
.reaction-btn:hover  { background: var(--surface3); }
.reaction-btn:active { transform: scale(0.92); }
.reaction-btn.reacted {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.r-emoji  { font-size: 0.95rem; line-height: 1; }
.r-count  { font-size: 0.75rem; font-weight: 600; min-width: 0; }
.r-count:empty { display: none; }

.post-meta-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.post-views, .post-time {
  font-size: 0.7rem;
  color: var(--subtext);
  white-space: nowrap;
}

/* ── Comments button ───────────────────────────────────────── */

.btn-open-comments {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--surface2);
  border-radius: 0 0 12px 12px;
  font-size: 0.82rem;
  color: var(--subtext);
  width: 100%;
  transition: background 0.15s, color 0.15s;
  border-top: 1px solid var(--border);
}
.btn-open-comments:hover,
.btn-open-comments:active { background: var(--primary-dim); color: var(--primary); }

.post-comment-count { font-weight: 600; }
.comments-label     { font-size: 0.8rem; }
.comments-arrow     { margin-left: auto; font-size: 1rem; opacity: 0.5; }

/* ── Skeleton ──────────────────────────────────────────────── */

.skeleton-list { display: flex; flex-direction: column; gap: 12px; padding: 12px 0; }

.skeleton-post {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.5 } }

.skel { background: var(--surface2); }
.skel-media  { height: 200px; }
.skel-title  { height: 18px; width: 70%; margin: 12px; border-radius: 4px; }
.skel-body   { height: 14px; width: 90%; margin: 0 12px 12px; border-radius: 4px; }

/* ── Comments drawer ───────────────────────────────────────── */

#comments-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
}

#comments-drawer {
  position: fixed;
  bottom: calc(var(--bar-h) + var(--nav-h)); left: 0; right: 0;
  max-width: 680px;
  margin: 0 auto;
  height: 75dvh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% + var(--bar-h) + var(--nav-h)));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#comments-drawer.open { transform: translateY(0); }

.drawer-handle {
  width: 36px; height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#comments-title {
  font-weight: 600; font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: calc(100% - 40px);
}

#btn-close-comments {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  font-size: 0.8rem; color: var(--subtext);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#btn-close-comments:hover { background: var(--surface3); color: var(--text); }

#comments-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-loading, .no-comments {
  text-align: center; color: var(--subtext);
  font-size: 0.85rem; padding: 2rem 0;
}

/* ── Comment bubble ────────────────────────────────────────── */

.comment {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.comment-bubble {
  background: var(--surface2);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px;
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
}

.comment-apodo {
  font-size: 0.75rem; font-weight: 700;
  color: var(--primary);
}

.comment-texto {
  font-size: 0.875rem; color: var(--text);
  word-break: break-word; line-height: 1.45;
}

.comment-time {
  font-size: 0.65rem; color: var(--subtext);
  align-self: flex-end;
}

/* ── Bottom nav ────────────────────────────────────────────── */

#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 60;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--subtext);
  font-size: 0.65rem;
  font-weight: 500;
  transition: color 0.15s;
  padding: 6px 0;
}
.nav-tab svg { transition: stroke 0.15s; }
.nav-tab.active { color: var(--primary); }
.nav-tab.active svg { stroke: var(--primary); }
.nav-tab:hover { color: var(--text); }

/* ── Sections ──────────────────────────────────────────────── */

.app-section { display: none; }

.app-section.active {
  display: block;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
}

#section-chat.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

/* ── Pinned bar (Telegram-style) ───────────────────────────── */

#pinned-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  background: var(--surface1);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.15s;
}
#pinned-bar:hover { background: var(--surface2); }
#pinned-bar.hidden { display: none; }
.pinned-bar-accent {
  width: 3px;
  min-height: 30px;
  border-radius: 2px;
  background: var(--primary);
  flex-shrink: 0;
}
.pinned-bar-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pinned-bar-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}
.pinned-bar-title {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
#pinned-bar-close {
  color: var(--subtext);
  font-size: 0.8rem;
  padding: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
#pinned-bar-close:hover { background: var(--surface3); color: var(--text); }

.section-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.section-header h2 { font-size: 1rem; font-weight: 700; }
.section-header p  { font-size: 0.8rem; color: var(--subtext); margin-top: 2px; }

.section-loading, .section-empty {
  text-align: center; color: var(--subtext);
  font-size: 0.88rem; padding: 3rem 1rem;
}

/* ── Historias grid (3 columnas Instagram-style) ───────────── */

#guardado-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0;
}

.guardado-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface2);
}
.guardado-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.guardado-item:hover img { transform: scale(1.04); }

.guardado-placeholder {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  background: var(--surface3);
}
.guardado-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  padding: 20px 6px 6px;
}
.guardado-titulo {
  font-size: 0.7rem; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.guardado-date { font-size: 0.6rem; color: rgba(255,255,255,0.65); }

/* ── Ganadores ─────────────────────────────────────────────── */

#ganadores-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }

.ganador-card {
  background: var(--surface2);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
}
.ganador-card-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.ganador-sorteo-titulo { font-size: 0.9rem; font-weight: 700; }
.ganador-premio        { font-size: 0.8rem; color: var(--subtext); margin-top: 2px; }
.ganador-meta          { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ganador-fecha         { font-size: 0.7rem; color: var(--subtext); white-space: nowrap; }
.ganador-names         { display: flex; flex-wrap: wrap; gap: 6px; }
.ganador-name {
  font-size: 0.8rem; background: var(--primary-dim);
  color: var(--primary); border-radius: 20px; padding: 3px 10px;
  border: 1px solid rgba(124,58,237,0.3);
}
.ganador-delete-btn {
  font-size: 0.85rem; color: var(--subtext);
  padding: 2px 4px; border-radius: 4px;
}
.ganador-delete-btn:hover { color: var(--danger); }

/* ── FAQ ───────────────────────────────────────────────────── */

#faq-list { padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }

.faq-item {
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.faq-question {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  gap: 12px;
}
.faq-question:hover { background: var(--surface3); }
.faq-text    { font-size: 0.88rem; font-weight: 600; flex: 1; }
.faq-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.faq-chevron {
  font-size: 1.2rem; color: var(--subtext);
  transition: transform 0.2s;
}
.faq-item.open .faq-chevron { transform: rotate(90deg); }
.faq-answer {
  display: none;
  padding: 0 16px 14px;
  font-size: 0.85rem; color: var(--subtext); line-height: 1.6;
  border-top: 1px solid var(--border);
}
.faq-item.open .faq-answer { display: block; padding-top: 12px; }
.faq-edit-btn { font-size: 0.8rem; padding: 2px 4px; border-radius: 4px; }
.faq-edit-btn:hover { background: var(--surface3); }

/* ── Admin FAB ─────────────────────────────────────────────── */

#btn-compose {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--bar-h) + 16px);
  right: 16px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  z-index: 65;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(124,58,237,0.4);
  transition: opacity 0.15s, transform 0.15s;
}
#btn-compose:hover  { opacity: 0.9; transform: scale(1.05); }
#btn-compose.hidden { display: none; }
#btn-compose.fab-hidden { opacity: 0; pointer-events: none; }

/* ── Admin: post guardado button ───────────────────────────── */

.post-admin-bar {
  padding: 4px 12px 8px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.btn-guardado, .btn-pin, .btn-unpublish, .btn-delete-post {
  font-size: 0.75rem; color: var(--subtext);
  background: var(--surface2);
  border-radius: 6px; padding: 4px 10px;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.btn-guardado.guardado-on {
  color: var(--primary);
  background: var(--primary-dim);
  border-color: var(--primary);
}
.btn-pin.pin-on {
  color: #f59e0b;
  background: rgba(245,158,11,0.15);
  border-color: #f59e0b;
}
.btn-unpublish.republish-on {
  color: #16a34a;
  border-color: rgba(22,163,74,0.3);
}
.btn-delete-post {
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}
.btn-delete-post:hover {
  background: rgba(239,68,68,0.12);
  border-color: var(--danger);
}
.post-unpublished { opacity: 0.5; }
.unpublished-badge {
  font-size: 0.7rem; color: var(--danger);
  padding: 2px 10px 0;
}

/* ── Admin: delete comment button ──────────────────────────── */

.comment-footer { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.btn-delete-comment {
  font-size: 0.65rem; color: var(--subtext);
  padding: 1px 4px; border-radius: 4px;
  line-height: 1;
}
.btn-delete-comment:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ── Modales ────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
@media (min-width: 480px) {
  .modal-overlay { align-items: center; padding: 20px; }
}

.modal-card {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px;
  max-height: 90dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
@media (min-width: 480px) {
  .modal-card { border-radius: 16px; }
}

.modal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 0.95rem;
  flex-shrink: 0;
}
.modal-header button {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface2); color: var(--subtext);
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-header button:hover { background: var(--surface3); color: var(--text); }

.modal-body {
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; flex: 1;
}

.modal-footer {
  padding: 12px 20px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 0.78rem; color: var(--subtext); font-weight: 500; }

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text); font-size: 0.9rem;
  outline: none; transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; font-family: inherit; }
select.form-input { appearance: none; }

.form-checks { flex-direction: row; gap: 16px; flex-wrap: wrap; }
.form-check  { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.form-check input { accent-color: var(--primary); }

.btn-primary {
  width: 100%;
  background: var(--primary); color: #fff;
  border-radius: 10px; padding: 12px;
  font-weight: 600; font-size: 0.95rem;
  transition: opacity 0.15s;
}
.btn-primary:hover    { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Apodo / login overlay ─────────────────────────────────── */

#apodo-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.apodo-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 14px;
}

.apodo-card h2 { font-size: 1.1rem; font-weight: 700; }
.apodo-card p  { font-size: 0.85rem; color: var(--subtext); line-height: 1.5; }

#login-email-panel, #login-sent-panel, #login-apodo-panel {
  display: flex; flex-direction: column; gap: 12px;
}

#login-email-input, #apodo-input, #admin-email, #admin-password {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text); font-size: 0.95rem;
  outline: none; transition: border-color 0.15s;
}
#login-email-input:focus, #apodo-input:focus,
#admin-email:focus, #admin-password:focus { border-color: var(--primary); }

#login-error, #apodo-error,
#login-error-admin { font-size: 0.8rem; color: var(--danger); margin-top: -4px; }

/* Panel OTP */
.login-sent-icon { font-size: 2.5rem; text-align: center; }
#login-otp-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .3em;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
#login-otp-input:focus { border-color: var(--primary); }
#login-otp-error { font-size: 0.8rem; color: var(--danger); margin-top: -4px; }
#btn-retry-magic-link {
  background: transparent; border: none;
  color: var(--subtext); font-size: 0.85rem;
  cursor: pointer; padding: 4px;
  text-decoration: underline; text-underline-offset: 3px;
  align-self: center;
}
#btn-retry-magic-link:hover { color: var(--text); }

#btn-set-apodo, #btn-admin-login {
  background: var(--primary); color: #fff;
  border-radius: 10px; padding: 11px;
  font-weight: 600; font-size: 0.95rem;
  transition: opacity 0.15s;
}
#btn-set-apodo:hover, #btn-admin-login:hover  { opacity: 0.85; }
#btn-set-apodo:disabled, #btn-admin-login:disabled { opacity: 0.5; cursor: not-allowed; }

.link-btn {
  background: none; color: var(--subtext);
  font-size: 0.8rem; text-decoration: underline;
  padding: 4px 0; text-align: center;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }

/* ── Toast ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--surface2); color: var(--text);
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 0.83rem; font-weight: 500;
  z-index: 200;
  white-space: nowrap; pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  border: 1px solid var(--border);
  max-width: calc(100vw - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
.toast.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { border-color: var(--success); color: var(--success); }
.toast-error   { border-color: var(--danger);  color: var(--danger);  }
.toast-info    { border-color: var(--primary);  color: var(--primary); }

/* ── Lightbox ──────────────────────────────────────────────── */

#lightbox {
  position: fixed; inset: 0;
  z-index: 90;
  background: rgba(0,0,0,0.95);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
#lightbox.hidden { display: none; }
#lightbox-img {
  max-width: 95vw; max-height: 95dvh;
  object-fit: contain; border-radius: 4px;
  cursor: default; user-select: none;
}
#lightbox-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: #fff;
  border: none; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 1;
}
#lightbox-close:hover { background: rgba(255,255,255,0.28); }

/* ── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar              { width: 4px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--surface3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover  { background: var(--subtext); }

/* ── Desktop ───────────────────────────────────────────────── */

@media (min-width: 680px) {
  #feed { padding: 16px 16px 8px; }
  .post-bubble { border-radius: 14px 14px 4px 14px; }
}

/* ── P2: Offline banner ────────────────────────────────────── */

#offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: #b45309; color: #fff;
  text-align: center; font-size: .8rem; font-weight: 600;
  padding: 6px 12px; letter-spacing: .02em;
}
#offline-banner.hidden { display: none; }

/* ── P2: Nueva publicación badge ───────────────────────────── */

.new-post-badge {
  position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff;
  border: none; border-radius: 20px;
  padding: 8px 18px; font-size: .85rem; font-weight: 600;
  cursor: pointer; z-index: 20;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
  animation: badge-in .2s ease;
}
@keyframes badge-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── P2: Feed error retry ──────────────────────────────────── */

.feed-error { color: var(--subtext); }
.btn-feed-retry {
  margin-left: 8px; padding: 4px 10px;
  background: var(--surface2); border: 1px solid var(--surface3);
  border-radius: 6px; color: var(--text); font-size: .8rem;
  cursor: pointer;
}
.btn-feed-retry:hover { background: var(--surface3); }

/* ── P2: Solo leer button ──────────────────────────────────── */

#btn-skip-login {
  margin-top: 8px; width: 100%;
  background: transparent; border: none;
  color: var(--subtext); font-size: .85rem;
  cursor: pointer; padding: 6px;
  text-decoration: underline; text-underline-offset: 3px;
}
#btn-skip-login:hover { color: var(--text); }

/* ── P2: FAQ orden badge (admin) ───────────────────────────── */

.faq-orden-badge {
  font-size: .7rem; color: var(--subtext);
  background: var(--surface2); border-radius: 4px;
  padding: 1px 5px; margin-right: 4px;
}

/* ── P3-A3: Audit log de actividad admin ───────────────────── */

#audit-list {
  padding: 8px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audit-entry {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1.4;
  transition: background .15s;
}
.audit-entry:hover { background: var(--surface2); }

.audit-icon {
  flex-shrink: 0;
  font-size: .9rem;
  width: 20px;
  text-align: center;
}

.audit-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.audit-apodo {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.audit-desc { color: var(--text); }

.audit-target {
  color: var(--subtext);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.audit-target em {
  font-style: italic;
  font-size: .8rem;
}

.audit-time {
  flex-shrink: 0;
  color: var(--subtext);
  font-size: .75rem;
  white-space: nowrap;
  margin-left: auto;
  padding-left: 8px;
}
