:root {
  color-scheme: dark;
  --bg: #070910;
  --panel: #111722;
  --panel-2: #151d2b;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f6f8fb;
  --muted: #9ba6b8;
  --green: #25d366;
  --cyan: #51c4ff;
  --red: #ff5d6c;
  --amber: #f6bd60;
  --glass: rgba(17, 23, 34, 0.78);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 18rem),
    radial-gradient(circle at top left, rgba(37, 211, 102, 0.16), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(81, 196, 255, 0.12), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }

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

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 0 18px;
  backdrop-filter: blur(18px);
}

.brand {
  font-weight: 800;
  letter-spacing: 0;
  color: #ffffff;
  text-shadow: 0 0 22px rgba(37, 211, 102, 0.28);
}

.nav-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-actions a, button, .primary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
  min-height: 42px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.primary, button.primary {
  background: linear-gradient(135deg, #30e58a, #22c7a0);
  color: #04110a;
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 14px 36px rgba(37, 211, 102, 0.2);
}

.danger {
  background: rgba(255, 93, 108, 0.16);
  border-color: rgba(255, 93, 108, 0.32);
  color: #ffd8dc;
}

.ghost {
  background: transparent;
}

.wide { display: block; width: 100%; text-align: center; }

.flash {
  background: rgba(246, 189, 96, 0.14);
  border: 1px solid rgba(246, 189, 96, 0.32);
  color: #ffe7ba;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.auth-grid, .dashboard, .chat-layout, .admin-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 18px;
  align-items: start;
}

.admin-dashboard {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.admin-menu-toggle {
  display: none;
}

.admin-menu-overlay,
.admin-menu-close {
  display: none;
}

.admin-nav {
  position: sticky;
  top: 64px;
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 34, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.28);
}

.admin-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font-weight: 800;
  min-height: 42px;
  text-align: center;
  white-space: nowrap;
}

.admin-nav a:hover {
  border-color: rgba(37, 211, 102, 0.42);
  color: #c9ffdb;
}

.admin-nav a.active {
  background: var(--green);
  border-color: transparent;
  color: #04110a;
}

.admin-category {
  scroll-margin-top: 132px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.category-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.category-head h2 {
  margin-bottom: 0;
}

.hero-copy {
  padding: clamp(22px, 6vw, 76px) 0;
}

.eyebrow {
  color: var(--green);
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(2.25rem, 5vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
  margin-bottom: 18px;
}

h2 { font-size: clamp(1.45rem, 3vw, 2.35rem); }

.hero-copy p, .muted, .privacy-note {
  color: var(--muted);
  line-height: 1.6;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035)),
    var(--glass);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 3vw, 24px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
  min-width: 0;
}

.narrow {
  max-width: 680px;
  margin: 0 auto;
}

