:root {
  --paper: #f3ecdf;
  --paper-strong: #e9dcc5;
  --ink: #15283f;
  --ink-soft: rgba(21, 40, 63, 0.7);
  --panel: rgba(255, 250, 241, 0.76);
  --line: rgba(21, 40, 63, 0.12);
  --accent: #c45f34;
  --accent-deep: #8b3414;
  --teal: #0d736d;
  --teal-soft: rgba(13, 115, 109, 0.12);
  --shadow: 0 28px 80px rgba(21, 40, 63, 0.12);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(196, 95, 52, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(13, 115, 109, 0.16), transparent 34%),
    linear-gradient(180deg, #f6f0e5 0%, #ecdfc8 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

.page-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(21, 40, 63, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 40, 63, 0.02) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.84), transparent);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(18px, 4vw, 44px) 8px;
}

.brand-mark {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
}

.brand-mark__eyebrow,
.eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.brand-mark__title,
h1,
h2 {
  margin: 0;
  font-family: "Baskerville", "Iowan Old Style", serif;
  letter-spacing: -0.04em;
  font-weight: 600;
}

.brand-mark__title {
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user,
.presence-chip,
.status-pill,
.member-pill,
.copy-button,
.archive-item span {
  font-family: Menlo, Consolas, monospace;
}

.header-user {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
}

.flash-stack {
  padding: 0 clamp(18px, 4vw, 44px);
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.flash--error {
  border-color: rgba(196, 95, 52, 0.32);
}

.flash--success {
  border-color: rgba(13, 115, 109, 0.28);
}

.auth-shell,
.ops-shell {
  padding: 18px clamp(18px, 4vw, 44px) 40px;
  display: grid;
  gap: 24px;
}

.auth-shell {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 440px);
}

.ops-shell {
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  align-items: start;
}

.auth-hero,
.auth-card,
.rail-card,
.chat-stage {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.auth-hero,
.rail-card--hero {
  padding: clamp(20px, 3vw, 28px);
}

.auth-card,
.rail-card,
.chat-stage {
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.auth-card::before,
.rail-card::before,
.chat-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(196, 95, 52, 0.12), transparent 30%),
    radial-gradient(circle at bottom left, rgba(13, 115, 109, 0.12), transparent 30%);
  pointer-events: none;
}

h1 {
  margin-top: 10px;
  font-size: clamp(2.1rem, 3vw, 3.2rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.9rem, 2.8vw, 2.5rem);
}

.lede,
.panel-copy,
.composer-note,
.composer__hint {
  color: var(--ink-soft);
  line-height: 1.7;
}

.hero-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink-soft);
  font-family: Menlo, Consolas, monospace;
  font-size: 0.76rem;
}

.hero-title {
  margin-top: 10px;
  line-height: 1.02;
}

.hero-title--auth {
  max-width: 12ch;
}

.hero-title--room {
  font-size: clamp(1.6rem, 2.1vw, 2.2rem);
}

.hero-summary {
  margin: 12px 0 0;
  max-width: 36rem;
}

