/* ===== Story card: shared by the composer preview and the viewer ===== */
.story-card { position: relative; width: 100%; aspect-ratio: 9 / 16; background: #111; overflow: hidden; border-radius: 12px; color: #fff; font-family: Verdana, sans-serif; isolation: isolate; }
.sc-media { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; background: #000; }
.sc-media img, .sc-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-empty { color: #aaa; font-size: 14px; text-align: center; padding: 20px; }
.sc-fx { position: absolute; inset: 0; pointer-events: none; }

/* ---- caption ---- */
.sc-caption { position: absolute; left: 6%; right: 6%; text-align: center; font-size: clamp(18px, 6cqw, 30px); line-height: 1.2; font-weight: bold; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); overflow-wrap: anywhere; z-index: 3; }
.story-card { container-type: inline-size; }
.sc-caption:empty { display: none; }
.pos-top { top: 12%; }
.pos-middle { top: 50%; transform: translateY(-50%); }
.pos-bottom { bottom: calc(var(--bottom, 0px) + 14%); }
.font-classic { font-family: Verdana, sans-serif; }
.font-comic { font-family: "Comic Sans MS", "Comic Sans", cursive; }
.font-gothic { font-family: "UnifrakturMaguntia", serif; font-weight: normal; font-size: clamp(22px, 8cqw, 38px); }
.font-pixel { font-family: "Press Start 2P", monospace; font-size: clamp(12px, 4.2cqw, 20px); line-height: 1.6; }
.font-marker { font-family: "Permanent Marker", cursive; font-weight: normal; transform: rotate(-3deg); }
.font-chrome { font-family: "Audiowide", sans-serif; font-weight: normal; background: linear-gradient(#fff, #9fb4c7 48%, #39516b 52%, #e6eef7); -webkit-background-clip: text; background-clip: text; color: transparent !important; filter: drop-shadow(0 2px 3px #000a); text-shadow: none; }
.font-glitter { font-family: "Pacifico", cursive; font-weight: normal; background: linear-gradient(90deg, #ff3cac, #ffd23f, #3bff9b, #3ad7ff, #b26bff, #ff3cac); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent !important; animation: sc-glitter 2.5s linear infinite; filter: drop-shadow(0 0 3px #fff) drop-shadow(0 2px 4px #0008); text-shadow: none; }
.font-glitter::after { content: " \2728"; -webkit-text-fill-color: initial; }
@keyframes sc-glitter { to { background-position: -200% 0; } }

/* Dragged text and stickers: centered on the point the person dropped them. Uses the separate
   `translate` property so the fonts' and stickers' own rotations still apply. */
.sc-caption.free-pos { right: auto; bottom: auto; width: max-content; max-width: 88%; translate: -50% -50%; transform: none; }
.sc-caption.free-pos.font-marker { transform: rotate(-3deg); }
.sc-sticker.free-pos { right: auto; bottom: auto; translate: -50% -50%; white-space: nowrap; }
.composer-preview .sc-caption, .composer-preview .sc-sticker { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.composer-preview .dragging { cursor: grabbing; outline: 2px dashed rgba(255, 255, 255, .85); outline-offset: 4px; }
.drag-hint { text-align: center; font-size: 11px; color: #666; margin: 6px 0 0; }

/* ---- stickers ---- */
.sc-sticker { position: absolute; top: calc(var(--top, 0px) + 4%); right: 5%; z-index: 4; font: bold 14px "Comic Sans MS", cursive; padding: 6px 10px; transform: rotate(6deg); border-radius: 8px; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.sc-sticker:empty, .sticker-none { display: none; }
.sticker-thx { background: #ffcc99; color: #ff6600; border: 2px solid #ff6600; }
.sticker-rawr { background: #39ff14; color: #000; font-family: "Fredoka", "Comic Sans MS", sans-serif; transform: rotate(-8deg); }
.sticker-sparkle { background: #ff9ad5; color: #fff; text-shadow: 0 0 4px #ff00a8; }
.sticker-online { background: #fff; color: #2e7d32; border: 2px solid #2ecc40; }
.sticker-online::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #2ecc40; margin-right: 5px; box-shadow: 0 0 5px #2ecc40; }
.sticker-top8 { background: #003399; color: #fff; border: 2px solid #6699cc; }
.sticker-brb { background: #ffeb3b; color: #000; font-family: Impact, sans-serif; letter-spacing: 1px; }
.sticker-heart { background: #ff1493; color: #fff; }
.sc-song { position: absolute; left: 5%; bottom: calc(var(--bottom, 0px) + 4%); z-index: 4; max-width: 90%; background: rgba(0, 0, 0, .7); border: 1px solid #6699cc; color: #fff; font: 12px Verdana, sans-serif; padding: 5px 9px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-song:empty { display: none; }

/* ---- frames ---- */
.sc-titlebar, .sc-webcam { display: none; }
.frame-polaroid { background: #fafafa; padding: 4% 4% 18%; box-shadow: 0 6px 18px rgba(0, 0, 0, .4); border-radius: 4px; }
.frame-polaroid .sc-media { inset: 4% 4% 18%; }
.frame-polaroid .pos-bottom { bottom: 4%; color: #333 !important; text-shadow: none; font-family: "Permanent Marker", cursive; font-weight: normal; }
.frame-glitter { padding: 10px; background: linear-gradient(120deg, #ff9ad5, #fff, #ffd6f5, #c9f2ff, #fff3a0, #ff9ad5); background-size: 300% 300%; animation: sc-shimmer 3s linear infinite; }
.frame-glitter .sc-media { inset: 10px; border-radius: 8px; }
@keyframes sc-shimmer { to { background-position: 300% 0; } }
.frame-win98 { background: #c0c0c0; border-radius: 0; box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf; }
.frame-win98 .sc-titlebar { display: flex; position: absolute; top: calc(var(--top, 0px) + 4px); left: 4px; right: 4px; height: 24px; align-items: center; justify-content: space-between; padding: 0 4px 0 8px; background: linear-gradient(90deg, #000080, #1084d0); color: #fff; font: bold 12px Tahoma, sans-serif; z-index: 5; }
.frame-win98 .sc-titlebar span { background: #c0c0c0; color: #000; padding: 0 4px; font-size: 11px; box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff; letter-spacing: 2px; }
.frame-win98 .sc-media { inset: calc(var(--top, 0px) + 32px) 6px 6px; }
.frame-zebra { padding: 12px; background: repeating-linear-gradient(115deg, #000 0 14px, #fff 14px 22px); }
.frame-zebra .sc-media { inset: 12px; border: 4px solid #ff1493; border-radius: 8px; }
.frame-starry { padding: 12px; background: radial-gradient(circle, #fff 1px, transparent 1.5px) 0 0 / 16px 16px, #0a1033; }
.frame-starry .sc-media { inset: 12px; border: 2px solid #f4c542; border-radius: 8px; }
.frame-webcam { border: 0; }
.frame-webcam .sc-webcam { display: flex; justify-content: space-between; position: absolute; left: 4%; right: 4%; top: calc(var(--top, 0px) + 3%); z-index: 5; font: bold 13px "Courier New", monospace; color: #fff; text-shadow: 1px 1px 0 #000; }
.frame-webcam .sc-webcam b { color: #ff3b30; animation: ns-blink 1s steps(2, start) infinite; }
.frame-webcam .sc-media::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 60px rgba(0, 0, 0, .7); pointer-events: none; }
@keyframes ns-blink { to { visibility: hidden; } }

/* ---- filters ---- */
.filter-webcam .sc-media img, .filter-webcam .sc-media video { filter: contrast(1.15) saturate(.7) brightness(1.1) blur(.3px); }
.filter-webcam .sc-fx { background: repeating-radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .05) 0 1px, transparent 1px 3px); mix-blend-mode: overlay; }
.filter-vhs .sc-media img, .filter-vhs .sc-media video { filter: saturate(1.4) contrast(1.1) hue-rotate(-8deg); }
.filter-vhs .sc-fx { background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .25) 2px 4px); box-shadow: inset 4px 0 0 rgba(255, 0, 80, .25), inset -4px 0 0 rgba(0, 200, 255, .25); }
.filter-emo .sc-media img, .filter-emo .sc-media video { filter: grayscale(1) contrast(1.4) brightness(.9); }
.filter-emo .sc-fx { background: radial-gradient(ellipse at center, transparent 50%, rgba(80, 0, 0, .55)); }
.filter-sepia .sc-media img, .filter-sepia .sc-media video { filter: sepia(.85) contrast(1.05); }
.filter-neon .sc-media img, .filter-neon .sc-media video { filter: saturate(2.2) contrast(1.15); }
.filter-neon .sc-fx { background: linear-gradient(135deg, rgba(255, 0, 200, .2), rgba(0, 255, 255, .2)); mix-blend-mode: screen; }
.filter-dreamy .sc-media img, .filter-dreamy .sc-media video { filter: brightness(1.1) saturate(1.2) blur(.6px); }
.filter-dreamy .sc-fx { background: radial-gradient(ellipse at center, rgba(255, 255, 255, .25), rgba(255, 182, 230, .35)); mix-blend-mode: soft-light; }

/* ===== Story tray ===== */
.story-tray { display: flex; gap: 14px; overflow-x: auto; padding: 10px 12px; margin-bottom: 16px; background: #fff; border: 1px solid #6699cc; scrollbar-width: thin; }
.story-tray.big { flex-wrap: wrap; overflow: visible; }
.tray-item { display: grid; justify-items: center; gap: 4px; text-decoration: none; font-size: 11px; flex: none; width: 76px; text-align: center; color: #003399; }
.tray-ring { padding: 3px; border-radius: 50%; background: conic-gradient(#feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5, #feda75); line-height: 0; }
.tray-item.seen .tray-ring { background: #ccc; }
.tray-ring img { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; background: #eee; }
.tray-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-add .tray-ring { background: none; border: 2px dashed #6699cc; padding: 1px; position: relative; }
.tray-add .tray-ring::after { content: "+"; position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; line-height: 20px; border-radius: 50%; background: #ff6600; color: #fff; font: bold 18px Arial; border: 2px solid #fff; }

/* ===== Composer ===== */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.composer-preview { position: sticky; top: 10px; }
.composer .field { display: grid; gap: 4px; font-weight: bold; font-size: 12px; margin-bottom: 12px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: 5px 10px; border: 1px solid #9bb4d4; border-radius: 999px; background: #fff; font-size: 12px; cursor: pointer; font-weight: normal; }
.choice input:checked + span { background: #003399; color: #fff; border-color: #003399; }
.choice input:focus-visible + span { outline: 2px solid #ff6600; }
.swatch span { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid #ccc; }
.swatch input:checked + span { border: 3px solid #ff6600; box-shadow: 0 0 0 2px #fff inset; }
.vis-choice span { padding: 10px 14px; border-radius: 8px; display: grid; gap: 2px; text-align: left; }
.vis-choice span small { opacity: .8; }
.file-drop { display: grid; place-items: center; gap: 6px; padding: 18px; border: 2px dashed #6699cc; background: #f2f6fc; text-align: center; cursor: pointer; border-radius: 8px; }
.file-drop input { max-width: 100%; }
.music-box { border: 1px solid #c9d6e8; border-radius: 10px; padding: 8px 12px 10px; margin: 0 0 12px; background: #f8fbff; }
.music-box legend { font-weight: bold; font-size: 13px; padding: 0 4px; }
.music-panel { margin-top: 10px; }
.music-panel[hidden] { display: none; }
.field-pair { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field-pair .field { flex: 1 1 140px; }
.music-play { margin-bottom: 12px; }
.music-play[hidden] { display: none; }
.post-btn {font-size: 16px; padding: 10px 26px; background: linear-gradient(90deg, #ff512f, #dd2476); border-color: #b0185d; }

@media (max-width: 760px) {
  .composer { grid-template-columns: minmax(0, 1fr); }
  .composer-preview { position: static; order: -1; max-width: 300px; margin: 0 auto; width: 100%; }
}

/* ===== Built-in camera ===== */
.cam-open { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; font-size: 17px; padding: 14px; margin-bottom: 10px; background: linear-gradient(90deg, #ff512f, #dd2476); border-color: #b0185d; border-radius: 10px; }
.cam-open small { font-weight: normal; font-size: 11px; opacity: .9; }
.cam-open[hidden] { display: none; }
.camera { position: fixed; inset: 0; z-index: 1000; background: #000; color: #fff; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.camera[hidden] { display: none; }
.camera .cam-view { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }
.camera .sc-media video { width: 100%; height: 100%; object-fit: cover; }
.camera video.mirror { transform: scaleX(-1); }
.camera .sc-media video.whole { object-fit: contain; }
.camera.flash::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: .85; pointer-events: none; }
.cam-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.cam-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; font-size: 24px; cursor: pointer; }
.cam-timer { font: bold 16px Verdana, sans-serif; color: #ff3b30; text-shadow: 0 1px 3px #000; }
.cam-error { position: absolute; top: 40%; left: 20px; right: 20px; z-index: 2; background: rgba(0, 0, 0, .75); padding: 14px; border-radius: 10px; text-align: center; font-size: 14px; }
.cam-error[hidden] { display: none; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 2; display: grid; justify-items: center; gap: 10px; }
.cam-filters { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding: 0 12px; scrollbar-width: none; }
.cam-filters button { flex: none; border: 1px solid rgba(255, 255, 255, .6); background: rgba(0, 0, 0, .4); color: #fff; border-radius: 999px; padding: 5px 11px; font: 12px Verdana, sans-serif; cursor: pointer; }
.cam-filters button.on { background: #fff; color: #000; }
.cam-shutter { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 5px solid #fff; background: rgba(255, 255, 255, .25); cursor: pointer; transition: transform .15s, background .15s; touch-action: none; }
.camera.recording .cam-shutter { transform: scale(1.15); background: #ff3b30; }
.cam-ring { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; }
.cam-ring circle { fill: none; stroke: #ff3b30; stroke-width: 5; stroke-dasharray: 289; stroke-dashoffset: 289; stroke-linecap: round; }
.cam-hint { margin: 0; font: 12px Verdana, sans-serif; text-shadow: 0 1px 3px #000; }

/* ===== Viewer ===== */
body.story-viewer { margin: 0; background: #0b0b0b; color: #fff; font: 13px Verdana, sans-serif; min-height: 100vh; overflow: hidden; }
.sv-stage { position: fixed; inset: 0; display: grid; place-items: center; padding: 10px; touch-action: none; }
body.story-viewer { overscroll-behavior: none; transition: background-color .2s; }
.sv-seen-list { touch-action: pan-y; }
.sv-wrap { position: relative; height: min(100%, 860px); max-height: calc(100vh - 20px); aspect-ratio: 9 / 16; max-width: 100%; }
.sv-wrap .story-card { height: 100%; width: auto; --top: 58px; --bottom: 46px; }
.sv-story:has(.sv-embed:not([hidden])) .sc-song { display: none; }
.sv-foot button { white-space: nowrap; font-size: 12px; }
.sv-story { position: absolute; inset: 0; display: none; }
.sv-story.active { display: block; }
.sv-bars { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 20; }
.sv-bars i { flex: 1; height: 3px; background: rgba(255, 255, 255, .35); border-radius: 2px; overflow: hidden; }
.sv-bars i b { display: block; height: 100%; width: 0; background: #fff; }
.sv-bars i.done b { width: 100%; }
.sv-head { position: absolute; top: 18px; left: 10px; right: 10px; display: flex; align-items: center; gap: 8px; z-index: 20; text-shadow: 0 1px 3px #000; }
.sv-head img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; }
.sv-head a { color: #fff; font-weight: bold; text-decoration: none; }
.sv-head .sv-meta { opacity: .85; font-size: 11px; }
.sv-close { margin-left: auto; background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; text-decoration: none; line-height: 1; }
.sv-tap { position: absolute; top: 60px; bottom: 70px; width: 35%; z-index: 15; background: none; border: 0; cursor: pointer; }
.sv-tap.prev { left: 0; }
.sv-tap.next { right: 0; }
.sv-foot { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 20; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.sv-seen { background: rgba(0, 0, 0, .6); border: 1px solid #555; color: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; }
.sv-seen-list { position: absolute; left: 10px; right: 10px; bottom: 50px; max-height: 45%; overflow: auto; background: rgba(20, 20, 20, .95); border: 1px solid #444; border-radius: 10px; padding: 8px; z-index: 25; }
.sv-seen-list[hidden] { display: none; }
.sv-seen-list li { display: flex; gap: 8px; align-items: center; padding: 4px; }
.sv-seen-list ul { list-style: none; margin: 0; padding: 0; }
.sv-seen-list img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.sv-seen-list a { color: #fff; }
.sv-del button { background: rgba(0, 0, 0, .6); border: 1px solid #a33; color: #f88; border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; }
.sv-sound { background: rgba(0, 0, 0, .6); border: 1px solid #555; color: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; }
.sv-sound[hidden] { display: none; }
.sv-embed { position: absolute; left: 10px; right: 10px; bottom: 54px; z-index: 18; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); background: #000; }
.sv-embed[hidden] { display: none; }
.sv-embed iframe { display: block; width: 100%; border: 0; }
.sv-embed-youtube iframe { height: 96px; }
.sv-embed-soundcloud iframe { height: 120px; }
.sv-embed-spotify iframe { height: 80px; }
.sv-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 30; color: #fff; font-size: 40px; text-decoration: none; opacity: .6; padding: 10px; }
.sv-nav:hover { opacity: 1; }
.sv-nav.left { left: 10px; }
.sv-nav.right { right: 10px; }
@media (max-width: 600px) { .sv-nav { display: none; } .sv-stage { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); } .sv-wrap { height: 100%; max-height: 100vh; } .sv-wrap .story-card { border-radius: 0; } }
@media (prefers-reduced-motion: reduce) { .font-glitter, .frame-glitter { animation: none; } }
