:root {
  color-scheme: dark;
  --bg: #100b1d;
  --shell: #171028;
  --panel: #201633;
  --panel-soft: #2a1d42;
  --text: #fbf9ff;
  --muted: #b7a9cd;
  --line: rgba(255, 255, 255, .10);
  --primary: #8b5cf6;
  --primary-strong: #7c3aed;
  --primary-soft: rgba(139, 92, 246, .18);
  --green: #35d399;
  --yellow: #f8c76b;
  --danger: #ff6b8a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3fb;
  --shell: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f0e9fb;
  --text: #231833;
  --muted: #756987;
  --line: rgba(80, 54, 115, .16);
  --primary: #7c3aed;
  --primary-strong: #6721c5;
  --primary-soft: rgba(124, 58, 237, .13);
  --green: #169b70;
  --yellow: #8a5b08;
  --danger: #ca3157;
  --shadow: 0 18px 50px rgba(72, 45, 111, .14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, .22), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 18px 14px;
  background:
    radial-gradient(circle at 20% 0%, rgba(168, 85, 247, .28), transparent 34%),
    linear-gradient(180deg, #201139, #151020);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  padding: 4px 4px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .10);
}

.brand strong,
.mobile-brand strong {
  display: block;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, .66);
  font-size: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6, #35d399);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.side-nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .76);
  padding: 0 12px;
  font-weight: 700;
  text-align: left;
}

.side-nav .nav-link.is-active {
  color: #fff;
  background: rgba(139, 92, 246, .24);
  box-shadow: inset 3px 0 0 #a855f7;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}

.sidebar-note strong,
.sidebar-note span {
  display: block;
}

.sidebar-note span {
  margin-top: 4px;
  color: rgba(255, 255, 255, .70);
  font-size: 12px;
  line-height: 1.35;
}

.main-area {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--shell) 92%, transparent);
  backdrop-filter: blur(18px);
}

.mobile-brand {
  display: none;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(430px, 42vw);
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
}

