/* #region VARIABLES */

@font-face {
  font-display: swap;
}

:root {
  --bg-deep: #101114;
  --bg-surface: #16181c;
  --bg-elevated: #1e2025;
  --bg-hover: #282a30;
  --border: #363840;
  --text-primary: #f0f1f3;
  --text-secondary: #c2c4c9;
  --text-tertiary: #9a9da5;
  --text-muted: #7d808a;
  --accent: #e86f33;
  --accent-text: #f0a070;
  --accent-dim: rgba(232, 111, 51, 0.25);
  --accent-glow: rgba(232, 111, 51, 0.55);
  --gold: #d9b667;
  --success: #3ecf8e;
  --success-dim: rgba(62, 207, 142, 0.18);
  --warning: #f0b429;
  --warning-dim: rgba(240, 180, 41, 0.18);
  --danger: #ef5350;
  --danger-dim: rgba(239, 83, 80, 0.18);
  --info: #60a5fa;
  --owner-blue: #9cc2fb;
  --owner-purple: #cdb8fa;
  --owner-teal: #7fe2c9;
  --owner-orange: #f7ad8b;
  --owner-yellow: #ecce7a;
  --owner-pink: #f8a9cf;
  --owner-green: #9be1ab;
  --owner-indigo: #c0c2fc;
  --owner-red: #f9a3a3;
  --owner-cyan: #7dd8ea;
  --ansi-red: #e06c66;
  --ansi-green: #3ecf8e;
  --ansi-yellow: #e0b04a;
  --ansi-blue: #60a5fa;
  --ansi-magenta: #c98ce0;
  --ansi-cyan: #4dc9c9;
  --ansi-bright-red: #ff8a84;
  --ansi-bright-green: #5ee3a8;
  --ansi-bright-yellow: #f0c56a;
  --ansi-bright-blue: #8bbdfb;
  --ansi-bright-magenta: #e0a8f0;
  --ansi-bright-cyan: #7ddede;
  --mono: 'IBM Plex Mono', monospace;
  --serif: 'Playfair Display', serif;
  --sans: Arial, Helvetica, sans-serif;
  --card-gap: 7px;
  /* the name's supporting lines read as one unit with it, so they sit tighter
     than the gap separating the card's independent rows */
  --card-gap-tight: 3px;
  /* aliases: many rules reference --font-mono/--font-serif; keep them on-brand */
  --font-mono: var(--mono);
  --font-serif: var(--serif);
  /* reading-surface scale for the message-detail and preview modals (Ctrl +/-/0) */
  --modal-zoom: 1;
  --review-panel-w: 320px;
}

/* Tokens derived from theme colors live on body, where color themes set those colors;
   on :root they would resolve to the defaults before a theme applies. */
body {
  /* Selection reads as a recess against the darker surface here, but light theme's deep tone
     sits within a shade of the sidebar, so there it has to rise instead. */
  --session-active-bg: var(--bg-deep);
  --ansi-black: var(--text-muted);
  --ansi-white: var(--text-secondary);
  --ansi-bright-black: var(--text-tertiary);
  --ansi-bright-white: var(--text-primary);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

body {
  font-family: var(--mono);
  font-size: 14px;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* #endregion */

/* #region RESET */
body::before {
  display: none;
}

/* #endregion */

/* #region SCROLLBAR */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.column-tasks::-webkit-scrollbar-thumb,
.sessions-list::-webkit-scrollbar-thumb {
  background: transparent;
}
.column-tasks:hover::-webkit-scrollbar-thumb,
.sessions-list:hover::-webkit-scrollbar-thumb {
  background: var(--border);
}
.column-tasks::-webkit-scrollbar-thumb:hover,
.sessions-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* #endregion */

/* #region LAYOUT */
.app {
  display: flex;
  height: 100vh;
}

/* #endregion */

/* #region SIDEBAR */
.sidebar {
  width: var(--sidebar-width, 415px);
  background: var(--sidebar-bg, var(--bg-surface));
  border-right: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
  box-shadow: 1px 0 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.resizing {
  transition: none;
}

.sidebar-header {
  padding: 6px 10px;
  border-bottom: none;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: bottom;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.activity-chips {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.activity-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.1s ease;
}

.activity-chip:hover {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--text-secondary) 30%, var(--border));
}

.activity-chip:active {
  transform: scale(0.97);
}

.activity-chip.activity-filter-on {
  --chip-color: var(--accent);
  background: color-mix(in srgb, var(--chip-color) 9%, var(--bg-deep));
  border-color: color-mix(in srgb, var(--chip-color) 50%, var(--border));
  color: color-mix(in srgb, var(--chip-color) 80%, var(--text-secondary));
}
.activity-chip.activity-waiting.activity-filter-on {
  --chip-color: var(--warning);
}

.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.activity-chip.activity-zero {
  color: var(--text-tertiary);
  border-color: var(--border);
  opacity: 0.6;
}
.activity-chip.activity-zero .activity-dot {
  background: var(--text-muted);
  box-shadow: none;
  animation: none;
}
.activity-chip.activity-zero:hover {
  opacity: 1;
}

.activity-chip.activity-waiting .activity-dot {
  background: var(--warning);
}

.activity-chip.activity-active .activity-dot {
  background: color-mix(in srgb, var(--accent) 60%, var(--text-muted));
  animation: pulse 2.5s ease-in-out infinite;
}

.activity-icon {
  display: inline-flex;
  margin: 0 -2px;
  color: var(--chip-color, var(--accent));
}
.activity-icon svg {
  width: 11px;
  height: 11px;
}
.activity-chip.activity-zero .activity-icon {
  color: var(--text-muted);
}
.activity-chip.activity-warn {
  --chip-color: var(--warning);
  background: var(--warning-dim);
  border-color: color-mix(in srgb, var(--chip-color) 60%, var(--border));
  color: var(--chip-color);
}

.sidebar.collapsed .activity-chips {
  display: none;
}

.new-session-pill {
  margin-left: auto;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 40%, var(--border));
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.new-session-pill:hover,
.new-session-pill:focus-visible {
  color: var(--accent-text);
  border-color: var(--accent);
  background: var(--accent-dim);
  outline: none;
}

.sidebar.collapsed .new-session-pill {
  display: none;
}

.sidebar-toggle-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.sidebar-toggle-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
  border-color: var(--border);
}

.sidebar-toggle-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.sidebar.collapsed .sidebar-toggle-btn svg {
  transform: rotate(180deg);
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.15s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--accent-dim);
}

.sidebar.collapsed .sidebar-resize-handle {
  display: none;
}

.panel-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.15s;
}
.panel-resize-handle:hover,
.panel-resize-handle.dragging,
.pane-divider:hover,
.pane-divider.dragging {
  background: var(--accent-dim);
}

.offline-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-deep);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.offline-overlay.visible {
  display: flex;
}
.offline-card {
  max-width: 460px;
  padding: 3rem 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.mascot-sleep {
  position: relative;
  display: inline-block;
  margin-bottom: 1.5rem;
}

.mascot-asleep {
  display: block;
  animation: mascot-breathe 3s ease-in-out infinite;
}

.mascot-zzz {
  position: absolute;
  top: -6px;
  right: -14px;
  color: var(--text-muted);
  font: 600 13px var(--mono, monospace);
  animation: mascot-zzz 3s ease-out infinite;
}

@keyframes mascot-breathe {
  50% {
    transform: scaleY(0.93);
  }
}

@keyframes mascot-zzz {
  from {
    opacity: 0;
    transform: translate(0, 6px);
  }
  30% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translate(6px, -10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mascot-asleep,
  .mascot-zzz {
    animation: none;
  }
}
.offline-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.offline-card p {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}
.offline-card code {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent-text);
  margin-bottom: 1.25rem;
  user-select: all;
}
.offline-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* #endregion */

/* #region SIDEBAR_SECTIONS */
.sidebar-section {
  display: flex;
  flex-direction: column;
  border-bottom: none;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: bottom;
}

.sidebar-section.flex-1 {
  flex: 1;
  border-bottom: none;
  overflow: hidden;
}

.section-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px 20px;
  font-size: 11px;
  color: var(--text-muted);
}

.section-header-label {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
}

/* Non-default filters, spelled out in the header so folding them into the popover
   never hides *that* the list is filtered. Empty (and invisible) at defaults. */
.filter-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--accent-text);
}

.section-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

/* Quiet at rest: no box around a header glyph. The hairline arrives on hover.
   Compounded with .icon-btn because that rule is declared later in this file and would
   otherwise win on size, border, and colour. */
.icon-btn.section-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  background: none;
  border-color: transparent;
  color: var(--text-muted);
}

.icon-btn.section-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-primary);
}

.icon-btn.section-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.icon-btn.section-btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.75;
}

/* Ember only while something is actually filtered — at rest the funnel is just chrome. */
.icon-btn.section-btn.has-filters,
.icon-btn.section-btn.active {
  color: var(--accent-text);
}

.filter-menu {
  display: none;
  position: absolute;
  top: calc(100% - 2px);
  right: 16px;
  left: 16px;
  z-index: 100;
  padding: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow:
    0 16px 44px rgba(0, 0, 0, 0.38),
    0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: default;
}

.filter-menu.open {
  display: block;
}

.filter-dropdown {
  flex: 1;
  appearance: none;
  background: var(--bg-deep);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 26px 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238b8d95' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  text-overflow: ellipsis;
  min-width: 0;
  transition: all 0.15s ease;
}

.filter-dropdown:hover {
  border-color: var(--border);
}

.filter-dropdown option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.filter-dropdown:focus,
.pf-field:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* The project box: path field with the 24h switch set into its right end. */
.pf-field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 9px;
  background: var(--bg-deep);
  border: 1px solid transparent;
  border-radius: 6px;
}

.pf-icon {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.pf-input {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  background: none;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-primary);
}

.pf-input::placeholder {
  color: var(--text-muted);
}