.form {
  display: grid;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.text-link { color: var(--cyan); }

.dashboard {
  grid-template-columns: 300px 1fr;
}

.profile-strip {
  position: sticky;
  top: 74px;
  background:
    linear-gradient(180deg, rgba(37, 211, 102, 0.1), transparent),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.stats-grid, .compose-grid, .content-grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}

.stats-grid div {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stats-grid strong {
  display: block;
  font-size: 1.8rem;
}

.stats-grid span, small {
  color: var(--muted);
}

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

.span { grid-column: 1 / -1; }

.admin-grid,
.span,
.feed {
  min-width: 0;
}

.post {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 10px 0;
  line-height: 1.55;
}

.post small {
  display: block;
  margin-top: 8px;
}

.poll {
  display: grid;
  gap: 10px;
  margin: 0 0 20px;
}

.poll-option {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr 42px;
  gap: 8px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.poll-option em {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(37, 211, 102, 0.11);
  z-index: -1;
}

.chat-layout {
  grid-template-columns: 320px 1fr;
}

.chat-side {
  display: grid;
  gap: 12px;
}

.phone-chat {
  height: min(760px, calc(100vh - 120px));
  min-height: 560px;
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  background:
    linear-gradient(rgba(6, 12, 18, 0.88), rgba(6, 12, 18, 0.88)),
    radial-gradient(circle at 20% 20%, rgba(37, 211, 102, 0.24), transparent 20rem);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.phone-chat header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #111b21;
  border-bottom: 1px solid var(--line);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chat-header-actions button,
.report-icon-btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.86rem;
}

.report-icon-btn {
  color: #ffd8dc;
  border-color: rgba(255, 93, 108, 0.28);
  background: rgba(255, 93, 108, 0.12);
}

.phone-chat header small {
  display: block;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
}

.icebreaker {
  display: block;
  margin: 12px auto;
  max-width: 86%;
  text-align: center;
  color: #d6ffe5;
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.22);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 0;
  line-height: 1.35;
}

.icebreaker:hover {
  background: rgba(37, 211, 102, 0.19);
  transform: translateY(-1px);
}

.report-popover {
  position: absolute;
  top: 72px;
  right: 12px;
  z-index: 5;
  width: min(280px, calc(100% - 24px));
  display: none;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(255, 93, 108, 0.28);
  border-radius: 8px;
  background: rgba(13, 18, 27, 0.98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.report-popover.open {
  display: grid;
}

.messages {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  width: fit-content;
  max-width: min(78%, 560px);
  background: #202c33;
  border-radius: 8px;
  padding: 9px 11px;
  animation: rise 160ms ease-out;
}

.bubble.mine {
  align-self: flex-end;
  background: #005c4b;
}

.bubble small {
  display: block;
  text-align: right;
  font-size: 0.72rem;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #111b21;
}

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

.compact-actions {
  margin-top: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.04);
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table form {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.status-pill.active {
  background: rgba(37, 211, 102, 0.14);
  color: #bcffd4;
}

.status-pill.offline {
  background: rgba(155, 166, 184, 0.12);
  color: #d4d9e2;
}

.status-pill.banned {
  background: rgba(255, 93, 108, 0.14);
  color: #ffd8dc;
}

.poll-admin-card {
  display: grid;
  gap: 12px;
}

.poll-admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.poll-admin-head small {
  display: block;
  margin-top: 6px;
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.045);
}

.option-list small {
  margin-left: 4px;
}

.content-manage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.content-manage-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-manage-grid section {
  min-width: 0;
}

.manage-post {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 14px, 680px);
    padding-top: 8px;
  }

  .topbar {
    align-items: flex-start;
    padding-bottom: 12px;
    gap: 10px;
  }

  .brand {
    min-height: 42px;
    display: flex;
    align-items: center;
  }

  .nav-actions a {
    min-height: 38px;
    padding: 8px 10px;
  }

  .auth-grid, .dashboard, .chat-layout, .admin-grid, .compose-grid, .content-grid {
    grid-template-columns: 1fr;
  }

  .admin-menu-toggle {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 4px;
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(17, 23, 34, 0.92);
    color: var(--text);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.22);
  }

  .admin-menu-toggle span {
    grid-column: 1;
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
  }

  .admin-menu-toggle strong {
    grid-column: 2;
    grid-row: 1 / 4;
    justify-self: start;
  }

  .admin-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: grid;
    align-content: start;
    grid-template-columns: 1fr;
    width: min(82vw, 310px);
    height: 100vh;
    gap: 10px;
    padding: 18px;
    border-width: 0 1px 0 0;
    border-radius: 0;
    background: rgba(11, 16, 25, 0.98);
    box-shadow: 22px 0 70px rgba(0, 0, 0, 0.42);
    transform: translateX(-105%);
    transition: transform 180ms ease-out;
    overflow-y: auto;
  }

  .admin-nav.open {
    transform: translateX(0);
  }

  .admin-nav a {
    min-height: 46px;
    justify-content: flex-start;
    padding: 11px 12px;
    font-size: 0.95rem;
    white-space: normal;
  }

  .admin-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgba(0, 0, 0, 0.52);
  }

  .admin-menu-overlay.open {
    display: block;
  }

  .admin-menu-close {
    display: block;
    width: 100%;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.08);
    text-align: left;
  }

  .admin-category {
    scroll-margin-top: 170px;
  }

  .category-head {
    display: grid;
    gap: 0;
  }

  .admin-dashboard {
    gap: 14px;
  }

  .panel {
    padding: 14px;
  }

  .hero-copy {
    padding: 24px 0 4px;
  }

  .profile-strip {
    position: static;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .phone-chat {
    height: calc(100vh - 176px);
    min-height: 520px;
  }

  .chat-header-actions {
    gap: 6px;
  }

  .chat-header-actions button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  .report-popover {
    top: 76px;
    right: 8px;
    width: min(270px, calc(100% - 16px));
  }

  .composer {
    grid-template-columns: 1fr 76px;
  }

  .poll-admin-head {
    display: grid;
  }

  .content-manage-grid,
  .content-manage-grid.two-col {
    grid-template-columns: 1fr;
  }

  .manage-post {
    grid-template-columns: 1fr;
  }

  .compact-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: min(100% - 12px, 420px);
  }

  .topbar {
    align-items: center;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions a {
    padding: 8px 9px;
    font-size: 0.9rem;
  }

  h1 {
    font-size: 2.25rem;
  }

  h2 {
    font-size: 1.55rem;
  }

  .profile-strip,
  .panel {
    border-color: rgba(255, 255, 255, 0.12);
  }

  .post {
    padding: 12px;
  }
}
