/* ═══════════════════════════════════════════════════════════════════════
   Stories: home circles, the Live / Archive pages, the full-screen viewer and the "new story" sheet.
   ═══════════════════════════════════════════════════════════════════════ */
body.sv-open, body.modal-open { overflow: hidden; }

/* Text-story backgrounds (viewer + tiles) */
.bg0 { background: radial-gradient(circle at 20% 15%, rgba(255, 140, 160, 0.25), transparent 55%), linear-gradient(160deg, #b0103a, #52051a); }
.bg1 { background: radial-gradient(circle at 80% 20%, rgba(255, 190, 150, 0.22), transparent 55%), linear-gradient(160deg, #be2f55, #740d2d); }
.bg2 { background: radial-gradient(circle at 30% 80%, rgba(255, 120, 150, 0.25), transparent 55%), linear-gradient(160deg, #9f1239, #3a0010); }
.bg3 { background: radial-gradient(circle at 70% 75%, rgba(255, 160, 130, 0.22), transparent 55%), linear-gradient(160deg, #bc1239, #70091f); }

/* ── Circles on Home ───────────────────────────────────────────────── */
.story-circles { display: flex; justify-content: center; align-items: flex-start; gap: clamp(20px, 9vw, 64px); margin: 4px 0 30px; }
.circle-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; width: 112px; }
.circle { position: relative; width: 84px; height: 84px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; display: grid; place-items: center; -webkit-tap-highlight-color: transparent; }
.circle-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); fill: none; stroke-width: 3.4; stroke-linecap: round; }
.ring-new  { stroke: url(#ring-grad); }
.ring-seen { stroke: rgba(255, 255, 255, 0.4); }
.ring-empty { stroke: rgba(255, 255, 255, 0.3); stroke-dasharray: 3 6; }
.circle.has-new .circle-ring { filter: drop-shadow(0 0 5px rgba(255, 90, 120, 0.75)); }
.circle-avatar {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 2.1rem; line-height: 1; color: #fff;
  background: radial-gradient(circle at 28% 18%, #ff7d95 0, #c4123c 20%, #7a0b26 55%, #3e0311 100%);
  border: 2px solid rgba(255, 255, 255, 0.22); box-shadow: 0 10px 22px -8px rgba(0, 0, 0, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 3px rgba(40, 0, 14, 0.7); transition: transform 0.25s var(--ease);
}
.circle:hover .circle-avatar { transform: scale(1.05); }
.circle.no-story .circle-avatar { opacity: 0.7; }
.circle-plus {
  position: absolute; left: calc(50% + 10px); top: 54px; width: 28px; height: 28px; padding: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: #8f0f33; background: linear-gradient(180deg, #fff, #ffd9e0); border: 2px solid #4a0414;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.circle-plus::after { content: ""; position: absolute; inset: -9px; }
.circle-plus .icon { width: 15px; height: 15px; stroke-width: 3; }
.circle-info { text-align: center; line-height: 1.25; text-shadow: 0 1px 3px rgba(20, 0, 8, 0.7); }
.circle-info b { display: block; font-size: 0.9rem; }
.circle-info b.new::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: #ff5a78; box-shadow: 0 0 8px #ff5a78; vertical-align: 1px; }
.circle-info small { display: block; font-size: 0.74rem; color: var(--ink-soft); }

/* ── Stories page ──────────────────────────────────────────────────── */
.stories-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stories-bar .tabs { margin-bottom: 0; }
.stories-bar .btn { display: inline-flex; align-items: center; gap: 8px; }
.stories-bar .btn .icon { width: 18px; height: 18px; stroke-width: 2.6; }
.stories-empty { text-align: center; padding: 38px 16px; border-radius: 22px; background: rgba(30, 0, 10, 0.35); border: 1px dashed rgba(255, 255, 255, 0.28); }
.stories-empty p { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.stories-empty small { color: var(--ink-soft); }
.story-group { margin-bottom: 28px; }
.story-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; text-shadow: 0 1px 3px rgba(20, 0, 8, 0.6); }
.story-group-head b { font-family: var(--font-display); font-size: 1.4rem; }
.story-group-head small { color: var(--ink-soft); }
.mini-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; background: radial-gradient(circle at 28% 18%, #ff7d95 0, #c4123c 20%, #7a0b26 55%, #3e0311 100%); border: 1.5px solid rgba(255, 255, 255, 0.3); }

.tiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile-story {
  position: relative; display: block; width: 100%; height: 0; padding: 0 0 133.333% 0; font-family: var(--font-body); border-radius: 18px; overflow: hidden; cursor: pointer; text-align: left; color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.24); background: #3a0716; box-shadow: 0 14px 28px -14px rgba(0, 0, 0, 0.7);
  transition: transform 0.25s var(--ease); -webkit-tap-highlight-color: transparent;
}
.tile-story:hover { transform: translateY(-3px); }
.tile-story.new { border-color: transparent; background: linear-gradient(#3a0716, #3a0716) padding-box, linear-gradient(135deg, #ffd9a0, #ff5a78, #e0207a) border-box; }
.tile-story.past { opacity: 0.88; }
.tile-media { position: absolute; inset: 0; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-media.text { display: flex; align-items: center; justify-content: center; padding: 46px 12px 78px; }
.tile-media.text p {
  margin: 0; max-height: 100%; overflow: hidden; text-align: center; font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; line-height: 1.28;
  overflow-wrap: anywhere; text-shadow: 0 1px 4px rgba(40, 0, 14, 0.6);
}
.tile-media.text p.cut { align-self: stretch; -webkit-mask-image: linear-gradient(#000 calc(100% - 34px), transparent); mask-image: linear-gradient(#000 calc(100% - 34px), transparent); }
.tile-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 10px 10px; background: linear-gradient(transparent, rgba(12, 0, 6, 0.96) 30%); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
.tile-info b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.88rem; line-height: 1.25; }
.tile-info small { display: block; margin-top: 2px; font-size: 0.72rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-tag, .tile-comments {
  position: absolute; top: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border-radius: 999px;
  background: rgba(16, 0, 8, 0.66); font-size: 0.72rem; font-weight: 700; line-height: 1.2; text-shadow: none;
}
.tile-tag { left: 8px; } .tile-comments { right: 8px; }
.tile-tag .icon, .tile-comments .icon { width: 14px; height: 14px; }
.tile-tag.is-new { background: linear-gradient(135deg, #e11d48, #be123c); }

/* Archive filters */
.filter-bar { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.filter-bar .field { margin-bottom: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.chip .icon { width: 16px; height: 16px; }
.chip.on { background: linear-gradient(180deg, #fff, #ffd9e0); color: #8f0f33; border-color: #fff; }
.filter-row { display: flex; align-items: center; gap: 12px; }
.sort-label { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
.sort-label .field { width: auto; flex: 1 1 auto; min-width: 0; max-width: 220px; padding: 9px 36px 9px 12px; font-size: 0.9rem; }
.filter-count { flex: none; margin-left: auto; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.filter-row .link-btn { flex: none; }
.more-filters summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; font-size: 0.9rem; color: var(--rose-light); }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.filter-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.76rem; font-weight: 700; color: var(--ink-soft); min-width: 0; }
.filter-grid .field { padding: 10px 12px; font-size: 0.9rem; }

/* ── New story sheet ───────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; background: rgba(10, 0, 5, 0.72); }
.modal-card { width: min(480px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border-radius: 26px; background: linear-gradient(135deg, rgba(112, 16, 46, 0.97), rgba(58, 6, 24, 0.98)); border: 1px solid var(--glass-border); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { font-size: 1.9rem; margin: 0; }
.modal-card .sub { margin-bottom: 14px; }
.compose-photo { margin-bottom: 12px; }
.compose-photo img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 16px; display: block; }

/* ── Story viewer ──────────────────────────────────────────────────── */
.sv { position: fixed; inset: 0; height: 100vh; height: 100dvh; z-index: 200; display: grid; place-items: center; background: rgba(8, 0, 4, 0.94); }
.sv-card { position: relative; overflow: hidden; height: min(94vh, 880px); height: min(94dvh, 880px); aspect-ratio: 9 / 16; max-width: 100vw; border-radius: 24px; background: #240411; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8); animation: svIn 0.28s var(--ease); }
@keyframes svIn { from { opacity: 0; transform: scale(0.96) translateY(12px); } to { opacity: 1; transform: none; } }
.sv-media { position: absolute; inset: 0; }
.sv-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.sv-media.contained .sv-photo { object-fit: contain; }
.sv-bgimg { position: absolute; inset: -8%; width: 116%; height: 116%; object-fit: cover; filter: blur(26px) brightness(0.6) saturate(1.25); display: none; }
.sv-media.contained .sv-bgimg { display: block; }
.sv-media.text { display: grid; place-items: center; padding: 90px 28px 130px; }
.sv-big { text-align: center; max-height: 100%; overflow: hidden; }
.sv-big h2 { font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.1; margin: 0 0 14px; text-shadow: 0 2px 10px rgba(40, 0, 14, 0.6); }
.sv-big p { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 5vw, 2rem); line-height: 1.3; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 14; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 2px 8px rgba(40, 0, 14, 0.6); }
.sv-scrim { position: absolute; left: 0; right: 0; pointer-events: none; }
.sv-scrim-top { top: 0; height: 150px; background: linear-gradient(rgba(0, 0, 0, 0.6), transparent); }
.sv-scrim-bottom { bottom: 0; height: 52%; background: linear-gradient(transparent, rgba(8, 0, 4, 0.9)); }
.sv-card.is-text .sv-scrim-bottom { height: 30%; }

.sv-bars { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 5; display: flex; gap: 4px; }
.sv-bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: #fff; transform: scaleX(0); transform-origin: 0 50%; }
.sv-head { position: absolute; top: 22px; left: 12px; right: 8px; z-index: 6; display: flex; align-items: center; gap: 10px; }
.sv-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; background: radial-gradient(circle at 28% 18%, #ff7d95 0, #c4123c 20%, #7a0b26 55%, #3e0311 100%); border: 2px solid rgba(255, 255, 255, 0.5); }
.sv-who { flex: 1; min-width: 0; line-height: 1.2; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); }
.sv-who b { display: block; font-size: 0.95rem; }
.sv-who small { font-size: 0.78rem; color: #ffe3e8; }
.sv-btn { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: rgba(0, 0, 0, 0.3); display: grid; place-items: center; cursor: pointer; transition: background 0.2s; }
.sv-btn:hover { background: rgba(0, 0, 0, 0.5); }
.sv-btn .icon { width: 22px; height: 22px; stroke-width: 2.2; }

.sv-tap { position: absolute; top: 76px; bottom: 96px; z-index: 2; touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none; }
.sv-tap-prev { left: 0; width: 34%; }
.sv-tap-next { right: 0; width: 66%; }
.sv-caption { position: absolute; left: 18px; right: 18px; bottom: 104px; z-index: 3; pointer-events: none; text-shadow: 0 1px 5px rgba(0, 0, 0, 0.85); }
.sv-caption b { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.15; margin-bottom: 4px; }
.sv-caption p { margin: 0; line-height: 1.45; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.sv-card.holding .sv-bars, .sv-card.holding .sv-head, .sv-card.holding .sv-foot, .sv-card.holding .sv-caption { opacity: 0; }
.sv-bars, .sv-head, .sv-foot, .sv-caption { transition: opacity 0.2s; }

.sv-foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
.sv-seen { display: flex; align-items: center; gap: 6px; margin: 0 4px 8px; font-size: 0.8rem; font-weight: 700; color: #ffe3e8; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.sv-seen:empty { display: none; }
.sv-seen .icon { width: 16px; height: 16px; }
.sv-form { display: flex; align-items: center; gap: 8px; }
.sv-count { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 14px; border-radius: 999px; cursor: pointer; color: #fff; background: rgba(0, 0, 0, 0.4); border: 1.5px solid rgba(255, 255, 255, 0.5); font-family: var(--font-body); font-size: 0.92rem; }
.sv-count .icon { width: 20px; height: 20px; }
.sv-count.bump { animation: bump 0.4s var(--ease); }
@keyframes bump { 40% { transform: scale(1.18); } }
.sv-input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 999px; font-family: var(--font-body); font-size: 1rem; color: #fff; background: rgba(0, 0, 0, 0.4); border: 1.5px solid rgba(255, 255, 255, 0.5); }
.sv-input::placeholder { color: #ffe0e6; opacity: 1; }
.sv-input:focus { outline: none; border-color: #fff; background: rgba(0, 0, 0, 0.55); }
.sv-send { flex: none; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: #8f0f33; background: linear-gradient(180deg, #fff, #ffd9e0); box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.6); }
.sv-send:disabled { opacity: 0.6; }
.sv-send .icon { width: 21px; height: 21px; stroke-width: 2.2; }

.sv-sheet { position: absolute; left: 10px; right: 10px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 8; max-height: 56%; display: flex; flex-direction: column; border-radius: 22px; background: rgba(30, 0, 12, 0.97); border: 1px solid rgba(255, 255, 255, 0.25); box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5); animation: svIn 0.22s var(--ease); }
.sv-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 4px 16px; }
.sv-sheet-head b { font-size: 1rem; }
.sv-comments { overflow-y: auto; padding: 4px 12px 12px; }
.sv-comment { padding: 9px 12px; margin-bottom: 8px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14); }
.sv-comment-head { display: flex; align-items: baseline; gap: 10px; }
.sv-comment-head b { font-size: 0.76rem; letter-spacing: 0.1em; text-transform: uppercase; color: #ffd0d8; }
.sv-comment.zain .sv-comment-head b { color: #ffe6bd; }
.sv-comment-head small { font-size: 0.74rem; color: #ffe3e8; }
.sv-comment-head .link-btn { margin-left: auto; }
.sv-comment p { margin: 3px 0 0; font-size: 0.95rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.sv-empty { margin: 8px 4px 12px; text-align: center; color: #ffe3e8; }
.sv-toast { position: absolute; left: 50%; top: 84px; z-index: 9; transform: translate(-50%, -8px); padding: 8px 16px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; background: rgba(16, 0, 8, 0.85); border: 1px solid rgba(255, 255, 255, 0.3); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.sv-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .sv-card { width: 100vw; height: 100%; aspect-ratio: auto; border-radius: 0; }
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100%; border-radius: 26px 26px 0 0; max-height: 92vh; max-height: 92dvh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { .sv-card, .sv-sheet { animation: none; } .sv-bars, .sv-head, .sv-foot, .sv-caption, .sv-toast { transition: none; } }

/* Small avatars: a tighter highlight so the letter always sits on the dark body */
.mini-avatar, .sv-avatar { background: radial-gradient(circle at 22% 14%, #ff8aa0 0, #b8113a 13%, #6e0a24 50%, #3e0311 100%); }

/* Phones turned sideways: use the whole screen instead of a narrow 9:16 strip */
@media (max-height: 520px) and (orientation: landscape) {
  .sv-card { width: 100vw; height: 100%; aspect-ratio: auto; border-radius: 0; }
  .sv-head { top: 16px; }
  .sv-btn, .sv-avatar { transform: none; }
  .sv-tap { top: 62px; bottom: 66px; }
  .sv-media.text { padding: 54px 48px 78px; }
  .sv-big h2 { font-size: 1.7rem; margin-bottom: 8px; }
  .sv-big p { font-size: 1.3rem; -webkit-line-clamp: 4; }
  .sv-caption { left: 28px; right: 28px; bottom: 74px; max-width: 640px; }
  .sv-caption b { font-size: 1.25rem; }
  .sv-caption p { -webkit-line-clamp: 2; }
  .sv-foot { padding: 6px 20px calc(10px + env(safe-area-inset-bottom)); }
  .sv-form { max-width: 620px; margin: 0 auto; }
  .sv-seen { display: none; }
  .sv-sheet { left: 20px; right: 20px; bottom: calc(66px + env(safe-area-inset-bottom)); max-height: 62%; max-width: 640px; margin: 0 auto; }
  .sv-toast { top: 66px; }
  .modal { align-items: center; padding: 10px; }
  .modal-card { width: min(560px, 100%); border-radius: 22px; max-height: 96vh; max-height: 96dvh; padding: 14px 18px; }
}

@media (min-width: 900px) { .tiles-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; } .tile-media.text p { font-size: 1.2rem; } }