.pf-recent {
  flex: none;
  padding: 3px 7px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.pf-recent:hover {
  color: var(--text-secondary);
}

.pf-recent[aria-pressed='true'] {
  background: var(--accent-dim);
  border-color: transparent;
  color: var(--accent-text);
}

.pf-recent:focus-visible,
.pf-seg button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Name first, folder after it, age last. The folder clips from its left end, so the part
   next to the name stays readable. */
.pf-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.pf-opt {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-family: var(--mono);
  cursor: pointer;
}

.pf-opt:hover,
.pf-opt.hl {
  background: var(--bg-hover);
}

.pf-name {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
}

.pf-dir,
.pf-age {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pf-dir {
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
}

.pf-opt mark {
  background: none;
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.pf-opt[aria-selected='true']::before {
  content: '';
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 2px;
  background: var(--accent);
}

.pf-opt[aria-selected='true'] .pf-name {
  color: var(--accent-text);
}

.pf-empty {
  padding: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.pf-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.pf-seg button {
  padding: 6px;
  background: none;
  border: none;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.pf-seg button:hover {
  color: var(--text-secondary);
}

.pf-seg button[aria-checked='true'] {
  background: var(--bg-deep);
  color: var(--text-primary);
}

/* #endregion */

/* #region COLLAPSIBLE */
.collapse-chevron {
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.collapse-chevron.rotated {
  transform: rotate(-90deg);
}

.collapsible-section {
  transition:
    max-height 0.2s ease,
    padding 0.2s ease,
    opacity 0.2s ease;
  overflow: hidden;
}

.collapsible-section.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

/* #endregion */

/* #region SESSIONS */
.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px 12px;
}

.sessions-list.zen {
  --zen-dot: var(--border);
  display: flex;
  flex-direction: column;
}

.sessions-list.zen[data-zen-state='working'] {
  --zen-dot: color-mix(in srgb, var(--success) 45%, var(--border));
}

.sessions-list.zen[data-zen-state='waiting'] {
  --zen-dot: color-mix(in srgb, var(--warning) 55%, var(--border));
}

/* The spacer fills the free space. With no free space it is 0 and the list scrolls from the top. */
.sessions-list.zen::after {
  content: '';
  flex: 1 0 0;
}

.sessions-list.zen {
  --zen-fill: radial-gradient(circle, var(--zen-dot) 1px, transparent 1.5px) 0 0 / 20px 20px;
  --zen-glow-y: 0;
}

/* The pattern glows out from the card. The glow has a fixed height, so it looks the same in a short space and a tall one. */
.sessions-list.zen::after {
  background: var(--zen-fill);
  mask-image: radial-gradient(110% 260px at 50% var(--zen-glow-y), rgb(0 0 0 / 0.9), transparent);
}

.sessions-list.zen > * {
  flex-shrink: 0;
}

/* After the ::after spacer, so the agents sit at the bottom of the free space. */
.zen-agents {
  order: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.zen-agents:empty {
  display: none;
}
.zen-agent {
  display: grid;
  grid-template-columns: 5px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: none;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.zen-agent:hover {
  background: var(--bg-hover);
}
.zen-agent-text {
  min-width: 0;
}
.zen-agent-task {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.zen-agent-time {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.session-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 13px 15px;
  margin-bottom: 6px;
  background: var(--sidebar-item-bg, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.session-skeleton {
  display: none;
  flex-direction: column;
  gap: 9px;
  padding: 15px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
}

body.booting .session-skeleton {
  display: flex;
}

.session-skeleton span,
.msg-log-loading-row span {
  height: 9px;
  width: 70%;
  border-radius: 4px;
  background: var(--border);
  animation: breathe 1.4s ease-in-out infinite;
}

.session-skeleton span + span {
  width: 40%;
}

body.booting #no-session {
  display: none;
}

.boot-splash {
  display: none;
  flex: 1;
}

.boot-splash,
.terminal-boot {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 12px;
}

body.booting .boot-splash {
  display: flex;
  animation: boot-fade 0.3s ease-out 0.15s both;
}

.mascot {
  width: 64px;
  height: 40px;
  fill: var(--accent);
  overflow: visible;
  transform-origin: 50% 100%;
}

.mascot-jump {
  animation: mascot-jump 0.9s ease-in-out infinite;
}

@keyframes mascot-jump {
  0%,
  100% {
    transform: translateY(0) scale(1, 1);
  }
  15% {
    transform: translateY(0) scale(1.1, 0.85);
  }
  45% {
    transform: translateY(-14px) scale(0.95, 1.05);
  }
  70% {
    transform: translateY(0) scale(1.08, 0.9);
  }
  85% {
    transform: translateY(0) scale(1, 1);
  }
}

@keyframes boot-fade {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .session-skeleton span,
  .msg-log-loading-row span,
  .mascot-jump {
    animation: none;
  }
}

/* `.active` is the open session, `.kb-selected` the keyboard cursor. They own different
   properties — fill and border — so the cursor landing on the open session adds to it
   instead of replacing how it looks. */
.session-item:hover {
  background: color-mix(in srgb, var(--bg-hover) 40%, var(--sidebar-item-bg, transparent));
}

.session-item.active {
  background: var(--session-active-bg);
  border-color: var(--border);
}

.session-item.kb-selected,
.terminal-prompt button:focus-visible {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 10px var(--accent-glow);
}

.session-item.stale {
  opacity: 0.85;
}

.session-item.stale:hover,
.session-item.stale.active,
.session-item.stale.kb-selected,
.session-item.stale:has(.session-pin-btn.sticky) {
  opacity: 1;
}

.session-item.stale .session-time,
.session-item.warm .session-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.session-item.stale .session-time::before,
.session-item.warm .session-time::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-item.warm .session-time {
  color: var(--success);
}

.session-item.warm .session-time::before {
  background: var(--success);
}

.session-item.warm.idle .session-time {
  color: var(--text-tertiary);
}

.session-item.warm.idle .session-time::before {
  background: var(--text-tertiary);
}

/* Declared on the element, not :root, so it picks up body.light's --success. */
.session-item.just-finished,
.sp-state.just-finished {
  --success-faded: color-mix(in srgb, var(--success) 35%, var(--text-muted));
}

.session-item.warm.idle.just-finished .session-time {
  color: var(--success-faded);
}

.session-item.warm.idle.just-finished .session-time::before {
  background: var(--success-faded);
}

.session-item.warm.permission-pending .session-time {
  color: var(--warning);
}

.session-item.warm.permission-pending .session-time::before {
  background: var(--warning);
}

.session-item.stale .session-time {
  color: var(--text-muted);
}

.session-item.stale .session-time::before {
  background: transparent;
  border: 1px solid var(--text-muted);
}

.session-name {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* reserve room for the absolutely-positioned pin button at top-right */
  padding-right: 22px;
}

.session-item.unread::before,
.session-item.permission-pending::before,
.sp-row.unread::before,
.sp-row.permission-pending::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-left: 3px solid var(--accent);
  pointer-events: none;
}

.session-item.unread::before,
.session-item.permission-pending::before {
  border-radius: inherit;
}

.session-item.permission-pending::before,
.sp-row.permission-pending::before {
  border-left-color: var(--warning);
  animation: agent-badge-pulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .session-item.permission-pending::before,
  .sp-row.permission-pending::before {
    animation: none;
  }
}

.session-indicators .pulse,
.session-waiting .pulse {
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.9);
  }
}

.session-item.session-placeholder {
  border-style: dashed;
}

.session-waiting {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--card-gap-tight);
  font-size: 11px;
  color: var(--text-muted);
}

.session-secondary {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 450;
  color: var(--text-tertiary);
  margin-top: var(--card-gap-tight);
  white-space: nowrap;
  overflow: hidden;
}

/* inline-block, not inline-flex: a flex box ignores text-overflow, so a long worktree name
   ran past the card edge instead of truncating. */
.wt-chip {
  display: inline-block;
  max-width: 60%;
  margin-left: 5px;
  padding: 0 5px;
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent-text);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 14px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-branch {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: var(--card-gap-tight);
  display: block;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
  margin-top: var(--card-gap);
  line-height: 1;
}

.session-progress {
  display: flex;
  align-items: center;
  gap: 9px;
}

.session-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: var(--card-gap);
  min-height: 18px;
}

.session-footer .session-time {
  min-width: 0;
}

.progress-bar {
  flex: 1;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.5s ease-out;
}

.progress-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.session-progress .progress-bar {
  display: flex;
}

.progress-fill.done {
  background: var(--success);
}

.context-bar-labels {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  white-space: nowrap;
}
.context-bar-track {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: visible;
  position: relative;
}
.context-bar-fill {
  height: 100%;
  border-radius: 1.5px;
  transition:
    width 0.4s ease,
    background 0.3s;
}
.context-bar-marker {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  opacity: 0.7;
  z-index: 2;
  border-radius: 1px;
}
.detail-context {
  margin-bottom: 16px;
}
.detail-context-bar {
  margin: 8px 0 4px;
}
.detail-context-bar .context-bar-track {
  height: 6px;
  border-radius: 3px;
}
.detail-context-bar .context-bar-fill {
  border-radius: 3px;
}
.detail-context-bar .context-bar-marker {
  top: -2px;
  bottom: -2px;
}
.detail-context-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.detail-context-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
}
.detail-context-stats .stat-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.detail-context-stats .stat-label {
  color: var(--text-secondary);
}
.detail-context-stats .stat-value {
  color: var(--text-primary);
}
.detail-context-stats .detail-context-open {
  grid-column: 1 / -1;
  justify-self: end;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}
.detail-context-stats .detail-context-open:hover {
  text-decoration: underline;
}
.detail-context-stats .stat-divider {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}
.detail-context-summary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

/* Zen view: the sidebar holds one card, so the usage detail that normally lives behind the
   info modal gets rendered underneath it. */
.zen-panel {
  margin-top: 10px;
  /* No bottom padding: the linked-docs section that always closes the panel carries its own. */
  padding: 10px 10px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.zen-panel .detail-context {
  margin-bottom: 0;
}

.zen-panel .detail-context-stats {
  gap: 3px 10px;
}

.zen-scratchpad {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.zen-scratchpad-label {
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.zen-scratchpad-path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.zen-panel:hover .row-actions {
  opacity: 1;
}

.session-time {
  font-size: 11px;
  font-weight: 450;
  color: var(--text-tertiary);
}

.session-latest-msg {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-latest-msg .lm-label {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 10px;
}
.session-latest-msg .lm-label-assistant {
  color: var(--accent-text);
}

/* #endregion */

/* #region FOOTER */
.sidebar-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: none;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: top;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-footer a {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s;
}

.sidebar-footer .footer-limits strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.sidebar-footer .footer-limits .footer-limit-reset {
  color: var(--text-tertiary);
  font-weight: 400;
  opacity: 0.75;
}

.sidebar-footer a:hover {
  color: var(--text-secondary);
}

.sidebar-footer .footer-version {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sidebar-footer .footer-plugin-warning {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  color: var(--warning);
  cursor: pointer;
}

.sidebar-footer .footer-plugin-warning:hover,
.sidebar-footer .footer-plugin-warning:focus-visible {
  filter: brightness(1.2);
}

.sidebar.collapsed {
  width: 48px;
}
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-footer {
  display: none;
}
.sidebar.collapsed .sidebar-header {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.sidebar.collapsed .sidebar-toggle-btn {
  position: static;
}

/* #endregion */

/* #region MAIN */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
}

/* #endregion */

/* #region EMPTY_STATE */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--text-muted);
}

.idle-board {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.idle-ghost {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 28px;
  opacity: 0.55;
  mask-image: radial-gradient(ellipse 70% 65% at 50% 50%, transparent 25%, #000 75%);
}

.idle-ghost > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 44px 12px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.idle-ghost span {
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-surface);
}

.idle-ghost span:nth-child(2n) {
  height: 92px;
}

.idle-glow {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.idle-glow span {
  position: absolute;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-dim), transparent 65%);
  animation: idle-drift 22s ease-in-out infinite alternate;
}

.idle-glow span:first-child {
  top: 12%;
  left: 18%;
}

.idle-glow span + span {
  right: 14%;
  bottom: 8%;
  width: 360px;
  height: 360px;
  animation-duration: 28s;
  animation-direction: alternate-reverse;
}

@keyframes idle-drift {
  to {
    transform: translate(90px, 50px) scale(1.15);
  }
}

.idle-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.idle-mascot {
  position: relative;
  padding-bottom: 10px;
  margin-bottom: 6px;
}

.idle-mascot .mascot {
  display: block;
  animation: idle-float 3.2s ease-in-out infinite;
}

.idle-mascot::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 44px;
  height: 6px;
  margin-left: -22px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.25;
  animation: idle-shadow 3.2s ease-in-out infinite;
}

@keyframes idle-float {
  50% {
    transform: translateY(-6px);
  }
}

@keyframes idle-shadow {
  50% {
    transform: scaleX(0.75);
    opacity: 0.15;
  }
}

.idle-title {
  font-size: 14px;
  color: var(--text-secondary);
}

.idle-hint span {
  opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
  .idle-glow span,
  .idle-mascot .mascot,
  .idle-mascot::after {
    animation: none;
  }
}

/* #endregion */

/* #region SESSION_VIEW */
.session-view {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.session-view.visible {
  display: flex;
}

/* #endregion */

/* #region HEADER */
.view-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.view-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-wrap: balance;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-progress .progress-bar {
  width: 120px;
  height: 3px;
}

.view-progress .progress-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* theme picker: palette icon button + custom popover with per-theme swatches
   (swatch colors are generated into themes.css) */
.theme-picker {
  position: relative;
}
.theme-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 170px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.theme-menu.open {
  display: block;
}
.theme-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  cursor: pointer;
}
.theme-menu-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
/* Highlighted with the row's *own* theme accent rather than the active theme's, so the selected
   row previews the theme it names. --sw-accent comes from the theme-swatch-<id> class on the row. */
.theme-menu-item.on {
  color: var(--sw-accent, var(--accent-text));
  background: color-mix(in srgb, var(--sw-accent, var(--accent-text)) 16%, transparent);
}
/* 3-dot palette preview: surface, accent, ink (colors from themes.css vars) */
.theme-swatch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}
.theme-swatch i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--sw-border);
}
.theme-swatch .sw-bg {
  background: var(--sw-bg);
}
.theme-swatch .sw-accent {
  background: var(--sw-accent);
}
.theme-swatch .sw-ink {
  background: var(--sw-ink);
}

/* #endregion */

/* #region KANBAN */
.kanban {
  position: relative;
  flex: 1;
  display: flex;
  gap: 24px;
  padding: 24px;
  overflow-x: auto;
}

.kanban-column {
  flex: 1;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: none;
  margin-bottom: 16px;
  background-image: linear-gradient(to bottom, transparent 80%, var(--border) 100%);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: bottom;
}

.column-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.column-dot.pending {
  background: var(--text-tertiary);
}
.column-dot.in-progress {
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}
.column-dot.completed {
  background: var(--success);
}

.column-title {
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.column-title.pending {
  color: var(--text-tertiary);
}
.column-title.in-progress {
  color: var(--accent);
}
.column-title.completed {
  color: var(--success);
}

.column-count {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.column-count.pending {
  background: var(--bg-elevated);
  color: var(--text-tertiary);
}

.column-count.in-progress {
  background: var(--accent-dim);
  color: var(--accent);
}

.column-count.completed {
  background: var(--success-dim);
  color: var(--success);
}

.column-tasks {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 8px;
}

.column-empty {
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin-top: 4px;
  text-align: center;
  padding: 32px 16px;
}

.column-empty svg {
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* #endregion */

/* #region TASK_CARD */
.task-card {
  padding: 10px 12px;
  padding-left: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-card:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  border-left-color: var(--text-muted);
}

.task-card:focus-visible {
  outline: none;
}

.task-card.in-progress {
  border-left: 2px solid var(--accent);
}

.task-card.completed {
  opacity: 0.85;
  border-left: 2px solid var(--success);
}

.task-card.completed:hover {
  border-left-color: var(--success);
}

.task-card.dim,
.task-card.dim:hover {
  opacity: 0.55;
  border-left-color: var(--border);
}

.task-card.blocked {
  border-left-style: dashed;
}
.task-card.blocked .task-title {
  color: var(--text-secondary);
}
.task-card.dragging {
  opacity: 0.4;
}
.column-tasks.drag-over {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 8px;
  outline: 2px dashed color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: -2px;
}

.task-card.selected,
.task-card.selected:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  border-left: 2px solid var(--accent);
  box-shadow:
    0 0 0 1px var(--accent-dim),
    0 0 12px var(--accent-dim);
  opacity: 1;
}

.task-id {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.task-card.completed .task-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.task-active {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
}

.task-active::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.task-blocked {
  margin-left: auto;
  color: var(--text-muted);
  white-space: nowrap;
}

.task-chip {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.task-chip-warn {
  color: var(--warning);
}

.task-chip-accent {
  color: var(--accent);
}

.task-desc {
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-tertiary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* #endregion */

/* #region DETAIL_PANEL */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--detail-panel-width, 540px);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
  box-shadow: -1px 0 12px rgba(0, 0, 0, 0.04);
  display: none;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.detail-panel.visible {
  display: flex;
}

.detail-panel.expanded {
  top: 50%;
  left: 50%;
  right: auto;
  width: min(1200px, calc(100vw - 48px));
  height: auto;
  max-height: calc(100vh - 96px);
  transform: translate(-50%, -50%);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);
  z-index: 900;
}

.detail-panel.expanded .panel-resize-handle {
  display: none;
}

.detail-expand svg {
  width: 15px;
  height: 15px;
}
.detail-panel.resizing,
.message-panel.resizing {
  transition: none;
}

.detail-header {
  padding: 16px 20px;
  border-bottom: none;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: bottom;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-header h3 {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
}

.detail-close {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.detail-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.detail-close svg {
  width: 20px;
  height: 20px;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: none;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: bottom;
}

.detail-section:last-child {
  background-image: none;
}

.detail-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text, var(--accent));
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-edit-icon {
  width: 12px;
  height: 12px;
  opacity: 0.8;
}

.detail-title,
.detail-title-input {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 4px;
}

.detail-title {
  border: 1px solid transparent;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

#detail-content.blocked .detail-title {
  box-shadow: inset 3px 0 var(--warning);
  padding-left: 13px;
  margin-left: -13px;
}

.detail-title.editable,
.detail-desc.editable {
  cursor: pointer;
}

.detail-title.editable:hover,
.detail-desc.editable:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-elevated));
}

.detail-title-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.detail-title-input:focus {
  outline: none;
}

.detail-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.detail-status.pending {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.detail-status.in_progress {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.detail-status.completed {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid var(--success);
}

#detail-content.blocked .detail-status.pending {
  background: var(--warning-dim);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
}

.detail-status .dot,
.detail-dep .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.detail-status.in_progress .dot {
  animation: pulse 2s ease-in-out infinite;
}

.detail-box {
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
}

.detail-box.active {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--text-primary);
}

.detail-box.active strong {
  color: var(--accent);
}

.detail-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
  overflow-x: auto;
}

.detail-desc-textarea {
  width: 100%;
  min-height: 120px;
  padding: 8px 10px;
  margin: -4px -6px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.detail-desc-textarea:focus {
  outline: none;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.edit-actions button {
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.edit-save {
  background: var(--accent);
  color: white;
}

.edit-save:hover {
  filter: brightness(1.1);
}

.edit-actions .edit-cancel {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.edit-cancel:hover {
  color: var(--text-primary);
}

.detail-deps {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  align-items: start;
  font-size: 12px;
}

.detail-deps .wait {
  --chip-color: var(--warning);
}

.detail-deps .next {
  --chip-color: var(--success);
}

.detail-deps-label {
  padding-top: 4px;
  color: var(--chip-color);
}

.detail-deps-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.detail-dep {
  --chip-color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--chip-color);
  background: color-mix(in srgb, var(--chip-color) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip-color) 40%, transparent);
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.detail-dep:hover,
.detail-dep:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--chip-color) 20%, transparent);
  border-color: var(--chip-color);
}

.detail-dep .dot {
  width: 6px;
  height: 6px;
}

.detail-dep-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-desc pre {
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0;
  font-size: 12px;
}

.detail-desc pre code.hljs,
.detail-desc pre code {
  background: color-mix(in srgb, var(--text-muted) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  --code-pad-x: 12px;
  padding: 12px var(--code-pad-x);
  border-radius: 6px;
  display: block;
  overflow-x: auto;
}

code.language-tree .hljs-punctuation {
  color: var(--text-muted);
}

code.language-tree .hljs-title {
  font-weight: 600;
}

code.ct {
  --ct-line: color-mix(in srgb, var(--text-muted) 85%, transparent);
}

/* One grid column: every row stretches to the widest one, so the bands line up when the block scrolls.
   The rows hold the side padding, so a band and the focus bar run to the block's edges. A container
   sets --code-pad-x to its code blocks' side padding. */
pre code.hljs.ct {
  display: grid;
  padding-inline: 0;
}

code.ct .ct-name {
  color: var(--text-primary);
  font-weight: 600;
}

code.ct .ct-lib:not(.ct-focus) .ct-name {
  font-weight: 400;
}

code.ct .ct-row {
  min-width: max-content;
  padding-inline: var(--code-pad-x, 10px);
}

code.ct .ct-row:empty::before {
  content: ' ';
}

code.ct .ct-nl,
code.ct .ct-hidden {
  display: none;
}

code.ct .ct-g {
  display: inline-block;
  position: relative;
  height: 1lh;
  vertical-align: top;
}

code.ct .ct-g::before,
code.ct .ct-g::after {
  content: '';
  position: absolute;
}

code.ct .ct-v::before,
code.ct .ct-t::before,
code.ct .ct-l::before {
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--ct-line);
}

code.ct .ct-l::before {
  bottom: 50%;
}

code.ct .ct-t::after,
code.ct .ct-l::after,
code.ct .ct-h::after {
  left: 50%;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--ct-line);
}

code.ct .ct-h::after {
  left: 0;
  right: 2px;
}

code.ct .ct-note,
code.ct .ct-star {
  color: var(--text-muted);
}

code.ct .ct-fold {
  color: var(--text-muted);
  font-style: italic;
}

code.ct .ct-loc {
  color: var(--accent-text);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}

code.ct .ct-focus {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 2px 0 0 var(--accent);
}

code.ct .ct-add {
  --ct-change: var(--success);
}

code.ct .ct-del {
  --ct-change: var(--danger);
}

code.ct :is(.ct-add, .ct-del) {
  background: color-mix(in srgb, var(--ct-change) 10%, transparent);
}

code.ct .ct-m {
  color: var(--ct-change);
  font-weight: 600;
}

code.ct .ct-has {
  cursor: pointer;
}

code.ct .ct-has:hover,
code.ct .ct-has:focus-visible {
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  outline: none;
}

code.ct .ct-has .ct-tilde {
  display: inline-block;
  color: transparent;
  position: relative;
}

code.ct .ct-has .ct-tilde::after {
  content: '▸';
  position: absolute;
  inset: 0;
  color: var(--text-muted);
  font-style: normal;
  text-align: center;
  transition: transform 0.12s;
}

code.ct .ct-has[aria-expanded='true'] .ct-tilde::after {
  transform: rotate(90deg);
}

/* Out of flow, so the notes stay in their column: it sits in the gap after the name. */
code.ct .ct-has[aria-expanded='false'] .ct-name {
  position: relative;
}

code.ct .ct-has[aria-expanded='false'] .ct-name::after {
  content: '…';
  position: absolute;
  left: 100%;
  padding-left: 0.3ch;
  color: var(--text-muted);
  font-weight: 400;
}

.detail-desc code {
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

#detail-content .detail-desc :not(pre) > code {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-text, var(--accent));
}

.detail-desc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.detail-desc h4 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0 0 8px 0;
}

