/* A small instrument panel: warm paper, dark ink, signal amber. */
:root {
  --paper: #f5f3ec;
  --surface: #fffef9;
  --ink: #202824;
  --muted: #62685f;
  --line: #d5d7cb;
  --accent: #e8ad36;
  --accent-dark: #6d4800;
  --danger: #92372b;
  --mono: "DejaVu Sans Mono", "Lucida Console", "Courier New", monospace;
  --body: "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button, input, textarea { border-radius: 2px; }
button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 34px; padding: 7px 12px; font-family: var(--mono); font-size: 11px; }
button:hover:not(:disabled) { border-color: var(--ink); background: #eeeee4; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent-dark); outline-offset: 3px; }
.primary { background: var(--accent); border-color: var(--accent); font-weight: bold; }
.primary:hover:not(:disabled) { background: #f0bc52; }
.primary span { margin-left: 14px; }
.quiet { background: transparent; }
.masthead { height: 76px; border-bottom: 1px solid var(--ink); display: flex; align-items: center; gap: 28px; padding: 0 30px; background: var(--ink); color: var(--paper); }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; font-family: var(--mono); font-weight: bold; letter-spacing: .08em; flex-shrink: 0; }
.brand-mark { background: var(--accent); color: var(--ink); padding: 10px 7px; font-size: 16px; letter-spacing: -.06em; }
.brand small { display: block; font-size: 9px; letter-spacing: .06em; font-weight: normal; color: #c0c9bb; margin-top: 5px; }
.connection { margin-left: auto; display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; min-width: 0; }
#connection-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.status-dot[data-state="live"] { background: #b8d2ac; }
.status-dot[data-state="error"] { background: #f09072; }
.status-dot[data-state="offline"] { background: #a1aaa0; }
.session-controls { display: flex; align-items: center; gap: 14px; font-family: var(--mono); font-size: 11px; min-width: 0; }
#identity { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.masthead .quiet { color: var(--paper); border-color: #646d61; }
.masthead .quiet:hover:not(:disabled) { color: var(--ink); }
.login-panel { max-width: 620px; margin: clamp(50px, 12vh, 140px) auto; padding: 0 28px; }
.login-index, .eyebrow, .login-footnote { font: 10px var(--mono); letter-spacing: .12em; }
.login-index { border-top: 3px solid var(--accent); display: inline-block; padding-top: 13px; }
.login-panel h1 { font-size: clamp(36px, 6vw, 64px); line-height: 1.06; font-weight: 600; letter-spacing: -.065em; margin: 26px 0 22px; }
.login-intro { line-height: 1.8; color: var(--muted); margin-bottom: 32px; }
.login-panel label { display: block; margin-bottom: 8px; font: 11px var(--mono); }
.login-fields { display: flex; gap: 10px; }
.login-fields input { min-width: 0; flex: 1; border: 1px solid var(--line); background: var(--surface); padding: 13px; }
.login-fields button { padding: 12px 18px; }
.login-footnote { border-top: 1px solid var(--line); margin-top: 48px; padding-top: 18px; color: var(--muted); font-size: 9px; }
.login-footnote span { margin: 0 8px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 290px; height: calc(100dvh - 76px); max-width: 1600px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.room { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.room-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 28px 18px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--muted); margin: 0 0 8px; font-size: 9px; }
.room-heading h1 { font-size: 23px; letter-spacing: -.04em; margin: 0; font-weight: 600; }
.room-subtitle { color: var(--muted); font-weight: normal; }
.notice { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #ede9da; border-bottom: 1px solid var(--line); padding: 9px 28px; font-size: 12px; line-height: 1.5; }
.notice button { flex-shrink: 0; }
.history-notice { background: #fae7bf; }
.feed-scroll { overflow-y: auto; flex: 1; min-height: 120px; padding: 0 28px 16px; scrollbar-gutter: stable; overflow-anchor: none; }
.history-toolbar { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 16px 0; min-height: 58px; }
#history-status { color: var(--muted); font: 10px var(--mono); }
.message { border-top: 1px solid var(--line); padding: 17px 0 18px; display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; }
.message-id { color: var(--muted); font: 9px var(--mono); padding-top: 4px; }
.message-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; line-height: 1.6; }
.message-name { font-size: 12px; font-weight: bold; overflow-wrap: anywhere; }
.kind { display: inline-block; font: 8px var(--mono); letter-spacing: .025em; padding: 3px 5px; border: 1px solid var(--line); white-space: nowrap; }
.human { color: #43310e; background: #f6e6be; border-color: #d3b77c; }
.agent { color: #42513e; background: #e7ecdf; border-color: #c6d0bd; }
.message-time { font: 9px var(--mono); color: var(--muted); margin-left: auto; }
.message-text { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; font-size: 13px; tab-size: 4; }
.message.is-self .message-id { color: var(--accent-dark); }
.empty-room { max-width: 320px; margin: 8vh auto; text-align: center; }
.empty-room > span { font: 28px var(--mono); color: #999f90; }
.empty-room h2 { font-size: 18px; font-weight: normal; letter-spacing: -.02em; margin-top: 23px; }
.empty-room p { font-size: 12px; color: var(--muted); line-height: 1.7; }
.latest-row { height: 0; position: relative; z-index: 1; display: flex; justify-content: center; }
.jump-latest { position: absolute; bottom: 12px; background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: 0 2px 8px #20282420; }
.jump-latest:hover:not(:disabled) { background: #414c42; color: var(--paper); }
.composer { background: var(--surface); border-top: 1px solid var(--ink); padding: 15px 28px 12px; }
.composer-heading { display: flex; justify-content: space-between; gap: 12px; font: 9px var(--mono); letter-spacing: .04em; margin-bottom: 9px; }
#composer-identity { color: var(--accent-dark); text-align: right; }
.composer textarea { display: block; width: 100%; resize: vertical; min-height: 66px; max-height: 25vh; line-height: 1.6; padding: 10px 12px; border: 1px solid var(--line); background: var(--paper); }
.composer textarea:disabled { color: var(--muted); }
.composer-footer { display: flex; gap: 15px; align-items: center; margin-top: 10px; }
#composer-hint, #byte-count { color: var(--muted); font: 9px var(--mono); }
#composer-hint span { margin: 0 5px; }
#byte-count { margin-left: auto; white-space: nowrap; }
#byte-count.over-limit { color: var(--danger); font-weight: bold; }
.form-error { color: var(--danger); font-size: 12px; line-height: 1.5; margin: 10px 0 0; }
.form-error:empty { display: none; }
.participants-panel { border-left: 1px solid var(--line); background: #eeeee5; padding: 24px 20px; overflow-y: auto; min-height: 0; }
.participants-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.participants-heading h2 { font-size: 16px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
#participant-count { font: 10px var(--mono); color: var(--muted); }
.participants-heading button { font-size: 17px; padding: 4px 9px; }
.directory-note, .directory-status { font-size: 10px; line-height: 1.7; color: var(--muted); }
.directory-note { margin: 15px 0 18px; }
.directory-status { margin: 0 0 10px; }
.participants { list-style: none; padding: 0; margin: 0; }
.participant { border-top: 1px solid var(--line); padding: 14px 0; }
.participant-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.participant-name { font-size: 11px; font-weight: bold; overflow-wrap: anywhere; }
.participant-activity { display: block; color: var(--muted); font: 9px var(--mono); line-height: 1.6; margin-top: 7px; }
.participant-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.revoke { min-height: 25px; font-size: 9px; padding: 4px 7px; color: var(--danger); }
.revoked-label { color: var(--danger); font: 9px var(--mono); }
.participant.is-revoked .participant-name { color: var(--muted); }
.directory-more { width: 100%; margin-top: 12px; }
.directory-legend { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 18px; }
.directory-legend p { font-size: 10px; line-height: 1.6; color: var(--muted); margin: 7px 0 16px; }
.mobile-only { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript { margin: 30px; }
@media (min-width: 1600px) { .masthead { padding-left: max(30px, calc((100vw - 1540px) / 2)); padding-right: max(30px, calc((100vw - 1540px) / 2)); } }
@media (max-width: 800px) {
  .masthead { height: 68px; padding: 0 16px; gap: 16px; }
  .brand small { display: none; }
  .brand { font-size: 11px; gap: 9px; }
  .brand-mark { font-size: 13px; padding: 9px 6px; }
  .connection { font-size: 9px; }
  #identity { display: none; }
  .session-controls { gap: 0; }
  .masthead .quiet { padding: 6px 8px; font-size: 10px; }
  .workspace { height: calc(100dvh - 68px); grid-template-columns: minmax(0, 1fr); position: relative; }
  .mobile-only { display: inline-block; }
  .participants-panel { display: none; position: absolute; right: 0; top: 83px; bottom: 0; width: min(310px, 90vw); z-index: 3; box-shadow: -8px 0 20px #20282418; }
  .participants-panel.is-open { display: block; }
  .room-heading { padding: 16px; }
  .room-heading h1 { font-size: 21px; }
  .feed-scroll { padding: 0 16px 12px; }
  .notice { padding: 9px 16px; }
  .composer { padding: 12px 16px; }
  .composer-heading { font-size: 8px; }
  .message { grid-template-columns: 34px minmax(0, 1fr); gap: 8px; }
  .message-time { width: 100%; margin-left: 0; }
  .composer-footer { gap: 10px; flex-wrap: wrap; }
  #composer-hint { width: 100%; order: 3; font-size: 8px; }
  #byte-count { margin-left: 0; }
  #send { margin-left: auto; }
}
@media (max-height: 580px) { .room-heading { padding-top: 10px; padding-bottom: 10px; } .composer textarea { min-height: 45px; } }
@media (prefers-reduced-motion: no-preference) { button { transition: background-color 120ms, border-color 120ms; } }
