/* Lamplight — Keller & Moss
   Night walnut wings, one amber pendant, the conversation in the pool of light.
   Fraunces carries names and titles. Outfit carries the talk. */

[hidden] { display: none !important; }

:root {
  --brand: #140C09;
  --brand-accent: #E8A33A;
  --brand-ink: #2A160C;
  --night: var(--brand);
  --walnut: #1C110C;
  --panel: #27160F;
  --pool: #3A2418;
  --pool-deep: #2A1A12;
  --line: rgba(243, 228, 208, 0.16);
  --cream: #F3E4D0;
  --cream-dim: #CDBBA6;
  --faint: #A8907C;
  --amber: var(--brand-accent, #E8A33A);
  --amber-2: #F6C56B;
  --ember: #C4622D;
  --ink: var(--brand-ink, #2A160C);
  --danger: #F0C2B4;
  --serif: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 18% -10%, rgb(from var(--amber) r g b / 0.16), transparent 60%),
    var(--night);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
::selection { background: var(--amber); color: var(--ink); }
:focus-visible { outline: 2px solid var(--amber-2); outline-offset: 3px; }
#main:focus { outline: none; }
#main:focus-visible { outline: 2px solid var(--amber-2); outline-offset: 4px; }

.skip {
  position: absolute;
  left: 0.6rem;
  top: 0.6rem;
  z-index: 80;
  transform: translateY(-140%);
  background: var(--amber);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  border-radius: 3px;
  font-weight: 600;
}
.skip:focus { transform: none; }

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.toast {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 70;
  max-width: min(26rem, calc(100vw - 2rem));
  background: var(--panel);
  color: var(--cream);
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}
.toast--err { border-left-color: var(--ember); }

.noscript {
  margin: 1rem;
  padding: 1rem;
  background: var(--panel);
  border-left: 4px solid var(--amber);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.55rem 1rem;
  background: transparent;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-wide { width: 100%; }
.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover { background: var(--amber-2); }
.btn-quiet {
  border-color: var(--line);
  color: var(--cream-dim);
  background: transparent;
}
.btn-quiet:hover { color: var(--cream); border-color: var(--cream-dim); }

.field { margin-bottom: 0.9rem; }
label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
input, textarea {
  width: 100%;
  background: var(--night);
  color: var(--cream);
  border: 1px solid rgba(243, 228, 208, 0.28);
  border-radius: 3px;
  padding: 0.7rem 0.8rem;
}
textarea { resize: vertical; min-height: 4.5rem; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--amber); outline: none; }
.hint { margin-top: 0.45rem; color: var(--faint); font-size: 0.86rem; }
.form-err {
  color: var(--danger);
  background: rgba(196, 98, 45, 0.18);
  border-left: 3px solid var(--ember);
  padding: 0.55rem 0.7rem;
  margin-top: 0.65rem;
}

.empty { padding: 1.4rem 0; max-width: 38ch; }
.empty-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.3rem;
}

.lamp-svg { width: 32px; height: 32px; }
.lamp-svg--sm { width: 28px; height: 28px; }
.lamp-svg .cord, .lamp-svg .stem { fill: none; stroke: var(--amber-2); stroke-width: 1.6; stroke-linecap: round; }
.lamp-svg .shade { fill: var(--amber); }
.lamp-svg .glow { fill: var(--amber-2); }

.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1;
}
.studio-name {
  display: block;
  margin-top: 0.2rem;
  color: var(--cream-dim);
  font-size: 0.92rem;
}
.brand-link { text-decoration: none; }

/* ── boot ── */
.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.8rem;
  text-align: center;
}
.boot-lamp .lamp-svg { width: 56px; height: 72px; margin: 0 auto 0.4rem; }
.boot-line { color: var(--cream-dim); }

