/* Minimal Slack-like shell in boring-tool's "Quiet Ink" language:
   warm paper, ink text, hairlines, color only where it means something. */

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f4f3f0;
  --ink: #1c1c1a;
  --ink-2: #55554f;
  --muted: #8a897f;
  --hairline: #e9e8e3;
  --hairline-strong: #dbdad3;
  --radius: 8px;
  --font-ui: "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

/* ============ sidebar ============ */
.sidebar {
  border-right: 1px solid var(--hairline);
  background: var(--bg);
  height: 100vh;
  padding: 14px 10px;
  display: flex; flex-direction: column; gap: 14px;
}
.workspace { font-weight: 700; font-size: 15px; padding: 2px 8px; }
.side-section { flex: 1; overflow-y: auto; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 4px; color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.side-add {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 4px;
}
.side-add:hover { background: var(--surface-2); color: var(--ink); }
.chan-row {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 4px 8px; border: none; background: none; cursor: pointer;
  border-radius: 6px; color: var(--ink-2); font: inherit; text-align: left;
}
.chan-row:hover { background: var(--surface-2); }
.chan-row.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.chan-hash { color: var(--muted); }
.chan-row.archived { color: var(--muted); text-decoration: line-through; }

/* session footer: who I am, and the way out */
.session-footer {
  border-top: 1px solid var(--hairline); padding-top: 10px;
  display: flex; align-items: center; gap: 8px;
}
/* the alerts affordance above the footer: a real button, or honest iOS
   install instructions — never an auto-prompt on load */
.alerts-hint { color: var(--muted); font-size: 12px; padding: 0 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
}
.me-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.members .member-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 8px; color: var(--ink-2);
}
.members .member-row .avatar { width: 20px; height: 20px; font-size: 10px; }
.side-section.members { flex: none; max-height: 30vh; }

