/*!
 * Web Stories Module — stories.css
 * Self-contained styles. No Bootstrap/Tailwind dependency.
 * Every class is namespaced with `story-module` / `story-admin`
 * to avoid colliding with the host application's CSS.
 */

.story-module {
  --sm-bg: #09090b;
  --sm-page: #f8fafc;
  --sm-surface: #ffffff;
  --sm-surface-alt: #f1f5f9;
  --sm-text: #0f172a;
  --sm-text-muted: #64748b;
  --sm-accent: #e11d48;
  --sm-accent-hover: #be123c;
  --sm-border: #e2e8f0;
  --sm-radius: 8px;
  --sm-radius-sm: 8px;
  --sm-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);

  font-family: var(--sm-font);
  color: var(--sm-text);
  box-sizing: border-box;
}

.story-module *,
.story-module *::before,
.story-module *::after {
  box-sizing: inherit;
}

/* ---------------------------------------------------------------- */
/* Collection grid (frontend index / collection page)               */
/* ---------------------------------------------------------------- */

.story-module--index {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.story-module__page-header {
  margin-bottom: 28px;
}

.story-module__heading {
  color: var(--sm-text);
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 800;
  line-height: 1.08;
  margin: 0 0 0.6rem;
}

.story-module__subheading {
  color: var(--sm-text-muted);
  font-size: 1rem;
  margin: 0;
  max-width: 620px;
}

/* ---------------------------------------------------------------- */
/* Collections nav bar (top, like a menu, on index + collection page) */
/* ---------------------------------------------------------------- */

.story-module__collections-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 2px 16px;
  margin: 0 0 24px;
  background: var(--sm-page);
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 1px solid var(--sm-border);
}

.story-module__collections-nav::-webkit-scrollbar {
  display: none;
}

.story-module__nav-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
  color: var(--sm-text);
  background: var(--sm-surface-alt);
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.story-module__nav-pill:hover {
  background: #e7e9ee;
}

.story-module__nav-pill.is-active {
  background: var(--sm-accent);
  border-color: var(--sm-accent);
  color: #fff;
}

.story-module__collection {
  margin-bottom: 34px;
}

.story-module__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.story-module__section-title {
  font-size: 1.08rem;
  font-weight: 750;
  margin: 0;
}

.story-module__section-title a,
.story-module__back-link {
  color: inherit;
  text-decoration: none;
}

.story-module__section-title a:hover,
.story-module__back-link:hover {
  color: var(--sm-accent);
}

