:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0d1828;
  --surface-2: #132234;
  --line: #24344a;
  --text: #f5f8fc;
  --muted: #9fb0c5;
  --blue: #1d74ff;
  --green: #12b981;
  --gold: #f4b400;
  --danger: #ef4444;
  --radius: 8px;
}

body.light {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --line: #d6e0ec;
  --text: #102033;
  --muted: #5f7084;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.app-ready .public-view,
body.app-ready .top-nav {
  display: none;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.brand, .header-actions, .top-nav, .landing-actions, .composer-tools, .post-actions, .group-toolbar, .modal-actions, .auth-tabs, .trust-row, .quick-row, .feed-tabs, .mini-actions, .preview-actions {
  display: flex;
  align-items: center;
}

.brand { gap: 10px; font-weight: 800; }
.brand img { width: 34px; height: 34px; }
.top-nav { gap: 6px; }
.top-nav a, .icon-text, .dixbase-link, .secondary, .login-method, .left-rail button, .post-actions button, .auth-tab, .feed-tabs button, .quick-row button, .mini-actions button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
}

.header-actions { gap: 8px; }
.dixbase-link { display: inline-flex; gap: 8px; font-weight: 700; }
.dixbase-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: white;
  font-weight: 900;
}

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 28px;
  align-items: end;
  min-height: calc(100vh - 64px);
  padding: 56px clamp(20px, 5vw, 72px) 36px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(29,116,255,.20), transparent 32%),
    linear-gradient(315deg, rgba(18,185,129,.16), transparent 30%),
    var(--bg);
}

.landing-copy { max-width: 760px; padding-bottom: 34px; }
.eyebrow {
  display: inline-block;
  color: var(--green);
  font-weight: 800;
  margin-bottom: 16px;
}
.landing h1 {
  margin: 0 0 18px;
  font-size: clamp(48px, 8vw, 92px);
  line-height: .92;
  letter-spacing: 0;
}
.landing p {
  max-width: 640px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.55;
}
.landing-actions { gap: 12px; margin-top: 28px; }
.landing-actions button,
.landing-actions a {
  min-height: 44px;
}
.secondary.strong {
  font-weight: 800;
  border-color: color-mix(in srgb, var(--green) 55%, var(--line));
}
.primary {
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: white;
  border-radius: var(--radius);
  padding: 11px 15px;
  font-weight: 800;
}
.small { padding: 8px 11px; }
.trust-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.trust-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.login-panel, .composer, .panel, .post, .profile-editor, .modal-card, .group-card, .safety-grid article, .message-layout, .landing-section article, .info-list, .notice-card, .thread-item, .profile-summary {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
}
.login-panel { padding: 18px; }
.login-panel h2 { margin: 0 0 8px; }
.login-panel p, .login-note, .warning, .mini { color: var(--muted); }
.auth-tabs {
  gap: 8px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
}
.auth-tab {
  flex: 1;
  border-color: transparent;
  background: transparent;
  font-weight: 800;
}
.auth-tab.active {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
}
.login-grid { display: grid; gap: 10px; margin: 16px 0; }
.login-method {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
}
.login-method:hover,
.auth-tab:hover,
.landing-actions .secondary:hover {
  border-color: color-mix(in srgb, var(--blue) 70%, var(--line));
}
.method-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 900;
}
.login-method small { display: block; color: var(--muted); margin-top: 3px; }
.method-status {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.method-status.ready {
  border-color: color-mix(in srgb, var(--green) 55%, var(--line));
  color: var(--green);
}
.method-status.missing {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  color: var(--danger);
}
.method-status.partial {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  color: var(--gold);
}
.wallet-help {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--green) 8%, var(--surface));
  color: var(--muted);
  line-height: 1.45;
}
.login-steps {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.login-steps div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}
.login-steps strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
}
.login-method.loading {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
}
.login-method[disabled] {
  cursor: wait;
  opacity: .72;
}
.landing-preview {
  margin-top: 28px;
  max-width: 560px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}