/* ── gate ── */
.gate {
  display: grid;
  grid-template-columns: minmax(0, 36rem) minmax(18rem, 24rem);
  gap: 4.5rem;
  align-items: start;
  padding: 9vh 7vw 4rem;
}
.gate h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.7rem, 5.4vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  max-width: 11ch;
  margin: 1.2rem 0 1rem;
}
.lede { max-width: 38ch; color: var(--cream-dim); font-size: 1.05rem; }
.gate-list { margin-top: 1.6rem; }
.gate-list li {
  display: flex;
  gap: 0.55rem;
  padding: 0.35rem 0;
  color: var(--cream);
}
.hash { color: var(--amber); font-family: var(--serif); font-weight: 600; }
.gate-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1.4rem 1.3rem 1.2rem;
  box-shadow: var(--shadow);
}
.gate-card h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
.demo {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.demo-title { font-family: var(--serif); font-size: 1.2rem; margin-bottom: 0.6rem; }
.demo-rows { margin-bottom: 0.8rem; }
.demo-rows div {
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.5rem;
  padding: 0.22rem 0;
}
.demo-rows dt { color: var(--faint); }
.demo-rows dd { margin: 0; overflow-wrap: anywhere; }

/* ── workspace ── */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1rem 1.8rem;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgb(from var(--night) r g b / 0.92);
}
.seat-name { font-family: var(--serif); font-size: 1.15rem; font-weight: 500; }
.seat-role, .seat-meta, .unread-line { color: var(--cream-dim); font-size: 0.92rem; }
.unread-line { justify-self: end; }
.top-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }

.workspace { flex: 1; min-height: 0; min-width: 0; width: 100%; }
.rail, .presence, .thread {
  background: var(--walnut);
  min-height: 0;
}
.rail { padding: 1rem 0.75rem 1.2rem; border-right: 1px solid var(--line); min-width: 0; max-width: 100%; }
.rail-block { margin-bottom: 1.1rem; }
.rail-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cream-dim);
  margin: 0 0.45rem 0.4rem;
}
.nav-link {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem 0.55rem;
  align-items: center;
  text-decoration: none;
  padding: 0.55rem 0.6rem;
  border-radius: 3px;
  min-height: 44px;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgb(from var(--amber) r g b / 0.08); }
