/* === Mobile Terminal Optimization (phones) === */
@media (max-width: 480px) {
  :root {
    --header-height: 36px;
    --nav-height: 46px;
  }

  /* Header — compact */
  .app-header {
    gap: 6px;
    padding: 4px 10px;
    padding-top: calc(var(--safe-top) + 4px);
  }
  .header-logo { height: 22px; }
  .btn-icon { padding: 6px; min-height: 36px; min-width: 36px; }
  .header-profile { padding: 3px 8px; gap: 5px; }
  .header-user-name { font-size: 0.7rem; }

  /* Tmux tabs — tighter */
  .tmux-tabs { padding: 2px 6px; gap: 2px; }
  .tmux-tab { padding: 4px 10px; min-height: 30px; font-size: 0.72rem; }
  .tmux-tab-add { padding: 4px 10px; }
  .tmux-tab-clear { padding: 4px 8px; font-size: 0.68rem; }
  .tmux-tab-bar { font-size: 0.6rem; padding: 1px 4px; margin-left: 6px; }

  /* Special keys — compact */
  .special-keys { padding: 2px 6px; gap: 3px; }
  .skey { padding: 4px 8px; min-width: 32px; min-height: 28px; font-size: 0.7rem; border-radius: 5px; }
  .skey-clip { padding: 4px 8px; }
  .skey-clip svg { width: 12px; height: 12px; }

  /* Chat bar — compact */
  .chat-bar { padding: 4px 8px; gap: 6px; }
  .chat-bar textarea { padding: 6px 12px; font-size: 0.82rem; border-radius: 16px; }
  .chat-bar-send, .chat-bar-mic { width: 32px; height: 32px; }
  .chat-bar-send svg, .chat-bar-mic svg { width: 16px; height: 16px; }

  /* Status bar — minimal */
  .terminal-status { padding: 1px 10px; font-size: 0.65rem; }

  /* Bottom nav — compact but visible */
  .nav-btn { padding: 4px 8px; min-height: 40px; font-size: 0.55rem; gap: 2px; }
  .nav-btn svg { width: 24px; height: 24px; }
}

