:root {
  --primary: #7028e4;
  --primary-dark: #5a1fc0;
  --blue: #2563eb;
  --bg: #f5f3ff;
  --card: #ffffff;
  --text: #24213b;
  --muted: #777;
  --soft: #f0ebff;
  --border: #ddd6fe;
  --danger: #c62828;
  --ok: #1b8a3a;
  --radius: 15px;
  --shadow: 0 3px 12px #e5e0f5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(100deg, var(--primary), var(--blue));
  color: #fff;
  padding: 14px 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-size: 26px; font-weight: bold; color: #fff; text-decoration: none; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-weight: bold; }
.nav a.active { text-decoration: underline; }
.nav .who { font-size: 14px; opacity: .9; }

/* ---------- Buttons / inputs ---------- */
button { font: inherit; cursor: pointer; border: 0; border-radius: 9px; padding: 10px 16px; font-weight: bold; }
button:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-soft { background: var(--soft); color: var(--primary); }
.btn-white { background: #fff; color: var(--primary); }
.btn-danger { background: #fdeaea; color: var(--danger); }

input, textarea {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { resize: vertical; min-height: 80px; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 15px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 230px;
  gap: 20px;
}
.container { max-width: 800px; margin: 24px auto; padding: 0 15px; }

.panel {
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.panel h2, .post h2 { margin: 0 0 12px; color: var(--primary); font-size: 20px; }
.menu a {
  display: block;
  padding: 11px 6px;
  text-decoration: none;
  color: var(--text);
  font-weight: bold;
  border-radius: 8px;
}
.menu a:hover { background: var(--soft); }
.small { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); }
.success { color: var(--ok); }

/* ---------- Composer ---------- */
.composer textarea { margin-bottom: 10px; }
.composer .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.composer .file-pick { display: inline-block; }
.composer .file-pick input { display: none; }
.composer .file-pick span {
  display: inline-block; background: var(--soft); color: var(--primary);
  padding: 10px 14px; border-radius: 9px; font-weight: bold; cursor: pointer;
}
.composer .spacer { flex: 1; }
.preview { margin-top: 10px; position: relative; }
.preview img, .preview video { width: 100%; max-height: 300px; object-fit: contain; border-radius: 12px; background: #000; }
.preview .remove { position: absolute; top: 8px; right: 8px; background: #000a; color: #fff; padding: 4px 10px; }

/* ---------- Post ---------- */
.post {
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar-sm {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--soft); display: grid; place-items: center; font-size: 20px; flex: none;
}
.post-author { font-weight: bold; text-decoration: none; color: var(--text); }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
.post-media { width: 100%; max-height: 500px; object-fit: contain; border-radius: 12px; background: #000; margin-top: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions button { background: var(--soft); color: var(--primary); }
.actions button.liked { background: var(--primary); color: #fff; }
.comments { margin-top: 12px; }
.comment { background: var(--bg); border-radius: 10px; padding: 8px 12px; margin-top: 6px; overflow-wrap: anywhere; }
.comment b { margin-right: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; }

.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg,#eee 25%,#f7f7f7 50%,#eee 75%); background-size: 200% 100%; animation: sh 1.2s infinite; margin-bottom: 18px; }
@keyframes sh { to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #222; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 50;
  max-width: 90%; text-align: center;
}

/* ---------- Auth page ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #6c3ce9, #2196f3);
}
.auth-card { background: var(--card); width: 100%; max-width: 410px; padding: 30px; border-radius: 18px; box-shadow: 0 10px 35px #0002; }
.auth-card .logo { display: block; text-align: center; font-size: 34px; color: var(--primary); margin-bottom: 6px; }
.auth-card .subtitle { text-align: center; color: #666; margin-bottom: 22px; }
.tabs { display: flex; gap: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; background: var(--soft); color: var(--primary); }
.tabs button.active { background: var(--primary); color: #fff; }
.auth-card input { margin: 7px 0; }
.auth-card .submit { width: 100%; margin-top: 14px; padding: 13px; color: #fff; background: linear-gradient(90deg, var(--primary), #2196f3); }
.back { display: block; text-align: center; margin-top: 18px; text-decoration: none; }

/* ---------- Profile ---------- */
.profile-card { background: var(--card); border-radius: 18px; padding: 24px; text-align: center; box-shadow: var(--shadow); }
.cover { height: 160px; background: linear-gradient(135deg, #7b42dc, #2589f5); border-radius: 14px; margin-bottom: -60px; }
.avatar-lg {
  width: 120px; height: 120px; border-radius: 50%; border: 5px solid var(--card); background: var(--soft);
  margin: 0 auto 12px; display: grid; place-items: center; font-size: 52px; position: relative;
}
.profile-card h1 { margin: 6px 0; font-size: 26px; }
.bio { max-width: 500px; margin: 10px auto; white-space: pre-wrap; }
.stats { display: flex; justify-content: center; gap: 40px; margin-top: 20px; padding-top: 18px; border-top: 1px solid #eee; }
.stats strong { display: block; font-size: 22px; color: var(--primary); }
#editForm { display: none; text-align: left; margin-top: 20px; }
#editForm label { font-weight: bold; display: block; margin-top: 8px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }

footer { padding: 25px; text-align: center; color: var(--primary); }

@media (max-width: 850px) {
  .layout { grid-template-columns: 1fr; }
  .left, .right { display: none; }
  .stats { gap: 22px; }
  .cover { height: 120px; }
}

/* ---------- ধাপ ২: avatar, search, follow ---------- */
.search {
  flex: 1;
  min-width: 160px;
  max-width: 360px;
  border: 0;
  border-radius: 20px;
  padding: 10px 16px;
}
.post-author { display: block; }
.avatar-sm, .avatar-lg { overflow: hidden; text-decoration: none; color: inherit; }
.avatar-sm img, .avatar-lg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px; border-radius: 10px;
  text-decoration: none; color: var(--text); font-weight: bold;
}
.user-row:hover { background: var(--soft); }
.stats > div { min-width: 70px; }
.back-link { display: inline-block; margin-bottom: 14px; padding: 10px 16px; border-radius: 9px; text-decoration: none; font-weight: bold; }

/* ---------- ধাপ ৩: Short video feed ---------- */
.reel-body { background: #000; overflow: hidden; }
.reel-body .site-header { position: relative; }
.reel {
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  background: #000;
}
.reel-item {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  justify-content: center;
  background: #000;
}
.reel-video { height: 100%; width: 100%; max-width: 480px; object-fit: contain; background: #000; }
.reel-info {
  position: absolute; bottom: 22px; left: max(14px, calc(50% - 226px));
  right: 90px; max-width: 360px; color: #fff; text-shadow: 0 1px 4px #000;
}
.reel-info p { margin: 6px 0; overflow-wrap: anywhere; }
.reel-author { color: #fff; font-weight: bold; text-decoration: none; }
.reel-side {
  position: absolute; bottom: 90px; right: max(10px, calc(50% - 232px));
  display: flex; flex-direction: column; gap: 16px; align-items: center; text-align: center;
}
.reel-side button {
  width: 52px; height: 52px; border-radius: 50%; padding: 0; font-size: 22px;
  background: #0008; color: #fff;
}
.reel-side small { display: block; color: #fff; font-size: 12px; text-shadow: 0 1px 3px #000; }
.reel-empty { color: #fff; text-align: center; padding: 60px 20px; }
.sound-btn { position: fixed; top: 76px; right: 14px; z-index: 6; background: #000a; color: #fff; border-radius: 50%; width: 44px; height: 44px; padding: 0; font-size: 20px; }
.sheet { position: fixed; inset: 0; background: #0008; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-card { background: var(--card); color: var(--text); width: 100%; max-width: 560px; max-height: 75vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px; }
.sheet-close { margin-bottom: 10px; }

/* ---------- ধাপ ৪: legal, terms, report ---------- */
.legal .panel { padding: 24px; }
.legal h1 { margin-top: 0; color: var(--primary); }
.legal h2 { margin-top: 22px; }
.legal li { margin: 6px 0; }
.terms { display: block; font-size: 13px; color: #555; margin: 8px 0; line-height: 1.5; }
.terms input { width: auto; margin: 0 8px 0 0; vertical-align: middle; }
.report-select { width: 100%; margin: 10px 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; }
.sheet .sheet-card textarea { margin-bottom: 12px; }
footer a { color: inherit; }

/* ---------- ধাপ ৫: notifications ---------- */
.badge { background: #ef4444; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.badge[hidden] { display: none; }
.notif { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; text-decoration: none; color: var(--text); margin-bottom: 6px; overflow-wrap: anywhere; }
.notif:hover { background: var(--soft); }
.notif.unread { background: var(--soft); border-left: 4px solid var(--primary); }

/* ---------- ধাপ ৬: chat ---------- */
a.btn-primary, a.btn-soft { display: inline-block; text-decoration: none; padding: 10px 18px; border-radius: 10px; font-weight: bold; }
.chat-container { max-width: 1000px; }
.chat { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 170px); min-height: 420px; }
.chat-side, .chat-main { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.chat-side { padding: 16px; overflow-y: auto; display: block; }
.chat-side h2 { margin: 0 0 12px; color: var(--primary); font-size: 20px; }
.conv { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; color: var(--text); padding: 10px; border-radius: 12px; margin-bottom: 4px; }
.conv:hover, .conv.active { background: var(--soft); }
.conv-text { flex: 1; min-width: 0; }
.conv-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-text span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.chat-empty p:first-child { font-size: 48px; margin: 0; }
.chat-thread { display: flex; flex-direction: column; height: 100%; }
.chat-thread[hidden], .chat-empty[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-head #backBtn { display: none; padding: 8px 14px; }
.chat-name { font-weight: bold; color: var(--text); text-decoration: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 16px; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--card); box-shadow: 0 1px 3px #0001; align-self: flex-start; }
.bubble.mine { align-self: flex-end; background: var(--primary); color: #fff; }
.bubble time { display: block; font-size: 11px; opacity: .7; margin-top: 2px; text-align: right; }
.chat-notice { padding: 8px 16px; margin: 0; color: var(--danger); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-form textarea { flex: 1; resize: none; max-height: 120px; min-height: 44px; margin: 0; }
@media (max-width: 720px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 150px); height: calc(100dvh - 150px); }
  body.chat-open .site-header, body.chat-open footer { display: none; }
  body.chat-open .chat-container { padding: 8px; }
  body.chat-open .chat { height: calc(100vh - 48px); height: calc(100dvh - 48px); }
  .chat .chat-main { display: none; }
  .chat.open .chat-side { display: none; }
  .chat.open .chat-main { display: flex; }
  .chat-head #backBtn { display: inline-block; }
}
.chat-form[hidden], a.btn-primary[hidden] { display: none; }

/* ---------- ধাপ ৭: settings ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.danger-zone { border: 1px solid #f5c2c2; }
.danger-zone h2 { color: var(--danger); }

/* ---------- logo ---------- */
.auth-logo { display: block; width: 190px; max-width: 70%; height: auto; margin: 0 auto 6px; }

/* ---------- ধাপ ৮: chat images ---------- */
.chat-img { display: block; max-width: 100%; max-height: 280px; border-radius: 12px; margin-bottom: 4px; cursor: pointer; }
.bubble .chat-img + div { margin-top: 2px; }
.attach-preview { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--soft); }
.attach-preview[hidden] { display: none; }
.attach-preview img { height: 64px; border-radius: 8px; }
.chat-form #attachBtn { padding: 10px 12px; font-size: 18px; }

/* ---------- ধাপ ৯: admin ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat-card { background: var(--soft); border-radius: 12px; padding: 12px; text-align: center; }
.stat-card b { display: block; font-size: 24px; color: var(--primary); }
.stat-card span { font-size: 13px; color: var(--muted); }
.admin-tabs { margin-bottom: 14px; }
.report { border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; overflow-wrap: anywhere; }
.report .reason { font-weight: bold; color: var(--danger); }
.report .rpost { background: var(--bg); border-radius: 10px; padding: 10px; margin: 8px 0; }
.report .rpost img, .report .rpost video { max-width: 100%; max-height: 240px; border-radius: 10px; display: block; margin-top: 6px; }
.report .ractions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag-banned { background: #fdeaea; color: var(--danger); border-radius: 8px; padding: 2px 8px; font-size: 12px; }

.hashtag { color: var(--primary); font-weight: 600; text-decoration: none; }
.hashtag:hover { text-decoration: underline; }
.trend-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 4px; text-decoration: none; color: inherit; border-radius: 8px; }
.trend-row:hover { background: var(--soft); }

.reaction-picker { display: flex; gap: 6px; padding: 6px 4px; }
.reaction-picker[hidden] { display: none; }
.reaction-picker button { font-size: 22px; background: var(--soft); border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.reaction-picker button:hover { transform: scale(1.2); }
.reaction-sum { padding: 4px 2px 0; }

/* stories */
.stories { padding: 12px; }
.stories-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px; }
.story-item { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 68px; flex: 0 0 auto; color: inherit; font: inherit; }
.story-item small { font-size: 11px; max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-ring { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--blue)); }
.story-ring .avatar-sm { width: 54px; height: 54px; border: 3px solid var(--card, #fff); font-size: 22px; }
.story-add .story-ring { background: var(--soft); }
.story-plus { color: var(--primary); font-size: 26px; display: grid; place-items: center; }
.story-viewer { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; }
.story-viewer[hidden] { display: none; }
body.story-open { overflow: hidden; }
.story-bars { display: flex; gap: 4px; padding: 10px 10px 0; }
.story-bars span { flex: 1; height: 3px; background: rgba(255,255,255,.3); border-radius: 2px; }
.story-bars .done { background: #fff; }
.story-bars .now { background: #fff; }
.story-top { display: flex; align-items: center; gap: 8px; padding: 10px; color: #fff; position: relative; z-index: 3; }
.story-top .spacer { flex: 1; }
.story-stage { position: absolute; inset: 70px 0 70px; display: grid; place-items: center; }
.story-stage img, .story-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-caption { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; color: #fff; padding: 0 16px; z-index: 3; text-shadow: 0 1px 4px #000; }
.story-nav { position: absolute; top: 70px; bottom: 70px; width: 35%; background: none; border: 0; z-index: 2; cursor: pointer; }
.story-prev { left: 0; }
.story-next { right: 0; width: 65%; }

.stat-link { cursor: pointer; }
.stat-link:hover { opacity: .75; }
.modal-back { position: fixed; inset: 0; background: #0008; z-index: 150; display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--card); color: var(--text); width: 100%; max-width: 420px; max-height: 80vh; overflow: auto; border-radius: 16px; padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { margin: 0; }
/* dark mode */
html[data-theme="dark"] {
  --bg: #14111f; --card: #1f1a33; --text: #ece8ff; --muted: #a9a3c7;
  --soft: #2b2447; --border: #3a3160; --shadow: 0 3px 12px #0006; --primary: #9b6bff;
}
html[data-theme="dark"] .btn-danger { background: #3a1d24; color: #ff8a8a; }
html[data-theme="dark"] .btn-white { background: var(--card); }
html[data-theme="dark"] .small, html[data-theme="dark"] .auth-card .subtitle { color: var(--muted); }

.chat-audio { max-width: 100%; width: 240px; height: 40px; }
#micBtn.recording { background: #fdeaea; color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.attach-preview audio { width: 220px; }

#postVisibility { font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); }
.modal-box input[type=text], .modal-box input:not([type]) { margin-bottom: 8px; }