.detail-desc p {
  margin: 0 0 12px 0;
}

.detail-desc p:last-child {
  margin-bottom: 0;
}

.detail-desc ol,
.detail-desc ul {
  padding-left: 1.5em;
  margin: 0 0 12px 0;
}

.detail-desc ol:last-child,
.detail-desc ul:last-child {
  margin-bottom: 0;
}

/* #endregion */

/* #region TEAM_BADGE */
.session-indicators {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.shared-tasklist-badge {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

/* Every clickable session-card icon shares one box so they blend into a single row;
   resizing the row means editing this rule, not four. Per-icon rules below override
   only what actually differs (color, glyph size). */
.team-info-btn,
.dispatched-badge,
.terminal-badge {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.team-info-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* The boxes are wider than their 12px glyphs, so the leading icon would sit inset
   from the card text above it. Cancel that inset — but only when a boxed icon leads;
   the pill badges have a different inset and must not be shifted. */
.session-indicators > .team-info-btn:first-child {
  margin-left: -3px;
}

.team-info-btn {
  font-size: 11px;
}

/* #endregion */

/* #region OWNER_BADGE */
.task-owner-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.task-owner-link {
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.task-owner-link:hover {
  text-decoration: underline;
}

.task-owner-link svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* #endregion */

/* #region TEAM_MODAL */
#team-modal .modal {
  max-width: 860px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
#team-modal .modal-body,
#agent-modal .modal-body,
.modal-help .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 8px;
}
#team-modal .modal-footer {
  flex-shrink: 0;
}

.agent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  white-space: nowrap;
  line-height: 1.4;
}
.agent-chip-label {
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.75;
}
.agent-chip-val {
  color: inherit;
}
.agent-chip-mono .agent-chip-val {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  letter-spacing: 0.2px;
}
.agent-chip-status {
  text-transform: capitalize;
}
.agent-chip-running {
  background: var(--success-dim);
  color: color-mix(in srgb, var(--success) 45%, var(--text-primary));
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}
.agent-chip-stopped {
  background: rgba(127, 127, 127, 0.15);
  color: var(--text-tertiary);
  border-color: rgba(127, 127, 127, 0.3);
}
.agent-chip-error,
.agent-chip-failed {
  background: var(--danger-dim);
  color: color-mix(in srgb, var(--danger) 55%, var(--text-primary));
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.team-modal-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 12px;
  align-items: center;
  margin-bottom: 16px;
}
/* Shared hover-reveal icon-button group, also used by the linked-doc rows. Each host
   supplies its own reveal trigger — the base only sets the resting opacity. */
.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0.3;
  transition: opacity 0.15s ease;
}
.info-grid:hover .row-actions {
  opacity: 1;
}
.row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    background 0.1s ease,
    border-color 0.1s ease,
    color 0.1s ease;
}
.row-actions button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent-text);
}
.row-actions button svg {
  width: 12px;
  height: 12px;
  display: block;
}
@media (hover: none) {
  .row-actions {
    opacity: 1;
  }
}


/* #endregion */

/* #region TERMINAL */
.terminal-pane {
  position: relative;
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
  padding: 8px 12px 12px;
  gap: 6px;
}

.session-view.terminal-mode .kanban,
.session-view.terminal-mode .agent-footer {
  display: none;
}

.session-view.terminal-mode .terminal-pane {
  display: flex;
}

.terminal-bar {
  position: absolute;
  z-index: 3;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.terminal-bar > * {
  pointer-events: auto;
}

.terminal-status:not(:empty) {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-surface);
}

.terminal-host {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

.terminal-pane:has(.terminal-prompt.visible) .terminal-frame {
  visibility: hidden;
}

.terminal-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.terminal-key-proxy {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.terminal-manager-modal {
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.terminal-manager-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}

.terminal-manager-row:last-child {
  border-bottom: none;
}

.terminal-manager-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
}

.terminal-manager-row.attached .terminal-manager-dot {
  border-color: var(--success);
  background: var(--success);
}

.terminal-manager-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.terminal-manager-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.terminal-manager-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-manager-here {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.terminal-manager-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.terminal-manager-mode {
  color: var(--text-secondary);
}

.terminal-manager-cwd {
  overflow: hidden;
  text-overflow: ellipsis;
}

.terminal-manager-proc {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.terminal-manager-proc:empty {
  display: none;
}

.terminal-manager-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.terminal-manager-actions .btn,
.terminal-manager-footer .btn {
  padding: 6px 14px;
}

.terminal-manager-end.btn-secondary:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.terminal-manager-footer {
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.terminal-manager-count {
  font-size: 12px;
  color: var(--text-muted);
}

.terminal-manager-stats:empty {
  display: none;
}

.terminal-manager-stats::before {
  content: '·';
  margin: 0 6px;
}

.companions-modal {
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.companion-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
}

.companion-row:last-child {
  border-bottom: none;
}

.companion-row.selected {
  background: var(--bg-hover);
}

.companion-row:not(.installed) .terminal-manager-dot {
  border-color: var(--warning);
}

.companion-row.update .terminal-manager-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.companion-row.installed .terminal-manager-dot {
  border-color: var(--success);
  background: var(--success);
}

.companion-name {
  font-weight: 500;
}

.companion-optional {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}

.companions-output {
  margin: 0 20px 12px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.companions-note {
  flex: 1;
  color: var(--text-muted);
  font-size: 12px;
}

#companions-btn {
  position: relative;
}

.companions-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.companion-hint {
  display: block;
  margin: 10px auto 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.companion-hint:hover {
  text-decoration: underline;
}

.agent-footer-content .companion-hint {
  margin: 8px 12px;
}

.terminal-manager-empty {
  color: var(--text-muted);
  padding: 24px 0;
  text-align: center;
}

.terminal-boot {
  display: none;
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.terminal-boot.visible {
  display: flex;
  animation: boot-fade 0.3s ease-out 0.2s both;
}

.terminal-boot-slow {
  display: none;
}

.terminal-boot.slow .terminal-boot-slow {
  display: block;
}

/* Opacity, not visibility: a hidden textarea drops focus, and the terminal must keep it. */
.terminal-pane:has(.terminal-boot.visible) .terminal-frame {
  opacity: 0;
}

.terminal-prompt {
  display: none;
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100% - 32px));
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 28px 20px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.25);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
}

.terminal-prompt.visible {
  display: flex;
}

.terminal-prompt-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.5;
}

.terminal-prompt-title {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
}

.terminal-prompt-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.terminal-prompt button:focus-visible {
  outline: none;
}

.terminal-host:focus-within {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.terminal-prompt:has(.terminal-prompt-output) {
  width: min(640px, calc(100% - 32px));
}

.terminal-prompt .terminal-prompt-output {
  align-self: stretch;
  max-height: 9.5em;
  overflow: auto;
  font-size: 12px;
  text-align: left;
  white-space: pre;
}

#terminal-toggle.active {
  color: var(--accent);
}

/* #endregion */

/* #region SHOW */
.terminal-host {
  position: relative;
}

.show-card {
  --show-inset: 8px;
  /* Six terminal rows (prompt, its rules, status line) at xterm's cell height of about 1.2 × font size. */
  --show-prompt-inset: calc(var(--show-inset) + 7.2 * var(--show-term-font, 13px));
  position: absolute;
  z-index: 2;
  top: var(--show-inset);
  right: var(--show-inset);
  display: none;
  flex-direction: column;
  box-sizing: border-box;
  min-width: 280px;
  max-width: var(--show-fit-w, 640px);
  width: max-content;
  max-height: var(--show-fit-h, 60%);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.3);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
}

body.light .show-card {
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.12);
}

.show-card.open {
  display: flex;
}

.terminal-pane:has(.terminal-prompt.visible) .show-card {
  display: none;
}

.show-card.html {
  width: var(--show-fit-w);
}

.show-card.sized {
  width: var(--show-w);
  height: var(--show-h);
  max-width: none;
  max-height: none;
}

.show-card.expanded {
  left: var(--show-inset);
  bottom: var(--show-prompt-inset);
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
}

.show-card.collapsed {
  left: auto;
  bottom: auto;
  width: max-content;
  height: auto;
  max-height: none;
}

.show-card.collapsed .show-body,
.show-card.collapsed .show-review,
.show-card.collapsed .show-grip,
.show-card.expanded .show-grip {
  display: none;
}

.show-card.collapsed .show-head {
  border-bottom-color: transparent;
}

/* The ticks wrap to the header's width instead of setting the card's. */
.show-card.collapsed .show-ticks {
  contain: inline-size;
  padding-bottom: 5px;
}

.show-card.flash {
  animation: show-in 0.16s ease-out;
}

@keyframes show-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.show-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding: 0 4px 0 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
}

.show-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.show-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  font-weight: 500;
}

.show-sep {
  opacity: 0.7;
  padding: 0 1px;
}

.show-key {
  flex: none;
  color: var(--text-tertiary);
}

.show-pager {
  flex: none;
  display: flex;
  align-items: center;
  margin-left: 8px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.show-pos {
  font-variant-numeric: tabular-nums;
}

.show-card.focused,
body.light .show-card.focused {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 10px var(--accent-glow);
}

.show-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: 6px;
}

.show-btn {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
}

.show-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.show-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.show-btn svg {
  width: 14px;
  height: 14px;
}

.show-btn.remove:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.show-ticks {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
  padding: 5px 10px 0;
}

.show-tick {
  width: 14px;
  height: 3px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
}

.show-tick:hover {
  background: var(--text-muted);
}

.show-tick.on {
  background: var(--text-tertiary);
}

.show-tick.dot {
  background: var(--accent);
}

.show-body {
  container-type: inline-size;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.show-body:focus {
  outline: none;
}

.show-card.html:not(.collapsed) .show-body {
  display: flex;
  overflow: hidden;
}

.show-frame {
  display: block;
  width: 100%;
  flex: 1;
  border: 0;
  background: transparent;
}

.show-card .show-review {
  flex: none;
  max-height: 40%;
  padding: 8px 10px 6px;
  border-left: 0;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
}

.show-md {
  padding: 0.8em 1.1em 1em;
  /* The same scale as an HTML card's frame (the zoom in showBridge). */
  font-size: clamp(12.5px, calc(9.7px + 0.58cqi), 17.5px);
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.show-md > :first-child {
  margin-top: 0;
}

.show-md > :last-child {
  margin-bottom: 0;
}

.show-md p {
  margin: 0.5em 0;
}

.show-md h1,
.show-md h2,
.show-md h3,
.show-md h4 {
  margin: 1em 0 0.4em;
  color: var(--text-primary);
  font-size: 1em;
  font-weight: 600;
}

.show-md h1 {
  font-size: 1.12em;
}

.show-md ul,
.show-md ol {
  margin: 0.4em 0;
  padding-left: 1.6em;
}

.show-md li {
  margin: 0.15em 0;
}

.show-md li:has(> input[type='checkbox']) {
  list-style: none;
  margin-left: -1.3em;
}

.show-md input[type='checkbox'] {
  accent-color: var(--accent);
  margin-right: 6px;
  vertical-align: -1px;
}

.show-md a {
  color: var(--accent);
}

.show-md blockquote {
  margin: 0.6em 0;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  color: var(--text-tertiary);
}

.show-md table {
  display: block;
  margin: 0.6em 0;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.96em;
}

.show-md th,
.show-md td {
  border: 1px solid var(--border);
  padding: 4px 9px;
  text-align: left;
}

.show-md th {
  background: var(--bg-hover);
  font-weight: 600;
  color: var(--text-primary);
}

.show-md :not(pre) > code {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-text);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.92em;
}

.show-md pre {
  margin: 0.6em 0;
  font-size: 0.92em;
  line-height: 1.5;
  overflow-wrap: normal;
}

.show-md pre code {
  display: block;
  overflow-x: auto;
  --code-pad-x: 10px;
  padding: 8px var(--code-pad-x);
  border-radius: 6px;
  background: color-mix(in srgb, var(--text-muted) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.show-md pre.preview-source {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.show-md pre.preview-source code {
  padding: 0;
  border: 0;
  background: none;
}

.show-md code.language-diff .hljs-addition,
.show-md code.language-diff .hljs-deletion {
  display: inline-block;
  min-width: 100%;
  margin: 0 -10px;
  padding: 0 10px;
  box-sizing: content-box;
}

.show-md code.language-diff .hljs-addition {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
}

.show-md code.language-diff .hljs-deletion {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.show-md pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

.show-md img {
  display: block;
  max-width: 100%;
  height: auto;
}

.show-gone {
  color: var(--text-muted);
}

.show-grip {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s ease;
  touch-action: none;
}

.show-card:hover .show-grip,
.show-card.sized .show-grip {
  opacity: 0.8;
}

.show-grip:hover {
  opacity: 1;
  color: var(--text-primary);
}

.show-grip svg {
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 9px;
  height: 9px;
}

body.show-resizing {
  user-select: none;
}

body.show-resizing iframe {
  pointer-events: none;
}

.show-reopen {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-surface);
  color: var(--text-tertiary);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.show-reopen[hidden] {
  display: none;
}

.show-reopen:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.show-reopen svg {
  width: 12px;
  height: 12px;
}

/* #endregion */

/* #region ASK */
.ask-modal {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg-deep) 30%, transparent);
}

.ask-modal[hidden] {
  display: none;
}

.ask-modal.ask-page {
  position: fixed;
  z-index: 1000;
}

.ask-reopen.ask-page {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.45);
}

.ask-box {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--text-muted) 45%, var(--border));
  border-radius: 10px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.ask-box[data-size='lg'] {
  width: min(960px, calc(100% - 32px));
}

.ask-box[data-size='full'] {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
}

.ask-head,
.ask-foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  color: var(--text-tertiary);
  font-size: 11px;
}

.ask-head {
  border-bottom: 1px solid var(--border);
}