.nav-link.is-current {
  background: rgb(from var(--amber) r g b / 0.12);
  border-left-color: var(--amber);
}
.nav-mark { color: var(--amber); font-family: var(--serif); font-weight: 600; }
.nav-name { font-weight: 500; }
.nav-preview {
  grid-column: 2 / -1;
  color: var(--faint);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lamp-count {
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.nav-people { margin-top: 0.4rem; }

.lamp {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: none;
  justify-self: center;
}
.lamp--online { background: var(--amber-2); box-shadow: 0 0 0 3px rgb(from var(--amber) r g b / 0.25); }
.lamp--away { background: var(--ember); }
.lamp--offline { background: transparent; border: 1.5px solid var(--faint); }

.column {
  background:
    radial-gradient(ellipse 90% 240px at 50% -30px, rgb(from var(--amber) r g b / 0.28), transparent 68%),
    linear-gradient(180deg, var(--pool) 0%, var(--pool-deep) 240px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.col-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.col-head h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.7rem, 2vw, 2.15rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.col-topic { color: var(--cream-dim); max-width: 62ch; margin-top: 0.25rem; }
.col-head .form-err, .column > .form-err { margin: 0.7rem 1.2rem 0; }
.conversation-tools { display: flex; flex-wrap: wrap; gap: .5rem; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); }
.conversation-tools input { width: auto; flex: 1; min-width: 0; padding: .5rem .7rem; }
.conversation-tools .btn { min-height: 38px; padding: .4rem .7rem; }
.sync-status { flex-basis: 100%; color: var(--faint); font-size: .8rem; }
.channel-retry { align-self: flex-start; margin: .8rem 1.2rem; }

.log, .thread-list {
  flex: 1;
  overflow: auto;
  padding: 0.4rem 1.2rem 1.2rem;
}
.day {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 1.3rem 0 0.7rem;
  color: var(--cream-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.98rem;
}
.day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.msg { padding: 0.55rem 0 0.55rem 0.15rem; max-width: 70ch; }
.msg--self { box-shadow: inset 2px 0 0 var(--amber); padding-left: 0.75rem; }
.msg-h { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: baseline; }
.avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--cream);
  background: #6E5344;
}
.msg--self .avatar { background: var(--amber); color: var(--ink); }
.msg-name { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; }
.msg-role, .msg time { color: var(--faint); font-size: 0.84rem; }
.msg-body { margin: 0.2rem 0 0.35rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 62ch; }

/* First open of a conversation this session: unlit lines in the transcript's
   rhythm hold the column while the messages arrive. Cached returns never
   show this. */
.opening { max-width: 70ch; }
.ghost-msg {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.6rem;
  row-gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0 0.55rem 0.15rem;
}
.ghost-msg--cont { grid-template-rows: auto; padding-top: 0; }
.ghost-msg--cont .ghost-avatar, .ghost-msg--cont .ghost-name { display: none; }
.ghost-msg--cont .ghost-body { grid-column: 2; }
.ghost-avatar { width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--line); }
.ghost-name { height: 0.85rem; width: 9rem; border-radius: 4px; background: var(--line); }
.ghost-body { grid-column: 1 / -1; height: 0.8rem; width: var(--w, 70%); border-radius: 4px; background: var(--line); }
.ghost-avatar, .ghost-name, .ghost-body { animation: ll-ghost 1.4s ease-in-out infinite; }
@keyframes ll-ghost { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.thread-btn {
  display: block;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.15rem 0;
  color: var(--amber-2);
  cursor: pointer;
  font-weight: 500;
}
.thread-btn:hover { color: var(--cream); }
.thread-peek { display: block; color: var(--cream-dim); font-weight: 400; max-width: 58ch; }

.composer {
  border-top: 1px solid var(--line);
  padding: 0.8rem 1.2rem 1rem;
  background: rgb(from var(--night) r g b / 0.35);
}
.composer-row { display: flex; gap: 0.6rem; align-items: flex-end; }
.composer-row textarea { flex: 1; }
.composer-row .btn { flex: 0 0 auto; }

.presence {
  border-left: 1px solid var(--line);
  padding: 1rem 1rem 1.3rem;
  overflow: auto;
}
.presence h2, .thread h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.8rem;
}
.presence-group { margin-bottom: 1rem; }
.presence-group h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cream-dim);
}
.person { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; padding: 0.45rem 0; }
.person .lamp { margin-top: 0.4rem; }
.person-name { font-family: var(--serif); font-weight: 500; }
.person-role, .person-focus { grid-column: 2; color: var(--cream-dim); font-size: 0.88rem; }
.person-focus { color: var(--faint); }
.presence-note { margin-top: 1rem; color: var(--faint); font-size: 0.84rem; max-width: 28ch; }

.thread {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}
.thread-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem 0.4rem;
}
.thread-head h2 { margin: 0; }
.composer--thread { background: transparent; }
.composer--thread .composer-row { flex-direction: column; align-items: stretch; }
.composer--thread .btn { width: 100%; }

.people { padding: 0.4rem 1.2rem 1.4rem; flex: 1; overflow: auto; min-height: 0; }
.seat-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  max-width: 44rem;
}
.seat-row .lamp { margin-top: 0.45rem; }
.seat-row h3 { font-family: var(--serif); font-weight: 500; font-size: 1.25rem; }
.seat-detail { color: var(--cream-dim); }
.seat-link { color: var(--amber-2); font-weight: 600; }

@media (min-width: 901px) {
  .shell { height: 100vh; height: 100dvh; }
  .workspace {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 270px;
    min-height: 0;
  }
  .column { overflow: hidden; }
  .log { min-height: 0; }
}