/* === DM Conversation List === */
.dm-convo-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dm-convo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  /* Slack-density rows: .dm-convo-item-scoped override of .card's 16px
     padding — applies to every row carrying this class (convo list AND
     search-result rows in the same panel); the shared .card component
     itself is untouched. 4px vertical + 26px avatars lands rows ~44px. */
  padding: 4px 10px;
}
.dm-convo-item:active { background: var(--glass-hover); }
.dm-convo-info { flex: 1; min-width: 0; }
.dm-convo-name {
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dm-convo-preview {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.dm-convo-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 12px;
}

/* === Sectioned sidebar (Pinned / Direct messages / Rooms) === */
.dm-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
}
.dm-section-chevron {
  display: inline-flex;
  font-size: 0.55rem;
  transition: transform 0.15s ease;
}
.dm-section.is-collapsed .dm-section-chevron { transform: rotate(-90deg); }
/* Aggregate unread pip only reads while collapsed — expanded rows carry their own. */
.dm-section:not(.is-collapsed) .dm-section-unread { display: none; }
.dm-section-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dm-unread-pip {
  background: var(--accent-red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.dm-header-actions { display: flex; align-items: center; gap: 4px; }

/* === DM Search === */
.dm-search {
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.dm-search.hidden { display: none; }
.dm-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.dm-search input:focus { border-color: var(--accent-red); }
.dm-search input::placeholder { color: var(--text-muted); }
.dm-search-from { color: var(--text-secondary); font-weight: 500; }

/* === DM User Picker === */
.dm-user-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.dm-pick-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.dm-pick-user:active { background: var(--glass-hover); }
.dm-pick-name { font-size: 0.9rem; font-weight: 600; }
.dm-pick-handle { font-size: 0.8rem; color: var(--text-muted); }

.dm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* === DM Thread === */
.dm-thread {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.dm-msg-menu {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 14px;
  opacity: 0.35;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity 0.15s;
  color: var(--text-muted);
  /* Reset default <button> chrome — general.js:670 renders this class on a
     <button> and iOS PWA fills in grey rounded background + border on any
     unstyled button. The rules below were written for the <div> path in
     messages.js:2639 and never reset those UA defaults, so the button-path
     twin looked wrong on iOS. background/border/appearance flatten the
     chrome; font-family/line-height/letter-spacing keep the ⋮ glyph
     rendering identical to the <div> path. Task ecfde453 pick B. */
  background: transparent;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  line-height: 1;
  letter-spacing: 2px;
}
.dm-msg:hover .dm-msg-menu { opacity: 0.85; }
.dm-msg-menu:hover { opacity: 1 !important; background: rgba(255,255,255,0.1); }
/* The ⋯ is now the trigger for Forward on every message plus Preview/Open on
   attachments and Delete (admin OR sender) — a universal glyph, not a hover-
   only reveal. Base opacity keeps it discoverable on desktop; touch bumps it
   for finger reach; hover on the message and on the button escalate from there. */
@media (hover: none) { .dm-msg-menu { opacity: 0.65; } }
/* Bot-DM panel — two view modes on the room thread. Messages are tagged
   .dm-route-panel at render (predicate v2, see classifyMsgRoute); the toggle
   flips .dm-panel-mode on #dm-thread. MAIN (default) hides panel-routed
   messages; PANEL shows ONLY them. Known v1 cosmetic: a date separator whose
   whole day is hidden by the active mode still renders. */
#dm-thread:not(.dm-panel-mode) .dm-route-panel { display: none; }
#dm-thread.dm-panel-mode > .dm-msg:not(.dm-route-panel),
#dm-thread.dm-panel-mode > .dm-msg-row:not(.dm-route-panel) { display: none; }
.dm-panel-btn { position: relative; }
.dm-panel-btn-active { color: var(--accent-red); background: rgba(255, 107, 107, 0.12); border-radius: 6px; }
/* Bot-activity pulse — loops while the class is present (JS re-arms a removal
   timer per live panel-routed arrival, so sustained chatter = sustained
   pulsing, decaying after the last message). Gentle scale + glow. */
.dm-panel-btn-pulse { animation: dm-panel-pulse 1.2s ease-in-out infinite; }
/* Amber since the Pit Wall reskin (#359) — red = dead in the status language.
   SINGLE definition: the reskin section aliases it, never redefines it. */
@keyframes dm-panel-pulse {
  0%, 100% { transform: scale(1); text-shadow: none; }
  50% { transform: scale(1.18); text-shadow: 0 0 10px rgba(254,202,87,0.8); color: var(--fleet-your-move); }
}
@media (prefers-reduced-motion: reduce) {
  .dm-panel-btn-pulse { animation: none; color: var(--accent-red); }
}
.dm-msg-self {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.22), rgba(255, 107, 107, 0.16));
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-bottom-right-radius: 4px;
}
.dm-msg-other {
  align-self: flex-start;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
}
/* Read receipt ("Seen" / "Seen by N") — hangs under my last sent message,
   right-aligned to match .dm-msg-self. Muted, small, non-interactive. */
.dm-receipt {
  align-self: flex-end;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.75;
  margin: 2px 4px 2px 0;
  -webkit-user-select: none;
  user-select: none;
}
/* Room receipt: a room self bubble sits in a .dm-msg-row [bubble][avatar], but
   the receipt is a sibling of the ROW in the thread column, so flex-end aligns
   it under the AVATAR. Offset it left by the avatar column (32px width + 10px
   row gap = 42px) so it lines up under the bubble's right edge instead. */
.dm-receipt-room {
  margin-right: 42px;
}
.dm-msg-sender { font-size: 0.75rem; font-weight: 700; margin-bottom: 4px; letter-spacing: 0.01em; }
.dm-msg-content { white-space: pre-wrap; -webkit-user-select: text; user-select: text; }
.dm-msg-sender { -webkit-user-select: text; user-select: text; }
.dm-msg { -webkit-user-select: text; user-select: text; cursor: text; }
.dm-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.7;
}
.dm-msg-self .dm-msg-time { text-align: right; }

/* === Room DM messages get an avatar column === */
/* The row wraps the bubble + avatar so max-width math still works. BOTH self
   and other room messages are wrapped (createBubble): other = [avatar][bubble]
   on the left, self = [bubble][avatar] on the right. Peer 1-on-1 DMs are NOT
   wrapped — the thread header already carries the peer's identity. */
.dm-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
}
.dm-msg-row-other { align-self: flex-start; }
.dm-msg-row-self { align-self: flex-end; }
.dm-msg-row .dm-msg {
  max-width: 100%;
  flex: 1 1 auto;
  min-width: 0;
}
.dm-msg-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-top: 2px;
  box-shadow: 0 0 0 2px var(--sender-color, var(--glass-border)), 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}