.ask-foot {
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.ask-dot {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.ask-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-x {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.ask-x svg {
  width: 14px;
  height: 14px;
}

.ask-foot button {
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}

.ask-x:hover,
.ask-foot button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ask-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.ask-frame {
  display: block;
  width: 100%;
  border: 0;
  background: var(--bg-surface);
}

.ask-box[data-size='full'] .ask-frame {
  flex: 1;
}

.ask-missing {
  margin: 0;
  padding: 16px;
  color: var(--text-tertiary);
}

.ask-reopen {
  max-width: 240px;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--text-secondary);
}

.ask-reopen-n {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-reopen .ask-dot {
  width: 14px;
  height: 14px;
  font-size: 9px;
  animation: ask-pulse 1.6s ease-out infinite;
}

@keyframes ask-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  }
  100% {
    box-shadow: 0 0 0 6px transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ask-reopen .ask-dot {
    animation: none;
  }
}

/* #endregion */

/* #region PANES */
.pane-strip {
  display: none;
  align-items: stretch;
  gap: 2px;
  padding: 4px 10px 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.pane-pin {
  display: flex;
  flex: none;
  margin-bottom: -1px;
}

.session-view.has-panes .pane-strip {
  display: flex;
}

.session-view.terminal-mode .pane-strip {
  display: none;
}

.session-view.pane-mode .board-side {
  display: none;
}

.pane-tabs {
  display: flex;
  gap: 2px;
  min-width: 0;
  margin-bottom: -1px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.pane-tabs::-webkit-scrollbar {
  display: none;
}

.pane-tabs.fade-l,
.pane-tabs.fade-r {
  mask-image: linear-gradient(
    to right,
    transparent,
    #000 var(--fade-l, 0),
    #000 calc(100% - var(--fade-r, 0)),
    transparent
  );
}

.pane-tabs.fade-l {
  --fade-l: 28px;
}

.pane-tabs.fade-r {
  --fade-r: 28px;
}

.pane-tab {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 6px;
  min-width: 112px;
  max-width: 190px;
  padding: 4px 5px 4px 9px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: none;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: nowrap;
  cursor: pointer;
}

.pane-tab:hover {
  background: var(--bg-hover);
}

.pane-tab.on {
  background: var(--bg-deep);
  border-color: var(--border);
  border-top-color: var(--accent);
  color: var(--text-primary);
}

.pane-tab.shown {
  background: var(--bg-deep);
  border-color: var(--border);
  color: var(--text-secondary);
}

.pane-tab.dragging {
  opacity: 0.5;
}

.pane-strip .drop-before {
  box-shadow: inset 2px 0 0 var(--accent);
}

.pane-strip .drop-after {
  box-shadow: inset -2px 0 0 var(--accent);
}

.pane-pair {
  display: flex;
  flex: 0 1 auto;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--bg-elevated);
}

.pane-pair.on {
  border-color: var(--accent-dim);
}

.pane-pair .pane-tab {
  min-width: 80px;
}

.pane-pair .pane-tab.on,
.pane-pair .pane-tab.shown {
  border-color: transparent;
}

.pane-pair-sep {
  flex: none;
  width: 1px;
  margin: 5px 0;
  background: var(--border);
}

.pane-group {
  position: relative;
  display: flex;
  gap: 2px;
  min-width: 0;
}

/* Over the tabs, so a tab's own background does not hide it. */
.pane-group:not(.closed)::after {
  content: '';
  position: absolute;
  inset: auto 0 1px;
  z-index: 1;
  height: 2px;
  background: var(--g);
  pointer-events: none;
}

.pane-group-chip,
.pane-group-input {
  flex: none;
  align-self: center;
  height: 18px;
  margin: 0 2px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.pane-group-chip {
  min-width: 14px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--g);
  color: var(--bg-deep);
  cursor: pointer;
}

.pane-group-chip:hover {
  filter: brightness(1.12);
}

.pane-group-count {
  font-weight: 400;
  opacity: 0.75;
}

.pane-group-count:not(:first-child) {
  margin-left: 6px;
}

.pane-group-chip.drop-in {
  box-shadow: 0 0 0 2px var(--accent);
}

.pane-group-input {
  width: 110px;
  color: var(--text-primary);
  background: var(--bg-deep);
  box-shadow: inset 0 0 0 1px var(--g);
  outline: none;
}

.pane-strip.drop-hot {
  background: var(--accent-dim);
}

.pane-tab.pinned {
  flex: none;
  min-width: 0;
  padding-right: 10px;
  font-weight: 500;
}

.pane-tab .pane-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-tab .pane-title-input {
  flex: 1;
  min-width: 80px;
  padding: 0 4px;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-deep);
  border: 1px solid var(--accent);
  border-radius: 3px;
  outline: none;
}

.pane-tab .pin-meta {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 400;
}

.pane-tab .kind {
  flex: none;
  width: 13px;
  height: 13px;
}

.pane-tab .state {
  flex: none;
  width: 6px;
  height: 6px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
}

.pane-tab .state.loaded {
  background: var(--success);
  border-color: var(--success);
}

.pane-tab .state.blocked {
  background: var(--warning);
  border-color: var(--warning);
}

.pane-tab .pane-x {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.pane-tab:not(.on, :hover, :focus-within) .pane-x {
  visibility: hidden;
}

.pane-tab .pane-x:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pane-sep {
  flex: none;
  width: 1px;
  margin: 5px 6px 7px;
  background: var(--border);
}

.pane-add,
.pane-tool,
.pane-split-btn {
  width: 26px;
  height: 26px;
  border-color: transparent;
}

.pane-split-btn.on {
  color: var(--accent);
}

.pane-add svg,
.pane-split-btn svg,
.pane-tool svg {
  width: 14px;
  height: 14px;
}

.pane-add {
  align-self: center;
  margin: 0 0 3px 4px;
}

.pane-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 0 3px auto;
}

.pane-tool:disabled,
.pane-split-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
}

.pane-views {
  position: relative;
  display: none;
  flex: 1;
  min-height: 0;
  background: var(--bg-deep);
}

.session-view.pane-mode:not(.terminal-mode) .pane-views {
  display: flex;
}

.pane-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.pane-view.on {
  display: flex;
}

.pane-split {
  --pane-split: 50%;
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

.board-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  container: board / inline-size;
}

.board-side > .kanban {
  min-height: 0;
}

/* 936px is where the full layout stops fitting: 3 × 280px columns, 2 × 24px gaps, 2 × 24px padding. */
@container board (max-width: 936px) {
  .kanban {
    gap: 12px;
    padding: 16px;
  }

  .kanban-column {
    min-width: 140px;
  }

  .column-header {
    gap: 6px;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .column-title {
    font-size: 12px;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .column-tasks {
    padding-right: 0;
  }
}

.session-view.terminal-mode .pane-split {
  display: none;
}

.pane-divider,
.pane-drop {
  display: none;
}

.pane-divider {
  background: linear-gradient(to right, transparent 2px, var(--border) 2px 4px, transparent 4px);
  transition: background 0.15s;
}

.session-view.split-mode:not(.terminal-mode) .pane-views {
  display: contents;
}

.session-view.split-mode .pane-split > .board-side.side-l,
.session-view.split-mode .pane-split > .board-side.side-r,
.session-view.split-mode .pane-view {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--bg-deep);
}

.session-view.split-mode .side-l {
  left: 0;
  right: calc(100% - var(--pane-split) + 3px);
}

.session-view.split-mode .side-r {
  left: calc(var(--pane-split) + 3px);
  right: 0;
}

.pane-split > .message-panel.log-l,
.pane-split > .message-panel.log-r {
  position: absolute;
  top: 0;
  bottom: 0;
  left: auto;
  height: auto;
  z-index: 3;
}

.pane-split > .message-panel.log-l {
  right: calc(100% - var(--pane-split) + 3px);
  width: min(var(--message-panel-width, 540px), calc(var(--pane-split) - 3px));
}

.pane-split > .message-panel.log-r {
  right: 0;
  width: min(var(--message-panel-width, 540px), calc(100% - var(--pane-split) - 3px));
}

.pane-split > .message-panel.full-width.log-l {
  left: 0;
  width: auto;
}

.pane-split > .message-panel.full-width.log-r {
  left: calc(var(--pane-split) + 3px);
  width: auto;
}

.session-view.split-mode .pane-focus::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 3;
}

.session-view.split-mode:not(.terminal-mode) .pane-divider {
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--pane-split) - 3px);
  width: 6px;
  cursor: col-resize;
  z-index: 4;
}

.pane-split.resizing {
  cursor: col-resize;
}

.pane-split.resizing iframe {
  pointer-events: none;
}

.pane-split.collapse-l .side-l,
.pane-split.collapse-r .side-r {
  opacity: 0.35;
}

.pane-split.dropping .pane-drop {
  display: flex;
  position: absolute;
  inset: 0;
  z-index: 5;
}

.pane-drop > div {
  flex: 1;
  margin: 8px;
  border-radius: 8px;
}

.pane-drop > div.hot {
  background: var(--accent-dim);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.pane-view:has(> .review-panel) {
  flex-direction: row;
}

.pane-view:has(> .pane-doc) {
  gap: 16px;
  padding: 16px;
}

.pane-view:has(> .review-panel) > :not(.review-panel) {
  width: auto;
  min-width: 0;
}

.pane-view > .review-panel {
  padding: 12px;
}

.pane-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.pane-url-bar {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.pane-view:hover > .pane-url-bar,
.pane-view.frame-focus > .pane-url-bar {
  opacity: 1;
  pointer-events: auto;
}

.pane-url-bar .icon-btn {
  width: auto;
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  border-color: transparent;
  font: inherit;
}

.pane-url-bar .pane-keys {
  display: none;
  color: var(--accent);
}

.pane-view.frame-focus .pane-keys {
  display: flex;
}

.pane-doc {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  width: 100%;
  max-width: var(--pane-doc-w, 860px);
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.pane-doc-body {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.pane-doc-body:focus {
  outline: none;
}

.pane-msg-meta {
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* The modal's corner grip; the pane fills the height, so it sets the width only. */
.pane-doc > .modal-resize-handle {
  cursor: ew-resize;
}

.pane-card {
  display: grid;
  flex: 1;
  place-items: center;
  font-family: var(--font-mono);
}

.pane-card-box {
  max-width: 460px;
  padding: 26px 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  text-align: center;
}

.pane-card-box svg {
  width: 30px;
  height: 30px;
  color: var(--warning);
}

.pane-card-box h3 {
  margin: 10px 0 6px;
  font-family: var(--font-serif);
  font-size: 17px;
}

.pane-card-box p {
  margin: 0 0 16px;
  color: var(--text-tertiary);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pane-card .btn {
  padding: 6px 12px;
  font-size: 12px;
}

.modal.pane-pop-dialog {
  display: flex;
  flex-direction: column;
  width: 520px;
  max-width: calc(100vw - 32px);
  padding: 18px 20px 14px;
  font-family: var(--font-mono);
}

.pane-pop-dialog .modal-header {
  margin-bottom: 12px;
}

.pane-pop-dialog .modal-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
}

.pane-pop-dialog .form-input {
  box-sizing: border-box;
  font: 13px var(--font-mono);
}

.pane-pop-detect {
  min-height: 16px;
  margin: 7px 2px 14px;
  color: var(--text-muted);
  font-size: 11px;
}

.pane-pop-detect.error {
  color: var(--warning);
}

.pane-pop-dialog .sp-hint {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.pane-pop-label {
  margin: 6px 2px;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pane-pop-docs {
  max-height: 260px;
  margin: 0 -6px;
  overflow-y: auto;
}

.pane-pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  outline: none;
  background: none;
  color: var(--text-secondary);
  font: 12px var(--font-mono);
  text-align: left;
  cursor: pointer;
}

.pane-pop-row:hover,
.pane-pop-row:focus-visible,
.pane-pop-row.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.pane-pop-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-pop-row svg {
  flex: none;
  width: 13px;
  height: 13px;
}

.pane-pop-empty {
  padding: 4px 6px;
  color: var(--text-muted);
  font-size: 11px;
}

/* #endregion */

/* #region MESSAGE_PANEL */
.message-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--message-panel-width, 540px);
  height: 100vh;
  background: var(--bg-deep);
  border-left: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
  box-shadow: -1px 0 12px rgba(0, 0, 0, 0.04);
  display: none;
  flex-direction: column;
  z-index: 99;
  overflow: hidden;
}
.message-panel.visible {
  display: flex;
}
.message-panel.msg-expanded-wide {
  width: 60vw;
}
.message-panel.full-width {
  left: var(--sidebar-edge, 0);
  width: auto;
}
.message-panel.full-width .panel-resize-handle {
  display: none;
}
#message-panel-full-btn.active {
  color: var(--accent);
}
.message-panel-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-image: linear-gradient(to right, transparent, var(--border), transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: bottom;
}
.message-panel-header h3 {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
}
.message-panel-content {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
}
.message-panel-content > * + * {
  margin-top: 8px;
}
.msg-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
}
.msg-item.msg-user {
  border-left: 3px solid var(--gold);
}
.msg-queued-tag {
  margin-left: 8px;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}
.msg-item.msg-assistant {
  border-left: 3px solid var(--accent);
}
.msg-item.msg-tool {
  border-left: 2px solid color-mix(in srgb, var(--text-muted) 45%, transparent);
  font-size: 11px;
  padding: 5px 10px;
  color: var(--text-secondary);
}
.msg-item.selected,
.msg-item.selected:hover {
  background: var(--bg-elevated);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 12px var(--accent-dim);
}
.msg-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  opacity: 0.9;
}
.msg-body {
  flex: 1;
  min-width: 0;
}
.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-assistant .msg-text {
  color: var(--text-primary);
}
.msg-text-md {
  display: block; /* override .msg-text -webkit-box clamp */
  -webkit-line-clamp: none;
  white-space: normal; /* override .msg-text pre-wrap */
  font-size: 12px;
}
/* Element spacing/borders come from .rendered-md (also on .msg-md-content);
   these are only the compact-feed deltas: smaller type + code/quote chrome. */
.msg-text-md table,
.msg-text-md pre,
.msg-text-md code {
  font-size: 11px;
}
.msg-text-md h1,
.msg-text-md h2,
.msg-text-md h3,
.msg-text-md h4,
.msg-text-md h5,
.msg-text-md h6 {
  font-size: 12px;
  font-weight: 600;
}
.msg-text-md pre {
  padding: 6px 8px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow-x: auto;
}
.msg-text-md blockquote {
  padding-left: 8px;
  border-left: 2px solid var(--border);
  color: var(--text-secondary);
}
.msg-md-content > :first-child {
  margin-top: 0;
}
.msg-md-content > :last-child {
  margin-bottom: 0;
}
/* Soften just the bottom edge of a truncated preview so it reads as "continues"
   without obscuring the last line of text. */
.msg-md-content.is-truncated {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 0.85em), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 0.85em), transparent);
}
.msg-md-more {
  display: block;
  width: fit-content;
  margin: 3px auto 0 0;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-hover);
  border-radius: 9px;
}
.msg-tool .msg-text {
  color: var(--text-secondary);
}
.msg-item.msg-tool.msg-tool-error {
  border-left-color: var(--danger);
}
.msg-tool-error .msg-text {
  color: color-mix(in srgb, var(--danger) 70%, var(--text-primary));
}
.tool-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 5px;
  font-family: var(--font-mono, monospace);
}
.msg-tool-group-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding-left: 22px;
  margin-top: 2px;
}
.msg-tool-group-items.show {
  display: flex;
}
.msg-tool-grouped {
  padding: 3px 8px;
  min-height: auto;
  font-size: 10px;
  opacity: 0.8;
}
.msg-tool-grouped .msg-time {
  font-size: 9px;
}
.msg-agent-link {
  color: var(--accent);
  font-size: 0.85rem;
  margin-left: 4px;
  opacity: 0.7;
}
.msg-agent-link:hover {
  opacity: 1;
}
.msg-agent-usage {
  color: var(--text-muted);
  font-size: 10px;
  opacity: 0.55;
  margin-left: 6px;
}
.msg-pin-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  margin-left: auto;
  align-self: flex-start;
}
.msg-item:hover .msg-pin-btn,
.agent-card:hover .msg-pin-btn {
  opacity: 0.6;
}
.msg-pin-btn:hover {
  /* biome-ignore lint/complexity/noImportantStyles: override parent hover opacity */
  opacity: 1 !important;
  color: var(--accent);
}
.msg-pin-btn.pinned {
  opacity: 1;
  color: var(--accent);
}
#message-panel-pinned:empty {
  display: none;
}
#message-panel-pinned {
  flex-shrink: 0;
  padding: 8px 16px;
}
.pinned-section {
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-surface));
}
.pinned-header {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.pinned-header svg {
  transition: transform 0.15s;
}
.pinned-header.collapsed svg {
  transform: rotate(-90deg);
}
.pinned-header.empty {
  cursor: default;
  color: var(--text-muted);
}
.pinned-items {
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pinned-items.collapsed {
  display: none;
}
.pinned-items .msg-item {
  margin: 0;
}
.pinned-item-unpin {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 2px;
  opacity: 0.6;
  margin-left: auto;
  align-self: flex-start;
}
.pinned-item-unpin:hover {
  opacity: 1;
  color: var(--text-primary);
}
.msg-pin-btn.pinned svg,
#msg-detail-pin-btn.active svg,
#agent-modal-pin-btn.active svg {
  fill: var(--accent);
  stroke: var(--accent);
}
#msg-detail-pin-btn.active,
#agent-modal-pin-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}
.session-pin-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 1;
  line-height: 0;
}
.session-item:hover .session-pin-btn:not(.pinned):not(.sticky) {
  opacity: 0.5;
}
.session-pin-btn:hover {
  /* biome-ignore lint/complexity/noImportantStyles: override parent hover opacity */
  opacity: 1 !important;
  color: var(--accent);
}
.session-pin-btn.pinned {
  opacity: 1;
  color: var(--accent);
}
.session-pin-btn.pinned svg {
  fill: var(--accent);
  stroke: var(--accent);
}
.session-pin-btn.sticky {
  opacity: 1;
  color: var(--warning);
}
.session-pin-btn.sticky svg {
  fill: var(--warning);
  stroke: var(--warning);
}
#session-info-sticky-btn.active {
  color: var(--warning);
}
.pinned-sessions-divider {
  height: 1px;
  margin: 4px 8px;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}