@media (max-width: 900px) {
  .gate { grid-template-columns: 1fr; gap: 2rem; padding: 4.5rem 1.1rem 2.5rem; }
  .gate h1 { max-width: 14ch; }
  .topbar { grid-template-columns: 1fr auto; }
  .top-seat { grid-column: 1 / -1; }
  .unread-line { justify-self: start; }
  .top-actions { grid-column: 1 / -1; }
  .workspace { display: flex; flex-direction: column; }
  .rail {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.55rem;
  }
  .rail-block { display: flex; align-items: center; gap: 0.3rem; margin: 0; }
  .rail-label { margin: 0 0.25rem 0 0; white-space: nowrap; }
  .rail-list { display: flex; gap: 0.3rem; }
  .nav-link { white-space: nowrap; min-width: max-content; }
  .nav-preview { display: none; }
  .nav-people { margin: 0; align-self: center; }
  .log { max-height: 62vh; min-height: 18rem; }
  .presence { border-left: 0; border-top: 1px solid var(--line); max-height: 22rem; }
  .thread {
    position: fixed;
    inset: 0;
    z-index: 40;
    border-left: 0;
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .boot-lamp { animation: lamp-glow 1.8s ease-in-out infinite; }
}
@keyframes lamp-glow {
  50% { filter: drop-shadow(0 0 14px rgb(from var(--amber) r g b / 0.8)); }
}
@media (prefers-reduced-motion: reduce) {
  .boot-lamp { animation: none; }
}
dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow: auto; border: 1px solid #8c6b4c; padding: 24px; background: #fff9ed; color: var(--brand-ink); }
dialog::backdrop { background: #140c09aa; }
dialog form { display: grid; gap: 10px; margin: 20px 0; }
dialog input, dialog select { width: 100%; min-width: 0; padding: 10px; font: inherit; }
dialog li { margin: 12px 0; overflow-wrap: anywhere; }
dialog button { margin: 4px; }
dialog .btn-quiet { color: #2a160c; border-color: #8c6b4c; }
.people-admin { align-self: flex-start; margin: 16px 24px 0; }
.seat-row > div { min-width: 0; overflow-wrap: anywhere; }
.seat-row [data-seat-status] { white-space: normal; text-align: left; }
.workspace-start { margin-top: 1rem; }
#signupForm .hint { margin-bottom: .8rem; }
.gate-card input { min-width: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

/* Messenger desk. Flat walnut surfaces, amber only on the live channel and the send. */
body { font-size: 15px; -webkit-font-smoothing: antialiased; }
.btn { border-radius: 8px; min-height: 36px; }
.btn-amber { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
input, textarea { border-radius: 8px; min-height: 40px; }
dialog { border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.toast { border-radius: 12px; }

/* gate */
.gate { gap: 3rem; padding: 8vh 6vw 3rem; align-items: center; }
.gate h1 { font-size: clamp(2.4rem, 4.6vw, 3.6rem); max-width: 12ch; }
.gate-card { border-radius: 16px; padding: 1.35rem 1.25rem 1.15rem; }
#gate[hidden] { display: none !important; }
#gate.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  grid-template-columns: minmax(0, 440px);
  padding: 28px 16px;
  background: #140c09;
}
#gate .gate-copy { color: #f3e4d0; }
#gate .gate-card, #gate form, #gate .panel { background: #24160f; color: #f3e4d0; }
.loading, .form-err { border-radius: 10px; }

/* top bar: one 48px strip */
.topbar {
  grid-template-columns: auto 1fr auto auto;
  gap: 0 18px;
  min-height: 48px;
  padding: 0 14px 0 12px;
  background: var(--night);
  backdrop-filter: none;
}
.topbar .brand { gap: 0.55rem; }
.topbar .brand-name { font-size: 1.15rem; }
.topbar .brand > span { display: flex; align-items: baseline; gap: 8px; }
.topbar .studio-name { margin: 0; font-size: 0.82rem; color: var(--faint); }
.topbar .lamp-svg--sm { width: 22px; height: 22px; }
.unread-line { justify-self: center; font-size: 0.82rem; color: var(--faint); }
.top-seat { display: flex; align-items: center; gap: 8px; }
.seat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber-2); box-shadow: 0 0 0 3px rgb(from var(--amber) r g b / 0.22); }
.top-seat .seat-name { font-family: var(--sans); font-size: 0.9rem; font-weight: 600; }
.top-seat .seat-role { font-size: 0.82rem; }
.top-seat .seat-role::before { content: "·"; margin-right: 8px; color: var(--faint); }
.top-seat .seat-meta { display: none; }
.top-actions .btn { min-height: 30px; padding: 0 10px; font-size: 0.82rem; border-color: transparent; }
.top-actions .btn:hover { border-color: var(--line); }

/* rail */
.rail { padding: 10px 8px 14px; background: var(--walnut); }
.rail-block { margin-bottom: 14px; }
.rail-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 8px 4px;
}
.nav-link {
  min-height: 30px;
  border-radius: 6px;
  padding: 4px 8px;
  border-left-width: 0;
  gap: 2px 8px;
  color: var(--cream-dim);
  font-size: 0.94rem;
}
.nav-link:hover { background: rgba(243, 228, 208, 0.06); color: var(--cream); }
.nav-link.is-current { background: rgb(from var(--amber) r g b / 0.18); color: var(--cream); box-shadow: none; }
.nav-link.is-current .nav-mark { color: var(--amber-2); }
.nav-mark { font-family: var(--sans); font-weight: 600; color: var(--faint); width: 12px; text-align: center; }
.nav-name { font-weight: 500; }
.nav-link:has(.lamp-count) .nav-name { font-weight: 700; color: var(--cream); }
.nav-preview { display: none; }
.lamp-count { min-width: 1.25rem; height: 1.25rem; font-size: 0.7rem; }
button.nav-add { width: 100%; background: transparent; border: 0; cursor: pointer; text-align: left; font: inherit; color: var(--faint); font-size: 0.9rem; }
button.nav-add:hover { color: var(--cream); }
.nav-people { margin-top: 0; }

/* conversation column */
.column { background: var(--pool-deep); }
.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}
.col-id { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.col-head h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.col-topic { margin: 0; font-size: 0.86rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-tools { display: flex; align-items: center; gap: 6px; padding: 0; border: 0; flex: none; }
.conversation-tools input { width: 220px; min-height: 32px; padding: 0 10px; font-size: 0.86rem; background: var(--walnut); border-color: var(--line); }
.conversation-tools input::placeholder { color: var(--faint); }
.conversation-tools .btn { min-height: 32px; padding: 0 10px; font-size: 0.84rem; }
.channel-retry { margin: 12px 16px; }

.log { padding: 8px 0 12px; display: flex; flex-direction: column; }
.log > * { flex: none; }
.log > :first-child { margin-top: auto; }
.day {
  justify-content: center;
  gap: 0;
  margin: 18px 0 6px;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cream-dim);
}
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day span { margin: 0 12px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--sans); font-style: normal; }

.msg {
  display: grid;
  grid-template-columns: 36px auto auto minmax(0, 1fr);
  grid-auto-rows: min-content;
  column-gap: 8px;
  align-items: baseline;
  max-width: none;
  margin: 0;
  padding: 6px 16px 4px;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.msg:hover { background: rgba(243, 228, 208, 0.035); }
.msg--self { box-shadow: none; padding-left: 16px; }
.msg-h { display: contents; }
.msg-h .avatar { grid-column: 1; grid-row: 1 / span 2; align-self: start; margin-right: 4px; width: 36px; height: 36px; border-radius: 8px; font-size: 0.86rem; }
.msg-h .msg-name { grid-column: 2; grid-row: 1; font-family: var(--sans); font-size: 0.95rem; font-weight: 700; color: var(--cream); white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.msg-h .msg-role { grid-column: 3; grid-row: 1; font-size: 0.8rem; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.msg-h time { grid-column: 4; grid-row: 1; justify-self: start; font-size: 0.76rem; color: var(--faint); }
.msg-body { grid-column: 2 / -1; grid-row: 2; margin: 0; font-size: 0.97rem; line-height: 1.45; max-width: 70ch; color: var(--cream); }
.msg--cont { padding-top: 2px; padding-bottom: 2px; }
.msg--cont .msg-time { grid-column: 1; grid-row: 1; align-self: start; font-size: 0.7rem; color: transparent; text-align: center; padding-top: 3px; }
.msg--cont:hover .msg-time, .msg--cont:focus-within .msg-time { color: var(--faint); }
.msg--cont .msg-body { grid-row: 1; }
.msg { position: relative; }
.thread-btn { grid-column: 2 / -1; margin-top: 3px; font-size: 0.82rem; color: var(--amber-2); }
.thread-btn:not(:has(.thread-peek)) {
  position: static;
  justify-self: start;
  margin-top: 4px;
  min-height: 44px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--walnut);
  font-size: 0.78rem;
  opacity: 1;
  pointer-events: auto;
}
.msg:hover .thread-btn, .msg:focus-within .thread-btn { opacity: 1; pointer-events: auto; }
.thread-btn { min-width: 0; max-width: 100%; text-align: left; }
.thread-peek { font-size: 0.8rem; overflow-wrap: anywhere; }
.empty { padding: 2rem 1rem; }
.empty-title { font-size: 1.2rem; }

/* composer, pinned to the bottom of the column */
#composer.composer {
  margin: 0;
  padding: 6px 16px 14px;
  background: transparent;
  border: 0;
}
.composer-box {
  border: 1px solid rgba(243, 228, 208, 0.22);
  border-radius: 10px;
  background: var(--walnut);
  overflow: hidden;
}
.composer-box:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgb(from var(--amber) r g b / 0.18); }
#composer textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 180px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cream);
  padding: 10px 12px 4px;
  resize: none;
  outline: none;
}
#composer textarea:focus-visible { outline: none; }
#composer textarea::placeholder { color: var(--faint); }
.composer-foot { display: flex; align-items: center; gap: 12px; padding: 2px 8px 8px 12px; }
.composer-foot .hint, .composer-foot .sync-status { margin: 0; font-size: 0.76rem; color: var(--faint); }
.composer-foot .sync-status { flex: none; }
.composer-foot .hint { flex: 1; }
.composer-foot .btn-send { min-height: 30px; padding: 0 12px; font-size: 0.84rem; margin-left: auto; }
.composer--thread { padding: 10px 12px 12px; }
.composer--thread .composer-row { border: 1px solid var(--line); border-radius: 10px; background: var(--walnut); padding: 6px; }
.composer--thread textarea { border: 0; background: transparent; min-height: 60px; }
.composer--thread .btn { min-height: 32px; font-size: 0.84rem; }
.composer--thread label { font-size: 0.86rem; color: var(--cream-dim); }

