:root {
  --paper: #121614;
  --ink: #e6e4d8;
  --muted: #8b8d80;
  --line: #2c332e;
  --card: #181c1a;
  --raised: #1f2521;
  --accent: #b7c389;
  --mention: #d2b36a;
  --danger: #c45c45;
  --live: #86a072;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;
  --sidebar: 18.5rem;
  --top: 3.4rem;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  background:
    radial-gradient(900px 520px at 8% -12%, rgba(183, 195, 137, 0.07), transparent 55%),
    linear-gradient(180deg, #161a18 0%, var(--paper) 28%);
  background-color: var(--paper);
}

body.body--app { overflow: hidden; }
body.body--gate { overflow: auto; }

a { color: inherit; }

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

button { cursor: pointer; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top {
  flex: 0 0 var(--top);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 rgba(183, 195, 137, 0.12);
  background: rgba(18, 22, 20, 0.92);
  min-width: 0;
}

.mark {
  flex: 0 0 auto;
  text-decoration: none;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
}

.mark span {
  color: var(--accent);
  margin-right: 0.45rem;
}

.nav {
  display: flex;
  gap: 0.35rem;
  min-width: 0;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border: 1px solid transparent;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.nav a[aria-current="page"] {
  color: var(--accent);
  border-color: rgba(183, 195, 137, 0.35);
  background: rgba(183, 195, 137, 0.08);
}

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  min-width: 0;
}

.who__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 12rem;
  letter-spacing: 0.04em;
}

.text-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.main--center {
  display: grid;
  place-items: center;
  padding: 3rem 1.25rem;
  overflow: auto;
}

.main--chat {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.main--board {
  display: block;
  overflow: hidden;
}

.gate { width: min(28rem, 100%); }

.kicker {
  margin: 0 0 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--accent);
}

h1 {
  margin: 0 0 0.55rem;
  font-family: var(--serif);
  font-size: 2.15rem;
  font-weight: 500;
  line-height: 1.2;
}

.lede {
  margin: 0 0 1.4rem;
  color: var(--muted);
  line-height: 1.55;
}

.error { color: var(--danger); }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

input, textarea, button[type="submit"] {
  border: 1px solid var(--line);
  background: var(--raised);
  padding: 0.7rem 0.8rem;
  border-radius: 2px;
  min-width: 0;
}

input:focus, textarea:focus {
  outline: 1px solid rgba(183, 195, 137, 0.55);
  border-color: var(--accent);
}

textarea { resize: vertical; }

button[type="submit"] {
  background: var(--accent);
  color: #121614;
  border-color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.rooms {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--card);
}

.rooms__head {
  flex: 0 0 auto;
  padding: 1rem 1.1rem 0.4rem;
}

.rooms h2,
.column__head h2,
.chat-head h1 {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rooms__list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.7rem 0.7rem;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.rooms__list li + li { margin-top: 0.15rem; }

.room {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--muted);
  padding: 0.55rem 0.65rem;
}

.room.is-active {
  color: var(--ink);
  background: rgba(183, 195, 137, 0.08);
  box-shadow: inset 2px 0 0 var(--accent);
}

.room__hash {
  color: var(--accent);
  font-weight: 600;
}

.room__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 1.4rem;
  text-align: center;
  font-size: 0.7rem;
  border: 1px solid var(--line);
  padding: 0.08rem 0.35rem;
  color: var(--accent);
}

.badge--mention {
  border-color: var(--mention);
  color: var(--mention);
}

.new-room,
.new-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.new-room {
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--line);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  min-width: 0;
}

.chat-head h1 {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: none;
  font-weight: 650;
}

.status {
  margin: 0;
  color: var(--live);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stream {
  overflow: auto;
  min-height: 0;
  padding: 1.1rem 1.5rem 1.4rem;
}

.msg {
  margin: 0 0 1.15rem;
  max-width: 46rem;
}

.msg__meta {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.msg__meta strong {
  color: var(--accent);
  font-weight: 700;
}

.msg__body {
  font-size: 1.05rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mention { color: var(--mention); font-weight: 650; }

.msg--mention {
  box-shadow: inset 2px 0 0 var(--mention);
  padding-left: 0.75rem;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.7rem;
  padding: 0.85rem 1.25rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.composer textarea {
  min-height: 3.4rem;
  max-height: 10rem;
}

.composer button { padding: 0.75rem 1.15rem; }

.board {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(16.5rem, 1fr));
  gap: 1rem;
  padding: 1rem 1.15rem 1.15rem;
  overflow: auto;
  align-items: stretch;
}

.column {
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
}

.column.is-over { outline: 1px dashed var(--accent); }

.column__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
}

.card {
  border: 1px solid var(--line);
  background: var(--raised);
  padding: 0.8rem 0.85rem;
  min-width: 0;
}

.card h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.assignee {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--accent);
}

.card.is-dragging { opacity: 0.45; }

.flashes {
  list-style: none;
  margin: 0;
  padding: 0.55rem 1.25rem;
  flex: 0 0 auto;
}

.flash--error { color: var(--danger); }

.empty {
  padding: 2rem 1.5rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  :root { --sidebar: 100%; }

  .main--chat {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .rooms {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 38vh;
  }

  .board {
    grid-template-columns: minmax(16.5rem, 1fr);
    height: auto;
    min-height: 100%;
  }

  .column {
    height: auto;
    max-height: none;
    min-height: 22rem;
  }

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