:root {
  --bg: #0e0e16;
  --bg-alt: #14141f;
  --card: #191924;
  --card-border: #26263a;
  --text: #eceaf5;
  --text-muted: #8f8ca8;
  --violet: #7c5cff;
  --violet-2: #5b8cff;
  --pink: #ff5c8a;
  --green: #34d399;
  --yellow: #f7b955;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
}

[data-theme="light"] {
  --bg: #f4f3fb;
  --bg-alt: #ffffff;
  --card: #ffffff;
  --card-border: #e5e3f3;
  --text: #1c1b29;
  --text-muted: #6d6a85;
  --shadow: 0 8px 24px rgba(40,30,90,.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  min-height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: background .25s ease, color .25s ease;
}

::selection { background: var(--violet); color: #fff; }

a { color: var(--violet-2); }

.hidden { display: none !important; }

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.brand-text h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -0.2px; }
.brand-text h1 span { color: var(--violet); }
.brand-text p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap .icon-search {
  position: absolute; left: 14px; width: 17px; height: 17px; color: var(--text-muted);
}
.search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--violet); }

.topbar-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; position: relative; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--text); border-color: var(--violet); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--violet), var(--violet-2));
  color: #fff; border: none;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(124,92,255,.35);
}
.btn-primary svg { width: 15px; height: 15px; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary.full { width: 100%; justify-content: center; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}
.user-chip svg { width: 14px; height: 14px; color: var(--text-muted); }
.avatar-mini {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--violet-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.user-menu {
  position: absolute;
  top: 46px; right: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 160px;
}
.user-menu button {
  width: 100%; text-align: left;
  padding: 10px 14px;
  background: none; border: none;
  color: var(--text); font-size: 14px;
  cursor: pointer;
}
.user-menu button:hover { background: var(--bg-alt); }

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 22px;
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 28px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== COMPOSER ===== */
.composer {
  display: flex;
  gap: 14px;
  padding: 20px;
  margin-bottom: 20px;
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--violet-2));
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.composer-body { flex: 1; min-width: 0; }
.composer-body textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  padding: 8px 0;
}
.composer-body textarea::placeholder { color: var(--text-muted); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--card-border);
  flex-wrap: wrap;
}

.category-select { position: relative; }
.category-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  cursor: pointer;
}
.category-btn svg { width: 15px; height: 15px; }
.category-btn .chev { width: 13px; height: 13px; margin-left: 2px; }
.category-btn.has-value { color: var(--text); }

.category-dropdown {
  position: absolute;
  top: 44px; left: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  list-style: none;
  margin: 0; padding: 6px;
  min-width: 200px;
  box-shadow: var(--shadow);
  z-index: 30;
  max-height: 260px;
  overflow-y: auto;
}
.category-dropdown li {
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.category-dropdown li:hover { background: var(--bg-alt); }

.composer-right { display: flex; align-items: center; gap: 14px; }
.char-count { font-size: 12.5px; color: var(--text-muted); }

/* ===== POSTS ===== */
.posts-list { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  padding: 18px 20px;
}
.post-head {
  display: flex; align-items: center; gap: 12px;
}
.post-head .avatar { width: 40px; height: 40px; font-size: 18px; }
.post-author { font-weight: 600; font-size: 14.5px; }
.post-time { font-size: 12.5px; color: var(--text-muted); }
.post-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.post-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.post-more { margin-left: auto; color: var(--text-muted); background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px 8px; }

.post-text {
  margin: 14px 0 6px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.post-actions {
  display: flex; align-items: center; gap: 22px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--card-border);
}
.post-action {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 13.5px;
  cursor: pointer;
}
.post-action svg { width: 17px; height: 17px; }
.post-action:hover { color: var(--text); }
.post-action.liked { color: var(--pink); }
.post-action.liked svg { fill: var(--pink); }
.post-action.disabled { cursor: default; opacity: .6; }

.loading-state, .empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .muted { font-size: 13.5px; margin-top: 4px; }

/* ===== SIDEBAR ===== */
.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 84px; }
.sidebar .card { padding: 20px; }

.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; margin: 0 0 14px;
}
.title-icon { font-size: 15px; }

.category-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.category-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 6px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.category-list li:hover { background: var(--bg-alt); }
.category-list li.active { background: var(--bg-alt); }
.cat-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.cat-info { display: flex; flex-direction: column; line-height: 1.3; }
.cat-count { font-size: 12px; color: var(--text-muted); }
.cat-arrow { margin-left: auto; color: var(--text-muted); }

.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tag-list li { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; }
.tag-list a { text-decoration: none; font-weight: 600; }
.tag-list .tag-count { color: var(--text-muted); }

.quote-card {
  border-radius: var(--radius);
  padding: 24px 20px;
  background: linear-gradient(160deg, #2c1f5e, #17162c);
  border: 1px solid var(--card-border);
  color: #d9d5f0;
  font-size: 14px;
  font-style: italic;
  line-height: 1.6;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,5,10,.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px 26px;
  width: 100%; max-width: 380px;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer;
}
.modal-brand { text-align: center; margin-bottom: 18px; }
.modal-brand img { width: 46px; height: 46px; border-radius: 12px; margin-bottom: 10px; }
.modal-brand h2 { margin: 0 0 4px; font-size: 19px; }
.modal-brand p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13.5px; }
.field span:first-child { color: var(--text-muted); }
.field input[type="email"], .field input[type="password"] {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--violet); }

.terms-field { font-size: 13px; }
.terms-row { display: flex; align-items: flex-start; gap: 8px; color: var(--text-muted); }
.terms-row input { margin-top: 2px; }

.auth-error {
  background: rgba(255,92,138,.12);
  color: var(--pink);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin: -2px 0 14px;
}

.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--text-muted); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--card-border); }

.btn-google {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 10px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-google:hover { border-color: var(--violet); }

.auth-switch { text-align: center; margin: 16px 0 0; font-size: 13.5px; color: var(--text-muted); }
.auth-switch button { background: none; border: none; color: var(--violet-2); font-weight: 600; cursor: pointer; font-size: 13.5px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  z-index: 300;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .search-wrap { order: 3; max-width: 100%; }
  .brand-text p { display: none; }
  .layout { padding: 0 14px; }
}
