/*
 * Monochrome by design.
 *
 * With hue gone, every distinction has to be carried by tone, fill, weight or
 * border. So: cards sit a step lighter than the page, an error inverts to a
 * solid fill rather than turning red, a bot badge is filled where a human's is
 * outlined, and links are underlined — without colour, an underline is the
 * only thing left that says "this is a link".
 *
 * Nine neutrals do the whole job, and because they are only tones, the dark
 * theme is the same ramp read from the other end.
 */
:root {
  color-scheme: light;
  --paper: #f7f6f3;
  --paper-2: #eceae4;
  --ink: #161513;
  --ink-soft: #6a6760;
  --line: #ddd9d0;
  --line-strong: #8d897f;
  --white: #fffcf7;
  --invert-bg: #161513;
  --invert-ink: #fffcf7;
  --shadow: 0 18px 44px rgba(22, 21, 19, 0.07);
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --page-pad: 1.5rem;
  --card-pad: 1.35rem 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0f0f0e;
    --paper-2: #232220;
    --ink: #f3f1ea;
    --ink-soft: #a39e93;
    --line: #2f2e2b;
    --line-strong: #6d6961;
    --white: #171716;
    --invert-bg: #f3f1ea;
    --invert-ink: #0f0f0e;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection {
  background: var(--ink);
  color: var(--paper);
}

/* Underlined, because colour is no longer available to mark a link. */
a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}
a:hover { text-decoration-thickness: 2px; }
a.btn, a.btn:hover, a.file-chip, a.file-chip:hover, a.brand, a.brand:hover {
  text-decoration: none;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.9rem var(--page-pad);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}
.mark {
  width: 28px;
  height: 28px;
  display: block;
  flex: none;
}
.brand h1 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.03em;
  font-optical-sizing: auto;
}
.brand span { color: var(--ink-soft); font-size: 0.9rem; }
.who {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.who-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  font-weight: 550;
}
.who-btn:hover { background: var(--paper-2); }
.account-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  min-width: 14rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.85rem 0.95rem 0.8rem;
  z-index: 8;
  gap: 0.45rem;
}
.who.is-open .account-menu { display: grid; }
.account-menu .btn { justify-self: start; padding-inline: 0.35rem; }
.account-menu .muted { overflow-wrap: anywhere; }

.wrap {
  width: min(980px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 2.25rem 0 4.5rem;
}
.landing {
  width: min(1100px, calc(100% - 3rem));
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: 3.25rem;
  align-items: start;
  padding-top: 2.5rem;
}
.landing-auth { position: sticky; top: 5.25rem; }

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}
.hero h2, .landing-story h2 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.35rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin: 0 0 1.1rem;
  font-optical-sizing: auto;
}
.lede {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  font-size: 1.14rem;
  line-height: 1.55;
  max-width: 36rem;
}

.steps {
  list-style: none;
  margin: 0 0 1.75rem;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}
.steps li {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}
.steps li strong { color: var(--ink); font-weight: 600; }
.step-n {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  margin-top: 0.12rem;
}

.preview {
  padding: 1.15rem 1.25rem 1.3rem;
  display: grid;
  gap: 1rem;
}
.preview-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}
.preview .msg { max-width: none; }
.credit {
  margin: 2.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}
