:root {
  --bg: #0f1117;
  --bg-2: #141824;
  --surface: rgba(26, 30, 44, 0.72);
  --surface-solid: #1a1e2c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --text: #e8eaf0;
  --text-muted: #9aa0b0;
  --text-dim: #6b7180;
  --danger: #f87171;
  --success: #34d399;
  --radius: 16px;
  --blur: blur(18px);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(99, 102, 241, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: 0.15s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: rgba(255,255,255,0.09); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--danger); border-color: rgba(248,113,113,0.35); }
.btn-danger:hover { background: rgba(248,113,113,0.12); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  width: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  outline: none;
  transition: 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }

.verified { color: var(--accent-2); }
.pill { display:inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-2); }
.pill.staff { background: rgba(52,211,153,0.14); color: var(--success); }
.pill.open { background: rgba(52,211,153,0.15); color: var(--success); }
.pill.closed { background: rgba(248,113,113,0.14); color: var(--danger); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

/* ── Login ───────────────────────────────────────────── */
#login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: 22px; padding: 34px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand-logo { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem;
  background: linear-gradient(135deg, var(--accent), #6366f1); box-shadow: 0 8px 24px rgba(139,92,246,0.4); }
.brand-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-name small { display:block; font-size: 0.72rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.login-card h2 { font-size: 1.05rem; margin: 22px 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 0.86rem; margin-bottom: 20px; }
.login-error { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.3); color: #fca5a5;
  padding: 10px 14px; border-radius: 12px; font-size: 0.85rem; margin-bottom: 14px; }
.login-hint { margin-top: 20px; font-size: 0.78rem; color: var(--text-dim); line-height: 1.6; text-align: center; }

/* ── App layout ──────────────────────────────────────── */
#shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; max-width: 1180px; margin: 0 auto; }
#sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--border);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.side-brand .brand-logo { width: 38px; height: 38px; font-size: 1.25rem; }
.side-brand .brand-name { font-size: 1.25rem; }
.nav-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 14px; border-radius: 12px;
  color: var(--text-muted); font-weight: 600; font-size: 0.95rem; transition: 0.15s; border: none; background: none; width: 100%; text-align: left;
}
.nav-item .ico { width: 22px; text-align: center; font-size: 1.05rem; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-spacer { flex: 1; }

.profile-switch {
  margin-top: 10px; border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: rgba(0,0,0,0.2);
}
.profile-switch .cur { display: flex; align-items: center; gap: 10px; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex-shrink: 0; display: grid; place-items: center; font-weight: 700; color: var(--accent-2); }
.avatar.sm { width: 34px; height: 34px; font-size: 0.85rem; }
.avatar.md { width: 46px; height: 46px; font-size: 1rem; }
.avatar.lg { width: 84px; height: 84px; font-size: 1.8rem; }
.profile-switch .meta { min-width: 0; }
.profile-switch .meta b { display: block; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-switch .meta span { font-size: 0.76rem; color: var(--text-muted); }
.profile-switch select { margin-top: 9px; padding: 8px 10px; font-size: 0.84rem; }
.logout { margin-top: 8px; width: 100%; justify-content: center; }

/* ── Main column ─────────────────────────────────────── */
#main { padding: 0 26px 80px; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; padding: 20px 4px 14px; margin-bottom: 8px;
  background: linear-gradient(var(--bg) 62%, transparent);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.topbar .sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

.card {
  background: var(--surface); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  margin-bottom: 16px;
}
.card.pad-lg { padding: 22px; }

/* Composer */
.composer textarea { border: none; background: transparent; padding: 6px 2px; min-height: 60px; font-size: 1.02rem; }
.composer textarea:focus { box-shadow: none; }
.composer .row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.composer .tools { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.char-count { font-size: 0.78rem; color: var(--text-dim); }

/* Post */
.post { display: flex; gap: 13px; }
.post .body { min-width: 0; flex: 1; }
.post .head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.post .head .name { font-weight: 700; }
.post .head .handle, .post .head .time { color: var(--text-muted); font-size: 0.85rem; }
.post .text { margin: 5px 0 10px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.post .media { border-radius: 14px; border: 1px solid var(--border); overflow: hidden; margin: 6px 0 10px; }
.post .media img { display: block; width: 100%; }
.actions { display: flex; gap: 22px; color: var(--text-muted); font-size: 0.86rem; }
.actions button { background: none; border: none; color: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 4px; border-radius: 8px; transition: 0.15s; }
.actions button:hover { color: var(--text); }
.actions button.liked { color: var(--accent-2); }
.actions button.del:hover { color: var(--danger); }

.comments { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 11px; }
.comment { display: flex; gap: 10px; }
.comment .c-body { background: rgba(0,0,0,0.22); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; flex: 1; min-width: 0; }
.comment .c-body .chead { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.comment .c-body .chead b { color: var(--text); }
.comment-form { display: flex; gap: 8px; margin-top: 4px; }
.comment-form input { border-radius: 999px; }

/* Grids */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.person { display: flex; align-items: center; gap: 12px; }
.person .meta { min-width: 0; flex: 1; }
.person .meta b { display: flex; align-items: center; gap: 6px; }
.person .meta span { font-size: 0.8rem; color: var(--text-muted); }

.market-card .media { height: 150px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 12px; background: rgba(0,0,0,0.25); }
.market-card .media img { width: 100%; height: 100%; object-fit: cover; }
.market-card .price { color: var(--accent-2); font-weight: 700; }

.cal-day { }
.cal-day h4 { font-size: 0.9rem; margin-bottom: 8px; color: var(--text-muted); }
.event { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; background: rgba(0,0,0,0.18); }
.event .time { font-weight: 700; color: var(--accent-2); min-width: 46px; }

.empty { text-align: center; color: var(--text-dim); padding: 48px 20px; }
.empty .big { font-size: 2.4rem; margin-bottom: 10px; opacity: 0.7; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { padding: 8px 16px; border-radius: 999px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: 0.86rem; }
.tab.active { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }

/* Profile header */
.profile-head .banner { height: 130px; border-radius: 14px; background: linear-gradient(135deg, rgba(139,92,246,0.35), rgba(99,102,241,0.25)); border: 1px solid var(--border); overflow: hidden; }
.profile-head .banner img { width: 100%; height: 100%; object-fit: cover; }
.profile-head .ptop { display: flex; align-items: flex-end; gap: 16px; margin-top: -42px; padding: 0 6px; }
.profile-head .ptop .avatar { border: 4px solid var(--surface-solid); }
.profile-head .pmeta { flex: 1; padding-bottom: 4px; }
.profile-head .pmeta h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 8px; }
.stat-row { display: flex; gap: 22px; margin: 12px 4px; }
.stat-row .s b { font-size: 1.05rem; }
.stat-row .s span { color: var(--text-muted); font-size: 0.82rem; margin-left: 5px; }

/* Modal + toast */
#modal-layer { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; z-index: 60; background: rgba(0,0,0,0.6); }
#modal-layer.show { display: flex; }
.modal { width: 100%; max-width: 480px; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 20px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,0.5); }
.modal h3 { font-size: 1.15rem; margin-bottom: 16px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

#toast-layer { position: fixed; top: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface-solid); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); padding: 12px 18px; border-radius: 12px; font-size: 0.88rem; box-shadow: 0 12px 40px rgba(0,0,0,0.4); animation: slidein 0.2s ease; max-width: 320px; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.legal { line-height: 1.7; color: var(--text-muted); }
.legal h3 { color: var(--text); margin: 18px 0 8px; font-size: 1rem; }
.legal p { margin-bottom: 10px; }

/* Mobile */
#mobile-nav { display: none; }
@media (max-width: 860px) {
  #shell { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #main { padding: 0 14px 90px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  #mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); backdrop-filter: var(--blur); border-top: 1px solid var(--border); padding: 8px; justify-content: space-around; }
  #mobile-nav button { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; padding: 8px 12px; border-radius: 10px; }
  #mobile-nav button.active { color: var(--accent-2); background: var(--accent-soft); }
}