.agent-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 16px;
  align-items: center;
}
.agent-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition:
    color 0.15s,
    border-color 0.15s;
  user-select: none;
}
.agent-tab:hover {
  color: var(--text-secondary);
  border-bottom-color: var(--text-muted);
}
.agent-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.agent-tab-panel {
  display: none;
  padding-top: 12px;
  overflow: hidden;
  position: relative;
}
.agent-tab-panel.active {
  display: block;
}
.agent-tab-copy {
  margin-left: auto;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-tertiary);
  opacity: 0.7;
  transition:
    opacity 0.15s,
    color 0.15s;
  margin-bottom: -1px;
}
.agent-tab-copy:hover {
  opacity: 1;
  color: var(--text-primary);
}
.agent-tab-copy svg {
  width: 14px;
  height: 14px;
  display: block;
}
.toast {
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 10000;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast.has-action.visible {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(480px, calc(100vw - 32px));
  overflow-wrap: anywhere;
}
.toast-action {
  flex-shrink: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
}
.toast-action:hover {
  background: var(--accent-dim);
}
.toast-hint {
  margin-top: 2px;
  color: var(--text-muted);
}
.toast.toast-success {
  border-color: var(--success);
  color: var(--success);
}
.toast.toast-error {
  border-color: var(--danger);
  color: var(--danger);
}
.toast.toast-info {
  border-color: var(--accent);
  color: var(--accent);
}
.rendered-md h1,
.rendered-md h2,
.rendered-md h3,
.rendered-md h4,
.rendered-md h5,
.rendered-md h6 {
  margin-top: 1em;
  margin-bottom: 0.4em;
}
.rendered-md h1:first-child,
.rendered-md h2:first-child,
.rendered-md h3:first-child {
  margin-top: 0;
}
.rendered-md p {
  margin: 0.5em 0;
}
.rendered-md ul,
.rendered-md ol {
  margin: 0.4em 0;
  padding-left: 2em;
}
.rendered-md li {
  margin: 0.2em 0;
}
.rendered-md ul > li:has(> input[type='checkbox']) {
  list-style: none;
}
.rendered-md a {
  color: var(--accent);
}
.rendered-md pre {
  margin: 0.6em 0;
}
.rendered-md blockquote {
  margin: 0.6em 0;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  color: var(--text-secondary);
}
.rendered-md table {
  margin: 0.6em 0;
  border-collapse: collapse;
  width: 100%;
  display: block;
  overflow-x: auto;
}
/* The bodies around these tables set `word-break: break-word` or `overflow-wrap: anywhere`, which let a cell break
   between any two letters, so the table layout shrinks short columns to one letter. */
.rendered-md th,
.rendered-md td,
.show-md th,
.show-md td {
  word-break: normal;
  overflow-wrap: break-word;
}
.rendered-md th,
.rendered-md td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.rendered-md th {
  background: var(--bg-hover);
  font-weight: 600;
}
.rendered-md hr {
  margin: 0.8em 0;
  border-color: var(--border);
}
.rendered-md img {
  max-width: 100%;
  height: auto;
}
.msg-detail-pre {
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.msg-detail-pre code.hljs {
  background: transparent;
  padding: 0;
}
.msg-detail-pre-tinted {
  background: color-mix(in srgb, var(--text-muted) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-radius: 6px;
  padding: 8px 10px;
}
.msg-detail-pre-old,
.msg-detail-pre-new {
  max-height: 200px;
  overflow: auto;
  padding-left: 8px;
}
.msg-detail-pre-old {
  border-left: 3px solid var(--danger);
}
.msg-detail-pre-new {
  border-left: 3px solid var(--success);
}
.tool-detail-section {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.tool-detail-section-wide {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.tool-detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.tool-detail-heading {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.tool-detail-pre-scroll {
  max-height: 300px;
  overflow: auto;
}
.modal-status {
  padding: 16px;
  color: var(--text-secondary);
}
.modal-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
}
.expand-toggle-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  margin-left: 6px;
}
.msg-cmd .msg-text code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}
.user-attach-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.user-attach-chip {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.msg-text-muted {
  color: var(--text-secondary);
  font-size: 12px;
}
.user-attach-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.user-attach-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.user-attach-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.user-attach-image {
  max-width: 100%;
  max-height: 480px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
}
.user-attach-toolresult {
  margin-top: 6px;
}
.user-attach-toolresult > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
}
.user-attach-toolresult > summary code {
  font-size: 10px;
}
.msg-item.msg-system {
  border-left: 3px solid var(--border);
}
.msg-system .msg-text code {
  background: none;
  padding: 0;
  font-size: 11px;
}
.msg-item.msg-teammate {
  border-left: 3px solid var(--info);
}
.msg-item.msg-protocol {
  border-left: 3px solid var(--border);
  opacity: 0.7;
}
.msg-item.msg-idle {
  border-left: 3px solid var(--border);
  opacity: 0.75;
}
.msg-item.msg-waiting {
  border-left: 3px solid var(--warning);
  background: color-mix(in srgb, var(--warning) 8%, transparent);
  animation: msg-waiting-pulse 2s ease-in-out infinite;
  cursor: pointer;
}
.msg-waiting-discard {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  margin-left: auto;
  align-self: flex-start;
  line-height: 0;
}
.msg-item.msg-waiting:hover .msg-waiting-discard {
  opacity: 0.6;
}
.msg-waiting-discard:hover {
  /* biome-ignore lint/complexity/noImportantStyles: override parent hover opacity */
  opacity: 1 !important;
  color: var(--text-primary);
}
.msg-waiting .msg-text {
  font-weight: 500;
}
.msg-waiting-body {
  font-size: 12px;
  margin-top: 4px;
  word-break: break-word;
}
.msg-waiting-body pre {
  white-space: pre-wrap;
  word-break: break-word;
}
@keyframes msg-waiting-pulse {
  0%,
  100% {
    background: color-mix(in srgb, var(--warning) 8%, transparent);
  }
  50% {
    background: color-mix(in srgb, var(--warning) 16%, transparent);
  }
}
.msg-waiting-body h1,
.msg-waiting-body h2,
.msg-waiting-body h3,
.msg-waiting-body h4 {
  font-size: 1em;
  font-weight: 600;
  line-height: 1.35;
}
.msg-waiting-body h1 {
  font-size: 1.15em;
}
.msg-item.msg-idle .msg-icon {
  width: 12px;
  height: 12px;
}
.teammate-name {
  font-weight: 600;
  font-size: 11px;
}
.idle-label,
.protocol-label {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}
.teammate-idle-detail {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
}
.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
.msg-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 12px;
}

.agent-log-back {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 0 8px 0 0;
  line-height: 1;
}
.agent-log-back:hover {
  color: var(--text-primary);
}
.agent-log-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.agent-log-id {
  font-size: 11px;
  color: var(--text-tertiary);
}
.agent-log-model {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.msg-agent-log-btn {
  flex-shrink: 0;
  margin-left: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  align-self: flex-start;
}
.msg-item:hover .msg-agent-log-btn {
  opacity: 1;
}
.msg-agent-log-btn:hover,
.msg-item:hover .msg-agent-log-btn:hover {
  opacity: 1;
  color: var(--accent);
}
.protocol-detail {
  padding: 8px 12px;
}
.protocol-detail + div {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.protocol-type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
  margin-bottom: 8px;
}
.protocol-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: baseline;
  font-size: 0.85rem;
}
.protocol-field {
  display: contents;
}
.protocol-field-key {
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}
.protocol-field-key::after {
  content: ':';
}
.protocol-bool {
  font-weight: 600;
}
.protocol-bool-true {
  color: var(--success);
}
.protocol-bool-false {
  color: var(--danger);
}
.msg-jump-latest {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--bg-deep);
  border: none;
  border-radius: 16px;
  padding: 6px 16px;
  font-size: 12px;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s;
}
.msg-jump-latest:hover {
  opacity: 0.9;
}
.msg-loading-more {
  text-align: center;
  padding: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.msg-limit-banner {
  text-align: center;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.msg-log-loading {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px;
  animation: boot-fade 0.2s ease-out var(--log-loading-delay, 0ms) both;
}
.msg-log-loading-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.msg-log-loading-row span {
  width: 75%;
}
.msg-log-loading-row span + span {
  width: 45%;
}
.msg-log-loading-row:nth-child(even) span:first-child {
  width: 60%;
}
.msg-log-loading-label {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

/* #endregion */

/* #region FINDINGS */
.findings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.finding-card {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
}
.finding-rank {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 1.6em;
  text-align: right;
  line-height: 1.7;
}
.finding-main {
  flex: 1;
  min-width: 0;
}
.finding-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}
.finding-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.finding-file {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  word-break: break-all;
}
.finding-summary {
  font-size: 0.88rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.finding-scenario {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.findings-result-note {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}
/* #endregion */

/* #region AGENT_FOOTER */
.agent-footer {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.agent-footer.visible {
  display: flex;
}
.agent-footer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px;
  cursor: pointer;
  user-select: none;
  color: var(--text-tertiary);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.agent-footer-header:hover {
  background: var(--bg-hover);
}
.agent-footer-toggle {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
}
.agent-footer-content {
  display: flex;
  gap: 10px;
  padding: 0 24px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.agent-footer.collapsed .agent-footer-content {
  display: none;
}
.agent-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  background: var(--bg-deep);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 180px;
  overflow: hidden;
  transition:
    opacity 0.3s,
    border-color 0.15s ease;
  cursor: pointer;
  position: relative;
}
.agent-card:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
}
.agent-card-log-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  padding: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.45;
  transition:
    opacity 0.15s,
    color 0.15s;
}
.agent-card-log-btn:hover {
  opacity: 1;
  color: var(--accent);
}
.agent-card.selected,
.agent-card.selected:hover {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
.agent-card.fading {
  opacity: 0.4;
}
.agent-task {
  max-width: 240px;
  padding-right: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-ident-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 240px;
  font-size: 11px;
  color: var(--text-secondary);
}
.agent-ident-sep {
  color: var(--text-muted);
  flex-shrink: 0;
}
.agent-type-ns {
  color: var(--text-muted);
}
.agent-type-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-owner-badge--compact {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 2px;
  flex-shrink: 0;
}
.agent-status-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.agent-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.agent-dot.active {
  background: var(--success);
  box-shadow: 0 0 4px color-mix(in srgb, var(--success) 50%, transparent);
}
.agent-dot.idle {
  background: var(--warning);
  box-shadow: 0 0 4px color-mix(in srgb, var(--warning) 50%, transparent);
}
.agent-dot.stopped {
  background: var(--text-muted);
}
.agent-type {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.agent-status {
  font-size: 10px;
  color: var(--text-muted);
}
.agent-card-model {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-dismiss-btn {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.agent-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  line-height: 1;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.terminal-badge {
  color: var(--text-secondary);
}
.terminal-badge:hover {
  color: var(--accent, var(--text-primary));
}
.dispatched-badge:not([onclick]) {
  cursor: default;
}
.dispatched-badge[onclick]:hover {
  color: var(--accent, var(--text-primary));
}
.agent-badge-waiting {
  color: var(--warning);
  animation: agent-badge-pulse 1.6s ease-in-out infinite;
}
.agent-badge-active {
  color: var(--accent, var(--text-secondary));
  animation: agent-badge-pulse 1.6s ease-in-out infinite;
}
@keyframes agent-badge-pulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

.linked-docs-badge,
.bookmarks-badge,
.scratchpad-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

.linked-docs-badge:hover,
.bookmarks-badge:hover,
.scratchpad-badge:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.linked-doc-list,
.scratch-file-list,
.zen-bookmark-list,
.artifact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.linked-doc-item,
.scratch-file-item,
.zen-bookmark-item,
.artifact-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.linked-doc-link,
.scratch-file-link,
.zen-bookmark-link,
.artifact-link {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.linked-doc-link,
.artifact-link {
  flex-shrink: 0;
}

.linked-doc-path {
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.scratch-file-time {
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Rides on the shared .row-actions group; only the reveal trigger differs — per row
   here, per grid in the session info. margin-left:auto pins the group to the same
   right edge however long the names in between are. */
.linked-doc-actions,
.scratch-file-actions,
.artifact-actions {
  margin-left: auto;
  align-self: center;
  flex-shrink: 0;
}

.linked-doc-item:hover .linked-doc-actions,
.scratch-file-item:hover .scratch-file-actions,
.artifact-item:hover .artifact-actions {
  opacity: 1;
}

/* Hangs off the Scratchpad path row, so it carries no header of its own. */
.scratch-files-section {
  margin-top: 6px;
  font-size: 11px;
}

.zen-bookmark-who {
  color: var(--text-muted);
  flex-shrink: 0;
}

.zen-bookmark-link,
.scratch-file-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
  /* A scratch name can be longer than the zen panel is wide; without this it pushes
     the action buttons out of their column. The full path is on the title. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-more {
  margin: 6px 0 0;
  font-size: 11px;
}

/* A folder row wraps so its child list lands on its own full-width line under the
   name, indented one chevron in. */
.scratch-folder-item {
  flex-wrap: wrap;
}

.scratch-folder-item > .scratch-file-list,
.scratch-folder-item > .scratch-folder-empty {
  flex-basis: 100%;
  margin-top: 4px;
  padding-left: 14px;
}

.scratch-folder-empty {
  color: var(--text-muted);
  opacity: 0.7;
}

.scratch-folder-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-secondary);
}

/* The × is a glyph, not an svg, so .row-actions button svg does not size it. */
.linked-doc-remove,
.artifact-remove {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1;
}

.linked-doc-actions .linked-doc-remove:hover,
.artifact-actions .artifact-remove:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}

/* A linked doc that does not open in the preview (the scratch viewer, or a file the
   previewer can't render) — the dashed underline keeps that difference visible before the click. */
.linked-doc-item.is-external .linked-doc-link {
  color: var(--text-secondary);
  text-decoration-style: dashed;
}

.linked-doc-item.is-url .linked-doc-link {
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-doc-external {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 10px;
  margin-left: -4px;
}

/* A section of the session panel: linked documents, artifacts. */
.panel-section {
  margin-bottom: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.linked-docs-section {
  margin-top: 12px;
}

/* Artifacts are read out of the transcript, so the section renders before the
   list arrives and stays in the DOM as the patch target when there is none. */
.artifacts-section:empty,
.scratch-files-section:empty {
  display: none;
}

.panel-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-section-header svg {
  width: 12px;
  height: 12px;
}

.panel-section-count {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 10px;
  color: var(--text-secondary);
}

/* The artifact title is a URL away from the reader, so it truncates where a file
   name, which the linked-doc row shows in full, does not. */
.artifact-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.linked-docs-empty,
.zen-panel-empty {
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
}

.linked-docs-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.linked-docs-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.linked-doc-editor-slot:not(:empty) {
  margin-bottom: 8px;
}

.linked-doc-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  box-shadow: 0 0 0 2px var(--accent-dim);
  outline: none;
}

.linked-doc-hint {
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Present but empty until a path fails to resolve. */
.linked-doc-error:empty {
  display: none;
}

.linked-doc-error {
  color: var(--danger);
  font-size: 11px;
  margin-top: 4px;
}

/* #endregion */

/* #region PERMISSION_PENDING */
.permission-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--warning-dim);
  border: 1px solid var(--warning);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--warning);
  white-space: nowrap;
  cursor: pointer;
  animation: permission-pulse 1.5s ease-in-out infinite;
}
.permission-badge:hover {
  background: color-mix(in srgb, var(--warning) 22%, transparent);
  animation-play-state: paused;
}
@keyframes permission-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* #endregion */

/* #region ANSI */

/* SGR colours from terminal output, consumed by every pane that renders it.
   The palette itself lives with the other colour tokens in VARIABLES /
   LIGHT_THEME / MEDIA_QUERIES, so it flips with the theme like everything else. */
.ansi-fg-black {
  color: var(--ansi-black);
}
.ansi-fg-red {
  color: var(--ansi-red);
}
.ansi-fg-green {
  color: var(--ansi-green);
}
.ansi-fg-yellow {
  color: var(--ansi-yellow);
}
.ansi-fg-blue {
  color: var(--ansi-blue);
}
.ansi-fg-magenta {
  color: var(--ansi-magenta);
}
.ansi-fg-cyan {
  color: var(--ansi-cyan);
}
.ansi-fg-white {
  color: var(--ansi-white);
}
.ansi-fg-bright-black {
  color: var(--ansi-bright-black);
}
.ansi-fg-bright-red {
  color: var(--ansi-bright-red);
}
.ansi-fg-bright-green {
  color: var(--ansi-bright-green);
}
.ansi-fg-bright-yellow {
  color: var(--ansi-bright-yellow);
}
.ansi-fg-bright-blue {
  color: var(--ansi-bright-blue);
}
.ansi-fg-bright-magenta {
  color: var(--ansi-bright-magenta);
}
.ansi-fg-bright-cyan {
  color: var(--ansi-bright-cyan);
}
.ansi-fg-bright-white {
  color: var(--ansi-bright-white);
}
.ansi-bg-black {
  background: var(--ansi-black);
}
.ansi-bg-red {
  background: var(--ansi-red);
}
.ansi-bg-green {
  background: var(--ansi-green);
}
.ansi-bg-yellow {
  background: var(--ansi-yellow);
}
.ansi-bg-blue {
  background: var(--ansi-blue);
}
.ansi-bg-magenta {
  background: var(--ansi-magenta);
}
.ansi-bg-cyan {
  background: var(--ansi-cyan);
}
.ansi-bg-white {
  background: var(--ansi-white);
}
.ansi-bg-bright-black {
  background: var(--ansi-bright-black);
}
.ansi-bg-bright-red {
  background: var(--ansi-bright-red);
}
.ansi-bg-bright-green {
  background: var(--ansi-bright-green);
}
.ansi-bg-bright-yellow {
  background: var(--ansi-bright-yellow);
}
.ansi-bg-bright-blue {
  background: var(--ansi-bright-blue);
}
.ansi-bg-bright-magenta {
  background: var(--ansi-bright-magenta);
}
.ansi-bg-bright-cyan {
  background: var(--ansi-bright-cyan);
}
.ansi-bg-bright-white {
  background: var(--ansi-bright-white);
}
.ansi-bg {
  padding: 0 1px;
  border-radius: 2px;
}
.ansi-inverse {
  background: var(--text-primary);
  color: var(--bg-deep);
}
.ansi-bold {
  font-weight: 700;
}
.ansi-dim {
  opacity: 0.65;
}
.ansi-italic {
  font-style: italic;
}
.ansi-underline {
  text-decoration: underline;
}
.ansi-strike {
  text-decoration: line-through;
}
.ansi-underline.ansi-strike {
  text-decoration: underline line-through;
}

/* #endregion */

/* #region LIGHT_THEME */
body.light {
  --on-accent: white;
  --bg-deep: #e8e6e3;
  --bg-surface: #efede9;
  --bg-elevated: #fbfaf9;
  --bg-hover: #d2d0cc;
  --session-active-bg: var(--bg-elevated);
  --border: #cfcbc4;
  --text-primary: #0a0a0a;
  --text-secondary: #2c2c2c;
  --text-tertiary: #565656;
  --text-muted: #767676;
  --accent-text: #a0501c;
  --accent-dim: rgba(184, 90, 32, 0.18);
  --accent-glow: rgba(232, 111, 51, 0.5);
  --gold: #a8842f;
  --success: #1a8a5a;
  --success-dim: rgba(26, 138, 90, 0.15);
  --info: #2563eb;
  --warning: #b07d0a;
  --warning-dim: rgba(176, 125, 10, 0.15);
  --danger: #c0392b;
  --danger-dim: rgba(192, 57, 43, 0.15);
  --ansi-red: #c0392b;
  --ansi-green: #1a8a5a;
  --ansi-yellow: #a8791a;
  --ansi-blue: #2b6cb0;
  --ansi-magenta: #8e44ad;
  --ansi-cyan: #1a7a7a;
  --ansi-bright-red: #e05548;
  --ansi-bright-green: #25a86f;
  --ansi-bright-yellow: #c2921f;
  --ansi-bright-blue: #3b82d6;
  --ansi-bright-magenta: #a855c9;
  --ansi-bright-cyan: #2a9a9a;
  --owner-blue: #163f8a;
  --owner-purple: #5524b0;
  --owner-teal: #064c3f;
  --owner-orange: #7a2c10;
  --owner-yellow: #634b06;
  --owner-pink: #831a4d;
  --owner-green: #0b4a22;
  --owner-indigo: #3730a3;
  --owner-red: #8f1d1d;
  --owner-cyan: #0b5566;
}

body.light::before {
  display: none;
}
body.light .session-latest-msg .lm-label-assistant {
  color: var(--text-primary);
}
body.light .msg-assistant .msg-text {
  color: var(--text-secondary);
}

/* #endregion */

/* #region INTERACTIVE */
.icon-btn.delete:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.column-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.column-header .icon-btn {
  width: 28px;
  height: 28px;
}

.column-header .icon-btn svg {
  width: 14px;
  height: 14px;
}

/* #endregion */

/* #region SEARCH */
.search-container {
  position: relative;
  padding: 0 16px 8px;
}

.search-input {
  width: 100%;
  padding: 9px 32px 9px 12px;
  background: var(--sidebar-item-bg, var(--bg-deep));
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 13px;
  transition: all 0.15s ease;
}

.search-input:hover {
  border-color: var(--border);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  right: 18px;
  top: 8px;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 3px;
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-clear.visible {
  display: flex;
}

/* #endregion */

/* #region MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-overlay.visible {
  display: flex;
}

/* For pickers: the dialog sits above the vertical centre so its list grows
   downward instead of shifting rows under the cursor as it filters. */
.modal-overlay.top-aligned {
  align-items: flex-start;
  padding-top: 12vh;
}

.stacked-modal-overlay {
  z-index: 10001;
  background: rgba(0, 0, 0, 0.6);
}

.modal {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 860px;
  max-height: 90vh;
  padding: 24px;
  box-shadow:
    0 16px 44px rgba(0, 0, 0, 0.38),
    0 4px 12px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

.modal.msg-detail-dialog:focus {
  outline: none;
}

/* Before .modal.fullscreen on purpose: at equal specificity the later
   fullscreen rule must win, same as for every other per-modal size. */
.modal.msg-detail-dialog {
  width: 90vw;
  max-width: calc(860px + var(--review-extra));
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* Height is a cap, not a floor — a two-line message should not sit in a 92vh box.
   The HTML preview keeps its explicit height below: its iframe is `height: 100%`
   and needs a resolvable parent height. */
.modal.fullscreen {
  width: 80vw;
  max-width: 80vw;
  max-height: 92vh;
}

.modal-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 1;
  color: var(--text-muted);
  opacity: 0.55;
  border-bottom-right-radius: 11px;
  background: linear-gradient(
    135deg,
    transparent 0 50%,
    currentColor 50% 56%,
    transparent 56% 64%,
    currentColor 64% 70%,
    transparent 70% 78%,
    currentColor 78% 84%,
    transparent 84%
  );
}

.modal-resize-handle:hover,
.modal-resize-handle.dragging {
  opacity: 1;
  color: var(--accent);
}

.modal.fullscreen .modal-resize-handle {
  display: none;
}

.modal.wide-modal {
  width: 60vw;
  max-width: 60vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal.wide-modal.fullscreen {
  width: 80vw;
  max-width: 80vw;
  height: 92vh;
  max-height: 92vh;
}

/* The comment panel opens beside the content, so the dialog grows by `--review-extra`
   instead of squeezing what is under review. */
.modal.review-host {
  --review-extra: 0px;
}

.review-host .modal-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.preview-modal-dialog {
  width: min(calc(90vw + var(--review-extra)), 96vw);
  max-width: calc(1200px + var(--review-extra));
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  outline: none;
}

.modal.preview-modal-dialog.fullscreen {
  width: 90vw;
  max-width: 90vw;
  height: 90vh;
  max-height: 90vh;
}

.preview-modal-dialog .modal-body {
  flex: 0 1 auto;
}

#msg-detail-body,
#preview-modal-body {
  word-break: break-word;
  font-size: 13px;
  line-height: 1.6;
  overflow-y: auto;
  flex: 0 1 auto;
  min-height: 0;
  padding-right: 8px;
}

/* Same reading size as the other modal bodies — `.detail-desc` is really the
   task-panel inline editor's style, and its 14px/1.7 is wrong here. */
.agent-tab-panel .detail-desc {
  font-size: 13px;
  line-height: 1.6;
}

/* One reading scale for every modal (Ctrl +/-/0). `zoom` rather than font-size
   because the bodies mix px, rem, inline sizes from tool rendering and an iframe.
   It hangs on the inner scrolling body — never on `.modal`, whose own vw/vh
   sizing would scale with it and push the dialog off-screen. */
.modal-zoomable {
  zoom: var(--modal-zoom, 1);
}

/* Height is left to the flex column under `.storage-modal`'s 85vh cap — a `vh`
   cap here would be multiplied by the zoom above. */
#storage-modal-body {
  overflow-y: auto;
  min-height: 200px;
  padding-top: 16px;
  padding-right: 8px;
}

.preview-image {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-hover);
}

#preview-modal-body .preview-image {
  max-height: 70vh;
}

#preview-modal-meta {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Rendered HTML pages need far more room than a markdown doc. */
.modal.preview-modal-dialog.preview-html {
  width: 96vw;
  max-width: 96vw;
  height: 92vh;
  max-height: 92vh;
}

/* Keeps the fullscreen button meaningful — the generic .fullscreen rule is smaller than this. */
.modal.preview-modal-dialog.preview-html.fullscreen {
  width: 98vw;
  max-width: 98vw;
  height: 98vh;
  max-height: 98vh;
}

/* User-dragged size (bottom-right grip, app.js initModalResize). Last of the
   modal sizing rules on purpose: at equal specificity, source order lets it
   beat every per-modal size above; fullscreen still wins via :not() while
   active, and JS keeps inline sizing off user-sized modals (autoSizeModal and
   "Show more" skip them, the drag clears leftovers). Height is a cap, not a
   floor (same rule as .fullscreen) — short content still collapses. min()
   keeps a size saved on a large screen inside the current viewport. */
.modal.user-sized:not(.fullscreen) {
  width: min(calc(var(--user-modal-w) + var(--review-extra, 0px)), 98vw);
  max-width: min(calc(var(--user-modal-w) + var(--review-extra, 0px)), 98vw);
  max-height: min(var(--user-modal-h), 95vh);
}

.modal.review-host.has-review {
  --review-extra: var(--review-panel-w);
}

/* Not on user-sized dialogs: the grip drag sets the width on every move and must not lag. */
.modal.review-host:not(.user-sized) {
  transition:
    width 150ms ease-out,
    max-width 150ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .modal.review-host {
    transition: none;
  }
}

.preview-split {
  display: flex;
  gap: 14px;
  flex: 0 1 auto;
  min-height: 0;
}

.preview-html .preview-split {
  flex: 1 1 auto;
}

.preview-split > #msg-detail-body,
.preview-split > #preview-modal-body {
  flex: 1 1 auto;
  min-width: 0;
}

.preview-html .modal-body,
.preview-html #preview-modal-body {
  flex: 1 1 auto;
  overflow: hidden;
  padding-right: 0;
}

/* Source is read line by line, so it keeps its own line breaks and scrolls sideways
   instead of inheriting the body's `word-break: break-word`. */
.preview-source {
  --src-pad-y: 10px;
  position: relative;
  margin: 0;
  padding: var(--src-pad-y) 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  word-break: normal;
  tab-size: 4;
}

.preview-source:has(.src-gutter) {
  display: grid;
  grid-template-columns: auto 1fr;
  padding-left: 0;
}

/* Sticky, so the numbers stay put while the code scrolls sideways. */
.preview-source .src-gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  margin-right: 12px;
  padding: 0 10px 0 12px;
  text-align: right;
  color: var(--text-muted);
  background: inherit;
  border-right: 1px solid var(--border);
  user-select: none;
}

/* `.hljs` in the selector outranks the theme's `pre code.hljs` padding and scroll, which would
   shift the text off the gutter and the line band. */
.preview-source code.hljs {
  position: relative;
  background: none;
  padding: 0;
  overflow: visible;
  font: inherit;
}

/* Lines never wrap (white-space: pre), so line N starts N - 1 line heights below the padding. */
.preview-source .src-line {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--src-pad-y) + var(--line) * 1lh);
  height: 1lh;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 2px 0 0 var(--accent);
  z-index: 2;
  pointer-events: none;
}

.preview-html-frame {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 6px;
  /* Pages authored for a light page default would be unreadable on the dark theme. */
  background: #fff;
}

/* The card base paints the body with --color-bg, which is --bg-surface; a white frame would
   show at the rounded corners. */
.preview-html-frame.show-base {
  background: var(--bg-surface);
}

/* The server refuses a pane for a file it cannot preview. */
.modal.preview-none #preview-pane-btn {
  display: none;
}