.search-box span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.theme-toggle button {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

[data-theme="dark"] .theme-toggle [data-theme="dark"],
[data-theme="light"] .theme-toggle [data-theme="light"] {
  color: #fff;
  background: var(--primary);
}

.ghost-action,
.secondary-action,
.primary-action {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-action {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.ghost-action {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 18px 92px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.page-title h1,
.profile-info h1 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.1;
}

.page-title h1 {
  font-size: clamp(24px, 3vw, 34px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.profile-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.panel,
.composer,
.post-card,
.church-card,
.event-card,
.profile-card,
.chat-window,
.chat-contacts {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.panel h2,
.church-card h2,
.event-card h2 {
  margin: 0 0 10px;
  font-size: 17px;
  letter-spacing: 0;
}

.composer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.composer-fields {
  flex: 1 1 auto;
  min-width: 0;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
}

textarea {
  display: block;
  padding: 12px;
  resize: vertical;
}

input,
select {
  min-height: 40px;
  padding: 0 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.composer-actions {
  display: grid;
  grid-template-columns: 170px 170px auto;
  gap: 8px;
  margin-top: 9px;
}

.stack,
.mini-list {
  display: grid;
  gap: 10px;
}

.post-card,
.church-card,
.event-card {
  overflow: hidden;
}

.post-head {
  display: flex;
  gap: 10px;
  padding: 12px 12px 6px;
}

.post-author {
  min-width: 0;
}

.post-author strong,
.post-author span {
  display: block;
}

.post-author span,
.handle,
.muted {
  color: var(--muted);
}

.post-author span {
  font-size: 12px;
}

.post-body {
  padding: 6px 12px 10px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.post-tag,
.status-badge,
.reserved-list span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.post-tag,
.status-badge {
  padding: 5px 8px;
}

.tag-prayer {
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 13%, transparent);
}

.tag-testimony,
.status-approved {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 13%, transparent);
}

.tag-post,
.status-pending {
  color: var(--primary);
  background: var(--primary-soft);
}

.post-special {
  margin: 0 12px 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--primary-soft);
  line-height: 1.4;
}

.post-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
}

.post-actions button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.comment-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.comment-form input {
  min-width: 0;
}

.comments {
  display: grid;
  gap: 6px;
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 13px;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.quick-stats .stat-box,
.admin-stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.quick-stats strong,
.admin-stat strong {
  display: block;
  font-size: 22px;
}

.quick-stats span,
.admin-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.profile-card {
  overflow: hidden;
}

.profile-cover {
  position: relative;
  min-height: 190px;
  background:
    radial-gradient(circle at 84% 18%, rgba(255, 255, 255, .28), transparent 20%),
    linear-gradient(135deg, rgba(139, 92, 246, .96), rgba(43, 20, 82, .96) 62%, rgba(53, 211, 153, .52));
}

.cover-action {
  position: absolute;
  right: 14px;
  bottom: 14px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, .20);
  border-radius: 8px;
  background: rgba(22, 13, 38, .50);
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  padding: 0 18px;
  min-height: 54px;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
}

.profile-info {
  padding: 12px 18px 18px;
}

.profile-info h1 {
  font-size: 30px;
}

.profile-info p {
  max-width: 760px;
  line-height: 1.45;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.stat-row div {
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: center;
}

.stat-row strong {
  display: block;
  font-size: 20px;
}

.stat-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 35% 24%, rgba(255, 255, 255, .30), transparent 22%),
    linear-gradient(135deg, #8b5cf6, #35d399);
  font-weight: 900;
}

.avatar-sm {
  width: 40px;
  height: 40px;
}

.avatar-lg {
  width: 104px;
  height: 104px;
  margin-top: -52px;
  border: 5px solid var(--panel);
  font-size: 32px;
}

.clean-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.church-card,
.event-card {
  padding: 14px;
}

.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  min-height: 560px;
}

.chat-contacts {
  padding: 10px;
}

.contact-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px;
  text-align: left;
}

.contact-button.is-active {
  background: var(--primary-soft);
}

.online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

.offline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.chat-window {
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-heading {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.messages {
  display: grid;
  align-content: end;
  gap: 8px;
  min-height: 360px;
  padding: 14px;
}

.message {
  max-width: 72%;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--panel-soft);
  line-height: 1.35;
}

.message.mine {
  justify-self: end;
  color: #fff;
  background: var(--primary);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.reserved-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.reserved-list span {
  padding: 6px 9px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.mini-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mini-item strong {
  display: block;
}

.mini-item span {
  color: var(--muted);
  line-height: 1.35;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  transform: translateX(-50%) translateY(12px);
  max-width: min(520px, calc(100vw - 28px));
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--shell);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-brand {
    display: flex;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .top-actions {
    justify-content: space-between;
  }

  .grid-two,
  .profile-layout,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .right-column {
    order: -1;
  }

  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--shell) 96%, transparent);
    backdrop-filter: blur(18px);
  }

  .bottom-nav .nav-link {
    min-height: 58px;
    border-radius: 0;
    color: var(--muted);
    padding: 0 4px;
    text-align: center;
    font-size: 12px;
  }

  .bottom-nav .nav-link.is-active {
    color: var(--primary);
    background: var(--primary-soft);
  }
}

@media (max-width: 640px) {
  .content {
    padding: 14px 12px 86px;
  }

  .page-title {
    align-items: stretch;
    flex-direction: column;
  }

  .composer {
    flex-direction: column;
  }

  .composer-actions,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .profile-cover {
    min-height: 150px;
  }

  .profile-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-actions {
    width: 100%;
  }

  .profile-actions button,
  .card-actions button {
    flex: 1 1 auto;
  }

  .profile-info h1 {
    font-size: 26px;
  }

  .stat-row,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .post-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .comment-form {
    flex-direction: column;
  }

  .message {
    max-width: 88%;
  }
}