/* ============ main pane ============ */
.main { display: flex; flex-direction: column; height: 100vh; background: var(--surface); }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-bottom: 1px solid var(--hairline); min-height: 49px;
}
.crumb { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--ink); font-weight: 600; }
.crumb .sep { margin: 0 6px; color: var(--hairline-strong); }
.crumb-btn { background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.crumb-btn:hover { text-decoration: underline dotted var(--hairline-strong); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; }
.btn {
  font: inherit; padding: 5px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.pane { flex: 1; overflow-y: auto; padding: 16px 24px; }

/* channel view: the thread catalog */
.catalog { display: flex; flex-direction: column; border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; }
.catalog-row {
  display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  padding: 10px 14px; border: none; border-bottom: 1px solid var(--hairline);
  background: var(--surface); cursor: pointer; font: inherit;
}
.catalog-row:last-child { border-bottom: none; }
.catalog-row:hover { background: var(--surface-2); }
.catalog-name { font-weight: 600; }
.catalog-name.untitled { color: var(--muted); font-weight: 400; font-style: italic; }
.catalog-when { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* thread view: messages */
.msg { display: flex; gap: 10px; padding: 6px 0; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; }
.msg-when { color: var(--muted); font-size: 12px; }
.msg-edited { color: var(--muted); font-size: 11px; }
.msg-content { white-space: pre-wrap; overflow-wrap: break-word; }
.msg-tombstone { color: var(--muted); font-style: italic; }
.msg-actions { visibility: hidden; display: flex; gap: 2px; margin-left: auto; }
.msg:hover .msg-actions { visibility: visible; }
.msg-act {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 12px; padding: 0 4px; border-radius: 4px;
}
.msg-act:hover { background: var(--surface-2); color: var(--ink); }

/* composer */
.composer-wrap { padding: 8px 24px 18px; }
.composer {
  border: 1px solid var(--hairline-strong); border-radius: var(--radius);
  background: var(--surface);
}
.composer:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(28, 28, 26, .06); }
.composer textarea {
  width: 100%; border: none; background: none; resize: none; font: inherit;
  color: var(--ink); padding: 10px 14px 4px; outline: none; min-height: 40px; display: block;
}
.composer-bar { display: flex; justify-content: space-between; align-items: center; padding: 2px 8px 8px 14px; }
.composer-hint { color: var(--muted); font-size: 11px; }

/* replies: the quoted original above a reply's content */
.msg-quote {
  display: block; max-width: 540px; text-align: left;
  margin: 1px 0 3px; padding: 2px 10px;
  background: var(--surface-2); border: none; border-left: 2px solid var(--hairline-strong);
  border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 12.5px;
  color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-quote:hover { border-left-color: var(--ink); }
.msg-replies {
  background: var(--surface-2); border: none; border-radius: 10px;
  color: var(--ink-2); cursor: pointer; font-family: inherit; font-size: 11.5px;
  padding: 0 8px; line-height: 18px;
}
.msg-replies:hover { color: var(--ink); background: var(--hairline); }
.msg-quote .quote-author { font-weight: 600; margin-right: 6px; }
.msg-quote.muted, .quote-snippet.muted { color: var(--muted); font-style: italic; cursor: default; }
.reply-chip {
  display: flex; align-items: center; gap: 4px;
  font-size: 12.5px; color: var(--ink-2); padding: 0 4px 6px;
}
.reply-chip .quote-snippet {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px;
}
.chip-x {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 0 4px; margin-left: auto;
}
.chip-x:hover { color: var(--ink); }

/* jump-to-message */
.msg.target {
  background: #fdf6e3;
  border-radius: var(--radius);
  outline: 1px solid #f0e6c8;
}
.island-edge {
  display: block; width: 100%; text-align: center;
  color: var(--muted); font-size: 12px; padding: 10px 0;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.island-edge:hover { color: var(--ink); }
.jump-latest {
  position: absolute; bottom: 96px; right: 28px; z-index: 5;
  box-shadow: 0 2px 8px rgba(28, 28, 26, .15);
}
.main { position: relative; }

.toast {
  position: fixed; bottom: 16px; right: 16px; max-width: 380px;
  background: var(--ink); color: var(--bg); padding: 10px 14px;
  border-radius: var(--radius); font-size: 13px; z-index: 10;
}

/* ============ auth + home screens ============ */
.screen {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg); overflow-y: auto;
}
.card {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.wordmark { font-weight: 700; font-size: 18px; }
.muted { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field-input {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline-strong); border-radius: 6px; padding: 8px 10px;
}
.field-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(28, 28, 26, .06); }
.form-error { color: #9d174d; font-size: 12.5px; }
.btn.wide { width: 100%; padding: 8px 12px; }
.btn:disabled { opacity: .6; cursor: default; }
.home-section { display: flex; flex-direction: column; gap: 4px; }
.row, .row-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 6px;
  background: var(--surface); font: inherit; text-align: left;
}
.row-btn { cursor: pointer; }
.row-btn:hover { background: var(--surface-2); }
.row-btn:disabled { color: var(--muted); cursor: default; }

/* ---------------------------------------------------------------------------
   links and runs.

   A message's declared links render as chips; an `agent:run.*` chip opens the
   run panel. Nothing here is an "agent message" style, deliberately — an
   agent's reply is an ordinary message by a principal, and the moment it has a
   render path of its own, agents have stopped being principals. */

.msg-links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.link-chip {
  font: inherit; font-size: 11px; line-height: 1.4;
  padding: 1px 7px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.link-chip:hover { color: var(--fg); border-color: var(--accent); }

.run-panel {
  border: 1px solid var(--line); border-radius: 8px;
  margin: 8px 12px 0; background: var(--surface); font-size: 13px;
}
.run-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.run-head .chip-x { margin-left: auto; }
.run-status { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); }
.run-running { color: var(--accent); border-color: var(--accent); }
.run-failed, .run-expired { color: #b4462a; border-color: #b4462a; }
.run-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.run-meta, .run-dead { color: var(--muted); padding: 8px 10px; }
.run-reason { color: #b4462a; margin-top: 2px; }
/* Lossy by contract: the commentary is a hint stream, kept nowhere. */
.run-progress {
  max-height: 140px; overflow-y: auto; font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px;
}
.run-tick { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-acts { display: flex; gap: 6px; }