.dm-msg-avatar:hover {
  transform: scale(1.06);
}
.dm-msg-avatar .avatar {
  width: 100% !important;
  height: 100% !important;
}

/* === Fresh-message entry animation === */
/* Only applied to bubbles whose msg.created is within the last 5s so the
   initial thread render doesn't stampede with animations. */
@keyframes dmBubbleEnter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.dm-msg-entering {
  animation: dmBubbleEnter 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dm-msg-row-entering .dm-msg {
  animation: dmBubbleEnter 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dm-msg-row-entering .dm-msg-avatar {
  animation: dmBubbleEnter 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .dm-msg-entering,
  .dm-msg-row-entering .dm-msg,
  .dm-msg-row-entering .dm-msg-avatar {
    animation: none;
  }
  .dm-msg-avatar { transition: none; }
}

/* CLI message indicator */
.dm-msg-cli { border-left: 2px solid var(--accent-red); }

/* Auto-linked URLs */
.dm-link { color: var(--accent-red); text-decoration: underline; word-break: break-all; }

/* === Collapsible bot-detail block === */
/* Rendered when a DM contains the `---` + `[bot-detail]` marker defined in
   ~/CLAUDE.md ("Human-readable headline first, bot-speak below"). Human portion
   renders normally; bot portion collapses behind a PASS/FAIL badge + chevron. */
.dm-bot-detail {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--glass-border);
}
.dm-msg-content + .dm-bot-detail { margin-top: 10px; }

.dm-bot-detail-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  min-height: 36px; /* Mobile touch target */
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.75rem;
  transition: background 0.12s ease;
}
.dm-bot-detail-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.dm-bot-detail-header:focus-visible {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}