.fineprint {
  margin: 0.9rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: var(--card-pad);
}
.row { display: flex; gap: 0.85rem; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.row input[type="text"],
.row input[type="email"],
.row input[type="password"],
.row input[type="url"] {
  flex: 1 1 14rem;
  min-width: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
}
/* Fields use the stronger rule: with no colour, a 1.3:1 hairline is not a
   visible boundary, and WCAG wants 3:1 on a control's edge. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: var(--invert-bg);
  color: var(--invert-ink);
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: color-mix(in srgb, var(--invert-bg) 82%, var(--paper)); }
.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn.secondary:hover { background: var(--paper-2); }
.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  padding-inline: 0.7rem;
  border-color: transparent;
}
.btn.ghost:hover { color: var(--ink); background: var(--paper-2); }
/* Destructive reads as an outline that fills in on hover — a deliberate,
   visible commitment rather than a red button you drift into. */
.btn.danger {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
  border-width: 2px;
  font-weight: 600;
}
.btn.danger:hover { background: var(--invert-bg); color: var(--invert-ink); }
.btn.small { padding: 0.45rem 0.9rem; font-size: 0.88rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.notice {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 0.94rem;
  margin: 0 0 1.15rem;
  border-left: 3px solid var(--line-strong);
}
/* Inverted, so a failure is unmissable without reaching for red. */
.notice.error {
  background: var(--invert-bg);
  color: var(--invert-ink);
  border-left-color: var(--invert-bg);
  font-weight: 500;
}
.notice.ok {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
}

.token-card {
  display: grid;
  gap: 0.75rem;
}
.token-card code, .prompt-box {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.prompt-box { max-height: 12rem; overflow: auto; cursor: pointer; }
.prompt-box:hover { border-style: solid; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.15rem;
}
.section-head h2 {
  font-family: var(--serif);
  margin: 0 0 0.3rem;
  font-size: 1.85rem;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}
.section-head + .card,
.create-card { margin-bottom: 1.35rem; }
.section-block { margin-top: 2.75rem; }

.room-list { display: grid; gap: 0.75rem; }
.room-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.15rem;
  align-items: center;
  padding: 1.15rem 1.35rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.room-card:hover { border-color: var(--line-strong); }
.room-card h3 { margin: 0 0 0.25rem; font-size: 1.12rem; font-weight: 600; }
.room-card p { margin: 0; color: var(--ink-soft); font-size: 0.88rem; }
.room-card a.title { color: inherit; text-decoration: none; }
.room-card a.title:hover h3 { text-decoration: underline; text-underline-offset: 0.16em; }
.empty {
  color: var(--ink-soft);
  padding: 1.6rem 0.2rem;
  text-align: center;
}
.messages .empty { margin: auto; padding: 2.5rem 0.5rem; }
.empty strong { color: var(--ink); font-weight: 600; }
.empty-card { padding: 2.1rem 1.4rem; }

.identity-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0.7rem 0 0;
  border-top: 1px solid var(--paper-2);
}
.identity:first-child { border-top: 0; padding-top: 0; }
.identity-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem; }
.identity .token-details { flex: 1 1 100%; margin-top: 0.15rem; }
.identity .hook-form { margin-top: 0.45rem; }

.login-card { max-width: none; }
.auth-title {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input { padding-right: 4.1rem; }
.show-pass {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 550;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
}
.show-pass:hover { color: var(--ink); background: var(--paper-2); }
button.text-link {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}
button.text-link:hover { text-decoration-thickness: 2px; }

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.25rem;
  height: calc(100vh - 68px);
  padding: 1.15rem var(--page-pad) 1.25rem;
}
.timeline-panel, .side-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.room-head {
  padding: 1.15rem 1.35rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}
.room-head h2 {
  font-family: var(--serif);
  margin: 0 0 0.2rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}
.muted { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.45; }
.mono { font-family: var(--mono); font-size: 0.78rem; }

.messages {
  flex: 1;
  overflow: auto;
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.msg { display: grid; gap: 0.35rem; max-width: 42rem; }
.msg.is-follow { gap: 0.2rem; margin-top: -0.55rem; }
.msg .meta { display: flex; gap: 0.55rem; align-items: baseline; flex-wrap: wrap; }
.msg .name { font-weight: 600; }
.msg .body { white-space: pre-wrap; line-height: 1.55; font-size: 1.02rem; }
.badge {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
  background: var(--paper-2);
  color: var(--ink-soft);
  border: 1px solid transparent;
}
/* Filled for bots, outlined for humans. Knowing which is which is the whole
   point of a room where both post, so it must survive with no colour at all. */
.badge.bot {
  background: var(--invert-bg);
  color: var(--invert-ink);
  font-weight: 600;
}
.badge.human {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.attachments { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.2rem; }
.attachments img {
  max-width: min(360px, 100%);
  max-height: 280px;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  font-size: 0.88rem;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 1rem 1.35rem 1.15rem;
  display: grid;
  gap: 0.65rem;
}
.composer.is-drop {
  outline: 2px dashed var(--ink);
  outline-offset: -8px;
  background: var(--paper);
}
.composer-row { display: flex; gap: 0.75rem; align-items: end; }
.composer textarea { flex: 1; min-height: 72px; max-height: 180px; }
.composer .row { margin-top: 0.15rem; }
.typing { min-height: 1.15rem; font-size: 0.82rem; color: var(--ink-soft); padding: 0 0.15rem; }
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
.file-btn input { display: none; }
.file-name { color: var(--ink-soft); font-size: 0.88rem; }

.side-panel {
  padding: 1.25rem 1.35rem 1.5rem;
  overflow: auto;
  gap: 0;
}
.side-section + .side-section { margin-top: 1.5rem; padding-top: 1.35rem; border-top: 1px solid var(--paper-2); }
.side-panel h3 {
  margin: 0 0 0.7rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.member {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--paper-2);
}
.member:last-child { border-bottom: 0; }
.member strong { margin-left: 0.15rem; }
/* Filled = online, hollow ring = offline. */
.dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; border: 1.5px solid var(--line-strong); display: inline-block; }
.dot.on { background: var(--ink); border-color: var(--ink); }
.side-panel .btn { margin-top: 0.65rem; }
.side-panel .row .btn { margin-top: 0; }
.token-details {
  margin-top: 0.85rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.token-details summary { cursor: pointer; }
.token-details[open] summary { margin-bottom: 0.7rem; }
.token-details label { margin-top: 0.5rem; }

.scrim {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 30;
}
.dialog {
  width: min(28rem, 100%);
  background: var(--white);
  color: var(--ink);
  border-radius: 18px;
  padding: 1.4rem 1.45rem 1.3rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.dialog h3 {
  font-family: var(--serif);
  font-size: 1.45rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.dialog p { margin: 0 0 1.15rem; color: var(--ink-soft); }

/* Closed by default. display:flex on .lightbox used to override [hidden] and block the room. */
.lightbox {
  display: none;
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 20;
}
.lightbox.is-open {
  display: flex;
  pointer-events: auto;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 900px) {
  .landing {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-top: 1.25rem;
  }
  .landing-auth { position: static; }
}
@media (max-width: 840px) {
  .wrap { width: min(960px, calc(100% - 2rem)); padding-top: 1.5rem; }
  .landing { width: min(960px, calc(100% - 2rem)); }
  .room-layout {
    grid-template-columns: 1fr;
    height: auto;
    padding: 1rem;
  }
  .timeline-panel { min-height: 72vh; }
  .brand span, .who .email { display: none; }
  .room-head {
    flex-direction: column;
    align-items: stretch;
  }
  .room-head .row { justify-content: flex-start; }
  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
