/* AgentMsg console — Slack-style layout: dark frame (top bar + sidebar), light reading area.
   Colors are tokens; dark mode follows the system. */

:root {
  /* reading area */
  --bg: #ffffff;
  --surface: #f6f7fb;
  --surface-2: #eef0f6;
  --text: #1b1f2c;
  --muted: #6a7084;
  --line: #e5e7ee;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #ffffff;
  --accent-soft: #eef0ff;
  --unread: #f7f7ff;
  --warn-bg: #fff7e0;
  --warn-line: #f2cc60;
  --danger: #d14343;
  --green: #22a55a;
  --blue: #3b82f6;
  --amber: #e5a00d;
  --gray: #9aa1b2;
  --code-bg: #f3f4f8;
  --code-line: #e3e6ee;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 6%);
  /* frame: top bar and sidebar */
  --frame: #1b1d2a;
  --frame-2: #262938;
  --frame-3: #31354a;
  --frame-text: #e8e9f1;
  --frame-muted: #9ea3b8;
  --frame-active: #4f46e5;
  --radius: 10px;
  --mono: ui-monospace, 'Cascadia Code', 'Cascadia Mono', Consolas, 'SF Mono', monospace;
  /* Latin letters in the system UI font; Chinese in each system's Traditional Chinese UI font:
     PingFang TC (Apple), Microsoft JhengHei UI (Windows, tighter line spacing than plain JhengHei),
     Noto Sans TC / Noto Sans CJK TC (Android, Linux). */
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei UI', 'Microsoft JhengHei', 'Noto Sans TC', 'Noto Sans CJK TC',
    system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* Text size chosen in the top bar (everything is sized in rem). */
:root.text-s {
  font-size: 13px;
}

:root.text-l {
  font-size: 15.5px;
}

:root {
  background: var(--bg);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191f;
    --surface: #1e2129;
    --surface-2: #252935;
    --text: #e5e7ee;
    --muted: #9aa0b4;
    --line: #2b2f3b;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-text: #14162a;
    --accent-soft: #262a4a;
    --unread: #1d2030;
    --warn-bg: #362d14;
    --warn-line: #7d6420;
    --danger: #f07a7a;
    --code-bg: #12141a;
    --code-line: #2b2f3b;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 16px rgb(0 0 0 / 30%);
    --frame: #101118;
    --frame-2: #1b1d27;
    --frame-3: #262938;
    --frame-active: #5b54e8;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

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

a {
  color: var(--accent);
}

/* ---------- buttons & inputs ---------- */

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 12px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

button:hover {
  background: var(--surface);
}

button:focus-visible,
a:focus-visible,
.act:focus-within,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.link {
  border: none;
  background: none;
  padding: 2px 4px;
  color: var(--accent);
}

button.link:hover {
  text-decoration: underline;
}

button.danger,
.act.danger {
  color: var(--danger);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

input,
textarea,
select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.88em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
}

.strong {
  font-weight: 600;
}

.grow {
  flex: 1;
  min-width: 0;
}

.boot {
  padding: 40px;
  color: var(--muted);
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  flex: none;
}

/* ---------- auth / setup cards ---------- */

.card-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 16px 48px;
  background: var(--surface);
}

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%;
  max-width: 420px;
}

.card-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 18px;
}

.card h1 {
  font-size: 1.35rem;
  margin: 0 0 4px;
}

.card p {
  color: var(--muted);
  margin: 4px 0 16px;
}

