/* Kyo live room: a branch register for local work around GitHub.
 *
 * The room is warm paper, and it shares its ink ramp with auth.css so that
 * signing in and arriving in the room are one surface rather than two. Warmth
 * is the brand and nothing else: it never encodes merge, build, or code health,
 * which live in GitHub. The only state colour here is the coral advisory, and
 * that says "your paths crossed", never "your code is broken".
 */
:root {
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --cloud: #e6e2da;
  --paper: #f2f0ec;
  --surface: #fbfaf7;
  --surface-tint: #ece6d9;
  --ink: #2a2622;
  --ink-2: #4a453c;
  --ink-3: #6a655c;
  --ink-4: #8a857c;
  --rule: #dcd8d0;
  --edge: #c5c0b8;
  --blue: #2456a8;
  --blue-dark: #1c4485;
  --coral: #b5533a;
  --coral-soft: #f6e9e2;
  --green: #3a7a4e;
  --amber: #a8722a;
  --purple: #7d3fa8;
  --focus: rgba(36, 86, 168, .32);
  --shadow: 0 12px 36px rgba(42, 38, 34, .12);
}

* { box-sizing: border-box; margin: 0; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

body {
  min-height: 100vh;
  background: var(--cloud);
  color: var(--ink-2);
  font: 14px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}

/* Header keeps service state and the GitHub boundary visible. */
.masthead {
  min-height: 58px;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--rule);
  background: rgba(242, 240, 236, .96);
  flex: none;
}
.brand-lockup { display: flex; align-items: baseline; gap: 8px; }
.brand {
  color: var(--ink);
  font: 700 20px/1 var(--display);
  letter-spacing: -.02em;
}
.brand-purpose {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.room-context { display: flex; align-items: center; gap: 8px; min-width: 0; }
.masthead-project {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-switcher {
  max-width: 170px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  font: 12px var(--ui);
}
.ws-switcher:hover { border-color: var(--edge); }
.masthead-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: 12px;
}
.truth-label {
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-3);
  white-space: nowrap;
}
.conn-state { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.conn-state .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-4);
}
.page.linked .conn-state .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(58, 122, 78, .14);
}