.preview-fm {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated, rgba(127, 127, 127, 0.06));
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 11px;
}

.preview-fm > summary {
  cursor: pointer;
  padding: 6px 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  user-select: none;
}

.preview-fm[open] > summary {
  border-bottom: 1px solid var(--border);
}

.preview-fm .fm-grid {
  padding: 8px 10px;
  display: grid;
  gap: 4px 12px;
}

.preview-fm .fm-row {
  display: grid;
  grid-template-columns: minmax(80px, 140px) 1fr;
  gap: 12px;
  align-items: baseline;
}

.preview-fm .fm-k {
  color: var(--accent);
  font-weight: 600;
}

.preview-fm .fm-v {
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

.modal-sm {
  max-width: 440px;
}

/* #region CONFIRM_DIALOG */
#confirm-modal {
  z-index: 10001;
}

.confirm-dialog {
  padding: 0;
  max-width: 560px;
  overflow: hidden;
}

.confirm-body {
  padding: 20px 20px 6px;
  display: grid;
  gap: 12px;
}

.confirm-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.confirm-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 700;
}

.confirm-title {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
}

.confirm-message {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.confirm-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirm-list {
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.confirm-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
}

.confirm-row + .confirm-row {
  border-top: 1px solid var(--border);
}

.confirm-row-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.confirm-row-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.confirm-step::before {
  content: '→';
  color: var(--accent);
}

.confirm-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.confirm-dot.busy {
  background: var(--success);
}

.confirm-dot.wait {
  background: var(--warning);
}

.confirm-warn {
  font-size: 12px;
  color: var(--warning);
}

.confirm-footer {
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px 16px;
}

.confirm-hint {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-muted);
}