.story-module__section-link,
.story-module__back-link {
  color: var(--sm-accent);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.story-module__back-link {
  display: inline-flex;
  margin-bottom: 20px;
}

.story-module__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---------------------------------------------------------------- */
/* Latest Stories home-page widget (<x-stories::latest-stories />)  */
/* ---------------------------------------------------------------- */

.story-module--widget {
  /* No forced max-width/centering here — the widget is meant to sit
     inside whatever container the host page already lays out. */
  width: 100%;
}

.story-module__grid.story-module__grid--widget {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.story-module__grid--widget.story-module__grid--sm {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.story-module__grid--widget.story-module__grid--lg {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

@media (min-width: 640px) {
  /* Above mobile, snap to the exact column count requested via the
     `columns` prop (--sm-cols), instead of the auto-fill count. */
  .story-module__grid--widget {
    grid-template-columns: repeat(var(--sm-cols, 4), 1fr);
  }
}

.story-module__card {
  position: relative;
  display: block;
  border-radius: var(--sm-radius);
  overflow: hidden;
  aspect-ratio: 9 / 16;
  background: var(--sm-surface);
  text-decoration: none;
  color: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.story-module__card:hover,
.story-module__card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(225, 29, 72, 0.45);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
  outline: none;
}

.story-module__card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-module__card-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #334155, #0f172a);
  color: var(--sm-text-muted);
  font-size: 0.75rem;
}

.story-module__card-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 55%);
}

.story-module__card-title {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 26px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-module__card-meta {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.story-module__card-meta svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.story-module__collection-info {
  color: var(--sm-text-muted);
  font-size: 1rem;
  line-height: 1.65;
  margin: 0;
  max-width: 760px;
}

/* ---------------------------------------------------------------- */
/* Pagination (frontend collection page)                            */
/* ---------------------------------------------------------------- */

.story-module__pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
}

.story-module__page-link,
.story-module__page-current,
.story-module__page-dots {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
  box-sizing: border-box;
}

.story-module__page-link {
  color: var(--sm-text);
  background: var(--sm-surface-alt);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.story-module__page-link:hover {
  background: #e7e9ee;
  border-color: var(--sm-border);
}

.story-module__page-current {
  color: #fff;
  background: var(--sm-accent);
}

.story-module__page-dots {
  color: var(--sm-text-muted);
}

.story-module__page-link[aria-disabled="true"] {
  color: var(--sm-text-muted);
  background: transparent;
  pointer-events: none;
  opacity: 0.5;
}

/* ---------------------------------------------------------------- */
/* Full-screen story viewer                                         */
/* ---------------------------------------------------------------- */

.story-module__viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: storyFadeIn 0.3s ease;
}

@keyframes storyFadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.story-module__viewer-inner {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 100dvh;
  background: #000;
  overflow: hidden;
}

@media (min-width: 640px) {
  .story-module__viewer-inner {
    height: min(94dvh, 860px);
    aspect-ratio: 9 / 16;
    border-radius: var(--sm-radius);
    box-shadow: var(--sm-shadow);
  }
}

.story-module__progress {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  gap: 5px;
}

.story-module__progress-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  overflow: hidden;
}

.story-module__progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 4px;
  transition: width 0.1s linear;
}

.story-module__progress-track.is-complete .story-module__progress-fill {
  width: 100%;
  transition: none;
}

.story-module__header {
  position: absolute;
  top: 24px;
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-module__header-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  letter-spacing: 0.01em;
}

.story-module__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.story-module__close,
.story-module__play-toggle {
  appearance: none;
  border: none;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-module__close:hover {
  background: rgba(225, 29, 72, 0.8);
  transform: rotate(90deg);
}

.story-module__play-toggle:hover {
  background: rgba(225, 29, 72, 0.8);
}

.story-module__play-toggle .story-module__icon-pause {
  display: none;
}

.story-module__play-toggle.is-playing .story-module__icon-play {
  display: none;
}

.story-module__play-toggle.is-playing .story-module__icon-pause {
  display: flex;
}

.story-module__close:focus-visible,
.story-module__play-toggle:focus-visible,
.story-module__nav-btn:focus-visible,
.story-module__card:focus-visible {
  outline: 2px solid var(--sm-accent);
  outline-offset: 2px;
}

.story-module__track {
  position: absolute;
  inset: 0;
  /*
   * z-index/pointer-events fix:
   * .story-module__navigation (the invisible full-size prev/next tap
   * buttons) has z-index: 10. Because this track creates its own
   * stacking context (will-change: transform below), its children's
   * z-index values were being compared *inside* that context only —
   * from the viewer's point of view the whole track sat at the
   * default "auto" level, UNDER the navigation layer. That's why
   * tapping the title/caption/"Learn More" link was actually
   * triggering the prev/next zone underneath it instead.
   *
   * Fix: push the track itself above the navigation layer, then make
   * everything in it transparent to clicks (pointer-events: none)
   * EXCEPT the caption content, which opts back in below. That way
   * taps on the image still fall through to prev/next as before, but
   * taps on the title/caption/link are captured correctly.
   */
  z-index: 16;
  pointer-events: none;
}

.story-module__track[data-direction="horizontal"] {
  display: flex;
  flex-direction: row;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.story-module__track[data-direction="vertical"] {
  display: flex;
  flex-direction: column;
  width: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.story-module__slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.story-module__media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  user-select: none;
}

/* ---------------------------------------------------------------- */
/* Caption overlay - clickable content                              */
/* ---------------------------------------------------------------- */

.story-module__caption-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 90px 20px 32px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.65) 45%, transparent 100%);
  pointer-events: none; /* Container doesn't block clicks, children are clickable */
}