/* The room thesis is status, not product marketing. */
.lede {
  padding: 24px 42px 22px;
  border-bottom: 1px solid var(--rule);
  background:
    linear-gradient(90deg, rgba(42, 38, 34, .05), transparent 38%),
    var(--paper);
  flex: none;
}
.section-kicker {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.lede-line {
  max-width: 960px;
  margin-top: 4px;
  color: var(--ink);
  font: 400 clamp(25px, 3vw, 36px)/1.2 var(--display);
  letter-spacing: -.018em;
}
.lede-line .state { font-weight: 700; box-shadow: inset 0 -3px 0 var(--edge); }
.lede-line .who { font-family: var(--ui); font-size: .72em; }
.lede-note { color: var(--ink-3); font-size: 12px; }

/* The weave: one strand per teammate whose agent is live. Strands run parallel
 * and never converge — a crossing would read as merge or conflict truth, which
 * is GitHub's to tell. This draws presence and stops there. */
.weave-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
/* The viewBox lets the figure scale rather than push the lede sideways on a
 * narrow screen; height:auto keeps the strand spacing proportional. */
.weave { flex: 0 1 auto; min-width: 0; max-width: 100%; height: auto; overflow: visible; }
.weave-strand { fill: none; stroke-linecap: round; }
.weave-idle { fill: none; stroke: var(--edge); }
.weave-idle.near { stroke: #b5b0a8; }
.weave-knot { fill: var(--paper); stroke: var(--ink-4); stroke-width: 2; }
.weave-knot-mark { fill: var(--ink-4); font: italic 11px var(--display); }
.weave-label { fill: var(--ink-3); font: 10px var(--ui); }
.path {
  padding: 2px 6px;
  border-radius: 4px;
  background: #e7e2d8;
  color: var(--ink-2);
  font: 12px var(--mono);
  overflow-wrap: anywhere;
}
.who { font-weight: 750; }

/* Main room + coordination rail. */
.columns {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
}
.column-main {
  position: relative;
  min-width: 0;
  padding: 28px 42px 40px;
  border-right: 1px solid var(--rule);
  overflow-y: auto;
}
.column-aside {
  padding: 28px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  overflow-y: auto;
  background: #eeebe5;
}
.passage + .passage,
.activity,
.event + .passage {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.section-head {
  margin-bottom: 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}
.section-head h2 {
  margin-top: 2px;
  color: var(--ink);
  font: 700 20px/1.2 var(--display);
  letter-spacing: -.01em;
}
.section-head > p {
  max-width: 390px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: right;
}
.section-head.compact { align-items: center; margin-bottom: 10px; }
.section-head.compact h2 { font-size: 18px; }
.rail-note { margin: 0 0 14px; color: var(--ink-3); font-size: 12px; }
/* An empty rail describes what it will hold rather than reading as broken. */
.empty-note { color: var(--ink-4); font-size: 12.5px; font-style: italic; line-height: 1.55; }

/* Focused onboarding. */
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.step {
  min-width: 0;
  padding: 16px;
  display: flex;
  gap: 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.step.pending { opacity: .58; }
.step-n {
  width: 24px; height: 24px;
  display: grid; place-items: center; flex: none;
  border-radius: 50%;
  background: var(--surface-tint);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}
.step-title { color: var(--ink); font-weight: 750; }
.step-body { margin-top: 5px; color: var(--ink-3); font-size: 12.5px; }
.step-body .gate { color: var(--ink-4); }
.command {
  max-width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  background: var(--ink);
}
.command code {
  min-width: 0;
  flex: 1;
  color: #e8e2d4;
  font: 11px var(--mono);
  overflow-wrap: anywhere;
}
.command button {
  padding: 2px 6px;
  border: 1px solid #4a453c;
  border-radius: 4px;
  background: transparent;
  color: #a89f8c;
  font-size: 11px;
}

/* Paths crossed is intentionally the only coral surface. */
.event { margin-bottom: 28px; }
.alert-card {
  padding: 14px 16px;
  border: 1px solid #e3c3b4;
  border-left: 4px solid var(--coral);
  border-radius: 8px;
  background: var(--coral-soft);
}
.alert-card + .alert-card { margin-top: 8px; }
.alert-body { color: var(--ink-2); }
.alert-note { margin-top: 6px; color: #7d5344; font-size: 11.5px; }

/* Signature branch register: identity rail + Git metadata at a glance. */
.meanwhile {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.presence-card {
  position: relative;
  min-width: 0;
  padding: 14px 14px 14px 18px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--surface);
}
.presence-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--member-color);
}
.presence-card.offline::before { background: var(--edge); }
.presence-card.offline { background: transparent; }
.presence-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.presence-identity { display: flex; align-items: center; gap: 7px; min-width: 0; }
.you-label {
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.presence-service { color: var(--ink-4); font-size: 10.5px; white-space: nowrap; }
.session-row {
  margin-top: 10px;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--rule);
}
.git-head { min-width: 0; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.git-branch {
  min-width: 0;
  color: var(--ink);
  font: 600 11.5px var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.git-branch::before { content: "⑂ "; color: var(--blue); }
.git-sha { color: var(--ink-4); font: 10.5px var(--mono); }
.dirty {
  color: var(--amber);
  font-size: 9.5px;
  font-weight: 750;
  white-space: nowrap;
}
.watch, .link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: 650 11.5px var(--ui);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.idle-row, .unlinked-row { margin-top: 9px; color: var(--ink-4); font-size: 11.5px; }
.unlinked-row { color: var(--amber); }
.unlinked-row .link-btn { margin-left: 6px; }

/* Recent edits. */
.ticker { list-style: none; display: flex; flex-direction: column; }
.ticker li {
  min-width: 0;
  padding: 8px 0;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  border-bottom: 1px solid #e4e0d8;
  font-size: 12px;
}
.ticker .t-who { font-weight: 750; overflow: hidden; text-overflow: ellipsis; }
.ticker .t-path { color: var(--ink-2); font: 11.5px var(--mono); overflow-wrap: anywhere; }
.ticker .t-tool { color: var(--ink-4); font-size: 10.5px; }

/* Hand-offs and shared memory. */
.handoffs, .memory-rail { display: flex; flex-direction: column; }
.handoff-card { padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 12.5px; }
.handoff-card.mine { margin: 0 -10px; padding: 12px 10px; border-radius: 7px; background: var(--surface-tint); }
.h-title { color: var(--ink); font-weight: 750; }
.h-meta, .h-state { margin-top: 2px; color: var(--ink-4); font-size: 10.5px; }
.h-body { margin-top: 7px; color: var(--ink-2); white-space: pre-wrap; }
.h-actions { margin-top: 9px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.memory-rail { list-style: none; gap: 0; }
.memory-rail li {
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 12.5px;
}
.mk {
  margin-bottom: 3px;
  color: var(--ink-4);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.mk.decision { color: var(--blue); }
.mk.blocker { color: var(--coral); }
.mk.convention { color: var(--purple); }
.mk.status { color: var(--green); }
.memory-source { margin-top: 4px; color: var(--ink-4); font-size: 10px; }

/* Controls. */
.btn {
  padding: 8px 14px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 700 12px var(--ui);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-4); }
.btn:disabled { opacity: .48; cursor: default; }
.btn-accent { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn-accent:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.btn-ghost {
  padding: 4px 6px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-3);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-sm { padding: 5px 9px; font-size: 11px; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 13px var(--ui);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
a { color: var(--blue); }

/* Watching a thread replaces only the main work area. */
.thread {
  position: absolute;
  inset: 0;
  z-index: 5;
  padding: 28px 42px 22px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  animation: thread-in .16s ease-out;
}
@keyframes thread-in { from { opacity: 0; transform: translateY(4px); } }
.thread-head {
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
}
.thread-title { color: var(--ink); font: 700 19px var(--display); }
.aside-note { color: var(--ink-4); font: 11px var(--mono); }
#thread-events {
  min-height: 0;
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#thread-events li {
  max-width: 760px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#thread-events .k-user { color: var(--ink); font-weight: 700; }
#thread-events .k-tool_use, #thread-events .k-tool_result {
  color: var(--ink-4);
  font: 11px var(--mono);
}
#thread-events .k-result { color: var(--green); }
#thread-events .k-steer { color: var(--amber); }
#steer-form { padding-top: 12px; display: flex; gap: 8px; border-top: 1px solid var(--rule); }
#steer-text { min-width: 0; flex: 1; }

/* Dialog sheets. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 8vh 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  background: rgba(42, 38, 34, .44);
  animation: fade-in .14s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.sheet-card {
  width: 100%;
  max-width: 32rem;
  padding: 26px 28px 30px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h2 { flex: 1; color: var(--ink); font: 700 22px var(--display); }
.sheet-card h3 { margin: 22px 0 8px; color: var(--ink); font: 700 16px var(--display); }
.settings-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settings-row input, .settings-row select { min-width: 12rem; flex: 1; }
.settings-hint { margin: 8px 0 16px; color: var(--ink-3); font-size: 12px; }
.invite-result { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.invite-link { min-width: 0; flex: 1; color: var(--blue); font: 11px var(--mono); overflow-wrap: anywhere; }
.settings-members { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.settings-members li { color: var(--ink-2); font-size: 12.5px; }
.handoff-label { min-width: 4rem; color: var(--ink-3); font-size: 11px; }
#handoff-form .settings-row { margin-bottom: 9px; }
#handoff-form input, #handoff-form select, #handoff-form textarea { width: 100%; }

.toasts {
  position: fixed;
  top: 70px;
  right: 18px;
  z-index: 40;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 13px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-4);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12px;
}
.toast.ok { border-left-color: var(--green); }
.toast.failed { border-left-color: var(--coral); }

@media (max-width: 1000px) {
  .steps { grid-template-columns: 1fr; }
  .meanwhile { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .page { height: auto; overflow: visible; }
  .masthead { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand-lockup { flex: 1; }
  .room-context { order: 3; width: 100%; }
  .masthead-right { gap: 7px; }
  .truth-label, .account-email { display: none; }
  .lede { padding: 20px 18px; }
  .columns { display: block; }
  .column-main { padding: 24px 18px 30px; border-right: 0; overflow: visible; }
  .column-aside { padding: 26px 18px 36px; border-top: 1px solid var(--rule); overflow: visible; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .section-head > p { text-align: left; }
  .section-head.compact { flex-direction: row; align-items: center; }
  .thread { position: fixed; padding: 20px 18px; }
  .ticker li { grid-template-columns: 68px minmax(0, 1fr); gap: 8px; }
  .ticker .t-tool { display: none; }
  .presence-head { align-items: flex-start; }
  .presence-service { white-space: normal; text-align: right; }
  .toasts { top: auto; right: 12px; bottom: 12px; left: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