.confirm-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.confirm-buttons {
  display: flex;
  gap: 8px;
}

.confirm-buttons .btn {
  padding: 8px 16px;
  white-space: nowrap;
}

/* The modal focuses a button itself, and after a mouse click Chrome does not match
   :focus-visible for that, so Enter would act on a button with no ring. */
.confirm-buttons .btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* #endregion */

/* Reference card, not reading material: it stays out of the modal zoom, uses the app's
   small type, and scrolls its body (rule shared with #team-modal) instead of growing past
   the viewport cap. */
.modal-help {
  max-width: 900px;
  height: min(700px, 90vh);
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.modal-help .modal-header {
  margin-bottom: 8px;
}
.modal-help .modal-title {
  font-size: 14px;
}

.help-docs {
  margin: 0 12px 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.help-docs:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* One shared grid for both halves (key | label | spacer | key | label): each key
   gutter is sized by its column's widest combo, and left/right rows share row
   tracks, so paired groups line up — a shorter group just leaves empty rows.
   Cells opt into a half via sc-l / sc-r; the markup is generated from
   SHORTCUT_TABS in app.js. */
.shortcuts {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr 28px max-content 1fr;
  column-gap: 14px;
}

.shortcuts dt.sc-l {
  grid-column: 1;
}
.shortcuts dd.sc-l {
  grid-column: 2;
}
.shortcuts dt.sc-r {
  grid-column: 4;
}
.shortcuts dd.sc-r {
  grid-column: 5;
}
.shortcuts .sc-group.sc-l {
  grid-column: 1 / 3;
}
.shortcuts .sc-group.sc-r {
  grid-column: 4 / 6;
}

.shortcuts dt {
  margin: 0;
  display: flex;
  align-items: center;
  align-self: center;
  gap: 4px;
  padding: 3px 0;
}

.shortcuts dd {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  align-self: center;
  padding: 3px 0;
}

/* Section headings carry the column: full-width rule + primary ink, so the eye
   finds the group before it reads any single row. */
.shortcuts .sc-group {
  padding: 18px 0 6px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.shortcuts .sc-group.sc-first {
  padding-top: 2px;
}

/* keycap chips: elevated fill + thicker bottom border reads as a key */
.sp-hint kbd,
.shortcuts kbd,
.terminal-boot-slow kbd,
.review-offer-btn kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  box-sizing: border-box;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-primary);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.shortcuts .sc-plus,
.shortcuts .sc-or {
  color: var(--text-muted);
  font-size: 11px;
}

.shortcuts .sc-empty {
  grid-column: 1 / -1;
  padding: 24px 0;
  color: var(--text-muted);
  text-align: center;
}

.help-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-tabs {
  display: flex;
}

.help-bar .help-filter {
  margin: 0 0 6px auto;
  width: 220px;
  padding: 4px 10px;
  font-size: 12px;
}

@keyframes live-border-pulse {
  0%,
  100% {
    border-color: var(--accent);
    box-shadow:
      0 20px 60px rgba(0, 0, 0, 0.5),
      0 0 20px var(--accent-dim),
      0 0 4px var(--accent);
  }
  50% {
    border-color: var(--accent-dim);
    box-shadow:
      0 20px 60px rgba(0, 0, 0, 0.5),
      0 0 6px var(--accent-dim);
  }
}
.modal-overlay.live-overlay {
  background: rgba(0, 0, 0, 0.25);
}
.modal.live {
  border-width: 2px;
  animation: live-border-pulse 2s ease-in-out infinite;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  margin-bottom: 0;
  overflow-y: auto;
  min-height: 0;
}

.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 14px;
  transition: all 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder {
  color: var(--text-muted);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  font-family: var(--mono);
}

select.form-input[multiple] {
  padding: 4px;
}

select.form-input optgroup {
  background: var(--bg-surface);
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 8px 4px 8px;
  margin-top: 4px;
  font-style: normal;
}

select.form-input optgroup:first-child {
  margin-top: 0;
}

select.form-input option {
  padding: 8px 8px 8px 16px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 400;
  font-size: 13px;
  border-radius: 4px;
  margin: 2px 4px;
}

select.form-input option:checked {
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 500;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 16px;
  flex-shrink: 0;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.offline-card .btn {
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 82%, black);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-danger {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: var(--accent);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* #endregion */

/* #region REVIEW */
::highlight(review) {
  background-color: var(--warning-dim);
}

::highlight(review-hot),
::highlight(review-pending) {
  background-color: color-mix(in srgb, var(--warning) 45%, transparent);
}

#review-pop {
  display: none;
  position: fixed;
  z-index: 10010;
  font-family: var(--mono);
  font-size: 12px;
}

#review-pop.visible {
  display: block;
}

#review-pop.editor {
  width: 320px;
  padding: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#review-pop textarea,
.review-card-edit {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 6px;
  padding: 6px;
  resize: vertical;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

#review-pop.offer {
  animation: review-offer-in 120ms ease-out;
}

#review-pop button.review-offer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  background: var(--bg-elevated);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#review-pop button.review-offer-btn:hover,
#review-pop button.review-offer-btn:focus-visible {
  border-color: var(--accent);
}

.review-offer-btn svg {
  width: 13px;
  height: 13px;
  margin: 0;
  color: var(--accent);
}

.review-offer-btn kbd {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  color: var(--text-muted);
  border-radius: 3px;
}

@keyframes review-offer-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #review-pop.offer {
    animation: none;
  }
}

.review-card-quote {
  overflow: hidden;
  padding-left: 8px;
  color: var(--text-muted);
  border-left: 2px solid var(--warning);
}

.review-pop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

#review-pop button,
.review-panel button {
  padding: 3px 10px;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

#review-pop button.primary,
.review-panel button.primary {
  color: var(--on-accent, var(--bg-deep));
  background: var(--accent);
  border-color: var(--accent);
}

.review-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 calc(var(--review-panel-w) - 14px);
  min-height: 0;
  padding-left: 12px;
  font-family: var(--mono);
  font-size: 12px;
  border-left: 1px solid var(--border);
}

.review-panel[hidden] {
  display: none;
}

.review-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
}

.review-panel-head span {
  flex: 1;
  color: var(--text-muted);
}

.review-panel-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-panel button.review-discard,
.review-panel button.review-remove,
.review-panel button.review-edit {
  padding: 3px 4px;
  color: var(--text-muted);
  background: none;
  border: none;
}

.review-panel button.review-discard:hover,
.review-panel button.review-discard:focus-visible {
  color: var(--text-primary);
  text-decoration: underline;
}

.review-card {
  position: relative;
  padding: 8px 44px 10px 0;
  cursor: pointer;
}

.review-card + .review-card {
  border-top: 1px solid var(--border);
}

.review-card-quote {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
  border-left-color: var(--warning-dim);
}

.review-card:hover .review-card-quote,
.review-card.hot .review-card-quote {
  color: var(--text-primary);
  border-left-color: var(--warning);
}

.review-card-comment {
  white-space: pre-wrap;
  word-break: break-word;
}

.review-panel button.review-remove,
.review-panel button.review-edit {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 6px;
}

.review-panel button.review-edit {
  right: 24px;
}

.review-edit svg {
  width: 11px;
  height: 11px;
}

.review-card-edit {
  border-color: var(--accent);
}

.review-orphan {
  margin-right: 6px;
  padding: 0 4px;
  font-size: 10px;
  color: var(--warning);
  border: 1px solid var(--warning-dim);
  border-radius: 3px;
}
/* #endregion */