/* presence */
.presence { padding: 12px 12px 16px; background: var(--walnut); }
.presence h2 { font-family: var(--sans); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.presence-group h3 { font-size: 0.78rem; color: var(--faint); margin-bottom: 2px; }
.person { padding: 5px 4px; column-gap: 10px; row-gap: 0; align-items: start; }
.person .lamp { margin-top: 7px; }
.person-name { font-family: var(--sans); font-size: 0.9rem; font-weight: 600; }
.person-role { font-size: 0.78rem; }
.person-focus { display: none; }
.presence-note { font-size: 0.74rem; }
.thread { min-width: 0; background: var(--walnut); }
.thread h2 { font-family: var(--sans); font-size: 1rem; font-weight: 700; }
.thread-list .msg { padding-inline: 12px; grid-template-columns: 36px minmax(0, 1fr) auto; }
.thread-list .msg-h .msg-name { grid-column: 2 / -1; }
.thread-list .msg-h .msg-role { grid-column: 2; grid-row: 2; }
.thread-list .msg-h time { grid-column: 3; grid-row: 2; }
.thread-list .msg-body { grid-row: 3; }

@media (max-width: 900px) {
  .shell { height: 100dvh; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; min-height: 44px; padding-inline: 10px; }
  .topbar .studio-name { display: none; }
  .topbar .brand-name { font-size: 1.05rem; }
  .unread-line { display: none; }
  .top-seat { grid-column: 2; justify-self: end; min-width: 0; max-width: 100%; }
  .top-seat .seat-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.86rem; }
  .top-seat .seat-role { display: none; }
  .top-actions { grid-column: 3; }
  #resetBtn { display: none; }
  .workspace { display: flex; flex-direction: column; min-height: 0; }
  .rail { display: flex; align-items: center; gap: 4px; padding: 6px 8px; overflow-x: auto; flex: none; border-bottom: 1px solid var(--line); }
  .rail-block { display: flex; align-items: center; gap: 2px; margin: 0; }
  .rail-label { display: none; }
  .rail-list { display: flex; gap: 2px; }
  .nav-link { white-space: nowrap; min-width: max-content; padding: 4px 10px; }
  button.nav-add { width: auto; }
  button.nav-add .nav-name { display: none; }
  .column { flex: 1; min-height: 0; overflow: hidden; }
  .log { max-height: none; min-height: 0; flex: 1; }
  .presence { display: none; }
  .col-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 48px; padding: 6px 12px; gap: 6px; }
  .col-id { min-width: 0; }
  .col-head h1 { white-space: normal; overflow-wrap: anywhere; }
  .col-topic { display: none; }
  .conversation-tools { display: contents; }
  .conversation-tools input { display: block; grid-column: 1 / -1; grid-row: 2; width: 100%; min-height: 44px; }
  .conversation-tools #conversationMembers { grid-column: 2; grid-row: 1; min-height: 44px; }
  .conversation-tools #refreshMessages { display: none; }
  .msg { padding-inline: 12px; grid-template-columns: 36px minmax(0, 1fr) auto; }
  .msg-h .msg-name { grid-column: 2 / -1; }
  .msg-h .msg-role { grid-column: 2; grid-row: 2; }
  .msg-h time { grid-column: 3; grid-row: 2; }
  .msg-body { grid-row: 3; }
  .msg--cont .msg-body { grid-row: 1; }
  .thread-btn:not(:has(.thread-peek)) { position: static; justify-self: start; margin-top: 4px; min-height: 44px; opacity: 1; pointer-events: auto; }
  .composer-foot .hint, .composer-foot .sync-status { display: none; }
  #composer.composer { padding: 6px 10px 10px; }
  .thread { position: fixed; inset: 0; z-index: 40; }
}