.hero-bullets {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-bullets li {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  font-family: Menlo, Consolas, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.hero-footnote {
  margin: 14px 0 0;
  color: var(--ink-soft);
}

.hero-metrics {
  margin-top: 18px;
}

.auth-notes {
  margin-top: 18px;
}

.auth-notes div,
.managed-users,
.participant-card,
.archive-item,
.metrics article,
.status-pill,
.timeline,
.composer {
  border: 1px solid var(--line);
}

.auth-notes div {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.42);
}

.auth-notes span,
.section-head,
.managed-users p {
  font-family: Menlo, Consolas, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

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

.auth-form input,
.composer textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(21, 40, 63, 0.14);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.auth-form input:focus,
.composer textarea:focus {
  border-color: rgba(13, 115, 109, 0.42);
  box-shadow: 0 0 0 4px rgba(13, 115, 109, 0.12);
  transform: translateY(-1px);
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled,
.button--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button--primary {
  color: #fff5ee;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 16px 36px rgba(139, 52, 20, 0.24);
}

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

.button--small {
  padding: 9px 14px;
  font-size: 0.9rem;
}

.button--active {
  border-color: rgba(13, 115, 109, 0.4);
  background: rgba(13, 115, 109, 0.12);
}

.managed-users {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.52);
}

.managed-users__list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.managed-users__list article {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(21, 40, 63, 0.05);
}

.managed-users__list span {
  color: var(--ink-soft);
}

.ops-rail {
  display: grid;
  gap: 18px;
}

.metrics {
  display: grid;
  gap: 12px;
}

.metrics--stacked {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.metrics article {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.56);
  display: grid;
  gap: 4px;
}

.metrics strong {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.participant-list,
.archive-list {
  display: grid;
  gap: 10px;
}

.participant-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.54);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.participant-card strong {
  display: block;
  font-size: 1rem;
}

.participant-card span,
.participant-card small {
  color: var(--ink-soft);
}

.participant-card--bot {
  background: rgba(196, 95, 52, 0.08);
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.archive-item,
.archive-empty {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.archive-item a {
  color: var(--accent-deep);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.archive-empty {
  color: var(--ink-soft);
}

.chat-stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 16px;
  min-height: 82vh;
}

.stage-head,
.stage-presence,
.composer-ribbon,
.composer__actions,
.message-head,
.message-meta,
.message-author {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-head {
  justify-content: space-between;
}

.stage-presence {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.presence-chip--bot {
  background: rgba(196, 95, 52, 0.12);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.presence-dot,
.voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.presence-dot {
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(13, 115, 109, 0.12);
}

.voice-dot {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(196, 95, 52, 0.12);
}

.timeline {
  min-height: 0;
  max-height: calc(82vh - 240px);
  overflow: auto;
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 248, 238, 0.62));
  display: grid;
  gap: 12px;
}

.message-card {
  width: min(82%, 880px);
  padding: 16px 18px;
  border-radius: 24px 24px 24px 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(21, 40, 63, 0.08);
  box-shadow: 0 12px 28px rgba(21, 40, 63, 0.08);
  animation: rise 180ms ease;
}

.message-card--self {
  margin-left: auto;
  border-radius: 24px 24px 8px 24px;
  background: rgba(13, 115, 109, 0.08);
}

.message-card--assistant {
  background: rgba(196, 95, 52, 0.08);
}

.message-card--system {
  width: 100%;
  border-style: dashed;
  background: rgba(21, 40, 63, 0.05);
}

.message-head {
  justify-content: space-between;
}

.message-author {
  align-items: baseline;
}

.message-author span,
.message-meta time {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.message-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.copy-button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 0.76rem;
}

.message-body {
  margin-top: 12px;
  line-height: 1.72;
  word-break: break-word;
}

.message-body > :first-child {
  margin-top: 0;
}

.message-body > :last-child {
  margin-bottom: 0;
}

.message-body pre {
  overflow: auto;
  padding: 14px;
  border-radius: 16px;
  background: rgba(21, 40, 63, 0.08);
}

.message-body code {
  font-family: Menlo, Consolas, monospace;
  background: rgba(21, 40, 63, 0.08);
  padding: 0.14em 0.36em;
  border-radius: 0.42em;
}

.message-body pre code {
  padding: 0;
  background: transparent;
}

.message-body blockquote {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border-left: 3px solid rgba(13, 115, 109, 0.36);
  background: rgba(13, 115, 109, 0.08);
}

.message-body table {
  width: 100%;
  border-collapse: collapse;
}

.message-body th,
.message-body td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

.composer {
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
}

.composer-ribbon,
.composer__actions {
  justify-content: space-between;
  flex-wrap: wrap;
}

.composer textarea {
  min-height: 140px;
  margin: 14px 0;
  resize: vertical;
}

.status-busy {
  color: var(--accent-deep);
}

code {
  font-family: Menlo, Consolas, monospace;
  background: rgba(21, 40, 63, 0.08);
  padding: 0.1em 0.34em;
  border-radius: 0.42em;
}

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

@media (max-width: 1080px) {
  .auth-shell,
  .ops-shell {
    grid-template-columns: 1fr;
  }

  .auth-card {
    order: 1;
  }

  .auth-hero {
    order: 2;
  }

  .chat-stage {
    order: 1;
  }

  .ops-rail {
    order: 2;
  }

  .auth-notes,
  .metrics--stacked {
    grid-template-columns: 1fr;
  }

  .timeline {
    max-height: 58vh;
  }

  .message-card,
  .message-card--system {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .site-header,
  .stage-head,
  .message-head,
  .composer-ribbon,
  .composer__actions,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header,
  .auth-shell,
  .ops-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .header-actions,
  .stage-presence,
  .status-strip {
    width: 100%;
    justify-content: flex-start;
  }

  .auth-hero,
  .auth-card,
  .rail-card,
  .chat-stage {
    padding: 18px;
  }

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

  .brand-mark__title {
    font-size: 1.28rem;
  }

  h1 {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
  }

  h2 {
    font-size: clamp(1.4rem, 6vw, 1.8rem);
  }

  .hero-bullets li {
    width: 100%;
  }

  .timeline {
    max-height: none;
    min-height: 46vh;
    padding: 12px;
  }

  .message-meta,
  .stage-presence {
    justify-content: flex-start;
  }

  .composer textarea {
    min-height: 120px;
  }

  .button,
  .button--small,
  .copy-button {
    width: 100%;
    justify-content: center;
  }

  .participant-card,
  .managed-users__list article {
    align-items: flex-start;
    flex-direction: column;
  }
}