/* #region SESSION_PICKER */
.modal.session-picker {
  max-width: 920px;
  max-height: 74vh;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.sp-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sp-head .sp-input {
  flex: 1;
}

.sp-scope {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.sp-scope button {
  padding: 4px 10px;
  background: none;
  border: none;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.sp-scope button:hover {
  color: var(--text-secondary);
}

.sp-scope button[aria-checked='true'] {
  background: var(--bg-deep);
  color: var(--text-primary);
}

.sp-section {
  margin-top: 8px;
  padding: 2px 8px;
  color: var(--text-muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sp-input {
  padding: 10px 12px;
  background: var(--bg-deep);
  font-size: 14px;
}

.modal.session-picker.peeking {
  max-width: 1240px;
}

.sp-body {
  display: flex;
  gap: 10px;
  min-height: 0;
}

.sp-body > * {
  min-width: 0;
}

.sp-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sp-peek {
  flex: 0 0 42%;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.modal.session-picker:not(.peeking) .sp-peek {
  display: none;
}

.sp-peek-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row clicks open the live panel's detail modal by index, which means nothing
   for a peeked session. The renderer's readOnly mode already drops the buttons. */
.sp-peek-items {
  pointer-events: none;
}

.sp-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.sp-row:hover {
  background: var(--bg-hover);
}

.sp-row.selected {
  background: var(--bg-elevated);
  border-color: var(--accent);
}

.sp-state {
  flex: none;
  width: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.sp-state.live {
  color: var(--success);
}

.sp-state.active {
  color: var(--accent);
}

.sp-state.waiting {
  color: var(--warning);
}

.sp-state.just-finished {
  color: var(--success-faded);
}

.sp-state.recent {
  color: var(--text-tertiary);
}

.sp-state.idle {
  color: var(--text-muted);
}

.sp-state .activity-dot {
  background: currentColor;
}

.sp-state.idle .activity-dot {
  background: transparent;
  border: 1px solid currentColor;
}

.sp-name,
.sp-project,
.sp-branch {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-name {
  flex: none;
  max-width: 40%;
  color: var(--text-primary);
}

.sp-pin {
  flex: none;
  width: 14px;
  display: flex;
  justify-content: center;
  line-height: 0;
}

.sp-pin.pinned svg {
  fill: var(--accent);
  stroke: var(--accent);
}

.sp-pin.sticky svg {
  fill: var(--warning);
  stroke: var(--warning);
}

.sp-row:not(.outside) + .sp-row.outside {
  margin-top: 8px;
}

.sp-section + .sp-row.outside {
  margin-top: 0;
}

.sp-row.current .sp-name {
  color: var(--accent-text);
}

.sp-project {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
}

.sp-branch {
  flex: none;
  max-width: 25%;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-tertiary);
  font-size: 11.5px;
}

.sp-count,
.sp-time {
  flex: none;
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.sp-time {
  min-width: 62px;
  text-align: right;
}

.sp-empty {
  padding: 20px 8px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.sp-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11px;
}

.pp-chips {
  display: flex;
  gap: 6px;
}

.sp-row.recent .sp-name::before {
  content: '•';
  margin-right: 5px;
  color: var(--accent-text);
}

/* #endregion */

/* #region NEW_SESSION */
.modal.new-session-modal {
  width: 640px;
  max-width: calc(100vw - 32px);
  overflow: visible;
}

.ns-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: visible;
}

.ns-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.new-session-modal.ns-resume .ns-extra {
  display: none;
}

.ns-label {
  padding-top: 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.ns-body .form-input {
  padding: 8px 10px;
  font-size: 13px;
}

.ns-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ns-inline .form-input {
  flex: 1;
  min-width: 0;
}

.ns-body select.form-input {
  appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8d95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.ns-notched {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.ns-notched:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.ns-notched legend {
  margin: 0 8px 0 auto;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 500;
  line-height: 13px;
  color: var(--text-secondary);
}

.ns-notched:focus-within legend {
  color: var(--accent-text);
}

/* The legend's lower half sits inside the box, so less top padding keeps the box as tall as a plain input. */
.ns-body .ns-notched select.form-input,
.ns-body .ns-notched select.form-input:focus {
  padding-top: 2px;
  font-size: 12px;
  background-position: right 10px top calc(50% - 3px);
  border: none;
  background-color: transparent;
  box-shadow: none;
}

.ns-body .btn.ns-browse {
  flex: none;
  padding: 8px 12px;
}

.ns-folder-field {
  position: relative;
}

.ns-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 2;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.ns-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
}

.ns-option:hover,
.ns-option.active {
  background: var(--bg-hover);
}

.ns-option.active {
  box-shadow: inset 2px 0 0 var(--accent);
}

.ns-option-name {
  flex: none;
  font-weight: 500;
  color: var(--text-primary);
}

.ns-option-path {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.ns-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.ns-check {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}

.ns-check input {
  accent-color: var(--accent);
}

.ns-check:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.ns-body textarea.form-input {
  min-height: 0;
}

.ns-prompt-field {
  position: relative;
}

.ns-prompt-field:has(.ns-mic:not([hidden])) textarea {
  padding-right: 36px;
}

.ns-mic {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.ns-mic[hidden] {
  display: none;
}

.ns-mic svg {
  width: 15px;
  height: 15px;
}

.ns-mic:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.ns-mic[aria-pressed='true'] {
  color: var(--danger);
  animation: ns-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes ns-mic-pulse {
  50% {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ns-mic[aria-pressed='true'] {
    animation: none;
  }
}

.ns-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ns-images[hidden] {
  display: none;
}

.ns-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: zoom-in;
}

.ns-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ns-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  cursor: pointer;
}

.ns-thumb-remove:hover {
  background: var(--danger);
}

.ns-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.75);
  cursor: zoom-out;
}

.ns-lightbox[hidden] {
  display: none;
}

.ns-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.ns-error {
  font-size: 12px;
  color: var(--danger);
}

.ns-footer {
  align-items: center;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.ns-stay,
.ns-edit {
  color: var(--text-tertiary);
}

.ns-edit {
  margin-right: auto;
}

.new-session-modal.ns-resume .ns-stay,
.new-session-modal.ns-resume .ns-edit {
  visibility: hidden;
}

.ns-footer .btn-primary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ns-footer .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .session-waiting .pulse {
    animation: none;
  }
}
/* #endregion */

/* #region TOOL_STATS */
.modal.tool-stats-modal {
  width: 90%;
  max-width: 860px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.tool-stats-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tool-stats-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 80px;
}

.tool-stats-chip-val {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.tool-stats-chip-val.failed {
  color: var(--danger);
}

.tool-stats-chip-lbl {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 8px;
}

.tool-stats-table thead th {
  text-align: right;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.tool-stats-table thead th:first-child {
  text-align: left;
}

.tool-stats-table thead th:hover {
  color: var(--text-primary);
}

.tool-stats-table tbody tr:nth-child(even) {
  background: var(--bg-surface);
}

.tool-stats-table tbody td {
  padding: 6px 10px;
  text-align: right;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.tool-stats-table tbody td.tool-name {
  text-align: left;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
}

.impact-cell-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.badge-success {
  display: inline-block;
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-failed {
  display: inline-block;
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-rejected {
  display: inline-block;
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
}

.tool-stats-chip-val.rejected {
  color: var(--warning);
}

.impact-bar-wrap {
  width: 48px;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-hover);
  flex-shrink: 0;
  overflow: hidden;
}

.impact-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  min-width: 2px;
}

.impact-pct {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 32px;
  text-align: right;
}
/* #endregion */

/* #region SCRATCHPAD */
.scratchpad-modal {
  width: 90%;
  max-width: 600px;
}

.scratchpad-textarea {
  width: 100%;
  min-height: 200px;
  max-height: 50vh;
  resize: vertical;
  padding: 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease;
}

.scratchpad-textarea:focus {
  border-color: var(--accent);
}

.scratchpad-textarea::placeholder {
  color: var(--text-muted);
}

.scratchpad-footer {
  justify-content: space-between;
}

.scratchpad-charcount {
  font-size: 12px;
  color: var(--text-muted);
  align-self: center;
}

.scratchpad-header {
  position: relative;
}

.scratchpad-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scratchpad-emoji-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.scratchpad-emoji-btn.set {
  border-style: solid;
  border-color: var(--accent);
}

.scratchpad-emoji-btn:hover {
  border-color: var(--accent);
}

.scratchpad-emoji-btn[hidden] {
  display: none;
}

.scratchpad-emoji-picker {
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 5;
  width: 300px;
  padding: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  outline: none;
}

.scratchpad-emoji-picker.open {
  display: block;
}

.scratchpad-emoji-grid {
  display: grid;
  gap: 2px;
}

.scratchpad-emoji-grid button {
  padding: 4px 0;
  font-size: 18px;
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.scratchpad-emoji-grid button:hover,
.scratchpad-emoji-grid button.kb {
  background: var(--bg-hover);
}

.scratchpad-emoji-grid button.cur {
  background: var(--accent-dim);
}

.scratchpad-emoji-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.scratchpad-emoji-row .form-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 13px;
}

.scratchpad-badge.has-emoji {
  font-size: 13px;
  line-height: 18px;
  padding: 0 5px;
}
/* #endregion */

/* #region STORAGE_MANAGER */
.storage-modal {
  width: 90%;
  max-width: 860px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.storage-project-group {
  margin-bottom: 12px;
}

.storage-project-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: 6px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.storage-project-header .storage-item-meta {
  font-weight: 400;
}

.storage-session-group {
  padding-left: 12px;
  border-left: 2px solid color-mix(in srgb, var(--border) 60%, transparent);
  margin-left: 8px;
  margin-bottom: 8px;
}

.storage-total {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.storage-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: -4px -24px 0;
  padding: 0 24px;
  flex-shrink: 0;
}

.storage-tab,
.help-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 13px;
  font-family: var(--mono);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.storage-tab:hover,
.help-tab:hover {
  color: var(--text-primary);
}

.storage-tab.active,
.help-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.storage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  gap: 8px;
}

.storage-item:last-child {
  border-bottom: none;
}

.storage-item-clickable {
  cursor: pointer;
}

.storage-item-clickable:hover {
  background: var(--bg-hover);
  border-radius: 4px;
}

.storage-item-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.storage-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.storage-item-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  flex-shrink: 0;
  font-family: var(--mono);
}

.storage-item-badge.orphan {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}

.storage-item-badge.pinned {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.storage-item-badge.sticky {
  background: color-mix(in srgb, var(--gold) 15%, transparent);
  color: var(--gold);
}

.storage-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.storage-item-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--mono);
  transition: all 0.15s;
}

/* Icon buttons sit beside text ones here, and copyWithFeedback swaps the glyph for a
   checkmark, so both svgs need a size or the button jumps on click. */
.storage-item-actions button svg {
  width: 12px;
  height: 12px;
  display: block;
}

.storage-item-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.storage-item-actions button.danger:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.storage-group-header {
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 0 4px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.storage-group-header:first-child {
  padding-top: 0;
}

.storage-group-header.storage-group-row {
  padding: 6px 0;
}

.storage-group-row .storage-item-actions {
  align-items: center;
  gap: 8px;
}

.storage-empty {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 13px;
}
/* #endregion */

/* #region A11Y */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 100000;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Visually hidden (a11y) */
.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;
}

/* #endregion */

/* #region MEDIA_QUERIES */
@media (prefers-color-scheme: light) {
  body:not(.dark-forced) {
    --on-accent: white;
    --bg-deep: #e8e6e3;
    --bg-surface: #efede9;
    --bg-elevated: #fbfaf9;
    --bg-hover: #d2d0cc;
    --session-active-bg: var(--bg-elevated);
    --border: #cfcbc4;
    --text-primary: #0a0a0a;
    --text-secondary: #2c2c2c;
    --text-tertiary: #565656;
    --text-muted: #767676;
    --accent-text: #a0501c;
    --accent-dim: rgba(184, 90, 32, 0.18);
    --accent-glow: rgba(232, 111, 51, 0.5);
    --gold: #a8842f;
    --success: #1a8a5a;
    --success-dim: rgba(26, 138, 90, 0.15);
    --info: #2563eb;
    --warning: #b07d0a;
    --warning-dim: rgba(176, 125, 10, 0.15);
    --danger: #c0392b;
    --danger-dim: rgba(192, 57, 43, 0.15);
    --ansi-red: #c0392b;
    --ansi-green: #1a8a5a;
    --ansi-yellow: #a8791a;
    --ansi-blue: #2b6cb0;
    --ansi-magenta: #8e44ad;
    --ansi-cyan: #1a7a7a;
    --ansi-bright-red: #e05548;
    --ansi-bright-green: #25a86f;
    --ansi-bright-yellow: #c2921f;
    --ansi-bright-blue: #3b82d6;
    --ansi-bright-magenta: #a855c9;
    --ansi-bright-cyan: #2a9a9a;
    --owner-blue: #163f8a;
    --owner-purple: #5524b0;
    --owner-teal: #064c3f;
    --owner-orange: #7a2c10;
    --owner-yellow: #634b06;
    --owner-pink: #831a4d;
    --owner-green: #0b4a22;
    --owner-indigo: #3730a3;
    --owner-red: #8f1d1d;
    --owner-cyan: #0b5566;
  }

  body:not(.dark-forced)::before {
    display: none;
  }
}

/* #endregion */

/* #region MERMAID */
pre.mermaid {
  text-align: center;
  background: transparent;
  overflow-x: auto;
}
pre.mermaid svg {
  max-width: 100%;
}
/* Hides the diagram source while it loads; a failed diagram shows its error instead. */
pre.mermaid:not(:has(svg), [data-mermaid-error]) {
  min-height: 40px;
  font-size: 0;
}
pre.mermaid:not(:has(svg), [data-mermaid-error])::before {
  content: 'Rendering diagram…';
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}
pre.mermaid[data-mermaid-error] {
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  font-size: 12px;
  text-align: left;
  white-space: pre-wrap;
  color: var(--text-secondary);
}
pre.mermaid[data-mermaid-error]::before {
  content: 'Diagram failed to render\A';
  color: var(--danger);
}
.modal.has-mermaid {
  width: 80vw;
  max-width: 80vw;
  max-height: 90vh;
}
/* #endregion */

/* #region ANIMATIONS */
/* No `to` and fill backwards: the card ends on its own opacity (.completed, .dim), not on 1. */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.column-tasks .task-card {
  animation: fadeSlideIn 150ms ease-out backwards;
}

.column-tasks .task-card:nth-child(1) {
  animation-delay: 0ms;
}
.column-tasks .task-card:nth-child(2) {
  animation-delay: 30ms;
}
.column-tasks .task-card:nth-child(3) {
  animation-delay: 60ms;
}
.column-tasks .task-card:nth-child(4) {
  animation-delay: 90ms;
}
.column-tasks .task-card:nth-child(5) {
  animation-delay: 120ms;
}
.column-tasks .task-card:nth-child(6) {
  animation-delay: 150ms;
}
.column-tasks .task-card:nth-child(7) {
  animation-delay: 180ms;
}
.column-tasks .task-card:nth-child(8) {
  animation-delay: 210ms;
}
.column-tasks .task-card:nth-child(9) {
  animation-delay: 240ms;
}
.column-tasks .task-card:nth-child(10) {
  animation-delay: 270ms;
}

/* Connection status breathing */
@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

/* Progress bar shimmer */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.progress-fill.shimmer {
  background: linear-gradient(90deg, var(--accent) 0%, rgba(232, 111, 51, 0.75) 50%, var(--accent) 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* #endregion */

/* #region PROJECT_GROUPS */
.project-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  margin-top: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.project-group-header:first-child {
  margin-top: 0;
}

.project-group-header:hover {
  color: var(--text-primary);
}

.project-group-header.kb-selected,
.pinned-sub-header.kb-selected,
.sg-section-toggle.kb-selected {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-radius: 4px;
}

.project-group-header .group-chevron,
.session-group-header .group-chevron,
.sg-section-toggle .group-chevron,
.scratch-folder-toggle .group-chevron {
  transition: transform 0.15s ease;
  flex-shrink: 0;
  display: block;
}

.project-group-header.collapsed .group-chevron,
.session-group-header.collapsed .group-chevron,
.sg-section-toggle.collapsed .group-chevron,
.scratch-folder-toggle.collapsed .group-chevron {
  transform: rotate(-90deg);
}

.project-group-header .group-name,
.session-group-header .group-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-group-header .group-name {
  flex: 1;
}

.project-view-btn,
.project-new-btn,
.header-pad-btn {
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition:
    color 0.15s,
    opacity 0.15s;
}

.project-view-btn:hover,
.project-new-btn:hover,
.header-pad-btn:hover {
  color: var(--accent);
}

.project-new-btn,
.header-pad-btn {
  opacity: 0;
}

.project-group-header:hover .project-new-btn,
.project-group-header.kb-selected .project-new-btn {
  opacity: 1;
}

.header-pad-btn.has-pad {
  color: var(--accent);
}

.header-pad-btn.has-pad,
.project-group-header:hover .header-pad-btn,
.project-group-header.kb-selected .header-pad-btn,
.session-group-header:hover .header-pad-btn,
.session-group-header.kb-selected .header-pad-btn {
  opacity: 1;
}

.project-group-header .group-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
}

.project-group-header .group-count-active {
  color: var(--success);
  font-weight: 500;
}

.project-group-header .group-count-sep {
  margin: 0 1px;
  opacity: 0.5;
}

.project-group-header .group-path-toggle {
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.project-group-header .group-path-toggle:hover {
  color: var(--accent);
}

.project-group-breadcrumb {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 10px 0 28px;
  font-family: var(--mono);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.2s ease,
    opacity 0.15s ease,
    padding 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.project-group-breadcrumb.expanded {
  max-height: 24px;
  opacity: 1;
  padding: 2px 10px 4px 28px;
}

.project-group-breadcrumb:hover {
  color: var(--accent);
}

.project-group-breadcrumb .sep {
  opacity: 0.4;
}

.project-group-sessions {
  display: block;
}

.project-group-sessions.collapsed {
  display: none;
}

.pinned-sub-section {
  margin-bottom: 2px;
}

.pinned-sub-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 3px 18px;
  cursor: pointer;
  user-select: none;
  font-size: 10px;
  color: var(--text-muted);
}

.pinned-sub-header:hover {
  color: var(--text-secondary);
}

.pinned-sub-header .group-chevron {
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.pinned-sub-header.collapsed .group-chevron {
  transform: rotate(-90deg);
}

.pinned-sub-label {
  font-weight: 500;
  letter-spacing: 0.3px;
}

.pinned-ungroup-btn,
.sg-action {
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  opacity: 0;
  transition:
    opacity 0.15s,
    color 0.15s;
}

.pinned-ungroup-btn {
  margin-left: auto;
  font-size: 14px;
  padding: 0 2px;
}

.pinned-sub-header:hover .pinned-ungroup-btn,
.session-group-header:hover .sg-action {
  opacity: 1;
}

.pinned-ungroup-btn:hover,
.sg-action:hover {
  color: var(--accent);
}

.sg-transient .group-name {
  font-weight: 500;
  color: var(--text-secondary);
}

.sg-keep {
  font-size: 10px;
  font-weight: 500;
}

.pinned-sub-items.collapsed {
  display: none;
}

.pinned-regroup-banner {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.pinned-regroup-banner:hover {
  color: var(--accent);
}

/* #endregion */

/* #region SESSION_GROUPS */
.sg-section-label {
  padding: 10px 10px 2px;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.sg-section-label:first-child {
  margin-top: 0;
}

.sg-section-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
  cursor: pointer;
}

.sg-section-toggle:hover {
  color: var(--text-primary);
}

.session-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  margin-top: 2px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 4px;
  background: transparent;
}

.session-group-header:hover {
  background: var(--bg-hover);
}

.session-group-header.kb-selected {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.session-group-header.sg-zen {
  color: var(--accent);
}

.sg-sub-label {
  padding: 8px 10px 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
}

.sg-name-input {
  flex: 1;
  min-width: 0;
  padding: 1px 4px;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-deep);
  border: 1px solid var(--accent);
  border-radius: 3px;
  outline: none;
}

.sg-action.sg-rename {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.sg-action.sg-delete {
  font-size: 15px;
  padding: 0 2px;
}

.session-group-sessions {
  display: block;
  margin-left: 6px;
}

.session-group-sessions .session-group-sessions {
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

.session-item.sg-child {
  width: calc(100% - var(--sg-indent));
  margin-left: var(--sg-indent);
}

.session-item.sg-depth-1 {
  --sg-indent: 14px;
}

.session-item.sg-depth-2 {
  --sg-indent: 28px;
}

.session-item.sg-depth-3 {
  --sg-indent: 42px;
}

.session-group-sessions.collapsed,
.sg-section-body.collapsed {
  display: none;
}

.sg-empty {
  padding: 10px 8px;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 4px;
  margin: 4px 2px;
  text-align: center;
}

.project-group-header.sg-nested {
  margin-top: 4px;
  padding-top: 4px;
}

/* Drag feedback */
.session-item.sg-dragging,
.project-group-header.sg-dragging,
.session-group-header.sg-dragging {
  opacity: 0.45;
}

.sg-drop-over {
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
  background: var(--accent-dim);
}

/* Centered in the 6px gap between cards (.session-item margin-bottom). */
.session-item.sg-insert-before::after,
.session-item.sg-insert-after::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  pointer-events: none;
}

.session-item.sg-insert-before::after {
  top: -5px;
}

/* A drop on the top edge of a child group's header goes to its parent group. */
.session-group-header.sg-insert-parent {
  position: relative;
}

.session-group-header.sg-insert-parent::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -8px;
  right: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  pointer-events: none;
}

.session-item.sg-insert-after::after {
  bottom: -5px;
}

/* An empty section shows only while a drag needs its ungroup drop zone. */
.sessions-list:not(.sg-dragging-active) .sg-section-empty {
  display: none;
}

.sessions-list.sg-dragging-active .sg-ungroup-zone {
  border: 1px dashed var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
}

/* Move-to-group menu (right-click / long-press); the pane tab menu shares the look */
.sg-menu,
.pane-menu {
  position: fixed;
  z-index: 3000;
  min-width: 180px;
  max-width: 260px;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sg-menu-label,
.pane-menu-label {
  padding: 6px 8px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.sg-menu-item,
.pane-menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: none;
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.sg-menu-item:hover,
.sg-menu-item:focus-visible,
.pane-menu-item:hover,
.pane-menu-item:focus-visible {
  background: var(--bg-hover);
  outline: none;
}

.sg-menu-remove {
  color: var(--text-secondary);
}

.pane-menu {
  font-family: var(--font-mono);
}

.pane-menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}
.pane-menu-path {
  display: flex;
}
.pane-menu-dir {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
}
.pane-menu-name {
  flex: none;
  color: var(--text-primary);
  font-weight: 600;
}
.pane-menu-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--g);
}
.pane-menu-swatches {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}
.pane-menu-item.pane-menu-swatch {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  background: var(--g);
}
.pane-menu-item.pane-menu-swatch:hover,
.pane-menu-item.pane-menu-swatch:focus-visible,
.pane-menu-swatch.on {
  background: var(--g);
  box-shadow:
    0 0 0 2px var(--bg-elevated),
    0 0 0 3px var(--text-primary);
}
/* #endregion */