/* ── motion ──
   One ease, one tempo. The transcript settles in on a channel switch, the
   thread slides in beside it, controls answer hover and press without lag.
   Everything collapses under reduced motion. */
:root {
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 160ms;
  --t-base: 200ms;
}
@keyframes ll-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes ll-slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes ll-rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes ll-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ll-toast {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes ll-slip {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes ll-col-load {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
.is-entering { animation: ll-enter var(--t-base) var(--ease-out) both; }
.thread:not([hidden]) { animation: ll-slide-in var(--t-base) var(--ease-out) both; }
.presence:not([hidden]) { animation: ll-fade var(--t-base) var(--ease-out) both; }
#gate:not([hidden]) .gate-card, #gate:not([hidden]) .gate-copy { animation: ll-enter var(--t-base) var(--ease-out) both; }
/* Opacity only: the thread overlay is position: fixed inside the workspace,
   and a transform here would briefly contain it. */
#app:not([hidden]) .workspace { animation: ll-fade var(--t-base) var(--ease-out) both; }
.toast:not([hidden]) { animation: ll-toast var(--t-base) var(--ease-out) both; }
dialog[open] { animation: ll-slip var(--t-base) var(--ease-out) both; }
dialog[open]::backdrop { animation: ll-fade var(--t-base) var(--ease-out) both; }
.form-err:not([hidden]), .channel-retry:not([hidden]), .empty { animation: ll-enter var(--t-base) var(--ease-out) both; }

/* Slow channel loads get a thin amber sweep across the top of the column;
   warm loads finish inside the delay and never show it. */
.column { position: relative; }
.column::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber-2), transparent);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.column[aria-busy="true"]::after { opacity: 1; animation: ll-col-load 900ms linear 240ms infinite; transition: opacity var(--t-fast) var(--ease-out) 240ms; }

.btn, .nav-link, .thread-btn, .seat-link, .msg, .msg--cont .msg-time, .lamp, .lamp-count,
.conversation-tools input, .composer-box, .nav-mark {
  transition:
    background-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out),
    opacity var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out);
}
input, textarea { transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out); }
.thread-btn:not(:has(.thread-peek)) { transition: opacity var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out); }
.btn:active:not(:disabled) { transform: translateY(1px); }

@media (max-width: 900px) {
  .thread:not([hidden]) { animation-name: ll-rise; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .column[aria-busy="true"]::after { animation: none; opacity: 0; }
}