.story-module__caption-content {
  pointer-events: auto; /* All content inside is clickable */
  position: relative;
  z-index: 1;
}

.story-module__media-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 6px;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 2px 14px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.01em;
  pointer-events: auto;
}

.story-module__caption {
  font-size: 0.96rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 2px 14px rgba(0, 0, 0, 0.7);
  pointer-events: auto;
}

.story-module__content {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.94);
  margin: 0 0 10px;
  line-height: 1.5;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 2px 14px rgba(0, 0, 0, 0.7);
  pointer-events: auto;
}

.story-module__media-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: rgba(225, 29, 72, 0.85);
  border: none;
  border-radius: 24px;
  padding: 8px 20px;
  text-decoration: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.3);
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.story-module__media-link:hover {
  background: #e11d48;
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(225, 29, 72, 0.4);
}

.story-module__media-link:active {
  transform: scale(0.95);
}

/* Navigation controls */

.story-module__navigation {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
}

.story-module__nav-zone {
  flex: 1;
  cursor: pointer;
  background: transparent;
  border: none;
  appearance: none;
  position: relative;
  pointer-events: auto;
}

.story-module__nav-zone[data-zone="prev"]::after,
.story-module__nav-zone[data-zone="next"]::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.25s ease;
  width: 30px;
  height: 30px;
  border-top: 3px solid rgba(255, 255, 255, 0.3);
  border-left: 3px solid rgba(255, 255, 255, 0.3);
}

.story-module__nav-zone[data-zone="prev"]::after {
  left: 16px;
  transform: translateY(-50%) rotate(-45deg);
}

.story-module__nav-zone[data-zone="next"]::after {
  right: 16px;
  transform: translateY(-50%) rotate(135deg);
}

.story-module__nav-zone:hover::after {
  opacity: 1;
}

.story-module__nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  pointer-events: auto;
}

.story-module__nav-btn:hover {
  background: rgba(225, 29, 72, 0.8);
  transform: translateY(-50%) scale(1.1);
}

@media (min-width: 640px) {
  .story-module__nav-btn {
    display: flex;
  }
}

.story-module__nav-btn--prev {
  left: -56px;
}

.story-module__nav-btn--next {
  right: -56px;
}

.story-module__viewer[data-direction="vertical"] .story-module__nav-btn {
  display: none;
}

/* Empty state */

.story-module__empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sm-text-muted);
  border: 1px dashed var(--sm-border);
  border-radius: var(--sm-radius);
  background: var(--sm-surface-alt);
}

/* ---------------------------------------------------------------- */
/* Admin editor                                                      */
/* ---------------------------------------------------------------- */

.story-admin {
  --sa-bg: #f8fafc;
  --sa-surface: #ffffff;
  --sa-border: #e2e8f0;
  --sa-text: #0f172a;
  --sa-text-muted: #64748b;
  --sa-accent: #2563eb;
  --sa-accent-hover: #1d4ed8;
  --sa-danger: #dc2626;
  --sa-radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--sa-text);
}

.story-admin *,
.story-admin *::before,
.story-admin *::after {
  box-sizing: border-box;
}

.story-admin__panel {
  background: var(--sa-surface);
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  overflow-x: auto;
}

.story-admin__title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 1rem;
  line-height: 1.2;
}

.story-admin__field {
  margin-bottom: 1rem;
}

.story-admin__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--sa-text-muted);
}