.dm-bot-detail-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  line-height: 1.2;
  flex-shrink: 0;
}
.dm-bot-detail-badge-pass {
  background: rgba(46, 213, 115, 0.15);
  color: #2ed573;
  border: 1px solid rgba(46, 213, 115, 0.4);
}
.dm-bot-detail-badge-fail {
  background: rgba(255, 107, 107, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(255, 107, 107, 0.4);
}

.dm-bot-detail-chevron {
  display: inline-block;
  transition: transform 0.18s ease;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
}
.dm-bot-detail[data-collapsed="false"] .dm-bot-detail-chevron {
  transform: rotate(180deg);
}

.dm-bot-detail-body {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-user-select: text;
  user-select: text;
}
.dm-bot-detail-body[hidden] { display: none; }

/* Code blocks */
.dm-code-block {
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}
.dm-code-lang {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid var(--glass-border);
}
.dm-code-block pre {
  margin: 0;
  padding: 10px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.dm-code-block code { font-family: 'SF Mono', 'Menlo', monospace; color: var(--text-primary); }

/* File attachment card */
.dm-file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.2s;
}
.dm-file-card:active { background: rgba(255,255,255,0.12); }
.dm-file-icon { font-size: 20px; }
.dm-file-name { flex: 1; font-weight: 500; word-break: break-word; }
.dm-file-size { font-size: 12px; color: var(--text-muted); }

/* Artifact-DM card (P1 T3a). First-class card, distinct from .dm-file-card —
 * artifacts are interactive review surfaces, not passive file previews. */
.artifact-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s;
}
.artifact-card:active { background: rgba(255,255,255,0.12); }
.artifact-card-title { font-weight: 600; word-break: break-word; }
.artifact-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.artifact-card-version {
  padding: 2px 8px; background: rgba(255,255,255,0.08);
  border-radius: 999px; font-weight: 500;
}
.artifact-card-parent-chip {
  padding: 2px 8px; background: rgba(255,255,255,0.04);
  border-radius: 999px; color: var(--text-muted);
}
.artifact-card-open {
  align-self: flex-start;
  padding: 6px 14px; border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg); color: var(--text-primary);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit;
}
.artifact-card-open:active { background: var(--glass-hover); }

/* Artifact-DM overlay (P1 T3b). Full-pane sandboxed-iframe host — same
 * lifecycle idioms as .preview-overlay (fixed inset, backdrop tap → close,
 * ESC → close), but its own class so future divergence (annotation composer
 * in the footer at T4/T5) doesn't leak into the file-preview overlay. */
.artifact-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.95); z-index: 1000;
  display: flex; flex-direction: column;
  outline: none;
}
/* P2.5 docked mode — same DOM as the overlay, positioned as a left column
 * beside the DM sidebar (which lives at right 35%). Composer + pip strip
 * inside behave identically to overlay mode. Below the desktop breakpoint,
 * the .artifact-docked modifier is IGNORED and the overlay defaults back
 * to full-screen (the JS side also detects the viewport and only ever
 * emits .artifact-docked above 900px, but the media-query belt catches
 * the case where a docked overlay outlives a viewport resize down to
 * mobile). z-index below the sidebar's 150 so the chat sidebar visually
 * layers on top when they overlap during the transition. */
