:root {
  --paper: #fbfaf4;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #667481;
  --line: #dce3e5;
  --teal: #14736f;
  --teal-dark: #0c4d4b;
  --coral: #e86452;
  --gold: #f4bd4a;
  --blue: #365a7f;
  --green-soft: #eaf6f2;
  --gold-soft: #fff4d4;
  --coral-soft: #fff0ed;
  --shadow: 0 16px 36px rgba(23, 33, 43, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--teal);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfc;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

.app-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

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

.topbar-actions,
.account-block,
.compose-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-block {
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 800;
}

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

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  font-size: 20px;
  line-height: 1.3;
}

p {
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

.auth-grid,
.forum-layout,
.studio-layout,
.people-grid,
.admin-layout {
  display: grid;
  gap: 16px;
}

.auth-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  align-items: start;
}

.auth-panel,
.consent-panel,
.channel-rail,
.composer-strip,
.compose-panel,
.thread-card,
.leadership-panel,
.writing-surface,
.notification-panel,
.member-directory,
.ownership-panel,
.invite-panel,
.deployment-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel,
.consent-panel,
.leadership-panel,
.writing-surface,
.notification-panel,
.member-directory,
.ownership-panel,
.invite-panel,
.deployment-panel {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

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

.compact-stack {
  margin-top: 14px;
}

.signin-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.signin-divider::before,
.signin-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.form-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.form-note.error {
  color: var(--coral);
}

.consent-row,
.toggle-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  gap: 10px;
  font-weight: 700;
}

.consent-row input,
.toggle-row input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.policy-list {
  display: grid;
  gap: 10px;
}

.policy-list p {
  margin: 0;
  border-left: 4px solid var(--gold);
  padding: 10px 0 10px 12px;
  color: #394755;
  background: #fffaf0;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ef;
  padding: 4px;
  margin-bottom: 16px;
}

.tab {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.tab:hover,
.tab.active {
  background: var(--teal);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.forum-layout {
  grid-template-columns: 190px minmax(0, 1fr) 260px;
  align-items: start;
}

.channel-rail {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.channel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0 10px;
}

.channel:hover,
.channel.active {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.channel strong {
  min-width: 28px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  padding: 3px 7px;
}

.thread-column {
  display: grid;
  gap: 14px;
}

.composer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-top: 5px solid var(--gold);
}

.compose-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ghost-button,
.text-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.ghost-button:hover,
.text-button:hover {
  background: #f3f6f4;
  color: var(--ink);
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
}

.icon-button {
  position: relative;
  width: 42px;
  min-width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--teal);
}

.icon-button:hover {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.notification-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  border-radius: 999px;
  background: var(--coral);
  color: white;
  font-size: 12px;
  line-height: 20px;
}

.thread-list {
  display: grid;
  gap: 14px;
}

.thread-card {
  overflow: hidden;
}

.thread-main {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.thread-meta,
.comment-meta,
.member-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.owner-chip,
.channel-chip,
.media-chip,
.sample-chip,
.local-chip {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
}

.owner-chip {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.channel-chip {
  background: #edf3f8;
  color: var(--blue);
}

.media-chip {
  background: var(--gold-soft);
  color: #805c00;
}

.sample-chip {
  background: #edf3f8;
  color: var(--blue);
}

.local-chip {
  background: var(--coral-soft);
  color: #9c382c;
}

.thread-body {
  margin: 0;
  color: #354453;
}

.thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.action-button:hover {
  background: var(--green-soft);
  color: var(--teal-dark);
}

.comment-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: #f8faf8;
  padding: 14px 18px 18px;
}

.comment {
  display: grid;
  gap: 5px;
  border-left: 3px solid var(--teal);
  padding-left: 10px;
}

.comment p {
  margin: 0;
  color: #394755;
}

.comment-form {
  display: grid;
  gap: 8px;
}

.starter-row,
.prompt-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.starter,
.prompt-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  background: white;
  color: var(--blue);
  padding: 0 10px;
}

.starter:hover,
.prompt-chip:hover {
  background: #edf3f8;
  color: var(--blue);
}

.side-section + .side-section {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.host-list,
.notification-feed,
.member-list,
.deployment-list,
.ownership-table {
  display: grid;
  gap: 10px;
}

.host-list div,
.member-list div,
.deployment-list div,
.ownership-table div,
.notification-feed div {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfc;
  padding: 12px;
}

.host-list span,
.member-list span,
.deployment-list span,
.ownership-table span,
.notification-feed span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.signal-grid div {
  display: grid;
  gap: 3px;
  border-radius: 8px;
  background: var(--coral-soft);
  padding: 10px;
}

.signal-grid strong {
  font-size: 24px;
}

.signal-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.norm-list {
  margin: 0;
  padding-left: 18px;
  color: #394755;
}

.norm-list li + li {
  margin-top: 7px;
}

.studio-layout,
.people-grid,
.admin-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  align-items: start;
}

.invite-output {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--gold-soft);
  padding: 14px;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .auth-grid,
  .forum-layout,
  .studio-layout,
  .people-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .channel-rail {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leadership-panel {
    order: 3;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1220px);
    padding-top: 14px;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .mode-tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    padding: 0 8px;
  }

  .channel-rail,
  .form-row,
  .signal-grid {
    grid-template-columns: 1fr;
  }

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