.story-admin__input,
.story-admin__select,
.story-admin__textarea {
  width: 100%;
  border: 1px solid var(--sa-border);
  border-radius: 8px;
  padding: 0.68rem 0.78rem;
  font-size: 0.92rem;
  color: var(--sa-text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.story-admin__input:focus,
.story-admin__select:focus,
.story-admin__textarea:focus {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.story-admin__textarea {
  resize: vertical;
  min-height: 70px;
}

.story-admin__error {
  color: var(--sa-danger);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

.story-admin__btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 0.62rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.story-admin__btn:hover {
  transform: translateY(-1px);
}

.story-admin__btn--primary {
  background: var(--sa-accent);
  color: #fff;
}

.story-admin__btn--primary:hover {
  background: var(--sa-accent-hover);
}

.story-admin__btn--danger {
  background: #fdecef;
  color: var(--sa-danger);
}

.story-admin__btn--danger:hover {
  background: #fbd9de;
}

.story-admin__btn--ghost {
  background: transparent;
  color: var(--sa-text);
  border: 1px solid var(--sa-border);
}

.story-admin__btn--ghost:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.story-admin__toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

.story-admin__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 720px;
}

.story-admin__table th,
.story-admin__table td {
  text-align: left;
  padding: 0.78rem 0.65rem;
  border-bottom: 1px solid var(--sa-border);
  vertical-align: middle;
}

.story-admin__table th {
    color: var(--sa-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: uppercase;
}

.story-admin__table tbody tr:hover {
  background: #f8fafc;
}

.story-admin__badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.story-admin__badge--draft {
  background: #f1f1f5;
  color: var(--sa-text-muted);
}

.story-admin__badge--published {
  background: #e4f8ec;
  color: #1c8a4d;
}

/* Dropzone */

.story-admin__dropzone {
  border: 2px dashed var(--sa-border);
  border-radius: var(--sa-radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--sa-text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: #f8fafc;
}

.story-admin__dropzone.is-dragover {
  border-color: var(--sa-accent);
  background: #eef0ff;
}

.story-admin__dropzone-input {
  display: none !important;
}

.story-admin__progress {
  height: 4px;
  background: var(--sa-border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.story-admin__progress-fill {
  height: 100%;
  width: 0%;
  background: var(--sa-accent);
  transition: width 0.15s ease;
}

/* Media slide cards (the drag-reorderable list) */

.story-admin__media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 1rem;
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  align-items: start;
}

.story-admin__media-card {
  border: 1px solid var(--sa-border);
  border-radius: var(--sa-radius);
  overflow: hidden;
  background: #fff;
  cursor: grab;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.story-admin__media-card:hover,
.story-admin__media-card.is-expanded {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
}

.story-admin__media-card.is-expanded {
  grid-column: span 2;
  cursor: default;
}

.story-admin__media-card.is-dragging {
  opacity: 0.4;
}

.story-admin__media-preview {
  position: relative;
  width: 100%;
  height: 118px;
  background: #111;
  cursor: pointer;
  overflow: hidden;
}

.story-admin__media-preview:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: -3px;
}

.story-admin__media-preview img,
.story-admin__media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-admin__media-order {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.story-admin__media-edit-chip {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.35rem 0.5rem;
  backdrop-filter: blur(8px);
}

.story-admin__media-body {
  display: none;
  padding: 0.75rem;
}

.story-admin__media-card.is-expanded .story-admin__media-body {
  display: block;
}

.story-admin__media-body .story-admin__field {
  margin-bottom: 0.6rem;
}

.story-admin__media-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.story-admin__media-save-hint {
  font-size: 0.72rem;
  color: var(--sa-text-muted);
  margin-right: auto;
  align-self: center;
}

.story-admin__empty-media {
  color: var(--sa-text-muted);
  font-size: 0.88rem;
  padding: 1rem 0;
}

/* Responsive helpers */

@media (max-width: 640px) {
  .story-module--index {
    width: min(100% - 24px, 1120px);
    padding-top: 24px;
  }

  .story-module__grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 12px;
  }

  .story-admin__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .story-admin__panel {
    padding: 1rem;
  }

  .story-admin__media-list {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  }

  .story-admin__media-card.is-expanded {
    grid-column: 1 / -1;
  }
}
