/* Explore feed + creator forms. Prefix: xp- (hooks used by inline JS keep their legacy names). */
.xp-body { --xp-ring: conic-gradient(from 200deg, var(--c-7), var(--c-6), var(--c-5), var(--c-4), var(--c-3), var(--c-7)); --xp-heart: var(--c-5); }
.xp-wrap { max-width: 600px; margin-inline: auto; padding: 16px 16px 40px; }
.xp-wrap.xp-narrow { max-width: 560px; }

/* alerts */
.xp-alert { padding: 12px 14px; border-radius: var(--r-md); margin-bottom: 14px; font-weight: 600; font-size: 14px; background: var(--info-bg); color: var(--info); }
.xp-alert.success { background: var(--ok-bg); color: var(--ok); }
.xp-alert.error { background: var(--bad-bg); color: var(--bad); }
.xp-alert.warning { background: var(--warn-bg); color: var(--warn); }

/* intro */
.xp-intro { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 18px; margin-bottom: 18px; background: var(--grad-primary); color: #fff; box-shadow: var(--shadow-2); }
.xp-intro::after { content: ""; position: absolute; inset-inline-start: -40px; top: -50px; width: 160px; height: 160px; border-radius: 50%; background: var(--grad-sun); opacity: .35; filter: blur(8px); pointer-events: none; }
.xp-intro h1 { margin: 0 0 6px; font-size: clamp(18px, 4.6vw, 22px); font-weight: 900; position: relative; }
.xp-intro p { margin: 0; font-size: 14px; line-height: 1.9; opacity: .95; position: relative; }
.xp-intro-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; position: relative; }
.xp-intro .btn { background: #fff; color: var(--c-1); border-color: transparent; box-shadow: none; }
.xp-intro .btn.xp-sun { background: var(--grad-sun); color: #2a0f40; }

/* stories */
.xp-stories { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; margin-bottom: 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
.xp-stories::-webkit-scrollbar { display: none; }
.story-item { flex: none; width: 74px; display: grid; justify-items: center; gap: 6px; scroll-snap-align: start; }
.story-avatar-wrap { position: relative; display: block; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 50%; color: inherit; }
.story-ring { width: 68px; height: 68px; border-radius: 50%; padding: 3px; display: grid; place-items: center; background: var(--line-strong); }
.story-ring-active { background: var(--xp-ring); animation: xp-spin-in .8s var(--ease) both; }
.story-ring-create { background: transparent; border: 2px dashed var(--c-4); padding: 3px; }
.story-avatar { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: var(--grad-primary); color: #fff; font-weight: 900; font-size: 22px; border: 3px solid var(--bg); }
.story-plus-badge { position: absolute; inset-block-end: 0; inset-inline-end: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-sun); color: #2a0f40; border: 2px solid var(--bg); }
.story-teacher-name { font-size: 12px; font-weight: 700; color: var(--ink-2); max-width: 74px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-avatar-wrap:focus-visible { outline: 3px solid var(--c-3); outline-offset: 3px; }
.xp-stories-empty { font-size: 13px; color: var(--muted); padding: 10px 4px; }
@keyframes xp-spin-in { from { transform: rotate(-90deg) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

.xp-feed-title { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px 12px; }
.xp-feed-title h2 { margin: 0; font-size: 16px; font-weight: 900; }
.xp-feed-title span { font-size: 12px; color: var(--muted); }

/* feed card */
.explore-feed { display: grid; gap: 22px; }
.feed-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); scroll-margin-top: calc(var(--header-h) + 12px); }
.feed-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.feed-author-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.author-avatar-ring { width: 44px; height: 44px; padding: 2px; border-radius: 50%; background: var(--xp-ring); flex: none; }
.author-avatar { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: var(--grad-primary); color: #fff; font-weight: 900; border: 2px solid var(--surface); }
.author-meta { min-width: 0; }
.author-name-row { display: flex; align-items: center; gap: 6px; }
.author-name { margin: 0; font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verified-badge { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--c-2); color: #fff; flex: none; }
.author-sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.xp-icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: transparent; border: 0; color: var(--ink-2); cursor: pointer; transition: background .2s; }
.xp-icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.feed-media-wrap { position: relative; background: #0b0512; aspect-ratio: 9 / 14; max-height: min(78vh, 680px); width: 100%; overflow: hidden; }
.feed-video { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; background: #0b0512; }
.video-play-indicator { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: rgba(20, 8, 36, .55); color: #fff; backdrop-filter: blur(6px); pointer-events: none; opacity: 0; transition: opacity .25s; }
.video-play-indicator svg { width: 30px; height: 30px; margin-inline-start: -3px; }
.video-play-indicator.show { opacity: 1; }
.double-tap-heart { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; pointer-events: none; opacity: 0; color: var(--c-5); }
.video-badge { position: absolute; inset-block-start: 10px; inset-inline-start: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: var(--r-pill); background: rgba(20, 8, 36, .6); color: #fff; font-size: 12px; font-weight: 700; backdrop-filter: blur(6px); }
.video-sound-btn { position: absolute; inset-block-end: 10px; inset-inline-start: 10px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: rgba(20, 8, 36, .6); color: #fff; border: 0; cursor: pointer; backdrop-filter: blur(6px); }

.feed-actions-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; }
.actions-left { display: flex; gap: 2px; }
.feed-action-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 800; font-size: 14px; border-radius: var(--r-pill); cursor: pointer; transition: background .2s, transform .15s; }
.feed-action-btn:hover { background: var(--accent-soft); }
.feed-action-btn:active { transform: scale(.94); }
.feed-action-btn svg { width: 24px; height: 24px; }
.like-btn .heart-filled { display: none; color: var(--xp-heart); }
.like-btn.liked .heart-outline { display: none; }
.like-btn.liked .heart-filled { display: block; animation: xp-pop .35s var(--ease); }
@keyframes xp-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

.feed-content-block { padding: 2px 16px 8px; }
.post-title { margin: 0 0 4px; font-size: 15px; font-weight: 900; line-height: 1.7; }
.post-caption { margin: 0; font-size: 14px; line-height: 1.9; color: var(--ink-2); }
.caption-author { font-weight: 800; color: var(--ink); margin-inline-end: 6px; }

.feed-comments-section { padding: 4px 16px 16px; }
.view-all-comments-btn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; padding: 8px 0; min-height: 44px; cursor: pointer; }
.comment-item-mini { font-size: 13px; line-height: 1.8; color: var(--ink-2); }
.comment-item-mini b { color: var(--ink); }
.quick-comment-form, #modal-comment-form { display: flex; gap: 8px; margin-top: 8px; }
.quick-comment-form input, #modal-comment-input { flex: 1; min-width: 0; min-height: 44px; padding: 0 16px; border-radius: var(--r-pill); border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px; }
.quick-comment-form input:focus, #modal-comment-input:focus { outline: 0; border-color: var(--c-3); box-shadow: 0 0 0 4px var(--accent-soft); }
.quick-comment-form button, #modal-comment-form button { min-height: 44px; padding: 0 18px; border: 0; border-radius: var(--r-pill); background: var(--grad-primary); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.quick-comment-form button:disabled, #modal-comment-form button:disabled { opacity: .55; }
.comment-guest-hint a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent); font-weight: 700; font-size: 13px; }
.comment-feedback { font-size: 12px; margin-top: 6px; color: var(--muted); }
.comment-feedback.success { color: var(--ok); }
.comment-feedback:empty { display: none; }

.xp-empty { margin-top: 8px; }
.xp-empty h3 { margin: 6px 0; font-size: 18px; color: var(--ink); }
.xp-empty p { margin: 0 auto 16px; max-width: 380px; line-height: 1.9; }

/* story viewer */
.story-modal { position: fixed; inset: 0; z-index: 400; background: rgba(8, 3, 16, .94); align-items: center; justify-content: center; }
.story-modal-inner { position: relative; width: 100%; max-width: 440px; height: 100%; max-height: 100dvh; background: #000; display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 560px) { .story-modal-inner { height: min(92vh, 800px); border-radius: var(--r-lg); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); } }
.story-progress-bars { position: absolute; inset-inline: 10px; top: 10px; z-index: 5; display: flex; gap: 4px; direction: ltr; }
.story-progress-bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.story-progress-fill { height: 100%; width: 0; background: var(--grad-sun); }
.story-modal-header { position: absolute; inset-inline: 0; top: 18px; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; color: #fff; background: linear-gradient(#000a, transparent); }
.story-modal-teacher { display: flex; align-items: center; gap: 10px; }
.story-modal-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-primary); font-weight: 900; border: 2px solid var(--c-7); }
.story-modal-teacher b { display: block; font-size: 14px; }
.story-modal-teacher small { opacity: .8; font-size: 12px; }
.story-close-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; cursor: pointer; }
.story-modal-content { flex: 1; display: grid; place-items: center; position: relative; min-height: 0; }
.story-media { width: 100%; height: 100%; object-fit: contain; }
.story-modal-caption { position: absolute; inset-inline: 16px; bottom: 28px; padding: 12px 14px; border-radius: var(--r-md); background: rgba(20, 8, 36, .65); color: #fff; font-size: 15px; line-height: 1.9; text-align: center; backdrop-filter: blur(8px); }
.story-modal-caption:empty { display: none; }
.story-nav-tap { position: absolute; top: 70px; bottom: 0; width: 35%; z-index: 3; cursor: pointer; }
.story-tap-prev { right: 0; }
.story-tap-next { left: 0; }

/* comments bottom-sheet */
.comments-modal { position: fixed; inset: 0; z-index: 390; align-items: flex-end; justify-content: center; }
.comments-modal-backdrop { position: absolute; inset: 0; background: rgba(13, 6, 23, .6); backdrop-filter: blur(3px); }
.comments-modal-sheet { position: relative; width: 100%; max-width: 560px; max-height: 82dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-2); animation: xp-sheet .3s var(--ease); }
@media (min-width: 700px) { .comments-modal { align-items: center; } .comments-modal-sheet { border-radius: var(--r-xl); max-height: 80vh; } }
@keyframes xp-sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.comments-sheet-header { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 22px 16px 10px; border-bottom: 1px solid var(--line); }
.comments-sheet-header h3 { margin: 0; font-size: 16px; font-weight: 900; }
.sheet-drag-handle { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); }
.close-sheet-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); cursor: pointer; }
.comments-sheet-body { flex: 1; overflow-y: auto; padding: 8px 16px; min-height: 120px; }
.modal-comment-item { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.9; color: var(--ink-2); }
.modal-comment-item b { color: var(--ink); }
.xp-cm-time { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.empty-comments-state { text-align: center; padding: 32px 12px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.comments-sheet-footer { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.comments-modal-login-prompt { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.modal-login-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: var(--r-pill); background: var(--grad-primary); color: #fff; font-weight: 800; }

.explore-toast { position: fixed; inset-inline: 16px; bottom: calc(var(--bar-h) + 24px); margin-inline: auto; width: fit-content; max-width: 92vw; z-index: 500; padding: 12px 18px; border-radius: var(--r-pill); background: var(--c-1); color: #fff; font-size: 14px; font-weight: 700; box-shadow: var(--shadow-2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .25s, transform .25s; }
.explore-toast.show { opacity: 1; transform: none; }
.explore-toast:empty { display: none; }

/* creator forms */
.xp-form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 4vw, 28px); box-shadow: var(--shadow-1); }
.xp-form-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.xp-form-head .icon-tile { flex: none; }
.xp-form-head h1 { margin: 0; font-size: clamp(18px, 4.6vw, 22px); font-weight: 900; }
.xp-form-head p { margin: 4px 0 0; font-size: 14px; color: var(--muted); line-height: 1.8; }
.xp-form-card .field label { font-weight: 800; font-size: 14px; }
.xp-form-card .field > input[type=text], .xp-form-card .field > textarea { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-md); border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 15px; box-sizing: border-box; }
.xp-form-card .field > textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.xp-form-card .field > input:focus, .xp-form-card .field > textarea:focus { outline: 0; border-color: var(--c-3); box-shadow: 0 0 0 4px var(--accent-soft); }
.xp-hint { font-size: 12px; color: var(--muted); line-height: 1.8; }
.xp-rules { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.xp-rules li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--info-bg); color: var(--info); font-size: 12px; font-weight: 700; }
html[data-theme="dark"] .xp-rules li { color: var(--c-9); }

.file-dropzone { position: relative; display: grid; justify-items: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--c-3); border-radius: var(--r-lg); background: var(--accent-soft); transition: background .2s, border-color .2s, transform .2s; cursor: pointer; }
.file-dropzone:hover, .file-dropzone.is-drag, .file-dropzone:focus-within { background: var(--surface-3); border-color: var(--c-5); transform: translateY(-1px); }
.file-dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.xp-drop-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--grad-primary); color: #fff; }
.xp-drop-title { font-weight: 800; font-size: 15px; word-break: break-all; }
.xp-drop-title.has-file { color: var(--ok); }
.video-preview, .preview-box { display: none; width: 100%; margin-top: 12px; border-radius: var(--r-md); background: #000; max-height: 340px; object-fit: contain; }
.duration-warning { display: none; margin-top: 10px; padding: 10px 14px; border-radius: var(--r-md); background: var(--bad-bg); color: var(--bad); font-size: 13px; font-weight: 700; line-height: 1.8; }
.xp-submit:disabled { opacity: .5; cursor: not-allowed; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .story-ring-active, .comments-modal-sheet, .like-btn.liked .heart-filled { animation: none; }
  .file-dropzone, .explore-toast { transition: none; }
}