.card label {
  display: block;
  margin: 12px 0 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.card .actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.error {
  color: var(--danger);
  margin-top: 10px;
  white-space: pre-wrap;
}

.fp {
  display: inline-block;
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  margin: 6px 0;
  letter-spacing: 0.03em;
}

/* ---------- layout ---------- */

.shell {
  display: grid;
  /* minmax(0, …): wide content (code, long names) scrolls inside, never widens the page */
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: 52px 1fr;
  height: 100vh;
  /* The visible height: on phones 100vh is the height with the address bar hidden, which made the
     page taller than the screen, so it scrolled and took the top bar (and its ☰) out of view. */
  height: 100dvh;
}

/* With the app shown, the page itself never scrolls: only the panes inside it do. */
html:has(.shell),
body:has(.shell) {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.shell > * {
  min-width: 0;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--frame);
  color: var(--frame-text);
  border-bottom: 1px solid var(--frame-2);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar .title {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar .spacer {
  flex: 1;
}

.topbar button.ghost,
.menu-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--frame-text);
  padding: 5px 10px;
}

.topbar button.ghost:hover,
.menu-toggle:hover {
  background: var(--frame-2);
}

.notify-toggle,
.topbar button {
  white-space: nowrap;
}

/* Header actions keep their size; on phones they wrap to a second row instead. */
.pane-head > button,
.pane-head > select {
  flex-shrink: 0;
  white-space: nowrap;
}

.md-h {
  font-weight: 700;
  margin: 8px 0 2px;
  line-height: 1.35;
}

.md-h1 {
  font-size: 1.25em;
}

.md-h2 {
  font-size: 1.12em;
}

.topbar .search {
  flex: 0 1 340px;
  min-width: 0;
  background: var(--frame-2);
  border: 1px solid var(--frame-3);
  color: var(--frame-text);
  border-radius: 8px;
  padding: 5px 10px;
}

.topbar .search::placeholder {
  color: var(--frame-muted);
}

.topbar .search:focus {
  background: var(--bg);
  color: var(--text);
}

.notify-toggle:not(.on) {
  border-color: var(--frame-3) !important;
}

.topbar .me {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: var(--frame-2);
  font-size: 0.9rem;
}

.menu-toggle {
  display: none;
  font-size: 1.1rem;
}

/* ---------- sidebar ---------- */

.sidebar {
  background: var(--frame);
  color: var(--frame-text);
  overflow-y: auto;
  padding: 10px 8px 24px;
  scrollbar-color: var(--frame-3) transparent;
}

.sidebar h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--frame-muted);
  margin: 18px 10px 6px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--frame-text);
  padding: 6px 10px;
  margin: 1px 0;
}

.side-item:hover {
  background: var(--frame-2);
}

.side-item.active {
  background: var(--frame-active);
  color: #fff;
}

.side-item.active .sub {
  color: rgb(255 255 255 / 75%);
}

.side-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.93rem;
}

.side-item .sub {
  display: block;
  color: var(--frame-muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--frame-2);
  color: var(--frame-muted);
  font-size: 0.85rem;
}

.side-item.active .side-icon {
  background: rgb(255 255 255 / 18%);
  color: #fff;
}

.side-icon.hash {
  font-weight: 700;
}

.side-empty {
  color: var(--frame-muted);
  font-size: 0.85rem;
  margin: 4px 10px;
}

.badge {
  background: #e5484d;
  color: #fff;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  padding: 1px 7px;
  flex: none;
}

.badge.warn {
  background: var(--amber);
  color: #1b1d2a;
}