.landing-preview div:first-child {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.landing-preview span,
.preview-actions span {
  color: var(--muted);
}
.landing-preview p {
  margin: 12px 0;
  font-size: 16px;
}
.preview-actions {
  gap: 8px;
  flex-wrap: wrap;
}
.preview-actions span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 13px;
}
.compact-info article p { margin-bottom: 0; }
.install-hidden { display: none; }
.install-ready { display: inline-block; }

.landing-section {
  max-width: 1180px;
  margin: 0 auto;
  padding: 54px clamp(20px, 5vw, 72px);
}
.section-head {
  max-width: 760px;
  margin-bottom: 22px;
}
.section-head span,
.section-kicker {
  color: var(--green);
  font-weight: 800;
}
.landing-section h2 {
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.05;
}
.landing-section p {
  color: var(--muted);
  line-height: 1.55;
}
.info-grid,
.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.feature-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.landing-section article,
.info-list {
  padding: 18px;
}
.landing-section article strong,
.info-list strong {
  color: var(--text);
}
.split-section {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(320px, 1fr);
  gap: 28px;
  align-items: center;
}
.info-list {
  display: grid;
  gap: 8px;
}
.info-list p {
  margin: 0;
}

.app-shell {
  display: none;
  grid-template-columns: 210px minmax(0, 760px) 310px;
  gap: 18px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px;
}
body.app-ready .app-shell {
  display: grid;
  min-height: calc(100vh - 64px);
}
.left-rail, .right-rail {
  position: sticky;
  top: 76px;
  height: calc(100vh - 92px);
}
.left-rail { display: grid; align-content: start; gap: 8px; }
.left-rail button { text-align: left; }
.left-rail .rail-active { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 18%, var(--surface)); }
.compose-button { background: linear-gradient(135deg, var(--blue), var(--green)) !important; color: white !important; font-weight: 800; }

.feed-column { min-width: 0; }
.feed-head {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 16px;
  margin-bottom: 14px;
}
.feed-head h2 { margin: 0 0 4px; }
.feed-head p { margin: 0; color: var(--muted); }
.connection-row {
  display: inline-flex;
  margin-top: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}
.connection-row.online {
  border-color: color-mix(in srgb, var(--green) 60%, var(--line));
  color: var(--green);
}
.connection-row.offline {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--line));
  color: var(--danger);
}
.searchbox { position: relative; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 11px 12px;
}
textarea { min-height: 110px; resize: vertical; }
.suggestions {
  position: absolute;
  inset: calc(100% + 6px) 0 auto;
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 8;
}
.suggestions.show { display: block; }
.suggestions button {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.composer { padding: 14px; margin-bottom: 12px; }
.composer-user, .post { display: flex; gap: 12px; }
.composer-user { align-items: center; margin-bottom: 12px; }
.composer-user strong,
.post-meta strong,
.profile-link {
  cursor: pointer;
}
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: white;
  font-weight: 900;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 92px; height: 92px; font-size: 32px; }
