/* =======================================================
   Balo Story Viewer — Zen & Minimal Edition
   Calm, understated, no inner scrollbars
   ======================================================= */

/* ===========================
   OVERLAY
   =========================== */

.db-story-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;

  /* initially hidden; .open will show it */
  display: none;

  align-items: center;
  justify-content: center;

  padding: 16px;

  /* very soft dusk backdrop */
  background:
    radial-gradient(circle at 10% 0%, rgba(148, 163, 184, 0.20), transparent 55%),
    radial-gradient(circle at 90% 100%, rgba(51, 65, 85, 0.32), transparent 60%),
    rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(16px);
}

/* JS adds .open → show as flex */
.db-story-modal.open {
  display: flex !important;
}

/* ===========================
   INNER SHELL
   =========================== */

.db-story-inner {
  position: relative;
  width: 100%;
  max-width: 840px;
  height: 90vh;
  max-height: 90vh;

  border-radius: 24px;
  overflow: hidden; /* no scrollbars inside */

  display: flex;
  flex-direction: column;

  /* subtle glass card */
  background:
    radial-gradient(circle at 0% 0%, rgba(148, 163, 184, 0.18), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(51, 65, 85, 0.40), transparent 60%),
    rgba(15, 23, 42, 0.98);
  box-shadow:
    0 30px 70px rgba(15, 23, 42, 0.85),
    0 0 0 1px rgba(30, 64, 175, 0.25);

  color: #e5e7eb;
}

/* Hide any scrollbars if some browser still tries */
.db-story-inner::-webkit-scrollbar {
  display: none;
}
.db-story-inner {
  scrollbar-width: none;
}

/* ===========================
   HEADER
   =========================== */

.db-story-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  padding-right: 52px; /* leave room for close button */
  background: linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 0.86)
  );
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.db-story-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  background: rgba(15, 23, 42, 1);
  border: 1px solid rgba(148, 163, 184, 0.9);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.7);
}

.db-story-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.db-story-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.db-story-name {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.db-story-counter {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ===========================
   CLOSE + DELETE BUTTONS
   =========================== */

.db-story-close {
  position: absolute;
  top: 10px;
  right: 12px;

  width: 32px;
  height: 32px;
  border-radius: 999px;

  border: none;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;

  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;

  box-shadow:
    0 0 0 1px rgba(75, 85, 99, 0.8),
    0 8px 18px rgba(15, 23, 42, 0.9);
  transition:
    background 130ms ease-out,
    transform 130ms ease-out,
    box-shadow 130ms ease-out;
}

.db-story-close:hover {
  background: rgba(15, 23, 42, 1);
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 1),
    0 12px 24px rgba(15, 23, 42, 0.9);
}

.db-story-close:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 3px;
}

/* Delete button: only shown for owner via JS */
.db-story-delete {
  position: absolute;
  top: 10px;
  left: 12px;

  border: none;
  border-radius: 999px;
  padding: 5px 11px;

  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;

  background: rgba(127, 29, 29, 0.22);
  color: #fecaca;
  cursor: pointer;

  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.4);

  display: none; /* JS toggles to block when allowed */

  transition:
    background 130ms ease-out,
    transform 130ms ease-out,
    box-shadow 130ms ease-out;
}

.db-story-delete:hover {
  background: rgba(185, 28, 28, 0.55);
  color: #fee2e2;
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(254, 226, 226, 0.98),
    0 10px 20px rgba(127, 29, 29, 0.8);
}

/* ===========================
   BODY / MEDIA AREA
   =========================== */

.db-story-body {
  position: relative;
  flex: 1 1 auto;

  padding: 10px 14px 8px;
  background:
    radial-gradient(circle at top, rgba(15, 23, 42, 0.96), #020617);
  display: flex;
  align-items: center;
  justify-content: center;
}

.db-story-media {
  position: relative;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;

  border-radius: 18px;
  overflow: hidden;

  /* calm, desaturated backdrop */
  background:
    radial-gradient(circle at 15% 0, rgba(51, 65, 85, 0.45), transparent 60%),
    radial-gradient(circle at 85% 100%, rgba(30, 64, 175, 0.40), transparent 55%),
    rgba(15, 23, 42, 1);

  display: flex;
  align-items: center;
  justify-content: center;

  /* portrait feel on most screens */
  aspect-ratio: 9 / 16;
  max-height: 72vh;

  box-shadow:
    0 24px 52px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(31, 41, 55, 0.9);
}

/* Actual image or video */
.db-story-media-el {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #020617;
}

/* Loading / error text inside media box */
.db-story-loading,
.db-story-error {
  font-size: 0.9rem;
  color: #e5e7eb;
  text-align: center;
  padding: 12px;
}

/* ===========================
   FOOTER (NAV BUTTONS)
   =========================== */

.db-story-footer {
  display: flex;
  gap: 10px;
  padding: 10px 14px 14px;
  background: linear-gradient(
    to top,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 0.86)
  );
  border-top: 1px solid rgba(31, 41, 55, 0.9);
}

/* Refine existing .btn / .btn-alt when inside viewer */
.db-story-footer .btn,
.db-story-footer .btn-alt {
  flex: 1 1 0;
  min-height: 40px;
  font-size: 0.9rem;
  border-radius: 999px;
  border-width: 0;
  padding-inline: 16px;
  white-space: nowrap;
}

/* primary action (Next/Reply/etc.) */
.db-story-footer .btn {
  background: linear-gradient(
    to right,
    rgba(37, 99, 235, 0.96),
    rgba(30, 64, 175, 0.96)
  );
  color: #e5e7eb;
  font-weight: 500;
  box-shadow:
    0 10px 22px rgba(30, 64, 175, 0.45);
}

.db-story-footer .btn:hover {
  background: linear-gradient(
    to right,
    rgba(37, 99, 235, 1),
    rgba(30, 64, 175, 1)
  );
}

/* secondary action */
.db-story-footer .btn-alt {
  background: rgba(15, 23, 42, 1);
  color: #e5e7eb;
  border: 1px solid rgba(75, 85, 99, 0.9);
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.75);
}

.db-story-footer .btn-alt:hover {
  background: rgba(15, 23, 42, 0.98);
}

/* ===========================
   AVATAR RING (has-story)
   =========================== */

.db-avatar-wrap.has-story,
.mk-avatar-wrap.has-story,
.pf-avatar-wrap.has-story {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;

  /* more muted, less neon */
  background:
    conic-gradient(
      from 220deg,
      rgba(251, 191, 36, 0.7),
      rgba(248, 113, 113, 0.75),
      rgba(59, 130, 246, 0.8),
      rgba(52, 211, 153, 0.8),
      rgba(251, 191, 36, 0.7)
    );

  box-shadow:
    0 0 0 1px rgba(248, 250, 252, 0.85),
    0 0 14px rgba(59, 130, 246, 0.5);
  cursor: pointer;
}

.db-avatar-wrap.has-story .db-avatar,
.mk-avatar-wrap.has-story .mk-avatar,
.pf-avatar-wrap.has-story .pf-avatar {
  border-radius: 999px;
  display: block;
}

/* ===========================
   RESPONSIVE TWEAKS
   =========================== */

/* Phones */
@media (max-width: 640px) {
  .db-story-modal {
    padding: 0;
  }

  .db-story-inner {