/* ---------- avatars & status ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  background: var(--av, var(--gray));
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  user-select: none;
}

.avatar.human {
  border-radius: 50%;
}

.avatar.sm {
  width: 26px;
  height: 26px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.avatar.sm.human {
  border-radius: 50%;
}

.avatar.md {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
}

.av-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
}

.av-wrap .dot {
  position: absolute;
  right: -3px;
  bottom: -3px;
  border: 2px solid var(--frame);
}

.tile-row .av-wrap .dot {
  border-color: var(--bg);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  background: var(--gray);
}

.dot.idle,
.dot.online {
  background: var(--green);
}

.dot.busy {
  background: var(--blue);
}

.dot.waiting_approval {
  background: var(--amber);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 4px rgb(229 160 13 / 30%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot.waiting_approval {
    animation: none;
  }
}

/* ---------- main pane ---------- */

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.pane-head {
  padding: 10px 20px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.pane-head h1 {
  font-size: 1.05rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-head .sub {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-head .side-icon {
  background: var(--surface-2);
  color: var(--muted);
}

.banner {
  margin: 12px 20px 0;
  padding: 10px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
}

.empty {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

/* ---------- messages ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 20px 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.divider span {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}

.divider.new {
  color: #e5484d;
}

.divider.new::before,
.divider.new::after {
  background: #e5484d;
  opacity: 0.5;
}

.divider.new span {
  border-color: #e5484d;
}

.msg {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 12px;
  padding: 8px 20px 6px;
  border-left: 3px solid transparent;
}

.msg.compact {
  padding-top: 1px;
  padding-bottom: 3px;
}

.msg:hover,
.msg.confirming {
  background: var(--surface);
}

/* The "新訊息" divider marks where unread messages start; each one only gets a faint line. */
.msg.unread {
  border-left-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.gutter {
  padding-top: 2px;
}

.hover-time {
  display: block;
  visibility: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
  padding-top: 4px;
  white-space: nowrap;
}

.msg:hover .hover-time {
  visibility: visible;
}

.msg-body {
  min-width: 0;
}

.msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 0.8rem;
  margin-bottom: 1px;
}

.msg-head .sender {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}

.pill {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0 7px;
}

.pill.room {
  color: var(--muted);
  background: var(--surface-2);
}

.thread {
  border: none;
  background: none;
  padding: 0 4px;
  font-size: 0.75rem;
  color: var(--muted);
  border-radius: 4px;
}

.thread:not(:disabled):hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.thread:disabled {
  opacity: 1;
}

.msg .text {
  overflow-wrap: anywhere;
  font-size: 0.965rem;
  line-height: 1.6;
  /* Long lines are hard to read: about 50 Chinese characters at most. */
  max-width: 52em;
}

.msg .text > * + * {
  margin-top: 6px;
}

.para {
  white-space: pre-wrap;
}

.md-list {
  margin: 0;
  padding-left: 1.4em;
}

.md-list li {
  margin: 1px 0;
  white-space: pre-wrap;
}

.md-list li::marker {
  color: var(--muted);
}

.md-tag {
  font-weight: 700;
}

code.inline {
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  border-radius: 5px;
  padding: 0 4px;
  font-size: 0.85em;
  white-space: pre-wrap;
}

.code {
  position: relative;
  margin: 6px 0;
  max-width: 920px;
}

.code pre {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
}

.code .copy {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.72rem;
  padding: 2px 8px;
  opacity: 0;
  background: var(--bg);
}

.code:hover .copy,
.code .copy:focus-visible {
  opacity: 1;
}

.msg-actions {
  position: absolute;
  top: -12px;
  right: 20px;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 1;
}

.msg:hover .msg-actions,
.msg:focus-within .msg-actions,
.msg.confirming .msg-actions {
  display: flex;
}

.act {
  border: none;
  background: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.act:hover {
  background: var(--surface-2);
  color: var(--text);
}

.act.danger:hover {
  color: var(--danger);
}

.act.emoji {
  padding: 3px 5px;
  font-size: 0.95rem;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.reaction {
  font-size: 0.8rem;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.reaction.mine {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.confirm {
  font-size: 0.8rem;
  padding: 0 6px;
}

/* ---------- attachments ---------- */

.atts {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.file:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.file-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
}

.file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.85rem;
}

.file-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta .muted {
  font-size: 0.75rem;
}

.image-att {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-att img {
  display: block;
  max-width: min(420px, 100%);
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* ---------- composer ---------- */

.composer {
  padding: 0 20px 16px;
}

.composer > .note {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.composer-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.composer-box:focus-within {
  border-color: var(--accent);
}

.composer-box textarea {
  display: block;
  border: none;
  border-radius: 0;
  background: transparent;
  resize: none;
  min-height: 46px;
  max-height: 260px;
  padding: 12px 14px 6px;
  line-height: 1.5;
  outline: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 8px;
}

.composer-bar .hint {
  color: var(--muted);
  font-size: 0.75rem;
}

.composer-bar .primary {
  padding: 5px 16px;
}

.composer-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}

.info-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  max-width: 100%;
  overflow: hidden;
}

.chip-x {
  border: none;
  background: none;
  padding: 0 6px;
  color: inherit;
  border-radius: 999px;
}

.chip-x:hover {
  background: rgb(0 0 0 / 8%);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 12px 0;
}

.chip {
  font-size: 0.78rem;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.attach {
  display: inline-flex;
  align-items: center;
}

/* ---------- dashboard ---------- */

.dashboard {
  padding: 28px 28px 40px;
  max-width: 1100px;
}

.hero h1 {
  font-size: 1.6rem;
  margin: 0;
}

.hero p {
  margin: 4px 0 0;
}

.dashboard .banner {
  margin: 16px 0 0;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.card-tile {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.card-tile h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
}

.tile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 6px 6px;
}

.tile-row:hover {
  background: var(--surface);
}

.tile-row .grow {
  display: flex;
  flex-direction: column;
}

.tile-row .grow > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-row .side-icon {
  background: var(--surface-2);
  color: var(--muted);
}

.tile-row .activity {
  color: var(--text);
  opacity: 0.85;
}

.state-pill {
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 8px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}

.state-pill.idle,
.state-pill.online {
  color: var(--green);
}

.state-pill.busy {
  color: var(--blue);
}

.state-pill.waiting_approval {
  color: #1b1d2a;
  background: var(--amber);
}

.listening {
  color: var(--green);
  font-size: 0.6rem;
}

.tile-alert {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.tips li {
  margin: 4px 0;
}

/* ---------- tasks ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  padding: 14px 20px;
  align-items: start;
}

.board-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 120px;
}

.board-col h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 2px 4px 10px;
}

.board-col .count {
  font-size: 0.72rem;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0 7px;
}

.task-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gray);
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.task-card.open {
  border-left-color: var(--amber);
}

.task-card.in_progress {
  border-left-color: var(--blue);
}

.task-card.done {
  border-left-color: var(--green);
}

.task-card.failed {
  border-left-color: var(--danger);
}

.task-main {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 10px 12px 8px;
}

.task-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.task-note {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 10px 6px;
  font-size: 0.82rem;
}

.task-actions button.link.danger {
  color: var(--danger);
  background: none;
}

.pill.task {
  border: none;
  cursor: pointer;
}

.pill.task.done {
  color: var(--green);
}

.pill.task.failed,
.pill.task.cancelled {
  color: var(--muted);
  background: var(--surface-2);
}

@media (max-width: 1000px) {
  .board {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
  }
}

@media (max-width: 560px) {
  .board {
    grid-template-columns: 1fr;
  }
}

/* ---------- alerts, forms ---------- */

.alert-list {
  padding: 8px 20px;
  max-width: 980px;
}

.alert-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.alert-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--amber);
}

.alert-row .text {
  overflow-wrap: anywhere;
}

.form-page {
  padding: 20px;
  max-width: 640px;
}

.form-page h2 {
  font-size: 1rem;
  margin: 24px 0 8px;
}

.form-page label {
  display: block;
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-page .row,
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.row select {
  width: auto;
  flex: 1;
  min-width: 200px;
}

.form-page .sub {
  color: var(--muted);
  font-size: 0.88rem;
}

.settings-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
}

.settings-title .side-icon {
  background: var(--surface-2);
  color: var(--muted);
}

.danger-zone {
  margin-top: 32px;
  padding: 14px 16px 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 5%, var(--bg));
}

.danger-zone h2 {
  margin-top: 0;
  color: var(--danger);
}

.danger-zone p {
  margin: 4px 0 8px;
  font-size: 0.9rem;
}

button.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}

button.danger-solid:hover:not(:disabled) {
  filter: brightness(1.08);
  background: var(--danger);
}

.check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
}

.check input {
  width: auto;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.note {
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--frame);
  color: var(--frame-text);
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: 90vw;
  z-index: 20;
  font-size: 0.9rem;
}

/* ---------- touch screens: actions stay visible ---------- */

@media (hover: none) {
  /* Hidden until the message is tapped (or a delete is being confirmed); a tap leaves a sticky :hover. */
  .msg-actions,
  .msg:hover .msg-actions,
  .msg:focus-within .msg-actions {
    display: none;
  }
  .msg.selected .msg-actions,
  .msg.confirming .msg-actions {
    display: flex;
  }
  .msg.selected {
    background: var(--surface);
  }
  .msg-actions {
    position: static;
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
    box-shadow: none;
  }
  .hover-time {
    visibility: visible;
  }
  .code .copy {
    opacity: 1;
  }
}

/* ---------- phones ---------- */

@media (max-width: 800px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .menu-toggle {
    display: inline-block;
  }
  .topbar {
    gap: 6px;
    padding: 0 8px;
  }
  .topbar .title,
  .topbar .spacer,
  .notify-label,
  .text-size-label {
    display: none;
  }
  .topbar .search {
    flex: 1 1 auto;
  }
  .pane-head {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .pane-head .grow {
    flex: 1 1 160px;
  }
  .pane-head > select {
    flex-shrink: 1;
    min-width: 0;
  }
  .topbar button.ghost {
    padding: 5px 7px;
  }
  .sidebar {
    display: none;
    position: fixed;
    inset: 52px 0 0 0;
    z-index: 5;
  }
  .shell.menu-open .sidebar {
    display: block;
  }
  .topbar .me-name,
  .composer-bar .hint {
    display: none;
  }
  .topbar .me {
    padding: 3px;
  }
  .msg {
    padding-left: 12px;
    padding-right: 12px;
    column-gap: 10px;
  }
  .pane-head,
  .composer {
    padding-left: 12px;
    padding-right: 12px;
  }
  .divider {
    margin-left: 12px;
    margin-right: 12px;
  }
  .dashboard {
    padding: 20px 14px 32px;
  }
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- scheduled messages ---------- */

.schedule-picker {
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.85rem;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.sched-page {
  padding: 8px 20px 20px;
}

.sched-page h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 0 8px;
}

.sched-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--bg);
}

.sched-row.cancelled,
.sched-row.sent {
  opacity: 0.7;
}

.sched-when {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 110px;
}

.sched-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 2px;
}

@media (max-width: 560px) {
  .sched-row {
    flex-wrap: wrap;
  }
}

/* ---------- shared notes ---------- */

.note-page {
  padding: 16px 24px 32px;
}

.note-text {
  max-width: 860px;
  line-height: 1.6;
}

.note-row {
  width: 100%;
}

.note-editor {
  width: 100%;
  min-height: 320px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.9rem;
  line-height: 1.5;
}

.pane-head select {
  max-width: 260px;
}

/* ---------- daily digest ---------- */

.digest-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.digest-stat {
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 10px;
}

.digest-num {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-tile {
  min-width: 0;
}

.digest-rooms .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digest-rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.digest-icon {
  width: 22px;
  text-align: center;
}


.composer-bar .act,
.composer-bar .hint,
.composer-bar button.primary {
  white-space: nowrap;
}

/* Touch screens: action links that send signed messages get a finger-sized target. */
@media (pointer: coarse) {
  .task-actions button,
  .sched-row button.link {
    min-height: 36px;
    padding: 6px 10px;
  }
  /* Phones zoom the page into a field whose text is smaller than 16px. */
  input,
  textarea,
  select {
    font-size: 16px;
  }
}

/* ---------- display names ---------- */

.names-page {
  padding: 8px 20px 24px;
  max-width: 760px;
}

.names-page h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 18px 0 8px;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.name-row .name-id {
  display: flex;
  flex-direction: column;
  min-width: 170px;
  margin: 0;
}

.name-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.name-row button {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .name-row {
    flex-wrap: wrap;
  }
  .name-row .name-id {
    min-width: 100%;
  }
}

/* A computer running an AgentMsg version older than the newest release. */
.outdated {
  color: var(--danger);
  font-weight: 600;
}

/* Text size switch in the top bar: "A" and the current size. */
.text-size {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.text-size-a {
  font-weight: 700;
  font-size: 1.05rem;
}

.text-size-label {
  font-size: 0.85rem;
}

/* ---------- account keys (a hub) ---------- */

/* The recovery code and the pairing code: large, easy to copy by hand and compare. */
.fp.recovery-code {
  display: block;
  font-size: 1.15rem;
  line-height: 1.7;
  word-spacing: 0.3em;
  text-align: center;
  user-select: all;
}

.fp.pairing-code {
  display: block;
  font-size: 2rem;
  letter-spacing: 0.12em;
  text-align: center;
}

.card details {
  margin-top: 14px;
}

.card summary {
  cursor: pointer;
  color: var(--muted);
}

/* Devices waiting for approval: on top of every view, so they are not missed. */
.approvals {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.approval {
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.approval .actions {
  display: flex;
  gap: 8px;
}

/* The instructions for Claude Code on a new computer (to copy). */
textarea.join-text {
  width: 100%;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}