.composer-tools { gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.composer-tools span { margin-left: auto; color: var(--muted); }
.upload-control { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 11px; background: var(--surface-2); }
.media-preview img, .media-preview video { width: 100%; margin-top: 10px; border-radius: var(--radius); max-height: 360px; object-fit: cover; }
.quick-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.quick-row button {
  min-width: 40px;
  padding: 8px 10px;
  background: var(--surface-2);
}

.view { display: none; }
.view.active { display: block; }
.feed-tabs {
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.feed-tabs button {
  white-space: nowrap;
}
.feed-tabs button.active {
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
  border-color: var(--green);
}
.post { padding: 14px; margin-bottom: 10px; }
.post-body { min-width: 0; flex: 1; }
.post-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.post-meta strong { color: var(--text); }
.post p { line-height: 1.5; }
.post-actions { gap: 8px; flex-wrap: wrap; }
.post-actions button.active {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
}
.post-media {
  margin-top: 10px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.post-media img,
.post-media video {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}
.reply-box {
  display: none;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}
.reply-box.show { display: grid; }
.reply-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.reply {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.mention { color: var(--green); font-weight: 800; }

.group-toolbar { gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.group-card { padding: 14px; }
.group-card h3 { margin: 0 0 6px; }
.group-card p { color: var(--muted); }
.group-cover {
  height: 72px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 80%, #000), color-mix(in srgb, var(--green) 70%, #000));
}
.group-card .mini-actions {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-row span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; color: var(--muted); }

.profile-cover { height: 140px; background: linear-gradient(135deg, var(--blue), var(--green), var(--gold)); border-radius: var(--radius) var(--radius) 0 0; }
.profile-main { display: grid; grid-template-columns: 130px 1fr; gap: 18px; padding: 18px; }
.avatar-upload { text-align: center; display: grid; gap: 8px; justify-items: center; align-content: start; }
.profile-fields { display: grid; gap: 12px; }

.topic-list, .safety-grid, .notice-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.topic-list article, .safety-grid article, .notice-card { padding: 14px; }
.message-layout { display: grid; grid-template-columns: 210px 1fr; min-height: 300px; }
.thread-list { border-right: 1px solid var(--line); padding: 10px; display: grid; align-content: start; gap: 8px; }
.thread-item {
  width: 100%;
  padding: 10px;
  color: var(--text);
  text-align: left;
}
.thread-item.active {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 14%, var(--surface));
}
.message-pane { padding: 14px; }
.message-compose { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 16px; }
.chat-line {
  max-width: 78%;
  padding: 9px 11px;
  border-radius: var(--radius);
  margin: 8px 0;
  background: var(--surface-2);
}
.chat-line.mine {
  margin-left: auto;
  background: color-mix(in srgb, var(--green) 18%, var(--surface-2));
}

.right-rail { display: grid; align-content: start; gap: 12px; }
.panel { padding: 14px; }
.panel h3 { margin: 0 0 12px; }
.panel a { display: block; color: var(--green); padding: 7px 0; }
.people-list { display: grid; gap: 8px; }
.person-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
}
.person-row .avatar { width: 34px; height: 34px; }
.person-row small,
.notice-card p,
.thread-item small,
.profile-summary p {
  color: var(--muted);
}
.person-row button { padding: 7px 9px; }
.logo-demo { display: flex; gap: 10px; align-items: center; }
.logo-demo img { width: 52px; height: 52px; }
.logo-demo span { display: block; color: var(--muted); font-size: 13px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv span { color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.58);
  z-index: 50;
}
.modal.show { display: grid; }
.modal-card { width: min(760px, 100%); padding: 18px; }
.profile-pop { width: min(680px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-head button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: var(--radius); padding: 8px 10px; }
.group-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.modal-actions { justify-content: end; gap: 8px; margin-top: 14px; }
.admin-panel { margin-bottom: 12px; padding: 14px; }
.profile-summary { padding: 16px; }
.profile-banner {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue), var(--green), var(--gold));
  margin-bottom: -34px;
}
.profile-summary .avatar {
  width: 76px;
  height: 76px;
  border: 3px solid var(--surface);
  margin-bottom: 8px;
}
.metric-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.metric-row span {
  color: var(--muted);
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: none;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.toast.show { display: block; }
.toast.good { border-color: color-mix(in srgb, var(--green) 60%, var(--line)); }
.toast.bad { border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .right-rail { display: none; }
  .left-rail button { font-size: 0; text-align: center; }
  .left-rail button::first-letter { font-size: 16px; }
}

@media (max-width: 760px) {
  .site-header { align-items: stretch; flex-direction: column; }
  .header-actions { flex-wrap: wrap; }
  .top-nav { overflow-x: auto; }
  .landing { grid-template-columns: 1fr; min-height: auto; }
  .landing-actions { flex-wrap: wrap; }
  .landing-actions button,
  .landing-actions a { flex: 1 1 150px; text-align: center; }
  .info-grid, .feature-strip, .split-section { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; padding: 14px; }
  .left-rail { position: static; height: auto; display: flex; overflow-x: auto; }
  .left-rail button { font-size: 14px; white-space: nowrap; }
  .feed-head, .profile-main, .group-grid, .topic-list, .safety-grid, .message-layout, .group-form-grid, .notice-list { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .message-compose { grid-template-columns: 1fr; }
  .thread-list { border-right: 0; border-bottom: 1px solid var(--line); }
}
