:root {
  --bg: #f6f3ef;
  --panel: #ffffff;
  --ink: #17161c;
  --muted: #6b6773;
  --line: #ece8e2;
  --orange: #e8620f;
  --orange-dark: #c24d08;
  --blue: #1877f2;
  --ig: #d62976;
  --green: #0f8a5f;
  --red: #c0392b;
  --human: #6b3fa0;
  --shadow: 0 10px 30px rgba(23, 22, 28, 0.06);
  --radius: 16px;
  --font: "Inter", "Vazirmatn", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
button, input, textarea, select { font: inherit; }
a { color: var(--orange-dark); }
button { cursor: pointer; }

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 400px at 10% -10%, rgba(232,98,15,.18), transparent 50%),
    radial-gradient(700px 300px at 100% 0%, rgba(24,119,242,.12), transparent 45%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand img { width: 36px; height: 36px; border-radius: 9px; object-fit: contain; }
.sidebar .brand {
  justify-content: flex-start;
  gap: 12px;
  padding: 2px 4px 18px;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.sidebar .brand img {
  width: 40px;
  height: 40px;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
}
.sidebar .brand span {
  white-space: nowrap;
}
.auth-card h1 { margin: 18px 0 6px; font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input, textarea, select {
  width: 100%;
  border: 1px solid #ddd7ce;
  border-radius: 12px;
  padding: 12px 13px;
  background: #fff;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  text-decoration: none;
}
.btn-primary { background: var(--orange); color: #fff; width: 100%; margin-top: 16px; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-ig { background: linear-gradient(135deg,#f9ce34,#ee2a7b,#6228d7); color: #fff; }
.btn-fb { background: var(--blue); color: #fff; }
.btn-human { background: var(--human); color: #fff; }
.btn-bot { background: var(--green); color: #fff; }
.btn-danger { background: #fff0ee; color: var(--red); border: 1px solid #f3cfc9; }
.btn-sm { padding: 7px 10px; border-radius: 10px; font-size: 12px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }
.hint { color: var(--muted); font-size: 13px; }
.switch-auth { margin-top: 16px; text-align: center; color: var(--muted); }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 250px 1fr;
}
.sidebar {
  background: #17161c;
  color: #f7f4ef;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar .brand { color: #fff; padding: 4px 8px 16px; }
.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d8d3cc;
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 600;
}
.nav-btn.active, .nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #21d07a; box-shadow: 0 0 0 4px rgba(33,208,122,.15);
  display: inline-block; margin-right: 6px;
}
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; color: #9b958b; font-size: 12px; }
.sidebar-foot a { color: #f0c2a3; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.topbar h2 { margin: 0; font-size: 18px; }
.userchip { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.view { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.view > .page { flex: 1; overflow: auto; }
.view > .inbox,
.view > .comments { flex: 1; min-height: 0; }

.inbox {
  height: 100%;
  display: grid;
  grid-template-columns: 340px 1fr;
}
.conv-list { border-right: 1px solid var(--line); background: #fff; overflow: auto; }
.conv-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.conv-item.active { background: #fff6ef; }
.avatar, .avatar-lg {
  width: 44px; height: 44px; border-radius: 50%;
  background: #efe8df; display: grid; place-items: center; font-weight: 800; overflow: hidden;
}
.avatar img, .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.cname { font-weight: 700; }
.cprev { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  min-width: 20px; height: 20px; border-radius: 999px; background: var(--orange);
  color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 800;
}
.mode-pill {
  font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
}
.mode-human { background: #efe6fb; color: var(--human); }
.mode-bot { background: #e6f6ee; color: var(--green); }

.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; background: #fff;
}
.thread-body { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg {
  max-width: min(640px, 86%);
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.msg.out { align-self: flex-end; background: #fff4ea; border-color: #f3d4bc; }
.msg.in { align-self: flex-start; }
.tag {
  display: inline-block;
  font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  background: #17161c; color: #fff; border-radius: 999px; padding: 3px 7px; margin-bottom: 8px;
}
.tag.story { background: #d62976; }
.tag.audio { background: #0f8a5f; }
.tag.human { background: var(--human); }
.media img, .media video { max-width: 100%; border-radius: 12px; display: block; }
.media audio, .media video { width: 100%; }
.story-gone {
  padding: 20px; border: 1px dashed #d9cfc4; border-radius: 12px; color: var(--muted); text-align: center;
}
.composer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 12px 16px 16px;
  display: grid;
  gap: 8px;
}
.composer-row { display: flex; gap: 8px; }
.composer textarea { min-height: 56px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.check input { width: auto; }

.page { padding: 22px; }
.grid { display: grid; gap: 16px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; }
.connect-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.connect-actions .btn { width: auto; min-width: 220px; }
.status-ok { color: var(--green); font-weight: 700; }
.status-off { color: var(--muted); }

.comments {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), transparent 120px),
    var(--bg);
}
.media-list {
  background: #fff;
  border-right: 1px solid var(--line);
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}
.media-list-head {
  padding: 16px 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.media-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 2px;
}
.media-search-wrap { padding: 0 12px 12px; }
.media-search,
.comment-search {
  width: 100%;
  border: 1px solid #e5dfd6;
  border-radius: 12px;
  padding: 10px 12px;
  background: #faf8f5;
}
.media-search:focus,
.comment-search:focus {
  outline: none;
  border-color: #f0c19a;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232, 98, 15, 0.08);
}
.media-scroll {
  overflow: auto;
  min-height: 0;
  padding-bottom: 12px;
}
.media-item {
  width: 100%;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid #f1ece5;
  background: transparent;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: background .15s ease;
}
.media-item:hover { background: #faf7f3; }
.media-item.active {
  background: linear-gradient(90deg, #fff4ea, #fffaf5);
  box-shadow: inset 3px 0 0 var(--orange);
}
.thumb-wrap { position: relative; width: 58px; height: 58px; }
.thumb {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
  background: #efe8df;
  display: block;
}
.thumb-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.thumb-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(23, 22, 28, 0.78);
  color: #fff;
  font-size: 9px;
  display: grid;
  place-items: center;
}
.media-copy { min-width: 0; }
.media-copy .cname {
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.media-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.media-count {
  align-self: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #17161c;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.media-item.active .media-count { background: var(--orange); }

.comment-pane {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
  min-width: 0;
}
.comment-post-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.comments-back { display: none; width: auto; }
.comment-post-main {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: center;
  min-width: 0;
}
.post-preview {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  background: #efe8df;
  box-shadow: 0 8px 20px rgba(23, 22, 28, 0.08);
}
.comment-post-copy { min-width: 0; }
.comment-post-copy strong {
  font-size: 15px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comment-post-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.post-link {
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.post-link:hover { text-decoration: underline; }

.comment-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
}
.comment-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
}
.filter-chip em {
  font-style: normal;
  margin-left: 4px;
  color: var(--ink);
}
.filter-chip.active {
  background: #17161c;
  border-color: #17161c;
  color: #fff;
}
.filter-chip.active em { color: #ffd7b8; }
.comment-search { max-width: 280px; }

.comment-list {
  overflow: auto;
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.cmt-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cmt-item:hover { border-color: #e5d8c8; }
.cmt-item.is-open { border-color: #f0c19a; box-shadow: 0 12px 28px rgba(232, 98, 15, 0.08); }
.cmt-item.is-hidden { opacity: 0.72; }
.cmt-item.is-reply {
  background: #fcfbf9;
  box-shadow: none;
  border-style: dashed;
}
.cmt-row { display: grid; grid-template-columns: 40px 1fr; gap: 12px; }
.cmt-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe1c8, #f3ebe3);
  color: #8a4b1d;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.cmt-body { min-width: 0; }
.cmt-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cmt-time { color: var(--muted); font-size: 12px; }
.cmt-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .01em;
}
.cmt-chip.muted { background: #f1ece5; color: var(--muted); }
.cmt-chip.ok { background: #e6f6ee; color: var(--green); }
.cmt-chip.danger { background: #fff0ee; color: var(--red); }
.cmt-text {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 14px;
}
.cmt-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.cmt-action {
  border: 0;
  background: #f6f2ec;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.cmt-action:hover { background: #efe7db; }
.cmt-action.danger { background: #fff0ee; color: var(--red); }
.cmt-thread {
  margin: 12px 0 0 20px;
  padding-left: 14px;
  border-left: 2px solid #efe7db;
  display: grid;
  gap: 10px;
}
.cmt-composer {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #faf7f3;
  border: 1px solid #ece3d7;
  display: grid;
  gap: 10px;
}
.cmt-composer textarea {
  min-height: 84px;
  resize: vertical;
  background: #fff;
}
.cmt-composer-tabs { display: flex; gap: 6px; }
.cmt-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.cmt-tab.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.cmt-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.empty-block {
  padding: 28px 18px;
  color: var(--muted);
  text-align: left;
}
.empty-block.center { text-align: center; }
.empty-block.tall {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 8px;
}
.empty-title {
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 6px;
}
.empty-block p { margin: 0 0 14px; line-height: 1.5; }

.cmt-skeleton-list { display: grid; gap: 10px; padding: 12px; }
.cmt-skeleton-list.wide { padding: 0; }
.cmt-skeleton-row,
.cmt-skeleton-card {
  border-radius: 14px;
  background: linear-gradient(90deg, #f1ece5 20%, #f8f4ee 40%, #f1ece5 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.cmt-skeleton-row { height: 78px; }
.cmt-skeleton-card { height: 118px; }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.hidden-note { color: var(--red); font-size: 12px; font-weight: 700; }

.empty { color: var(--muted); padding: 40px 20px; text-align: center; }
.legal { max-width: 820px; margin: 0 auto; padding: 40px 20px 80px; line-height: 1.65; }
.legal h1 { margin-top: 0; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 32px));
  background: #17161c;
  color: #fff;
  padding: 14px 16px;
  border-radius: 14px;
  display: none;
  z-index: 9999;
  box-shadow: 0 16px 40px rgba(23, 22, 28, 0.28);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  border-left: 4px solid var(--orange);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-ok { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); background: #2a1514; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .inbox, .comments { grid-template-columns: 1fr; }
  .comments.show-posts .comment-pane { display: none; }
  .comments.show-thread .media-list { display: none; }
  .comments-back { display: inline-flex; }
  .comment-post-head {
    grid-template-columns: auto 1fr;
    align-items: start;
  }
  .comment-toolbar { padding: 12px; }
  .comment-search { max-width: none; }
  .comment-list { padding: 12px; }
  .cmt-thread { margin-left: 8px; padding-left: 10px; }
}