@media (min-width: 900px) {
  .artifact-overlay.artifact-docked {
    inset: auto;
    top: calc(var(--header-height) + var(--safe-top));
    left: 0;
    right: 35%;
    bottom: calc(var(--nav-height) + max(0px, env(safe-area-inset-bottom, 0px) - var(--viewport-bottom-gap)));
    z-index: 149;
    border-right: 1px solid var(--glass-border);
  }
}
.artifact-overlay-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.5); flex-shrink: 0;
}
.artifact-overlay-title {
  flex: 1; color: var(--text-primary);
  font-size: 0.95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.artifact-overlay-version {
  padding: 2px 8px; background: rgba(255,255,255,0.08);
  border-radius: 999px; color: var(--text-muted);
  font-size: 12px; flex-shrink: 0;
}
.artifact-overlay-close {
  background: none; border: none; color: white;
  font-size: 1.8rem; cursor: pointer;
  padding: 0 4px; line-height: 1; font-family: inherit;
  flex-shrink: 0;
}
.artifact-overlay-body {
  flex: 1; overflow: hidden; display: flex;
  background: rgba(0, 0, 0, 0.6);
  -webkit-overflow-scrolling: touch;
}
.artifact-frame {
  flex: 1; width: 100%; height: 100%;
  border: 0; background: #fff;
}
.artifact-overlay-footer {
  flex-shrink: 0; padding: 0;
  background: rgba(0, 0, 0, 0.5);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Done button + newer-version chip in the overlay header (P1 T5a / T4c). */
.artifact-overlay-done {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.artifact-overlay-done:disabled { opacity: 0.5; cursor: not-allowed; }
.artifact-overlay-done.has-notes {
  background: #2ed573; border-color: #2ed573; color: #000;
}
.artifact-overlay-newer {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f39c12;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.artifact-overlay-newer.hidden { display: none; }

/* Pip strip along the right edge of the overlay body (P1 T4a — worker's
 * recommended "bounds-preview strip" layout, not absolute-positioned pips,
 * so we sidestep cross-origin iframe scroll drift). */
.artifact-pip-strip {
  flex-shrink: 0;
  width: 44px;
  padding: 8px 4px;
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
  overflow-y: auto;
  background: rgba(0,0,0,0.35);
  border-left: 1px solid rgba(255,255,255,0.05);
}
.artifact-pip {
  width: 28px; height: 28px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.artifact-pip.saved { background: #2ed573; color: #000; border-color: #2ed573; }
.artifact-pip.pending { background: #f39c12; color: #000; border-color: #f39c12; }
/* P2 pip differentiator (spec §Change 4). Notes keep the T4 default look
 * (green circle) via the .saved rule above; decisions render as a distinct
 * blue square so the reviewer can tell them apart on the strip at a glance.
 * Note-pip class exists purely to opt IN to the future-safe override —
 * without it, .artifact-pip.saved's green still wins. */
.artifact-pip.decision-pip {
  background: #3742fa;
  color: #fff;
  border-color: #3742fa;
  border-radius: 4px;      /* square vs circle */
}

/* Author-hook for P2 decision buttons (spec §Change 1a). The shim adds this
 * class to every element carrying data-decision-id at load. Default styling
 * is intentionally minimal — the recommended CSS snippet in the spec is
 * paste-and-adapt in the bot's own artifact HTML; author owns the visual. */
.artifact-decision-affordance {
  /* No default paint. Authors override in-artifact. */
}

/* Annotation composer in the overlay footer (P1 T4a). Sticky-bottom on
 * mobile, inline on desktop; hidden by default until a shim payload arrives
 * or a saved pip is tapped for edit. */
.artifact-composer {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.artifact-composer.hidden { display: none; }
.artifact-composer-snippet {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}
.artifact-composer-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
}
.artifact-composer-nlabel {
  float: right;
  color: var(--text-muted);
  font-size: 11px;
}
.artifact-composer-comment {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.artifact-composer-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}
.artifact-composer-cancel,
.artifact-composer-save {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.artifact-composer-save {
  background: #2ed573; border-color: #2ed573; color: #000;
}
/* P2.5 Feature 2 — Share now button. Outlined amber signals "your move
 * now" without competing with Save's primary green. Sits BETWEEN Cancel
 * and Save so the tap-order reads Cancel → Share (light commitment,
 * one-off) → Save (heavier commitment, joins the batch). */
.artifact-composer-share {
  border-color: #feca57;
  color: #feca57;
  background: transparent;
}
.artifact-composer-share:active {
  background: rgba(254, 202, 87, 0.15);
}

/* Inline image preview in DM */
.dm-img-wrap { cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.dm-img-preview {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  object-fit: contain;
}
.dm-img-name {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline video preview in DM */
.dm-video-wrap { border-radius: 8px; overflow: hidden; }
.dm-video-preview {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

/* Inline audio preview in DM */
.dm-audio-wrap { display: flex; flex-direction: column; gap: 6px; }
.dm-audio-label { font-size: 13px; font-weight: 500; }
.dm-audio-wrap audio { width: 100%; max-width: 280px; }

/* PDF file card in DM — click to preview */
.dm-doc-wrap {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: background 0.15s;
}
.dm-doc-wrap:hover { background: rgba(255,255,255,0.1); }

.dm-text-preview-wrap {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}
.dm-text-header {
  padding: 8px 12px;
  font-size: 12px;
  opacity: 0.7;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dm-text-header:hover { opacity: 1; }
.dm-text-toggle {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.6;
}
/* "⛶ Open" full-preview button on a text attachment header — sits right of the
   inline ▶ Preview toggle, subtle until hover (matches the header's muted type). */
.dm-text-open {
  margin-left: 6px;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-size: 11px;
  opacity: 0.6;
  cursor: pointer;
}
.dm-text-open:hover { opacity: 1; }
.dm-text-preview {
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--text-primary);
}

/* DM drop zone */
.dm-sidebar-thread.dm-drop-active {
  outline: 2px dashed var(--accent-yellow);
  outline-offset: -2px;
  background: rgba(254, 202, 87, 0.05);
}


/* === DM Compose Bar (Instagram-style) === */
.dm-compose {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  flex-shrink: 0;
  background: #000;
  border: none;
}
/* Base rule keeps the env() term for surfaces that DO reach the screen edge
   (currently: none of the shipped views — both .dm-sidebar and #view-general
   override to plain 8px, since both sit above the .bottom-nav which owns the
   inset). Kept as the base rule for any future surface that IS bottom-edge. */
.dm-sidebar .dm-compose { padding-bottom: 8px; }
/* Same double-count strip as .dm-sidebar .dm-compose above: #view-general
   sits inside <main>, which sits above .bottom-nav — so the composer never
   reaches the screen edge, and .bottom-nav owns the home-indicator inset via
   its own padding-bottom. Extending the sidebar fix from #483 to #general;
   PR #483's "#general keeps the env() term" note was wrong. */
#view-general .dm-compose { padding-bottom: 8px; }
#view-general .dm-compose.has-refs { margin-bottom: 8px; }
.dm-compose textarea {
  flex: 1;
  padding: 10px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  margin: 0;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
}
.dm-compose textarea:focus { border-color: rgba(255, 255, 255, 0.25); }
.dm-compose textarea::placeholder { color: rgba(255, 255, 255, 0.35); }
.dm-send {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--accent-red);
  padding: 0;
}
.dm-send:active { opacity: 0.6; }
.dm-mic {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-muted);
  padding: 0;
  position: relative;
  transition: color 0.2s;
}
.dm-mic:active { opacity: 0.6; }
.dm-attach {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-muted);
  padding: 0;
  transition: color 0.2s;
}
.dm-attach:active { opacity: 0.6; }
.dm-attach-input { display: none; }
.dm-mic.recording {
  color: var(--accent-red);
  animation: mic-pulse 1s ease-in-out infinite;
}
.dm-mic.live {
  color: var(--accent-red);
  animation: mic-pulse 1.6s ease-in-out infinite;
  opacity: 0.85;
}
@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.dm-mic.transcribing { color: var(--accent-yellow); }
.dm-mic.mic-error { color: var(--accent-red); animation: mic-shake 0.3s ease-in-out; }
@keyframes mic-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.dm-mic-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: var(--accent-yellow);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dm-thread { background: linear-gradient(180deg, var(--bg-secondary) 0%, #0a0a14 100%); }

/* === Avatar === */
.avatar { line-height: 0; }
.avatar img { border-radius: 50%; }

/* === Presence Dots === */
.dm-convo-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  margin-right: 12px;
}
.presence-dot {
  position: absolute;
  /* Sized for the 26px convo-row avatar (was 10px on the 40px avatar);
     the slight negative offset keeps the dot readable on the smaller circle. */
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}
.presence-typing { background: var(--fleet-working, #2ed573); }
.presence-active { background: var(--fleet-your-move, #ffb400); }
.presence-idle { background: rgba(255,255,255,0.20); }

/* === Date Separator === */
.dm-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 6px;
}
.dm-date-separator::before,
.dm-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}
.dm-date-separator span {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* === Typing Indicator === */
.dm-typing-indicator {
  padding: 10px 14px !important;
  max-width: 70px !important;
}
.dm-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.dm-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s infinite ease-in-out;
}
.dm-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.dm-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* === Profile Dropdown === */
.header-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background 0.15s;
  position: relative;
}
.header-profile:hover { background: rgba(255,255,255,0.06); }

.profile-dropdown {
  position: absolute;
  top: calc(var(--header-height) + var(--safe-top) - 4px);
  left: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  z-index: 200;
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.profile-dropdown.hidden { display: none; }
.profile-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.profile-dropdown-info {
  flex: 1;
  min-width: 0;
}
#profile-dropdown-name {
  font-size: 0.95rem;
  font-weight: 600;
}
#profile-dropdown-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.profile-avatar-upload-btn {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: center;
  background: rgba(255,107,107,0.15);
  color: var(--accent-red);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.profile-avatar-upload-btn:hover { background: rgba(255,107,107,0.25); }
/* Hidden file input inside the upload label — uses opacity:0 + absolute
   positioning instead of the `hidden` attribute because iOS Safari and some
   Android browsers won't open a file picker for display:none inputs. */
.avatar-upload-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* === Sleep Monitor toasts === */
/* Non-blocking popup stack in the bottom-right corner. Admin-only. */
.sleep-monitor-stack {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom, 0px));
  display: flex;
  flex-direction: column-reverse; /* new toasts above older ones */
  gap: 10px;
  z-index: 400;
  pointer-events: none; /* children re-enable */
  max-width: calc(100vw - 32px);
}
.sleep-toast {
  pointer-events: auto;
  width: 320px;
  max-width: 100%;
  background: rgba(20, 20, 28, 0.92);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--accent-red);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  font-size: 0.85rem;
  color: var(--text-primary);
  animation: sleepToastEnter 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.sleep-toast-leaving {
  opacity: 0;
  transform: translateX(12px);
}
@keyframes sleepToastEnter {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.sleep-toast-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.sleep-toast-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.sleep-toast-title {
  flex: 1 1 auto;
  min-width: 0;
}
.sleep-toast-room {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-word;
}
.sleep-toast-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.sleep-toast-sev {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.sleep-toast-body {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 12px;
}
.sleep-toast-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.sleep-toast-actions button {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.sleep-toast-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.sleep-toast-btn-snooze {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
}
.sleep-toast-btn-snooze:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}
.sleep-toast-btn-sleep {
  background: var(--accent-red);
  border: 1px solid var(--accent-red);
  color: #fff;
  font-weight: 600;
}
.sleep-toast-btn-sleep:hover:not(:disabled) {
  background: #ff5050;
  border-color: #ff5050;
}

/* Severity color variants — override the left border + badge color */
.sleep-toast-warn {
  border-left-color: #feca57;
}
.sleep-toast-warn .sleep-toast-sev { color: #feca57; }
.sleep-toast-restart {
  border-left-color: #ff9f43;
}
.sleep-toast-restart .sleep-toast-sev { color: #ff9f43; }
.sleep-toast-critical {
  border-left-color: #ff3838;
}
.sleep-toast-critical .sleep-toast-sev { color: #ff3838; }
.sleep-toast-sleeping { opacity: 0.75; }

@media (prefers-reduced-motion: reduce) {
  .sleep-toast { animation: none; transition: none; }
}

@media (max-width: 600px) {
  .sleep-monitor-stack {
    right: 8px;
    left: 8px;
    bottom: calc(12px + var(--safe-bottom, 0px));
  }
  .sleep-toast { width: 100%; }
}

/* === Avatar crop editor === */
.avatar-crop-modal { text-align: center; }
.avatar-crop-viewport {
  position: relative;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  border: 3px solid var(--accent-red);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.2), 0 4px 20px rgba(0, 0, 0, 0.4);
}
.avatar-crop-viewport:active { cursor: grabbing; }
.avatar-crop-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.profile-remove-btn {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: center;
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.profile-remove-btn:hover { border-color: rgba(255,255,255,0.2); color: var(--text-secondary); }

/* === Build Note Author Wrap === */
.build-note-author-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.build-note-reply-author-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* === DM Convo Item with avatar === */
.dm-convo-item {
  gap: 0;
}
.dm-pick-user {
  gap: 10px;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Copy path button on file cards */
.file-copy-path {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-copy-path:hover {
  opacity: 1 !important;
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.file-card:hover .file-copy-path { opacity: 0.6; }

/* Toast notification for copy */
.copy-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-green);
  color: #111;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  animation: toastFade 1.5s ease forwards;
}
@keyframes toastFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* === Channel List === */
.channel-list { display: flex; flex-direction: column; overflow-y: auto; padding-bottom: 16px; }
.channel-section-header { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 16px 16px 6px; display: flex; align-items: center; justify-content: space-between; }
.channel-section-add { background: none; border: 1px solid var(--glass-border); color: var(--text-muted); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; font-size: 0.9rem; line-height: 1; display: flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s; }
.channel-section-add:hover { background: var(--glass-hover); color: var(--text-primary); }
/* Collapsible channel sections (My Sessions / Pinned / Rooms) — mirrors the
   Messages sidebar .dm-section pattern (rotating chevron + is-collapsed) with
   channel-scoped classes so the two panels stay visually in lockstep. The toggle
   is a real <button> that inherits the header's uppercase-muted type; rows keep
   their own margins, so the rows wrapper adds no gap of its own. */
.channel-section { display: flex; flex-direction: column; }
.channel-section-toggle { flex: 1; min-width: 0; display: inline-flex; align-items: center; padding: 0; background: none; border: none; cursor: pointer; user-select: none; text-align: left; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.channel-section-toggle:hover { color: var(--text-secondary); }
.channel-section-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-section-chevron { display: inline-flex; flex-shrink: 0; font-size: 0.55rem; color: var(--text-muted); margin-right: 6px; transition: transform 0.15s ease; }
.channel-section.is-collapsed .channel-section-chevron { transform: rotate(-90deg); }
.channel-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; cursor: pointer; transition: background 0.15s; border-radius: 8px; margin: 0 8px 1px; }
.channel-row:active { background: var(--glass-hover); }
.channel-active { background: var(--glass-bg); }
.channel-active .channel-name { color: var(--text-primary); font-weight: 600; }
.channel-icon { font-size: 1rem; color: var(--text-muted); flex-shrink: 0; width: 20px; text-align: center; }
.channel-info { flex: 1; min-width: 0; }
.channel-name { font-size: 0.95rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-members { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.channel-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.channel-online-dot { width: 7px; height: 7px; border-radius: 50%; background: #2ed573; }
.channel-menu-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px 8px; font-size: 1rem; min-height: 32px; }
.channel-power-btn { background: none; border: none; cursor: pointer; padding: 4px 8px; font-size: 0.7rem; min-height: 32px; min-width: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.channel-power-stop { color: var(--text-muted); }
.channel-power-stop:hover { color: var(--accent-red); background: rgba(255,107,107,0.1); }
.channel-power-start { color: #2ed573; }
.channel-power-start:hover { background: rgba(46,213,115,0.1); }
.channel-stopped .channel-name { color: var(--text-muted); }
.channel-stopped .channel-icon { color: rgba(255,255,255,0.2); }
.channel-offline-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); opacity: 0.3; }

/* === Transcription Episodes section === */
.tx-episodes-header { cursor: pointer; user-select: none; }
.tx-episodes-header:hover { color: var(--text-secondary); }
.tx-chevron { display: inline-block; width: 12px; font-size: 0.85em; color: var(--text-muted); margin-right: 4px; }
.tx-episode-row .channel-icon { color: var(--accent); }
.tx-status-pill {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.tx-status-untouched { color: var(--text-muted); border-color: var(--glass-border); }
.tx-status-in-progress { color: #fbbf24; }
.tx-status-exported { color: #2ed573; }

