/*
 * ── CAR UI STYLE GUIDE ─────────────────────────────────────────────
 *
 * DENSITY
 *   Prefer compact over spacious. Mobile chrome should feel thin.
 *   Cards: 4-8 px padding.  Touch targets: ≥ 44 px (Apple HIG).
 *   Use --sp-* tokens (2/4/6/8/12/16/24) instead of magic numbers.
 *
 * BADGES
 *   Badges (pills) belong immediately after the element they describe.
 *   Repo rows: title then badges, left-aligned. Action buttons right.
 *
 * MODALS
 *   Section groups separated by subtle border-bottom.
 *   Danger sections: label in --error colour, no extra wrapper div.
 *   Modal actions: right-aligned, top-bordered from body.
 *
 * RESPONSIVE
 *   Avoid column stacking for repo rows; prefer horizontal wrapping.
 *   On mobile, shrink font/padding rather than reflowing layout.
 *
 * TOKENS
 *   Always reference :root variables for colours, spacing, radius.
 *   New components must use --sp-* for all spacing values.
 * ───────────────────────────────────────────────────────────────────
 */

/* JetBrains Mono (self-hosted). Keep in sync with Google Fonts subsets. */
/* cyrillic */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-400-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* cyrillic-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-400-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* greek */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-400-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* vietnamese */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-400-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* cyrillic */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-500-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* cyrillic-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-500-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* greek */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-500-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* vietnamese */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-500-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* cyrillic */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-600-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* cyrillic-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-600-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* greek */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-600-greek.woff2') format('woff2');
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-600-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* vietnamese */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('./vendor/fonts/jetbrains-mono/JetBrainsMono-600-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/*
 * ── DESIGN TOKENS ──────────────────────────────────────────────────
 * All new/modified components MUST use these variables.
 * Spacing: 2-4-6-8-12-16-24 scale (--sp-*).
 * Prefer --sp-* over magic numbers to keep density consistent.
 * Keep mobile chrome thin: prefer ≤6 px padding on cards/stat bars
 * and ≤ 44 px touch targets (Apple HIG minimum).
 * ───────────────────────────────────────────────────────────────────
 */
:root {
  --bg: #0a0c12;
  --panel: #10131c;
  --panel-elevated: #141825;
  --muted: #7a8ba8;
  --text: #e5ecff;
  --accent: #6cf5d8;
  --accent-2: #6ca8ff;
  --border: #1a2033;
  --border-subtle: rgba(26, 32, 51, 0.6);
  --error: #ff5566;
  --success: #58d68d;
  --warning: #ffd166;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 3px;
  --radius-lg: 6px;

  /* Spacing scale */
  --sp-1: 2px;
  --sp-2: 4px;
  --sp-3: 6px;
  --sp-4: 8px;
  --sp-5: 12px;
  --sp-6: 16px;
  --sp-7: 24px;
}

* {
  box-sizing: border-box;
}

/* Custom selection */
::selection {
  background: rgba(108, 245, 216, 0.3);
  color: var(--text);
}

.mobile-terminal-view ::selection,
.mobile-terminal-view span::selection {
  background: rgba(190, 190, 190, 0.6);
  color: #0a0c12;
}

/* Focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

:focus:not(:focus-visible) {
  outline: none;
}

html {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", "SF Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  min-height: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hub-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hub-shell>section {
  flex-shrink: 0;
}

.hub-shell>.hub-repo-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hub-shell[data-hub-open-panel="repos"]>#hub-repo-panel,
.hub-shell[data-hub-open-panel="agents"]>#hub-agent-panel {
  flex: 1 1 auto;
}

.hub-shell[data-hub-open-panel="repos"]>#hub-agent-panel,
.hub-shell[data-hub-open-panel="agents"]>#hub-repo-panel {
  flex: 0 0 auto;
}

.hub-shell>.hub-repo-panel.hub-panel-collapsed {
  flex: 0 0 auto;
  min-height: auto;
}

.hub-repo-list {
  flex: 1;
  overflow: auto;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* Combined nav bar: brand + tabs in one row */
.nav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  /* Ensure tabs remain clickable (avoid overlays stealing clicks). */
  position: relative;
  z-index: 1500;
}

.nav-brand {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  padding: 0 8px;
  flex-shrink: 0;
  user-select: none;
}

.nav-repo-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  padding: 0 8px;
  flex-shrink: 0;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-back-btn {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  flex-shrink: 0;
  transition: all 0.1s ease;
}

.hub-back-btn:hover {
  color: var(--text);
  border-color: var(--muted);
  background: #161b28;
}

/* Tabs - compact horizontal bar */
.tabs {
  display: flex;
  flex: 1;
  gap: 2px;
  background: var(--panel);
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  z-index: 1501;
  overflow: hidden;
  min-width: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
  z-index: 1505;
}

.nav-actions:empty {
  display: none;
}

.inbox-btn {
  position: relative;
}

.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  background: #ff9500;
  color: #000;
}

.tab {
  position: relative;
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.1s ease;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  color: var(--bg);
  background: var(--accent);
}

main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Ensure main fills remaining space after nav */
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
}

.panel {
  display: none;
}

.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Cards grid */
.cards {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 280px);
  gap: 10px;
  max-width: 100%;
  overflow: hidden;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 10px;
  overflow: hidden;
  min-width: 0;
  /* Allow cards to shrink below content size */
}

/* ===== Compact Per-Repo Usage Card ===== */
.usage-card-compact {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.usage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.usage-total-badge {
  background: linear-gradient(135deg, rgba(108, 245, 216, 0.15), rgba(108, 168, 255, 0.1));
  border: 1px solid rgba(108, 245, 216, 0.3);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: var(--radius);
  letter-spacing: -0.02em;
}

.usage-events-badge {
  color: var(--muted);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.usage-breakdown {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}

.usage-chart {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 6px;
}

.usage-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.usage-chart-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.usage-chart-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.usage-chart-label {
  font-size: 9px;
  color: var(--muted);
}

.usage-chart-select {
  font-size: 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 6px;
  min-width: 44px;
}

.usage-chart-canvas {
  height: 88px;
  width: 100%;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(108, 245, 216, 0.06), rgba(0, 0, 0, 0));
  border: 1px dashed rgba(108, 245, 216, 0.2);
  position: relative;
  overflow: hidden;
}

.usage-chart-canvas svg {
  width: 100%;
  height: 100%;
  display: block;
}

.usage-chart-canvas.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.usage-chart-canvas.loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 18, 0.25);
  pointer-events: none;
}

.usage-chart-focus {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: rgba(108, 245, 216, 0.5);
  pointer-events: none;
  opacity: 0;
}

.usage-chart-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6cf5d8;
  box-shadow: 0 0 6px rgba(108, 245, 216, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
}

.usage-chart-tooltip {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 6px 8px;
  background: rgba(9, 13, 20, 0.95);
  border: 1px solid rgba(108, 245, 216, 0.2);
  border-radius: var(--radius);
  font-size: 10px;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  max-width: 180px;
}

.usage-chart-tooltip-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.usage-chart-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.usage-chart-empty {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

@media (max-width: 720px) {
  .usage-chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .usage-chart-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

.usage-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.usage-stat-cached {
  background: rgba(108, 245, 216, 0.05);
  border-color: rgba(108, 245, 216, 0.2);
}

.usage-stat-cached .usage-stat-val {
  color: var(--accent);
}

.usage-stat-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.usage-stat-lbl {
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usage-footer {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  opacity: 0.7;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

/* Usage Progress Bars */
.usage-rates-visual {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}

.usage-rate-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.usage-rate-label {
  font-size: 9px;
  color: var(--muted);
  width: 45px;
  flex-shrink: 0;
}

.usage-rate-bar-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.usage-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.usage-progress-bar-empty {
  opacity: 0.5;
}

.usage-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.usage-bar-ok {
  background: var(--accent);
}

.usage-bar-warning {
  background: #ffcc00;
}

.usage-bar-critical {
  background: #ff5566;
}

.usage-progress-label {
  font-size: 9px;
  color: var(--text);
  font-family: monospace;
  min-width: 50px;
  text-align: right;
}

/* ===== Compact Hub Usage Section ===== */
.hub-usage-compact {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 8px 0;
}

.hub-usage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.hub-usage-path {
  flex: 1;
  font-size: 9px;
  color: var(--muted);
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.hub-usage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hub-usage-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 10px;
  min-width: 0;
  flex: 0 0 auto;
}

.hub-usage-chip:hover {
  border-color: var(--accent);
  background: rgba(108, 245, 216, 0.04);
}

.hub-usage-chip-unmatched {
  opacity: 0.6;
}

.hub-usage-chip-name {
  font-weight: 600;
  color: var(--text);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-usage-chip-total {
  font-weight: 700;
  color: var(--accent);
  font-size: 11px;
}

.hub-usage-chip-meta {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

/* Hub shell */
.hub-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
  gap: var(--sp-3);
}

.hub-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sp-3);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: var(--sp-3) var(--sp-2);
}

.hub-hero h1 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--accent);
  font-weight: 700;
}

.hub-hero p {
  margin: 0;
  font-size: 11px;
}

.hub-hero-text {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.hub-hero-text > * {
  min-width: 0;
}

.hub-hero-text>.muted.small {
  display: none;
}

.hub-hero-actions {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}

.notifications-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notifications-bell-btn {
  position: relative;
}

.notifications-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  border: 1px solid var(--bg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.notifications-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2600;
}

.notifications-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.notifications-item:hover {
  background: rgba(108, 168, 255, 0.08);
  border-color: var(--border);
}

.notifications-item-repo {
  font-weight: 600;
  color: var(--accent);
}

.notifications-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.notifications-item-pill {
  justify-self: end;
}

.notifications-empty {
  padding: 8px 10px;
}

.notifications-modal-dialog {
  max-width: 640px;
  width: 100%;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notifications-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notifications-modal-body-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notifications-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notifications-modal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.notifications-modal-label {
  color: var(--muted);
  font-size: 11px;
}

.notifications-modal-value {
  color: var(--text);
}

.notifications-modal-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
}

.notifications-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.notifications-modal-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.notifications-modal-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.notifications-modal-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notifications-section-label {
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.notifications-key-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.notifications-key-pill {
  background: rgba(108, 168, 255, 0.12);
  border: 1px solid rgba(108, 168, 255, 0.18);
  color: var(--accent);
}

.notifications-modal-prompt {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
}

.notifications-open-run {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  border: none;
}

.notifications-open-run:hover {
  background: #5de6c9;
  color: var(--bg);
}

.notifications-modal-placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.hub-mode-toggle {
  justify-self: end;
}

.hub-mode-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px;
  background: rgba(255, 255, 255, 0.02);
  gap: 1px;
}

.hub-mode-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.hub-mode-btn:hover:not(:disabled) {
  color: var(--text);
}

.hub-mode-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: transparent;
}

.hub-mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hub-mode-short {
  display: none;
}

.hub-hero-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hub-stats {
  display: none;
}

.hub-stats-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-2);
  margin: var(--sp-2) 0;
  font-size: 10px;
  color: var(--muted);
}

.hub-stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.hub-stat-inline .hub-stat-value {
  font-weight: 700;
  color: var(--text);
  font-size: 11px;
}

.hub-stat {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.hub-stat p {
  margin: 0;
  font-size: 10px;
}

.hub-stat-value {
  font-size: 11px;
  font-weight: 700;
  margin: 0;
}

.hub-repo-panel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.hub-panel-expanded {
  border-color: var(--border);
}

.hub-panel-collapsed {
  background: transparent;
  border-color: transparent;
}

.hub-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--sp-2);
  padding-bottom: 0;
  border-bottom: none;
}

.hub-panel-header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.hub-panel-header p {
  margin: 0;
  font-size: 10px;
}

.hub-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hub-panel-summary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 100ms ease;
}

.hub-panel-summary:hover {
  background: rgba(108, 245, 216, 0.06);
}

.hub-panel-summary-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.hub-panel-summary-copy .label {
  font-size: 11px;
  letter-spacing: 0.04em;
}

.hub-panel-summary-note {
  display: none;
}

.hub-panel-summary-state {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  transition: opacity 100ms ease;
}

.hub-panel-summary:hover .hub-panel-summary-state {
  opacity: 1;
}

.hub-panel-summary-state::after {
  content: "▾";
  font-size: 10px;
  line-height: 1;
  transition: transform 120ms ease;
}

.hub-panel-summary[aria-expanded="false"] .hub-panel-summary-state::after {
  transform: rotate(-90deg);
}

.hub-panel-collapsed .hub-panel-header {
  margin-bottom: 0;
  padding-bottom: 0;
}

.hub-panel-collapsed .hub-repo-controls,
.hub-panel-collapsed .hub-repo-list {
  display: none;
}

.hub-repo-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
  padding: var(--sp-1) 0;
}

/* Matches button:disabled look but keeps clicks (handler shows a toast). */
button#hub-cleanup-all.hub-cleanup-all--empty {
  opacity: 0.4;
  cursor: not-allowed;
}

.hub-repo-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.hub-repo-select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 20px 3px 8px;
  font-size: 10px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%237a8ba8' d='M4 5L1 2h6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
}

.hub-repo-search-control {
  flex: 0 1 220px;
  min-width: 140px;
}

.hub-repo-search-input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 10px;
  min-width: 180px;
  width: 100%;
}

.hub-panel-actions {
  display: flex;
  gap: 4px;
}

.hub-repo-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: auto;
}

.hub-chat-binding-block {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hub-chat-binding-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
}

.hub-chat-binding-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.hub-chat-binding-summary {
  flex-wrap: wrap;
  row-gap: 2px;
}

.hub-chat-binding-source {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 9px;
}

.hub-chat-binding-source-discord {
  border-color: rgba(88, 166, 255, 0.55);
  color: #9ac7ff;
}

.hub-chat-binding-source-telegram {
  border-color: rgba(85, 210, 196, 0.55);
  color: #85f2e5;
}

.hub-chat-binding-source-pma {
  border-color: rgba(249, 196, 105, 0.55);
  color: #f9c469;
}

.hub-chat-binding-source-unknown {
  border-color: var(--border);
  color: var(--muted);
}

.hub-chat-binding-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

.hub-chat-binding-key {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.hub-chat-binding-more {
  white-space: nowrap;
}

.hub-chat-binding-count {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.hub-chat-binding-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Hub worktrees (worktree repos grouped under a base repo) */
.hub-worktree-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  margin-top: 4px;
  margin-bottom: 6px;
}

.hub-worktree-row-inner {
  display: block;
}

.hub-worktree-card {
  padding-left: 8px;
}

.hub-worktree-orphans {
  margin: 8px 0 4px;
}

/* Legacy hub-usage-list styles removed - using hub-usage-grid now */

/* Repo card - compact single-row layout */
.hub-repo-card {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-4);
  background: transparent;
  transition: background 80ms ease, border-color 80ms ease;
}

.hub-repo-card.hub-repo-clickable {
  cursor: pointer;
}

.hub-repo-card.hub-repo-clickable:hover {
  border-color: var(--border);
  background: rgba(108, 245, 216, 0.03);
}

.hub-repo-card.hub-repo-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* New compact row layout */
.hub-repo-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 28px;
}

.hub-repo-left {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.hub-repo-center {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.hub-repo-mainline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  overflow: hidden;
}

.hub-repo-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.5;
  transition: opacity 120ms ease;
}

.hub-repo-card:hover .hub-repo-right {
  opacity: 1;
}

.hub-repo-title {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}

.hub-repo-clickable:hover .hub-repo-title {
  color: var(--accent);
}

.hub-repo-meta-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.hub-repo-info-line {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-repo-subline {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.hub-destination-pill {
  color: var(--muted);
}

.hub-destination-pill-docker {
  color: var(--accent-2);
}

.hub-usage-pill {
  background: rgba(108, 245, 216, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  flex-shrink: 0;
}

.hub-usage-pill-meta {
  color: var(--muted);
  white-space: nowrap;
}

/* Hub ticket flow progress indicator */
.hub-repo-flow-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.hub-flow-bar {
  width: 60px;
  min-width: 60px;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.hub-flow-fill {
  height: 100%;
  background: linear-gradient(90deg, #3fb950, #58d66a);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.hub-repo-flow-line.active .hub-flow-fill {
  background: linear-gradient(90deg, #58a6ff, #79c0ff);
}

.hub-flow-text {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.hub-repo-flow-line.active .hub-flow-text {
  color: var(--text);
}

.hub-usage-unmatched-note {
  margin-top: 4px;
  padding-left: 2px;
}

a.hub-pr-pill {
  text-decoration: none;
  border-color: rgba(108, 245, 216, 0.35);
  color: var(--accent);
}

a.hub-pr-pill:hover {
  border-color: var(--accent);
}

.hub-repo-open-indicator {
  color: var(--muted);
  font-size: 14px;
  margin-left: 2px;
  opacity: 0.5;
  transition: all 0.1s ease;
}

.hub-repo-clickable:hover .hub-repo-open-indicator {
  color: var(--accent);
  opacity: 1;
  transform: translateX(2px);
}

.hub-repo-note {
  margin-top: 4px;
  color: #ff8899;
  font-size: 10px;
  padding-left: 4px;
}

/* Legacy support - keep for backwards compat */
.hub-repo-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.hub-repo-info {
  flex: 1;
  min-width: 0;
}

.hub-repo-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.hub-repo-path {
  color: var(--muted);
  font-size: 10px;
  opacity: 0.7;
}

.hub-repo-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
  flex-wrap: wrap;
}

.hub-repo-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.hub-pin-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 245, 216, 0.08);
}

.hub-pin-btn {
  min-width: 22px;
  padding: 2px 6px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hub-pin-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.hub-pin-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hub-pin-btn.active .hub-pin-icon {
  opacity: 1;
}

.hub-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 11px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.label {
  color: var(--muted);
  letter-spacing: 0.06em;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 500;
  user-select: none;
}

.hub-version,
.version-label {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.01em;
  opacity: 0.7;
}

.hub-version {
  display: inline-block;
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 16ch;
}

/* Status pills */
.pill {
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  border: 1px solid transparent;
}

.pill-idle {
  border-color: var(--border);
  background: var(--bg);
  color: var(--muted);
}

.pill-running {
  border-color: var(--accent);
  background: rgba(108, 245, 216, 0.12);
  color: var(--accent);
  animation: pulse-running 1.5s ease-in-out infinite;
}

@keyframes pulse-running {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.pill-error {
  border-color: #ff5566;
  background: rgba(255, 85, 102, 0.12);
  color: #ff8899;
}

.pill-warn {
  border-color: var(--accent-2);
  background: rgba(108, 168, 255, 0.12);
  color: var(--accent-2);
}

.pill-success {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

.pill-action {
  border-color: #f5a623;
  background: rgba(245, 166, 35, 0.15);
  color: #f5a623;
}

.pill-info {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.pill-small {
  padding: 1px 5px;
  font-size: 9px;
}

/* Metrics grid */
.grid-two {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.grid-two>div {
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}

.grid-two .muted {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.metric {
  font-size: 13px;
  font-weight: 600;
  margin: 1px 0 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.run-history-list {
  display: grid;
  gap: 6px;
  font-size: 12px;
  overflow-x: auto;
}

.run-history-row,
.run-history-head {
  display: grid;
  grid-template-columns: 72px 80px 90px minmax(140px, 1fr) minmax(120px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
}

.run-history-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.run-history-head {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.run-history-id {
  font-family: var(--font-mono);
  font-weight: 600;
}

.run-history-status {
  text-transform: capitalize;
}

.run-history-step {
  color: var(--muted);
}

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

.small {
  font-size: 11px;
}

.runner-config {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.runner-config-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-transform: uppercase;
  opacity: 0.75;
}

.runner-config-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}


/* Actions */
.actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
  max-width: 100%;
}

/* Buttons */
button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.1s ease;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) {

  button,
  .tab,
  .ticket-fm-toggle,
  select {
    min-height: 44px;
    min-width: 44px;
  }

  button.icon-btn {
    min-width: 36px;
    min-height: 36px;
  }
}

button:hover:not(:disabled) {
  border-color: var(--muted);
  background: #161b28;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

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

button.primary:hover:not(:disabled) {
  background: #5de6c9;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

button.ghost:hover:not(:disabled) {
  background: rgba(108, 168, 255, 0.08);
  color: var(--text);
  border-color: var(--border);
}

button.danger {
  background: rgba(255, 85, 102, 0.1);
  border-color: #ff5566;
  color: #ff8899;
}

button.danger:hover:not(:disabled) {
  background: rgba(255, 85, 102, 0.2);
}

button.sm {
  padding: 4px 8px;
  font-size: 10px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Icon-only buttons (e.g. ↻) */
button.icon-btn {
  padding: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

/* TODO checklist */
.todo-preview .checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.checklist li {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
}

.checklist .box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
}

.checklist .box.done {
  border-color: var(--accent);
  background: var(--accent);
}

.checklist .box.done::after {
  content: "✓";
  position: absolute;
  top: -1px;
  left: 1px;
  font-size: 10px;
  color: var(--bg);
  font-weight: 700;
}

/* GitHub card */
.github-card .github-grid {
  display: grid;
  gap: 8px;
  margin: 10px 0 6px;
}

.github-card .github-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 8px;
  align-items: center;
}

.github-card .github-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.github-card .github-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 12px;
}

.github-card .github-pr-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.github-card .icon-btn-inline {
  padding: 2px 4px;
  min-width: unset;
  font-size: 12px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.github-card .icon-btn-inline:hover:not(:disabled) {
  opacity: 1;
}

.github-card .icon-btn-inline:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.github-card .github-actions {
  margin-top: 10px;
}

.github-card .github-flow {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.github-card .github-flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.github-card .github-flow-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 10px;
  align-items: center;
}

.github-card .github-flow-grid input,
.github-card .github-flow-grid select {
  width: 100%;
}

.github-card .github-flow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.github-card .github-flow-status {
  display: grid;
  gap: 6px;
}

.github-card .github-flow-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 8px;
  align-items: center;
}

.github-card .github-flow-artifacts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Ticket flow */
#tickets.panel.active {
  display: flex;
  flex-direction: column;
}

.ticket-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ticket-card .ticket-header-left {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ticket-card .ticket-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

.ticket-card .ticket-flow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.ticket-card .ticket-flow-actions .agent-controls {
  flex-basis: 100%;
  margin-bottom: 0;
}

.ticket-card .ticket-flow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 6px 10px;
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(111, 137, 255, 0.12), rgba(16, 21, 33, 0.6));
  border: 1px solid var(--border);
  font-size: 11px;
}

.ticket-card .ticket-flow-meta>div {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.ticket-card .ticket-flow-meta .muted {
  font-size: 11px;
  opacity: 0.6;
}

.ticket-card .ticket-flow-meta .ticket-flow-action {
  padding: 2px 6px;
  font-size: 10px;
  line-height: 1.1;
}

.ticket-card .ticket-flow-meta .ticket-flow-pill {
  margin-left: 2px;
}

/* Ticket meta details container - desktop shows all */
.ticket-card .ticket-meta-details {
  display: contents;
}

.ticket-card .ticket-meta-details>div {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}


/* Overflow menu container */
.ticket-overflow-menu {
  display: none;
  position: relative;
}

.ticket-overflow-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  min-width: 140px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 4px;
  margin-top: 4px;
}

.ticket-overflow-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ticket-overflow-item:hover {
  background: rgba(108, 245, 216, 0.1);
}

.ticket-overflow-item:active {
  background: rgba(108, 245, 216, 0.15);
}

/* Split button for New Ticket + Template dropdown */
.ticket-new-split {
  display: flex;
  align-items: center;
  position: relative;
}

.ticket-new-split .ticket-new-dropdown-toggle {
  margin-left: -4px;
  padding: 6px 8px;
  border-left: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
}

.ticket-new-split>button:first-child {
  border-radius: 6px 0 0 6px;
}

.ticket-new-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  min-width: 140px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 4px;
  margin-top: 4px;
}

.ticket-new-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 4px;
}

.ticket-new-dropdown-item:hover {
  background: rgba(108, 245, 216, 0.1);
}

.ticket-new-dropdown-item:active {
  background: rgba(108, 245, 216, 0.15);
}

/* Template Picker Modal */
#ticket-template-modal {
  z-index: 2100;
}

#ticket-template-modal.hidden {
  display: none;
}

.ticket-template-modal-content {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #10131c;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.ticket-template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #10131c;
}

.ticket-template-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.ticket-template-body {
  padding: 16px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #10131c;
}

/* === Input Section === */
.ticket-template-input-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticket-template-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.ticket-template-input {
  flex: 1;
  padding: 12px 14px;
  padding-right: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease;
}

.ticket-template-input:focus {
  outline: none;
  border-color: var(--accent);
}

.ticket-template-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.ticket-template-input-hint {
  position: absolute;
  right: 12px;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.ticket-template-input-hint.hidden {
  opacity: 0;
}

/* Clear button inside input */
.ticket-template-clear {
  position: absolute;
  right: 130px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.ticket-template-clear:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.ticket-template-clear.hidden {
  display: none;
}

/* Repo chips row */
.ticket-template-repos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* === Preview Section === */
.ticket-template-preview-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
}

.ticket-template-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

.ticket-template-preview-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ticket-template-preview-status {
  font-size: 0.7rem;
  color: var(--accent);
}

.ticket-template-preview {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  min-height: 60px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.ticket-template-preview:empty::before {
  content: "Template preview will appear here";
  opacity: 0.4;
}

.ticket-template-preview.has-content {
  color: var(--text);
}

.ticket-template-preview.loading {
  opacity: 0.5;
}

/* === Error === */
.ticket-template-error {
  padding: 8px 12px;
  background: rgba(255, 100, 100, 0.1);
  border: 1px solid rgba(255, 100, 100, 0.25);
  border-radius: 6px;
  color: #ff6464;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Warning state (not blocking, just informational) */
.ticket-template-error.warning {
  background: rgba(255, 180, 80, 0.1);
  border-color: rgba(255, 180, 80, 0.25);
  color: #ffb450;
}

/* === Footer === */
.ticket-template-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.ticket-template-options {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-template-option-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.ticket-template-agent-select {
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.ticket-template-agent-select:focus {
  outline: none;
  border-color: var(--accent);
}

.ticket-template-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-template-actions button {
  padding: 6px 14px;
}

/* Recent templates section */
.ticket-template-recent {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.ticket-template-recent .ticket-template-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Chips container */
.ticket-template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Chip buttons */
.ticket-template-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(108, 245, 216, 0.08);
  border: 1px solid rgba(108, 245, 216, 0.2);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ticket-template-chip:hover {
  background: rgba(108, 245, 216, 0.15);
  border-color: rgba(108, 245, 216, 0.4);
}

.ticket-template-chip:active {
  background: rgba(108, 245, 216, 0.25);
}

/* Active/selected repo chip state */
.ticket-template-chip.active {
  background: rgba(108, 245, 216, 0.3);
  border-color: rgba(108, 245, 216, 0.6);
  color: #fff;
  font-weight: 500;
}

.ticket-template-chip.active:hover {
  background: rgba(108, 245, 216, 0.35);
}

.ticket-template-chip-recent {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
  color: var(--muted);
}

.ticket-template-chip-recent:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.ticket-template-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ticket-card .ticket-flow-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 8px;
  flex: 1;
  min-height: 0;
}

.ticket-card .ticket-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.02), rgba(26, 33, 48, 0.7));
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  container-type: inline-size;
  container-name: ticket-panel;
  position: relative;
}

/* Scroll fade indicator - shows when content is scrollable */
.ticket-card .ticket-panel::after {
  content: "";
  position: absolute;
  bottom: 10px;
  /* Match panel padding */
  left: 10px;
  right: 16px;
  /* Leave room for scrollbar */
  height: 32px;
  background: linear-gradient(to bottom, transparent, rgba(26, 33, 48, 0.95));
  border-radius: 0 0 8px 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ticket-card .ticket-panel.has-scroll-bottom::after {
  opacity: 1;
}

.ticket-card .ticket-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 6px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 2px;
}

.ticket-card .ticket-panel-header .ticket-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ticket-card .ticket-panel-header .ticket-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ticket-card .ticket-panel-header .ticket-panel-actions button {
  padding: 2px 8px;
  font-size: 11px;
}

/* Ticket progress bar */
.ticket-progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin: 4px 0 6px 0;
  flex-shrink: 0;
}

.ticket-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3fb950, #58d66a);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Hide progress bar when empty (0 tickets) */
.ticket-progress-bar:empty,
.ticket-progress-bar.hidden {
  display: none;
}

.ticket-card .ticket-list {
  display: grid;
  gap: 6px;
  flex: 1;
  overflow: auto;
  padding: 4px 4px 8px 4px;
  align-content: start;
}

.ticket-card .ticket-list::-webkit-scrollbar {
  width: 6px;
}

.ticket-card .ticket-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.ticket-card .ticket-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Dispatch history specific styling for graceful overflow */
#ticket-dispatch-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 4px 16px 4px;
}

#ticket-dispatch-history::-webkit-scrollbar {
  width: 6px;
}

#ticket-dispatch-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Compact dispatch items that don't stack */
.dispatch-item {
  flex-shrink: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: default;
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: row;
}

.dispatch-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
}

/* Reddit-style thin collapse bar on the left */
.dispatch-collapse-bar {
  flex-shrink: 0;
  width: 4px;
  min-height: 100%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  transition: background 0.15s ease, width 0.1s ease;
  position: relative;
}

.dispatch-collapse-bar:hover {
  background: var(--accent);
  width: 6px;
}

.dispatch-collapse-bar:active {
  background: var(--accent-hover, var(--accent));
}

/* Collapsed state - bar is dimmer */
.dispatch-item.collapsed .dispatch-collapse-bar {
  background: rgba(255, 255, 255, 0.08);
}

.dispatch-item.collapsed .dispatch-collapse-bar:hover {
  background: var(--accent);
  width: 6px;
}

/* Dispatch content wrapper */
.dispatch-content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Dispatch header */
.dispatch-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
  cursor: pointer;
}

.dispatch-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.dispatch-item.collapsed .dispatch-header {
  border-bottom: none;
}

/* Hide old collapse button - replaced by bar */
.dispatch-collapse-btn {
  display: none;
}

/* Header content area */
.dispatch-header-content {
  flex: 1;
  min-width: 0;
}

.dispatch-item.turn-summary .dispatch-header-content {
  cursor: default;
}

.dispatch-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

/* Dispatch body wrapper */
.dispatch-body-wrapper {
  padding: 0 10px 10px 10px;
}

.dispatch-item.collapsed .dispatch-body-wrapper {
  display: none;
}

.dispatch-item .ticket-name {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
}

.dispatch-item .ticket-agent {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(111, 137, 255, 0.2);
  color: #a8b4ff;
}

/* Full content display in dispatch items */
.dispatch-item .ticket-body {
  font-size: 12px;
  line-height: 1.5;
  color: #b8c0d0;
  word-break: break-word;
}

.dispatch-item .ticket-dispatch-title {
  font-weight: 600;
  color: #e0e6f0;
  margin-bottom: 6px;
}

.dispatch-item .ticket-dispatch-body {
  color: #a0a8b8;
}

/* Markdown rendering in dispatch items */
.dispatch-item .messages-markdown p {
  margin: 0 0 8px 0;
}

.dispatch-item .messages-markdown p:last-child {
  margin-bottom: 0;
}

.dispatch-item .messages-markdown ul {
  margin: 4px 0;
  padding-left: 20px;
}

.dispatch-item .messages-markdown li {
  margin: 2px 0;
}

.dispatch-item .messages-markdown code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

#ticket-dispatch-history .messages-markdown pre.md-code {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
}

#ticket-dispatch-history .messages-markdown pre.md-code code {
  background: none;
  padding: 0;
  font-size: 11px;
}

/* Turn summary dispatch styling */
.dispatch-item.turn-summary {
  background: rgba(63, 185, 80, 0.06);
  border-color: rgba(63, 185, 80, 0.3);
}

.dispatch-item.turn-summary:hover {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.5);
}

.dispatch-item.turn-summary .dispatch-collapse-bar {
  background: rgba(63, 185, 80, 0.5);
}

.dispatch-item.turn-summary .dispatch-collapse-bar:hover {
  background: rgba(63, 185, 80, 0.8);
}

.dispatch-item .turn-summary-badge {
  background: rgba(63, 185, 80, 0.25);
  color: #8dc896;
}

/* Pause/handoff dispatch styling - red */
.dispatch-item.pause {
  background: rgba(248, 81, 73, 0.06);
  border-color: rgba(248, 81, 73, 0.3);
}

.dispatch-item.pause:hover {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.5);
}

.dispatch-item.pause .dispatch-collapse-bar {
  background: rgba(248, 81, 73, 0.5);
}

.dispatch-item.pause .dispatch-collapse-bar:hover {
  background: rgba(248, 81, 73, 0.8);
}

/* Notify dispatch styling - orange */
.dispatch-item.notify {
  background: rgba(255, 163, 68, 0.06);
  border-color: rgba(255, 163, 68, 0.3);
}

.dispatch-item.notify:hover {
  background: rgba(255, 163, 68, 0.1);
  border-color: rgba(255, 163, 68, 0.5);
}

.dispatch-item.notify .dispatch-collapse-bar {
  background: rgba(255, 163, 68, 0.5);
}

.dispatch-item.notify .dispatch-collapse-bar:hover {
  background: rgba(255, 163, 68, 0.8);
}

/* Ticket reference in dispatch items */
.dispatch-ticket-ref {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #a0a8b8;
}

/* Timestamp in dispatch items */
.dispatch-time {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  margin-left: auto;
}

/* Diff stats in dispatch items (GitHub-style +/- indicators) */
.dispatch-diff-stats {
  display: inline-flex;
  gap: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
  font-size: 11px;
  white-space: nowrap;
}

.dispatch-diff-stats .diff-add {
  color: #3fb950;
}

.dispatch-diff-stats .diff-del {
  color: #f85149;
}

/* Diff stats on ticket items (cumulative per ticket) */
.ticket-diff-stats {
  display: inline-flex;
  gap: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
  font-size: 11px;
  white-space: nowrap;
  margin-left: 6px;
}

.ticket-diff-stats .diff-add {
  color: #3fb950;
}

.ticket-diff-stats .diff-del {
  color: #f85149;
}

/* Diff stats in analytics metrics */
.diff-stats-metric {
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
}

.diff-stats-metric .diff-add {
  color: #3fb950;
}

.diff-stats-metric .diff-del {
  color: #f85149;
}


.ticket-card .ticket-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px 10px 34px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 56px;
  /* Consistent height for visual rhythm with body preview */
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  overflow: hidden;
  position: relative;
}

.ticket-card .ticket-reorder-handle {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(160, 168, 184, 0.9);
  cursor: grab;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  padding: 0;
  z-index: 2;
}

.ticket-card .ticket-reorder-handle::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 30px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.ticket-card .ticket-reorder-handle span {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
}

.ticket-card .ticket-reorder-handle:hover,
.ticket-card .ticket-item.drag-source .ticket-reorder-handle,
.ticket-card .ticket-reorder-handle:focus-visible {
  color: rgba(108, 245, 216, 0.95);
}

.ticket-card .ticket-reorder-handle:active {
  cursor: grabbing;
}

.ticket-card .ticket-reorder-handle:focus-visible {
  outline: 1px solid rgba(108, 245, 216, 0.7);
  outline-offset: 1px;
}

.ticket-card .ticket-item.drag-source {
  opacity: 0.7;
}

.ticket-card .ticket-item.drop-before::before,
.ticket-card .ticket-item.drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 2px;
  background: rgba(108, 245, 216, 0.9);
}

.ticket-card .ticket-item.drop-before::before {
  top: 2px;
}

.ticket-card .ticket-item.drop-after::after {
  bottom: 2px;
}

.ticket-card .ticket-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.ticket-card .ticket-item.selected {
  border-color: var(--accent, #6f89ff);
  background: rgba(111, 137, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(111, 137, 255, 0.3);
}

.ticket-card .ticket-item.selected:hover {
  background: rgba(111, 137, 255, 0.12);
}

.ticket-card .ticket-item.done {
  border-color: #3fb950;
  background: rgba(63, 185, 80, 0.06);
  opacity: 0.85;
}

.ticket-card .ticket-item.done .ticket-name {
  color: #8dc896;
}

.ticket-card .ticket-item.done .ticket-title,
.ticket-card .ticket-item.done .ticket-body {
  color: #7fa888;
}

.ticket-card .ticket-item.active {
  border-color: #f0b429;
  background: rgba(240, 180, 41, 0.12);
  box-shadow: 0 0 12px rgba(240, 180, 41, 0.25);
  animation: ticket-active-pulse 2s ease-in-out infinite;
}

@keyframes ticket-active-pulse {

  0%,
  100% {
    box-shadow: 0 0 12px rgba(240, 180, 41, 0.25);
  }

  50% {
    box-shadow: 0 0 20px rgba(240, 180, 41, 0.4);
  }
}

.ticket-card .ticket-item.active .ticket-agent {
  background: rgba(240, 180, 41, 0.25);
  color: #fff3cd;
}

.ticket-card .ticket-item.active .ticket-working-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(240, 180, 41, 0.35);
  color: #fff3cd;
  white-space: nowrap;
}

.ticket-card .ticket-item.active .ticket-working-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f0b429;
  animation: working-dot-pulse 1s ease-in-out infinite;
}

@keyframes working-dot-pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

.ticket-card .ticket-item .ticket-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  /* Allow flex children to shrink */
}

.ticket-card .ticket-item .ticket-name {
  font-size: 12px;
  font-weight: 500;
  color: #b8c0d0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ticket number span - inline by default */
.ticket-card .ticket-item .ticket-num {
  font-weight: 600;
  color: #c8d0e0;
}

/* Ticket title text span - follows number */
.ticket-card .ticket-item .ticket-title-text {
  color: #9098a8;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-card .ticket-item .ticket-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ticket-card .ticket-item .ticket-agent {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(111, 137, 255, 0.18);
  color: #dbe4ff;
  white-space: nowrap;
}

.ticket-card .ticket-item.done .ticket-agent {
  background: rgba(63, 185, 80, 0.2);
  color: #d6ffe1;
}

.ticket-card .ticket-item.done .ticket-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(63, 185, 80, 0.25);
  color: #a8e6b4;
  white-space: nowrap;
}

.ticket-card .ticket-item.done .ticket-done-badge::before {
  content: "✓";
  font-size: 9px;
}

.ticket-card .ticket-item .ticket-title {
  font-size: 12px;
  font-weight: 500;
  color: #e0e6f0;
  line-height: 1.35;
}

.ticket-card .ticket-item .ticket-body {
  font-size: 11px;
  color: #9098a8;
  line-height: 1.4;
  max-height: 2.8em;
  /* ~2 lines */
  min-height: 1.4em;
  /* Reserve space for at least 1 line */
  overflow: hidden;
  word-break: break-word;
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

/* Empty body placeholder */
.ticket-card .ticket-item .ticket-body:empty::before {
  content: "No description";
  color: rgba(144, 152, 168, 0.5);
  font-style: italic;
}

/* Compact mode when panel is narrow */
@container ticket-panel (max-width: 350px) {
  .ticket-item .ticket-body {
    display: none;
  }

  .ticket-item .ticket-name {
    font-size: 11px;
  }

  .ticket-item .ticket-title {
    font-size: 11px;
  }
}

/* ===== Desktop (>=1024px): Compact emoji-only badges ===== */
@media (min-width: 1024px) {

  /* Hide badge text on desktop, show emoji only */
  .ticket-card .ticket-item .ticket-done-badge .badge-text,
  .ticket-card .ticket-item .ticket-working-badge .badge-text {
    display: none;
  }

  /* Compact done badge - just checkmark */
  .ticket-card .ticket-item.done .ticket-done-badge {
    padding: 2px 6px;
    gap: 0;
  }

  /* Compact working badge - hammer emoji instead of animated dot */
  .ticket-card .ticket-item.active .ticket-working-badge {
    padding: 2px 6px;
    gap: 0;
  }

  .ticket-card .ticket-item.active .ticket-working-badge::before {
    content: "🔨";
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    animation: none;
    font-size: 11px;
  }
}

/* ===== Collapsible Dispatch Panel for Medium Screens ===== */

/* Mini dispatch list - hidden by default, shown in collapsed mode */
.dispatch-mini-list {
  display: none;
}

/* Toggle button in panel header */
.ticket-panel-toggle {
  display: none;
  /* Hidden by default, shown on medium screens */
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(111, 137, 255, 0.12);
  border: 1px solid rgba(111, 137, 255, 0.25);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.ticket-panel-toggle:hover {
  background: rgba(111, 137, 255, 0.2);
  border-color: var(--accent);
}

.ticket-panel-toggle:active {
  transform: scale(0.95);
}

.ticket-panel-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

/* Collapsed state arrow rotation */
.ticket-panel.collapsed .ticket-panel-toggle svg {
  transform: rotate(180deg);
}

/* ===== Mobile (<=1100px): Stacked layout with full ticket info ===== */
@media (max-width: 1100px) {

  /* Force single column stacked layout on mobile */
  .ticket-card .ticket-flow-grid {
    grid-template-columns: 1fr !important;
  }

  /* Hide toggle button on mobile */
  .ticket-panel-toggle {
    display: none;
  }

  /* Compact ticket items for mobile - even vertical spacing */
  .ticket-card .ticket-item {
    padding: 8px 10px 8px 34px !important;
    gap: 0 !important;
    flex-direction: row !important;
    align-items: center !important;
  }

  .ticket-card .ticket-item .ticket-item-head {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1;
    min-width: 0;
  }

  /* Ensure ticket name doesn't overflow */
  .ticket-card .ticket-item .ticket-name {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Badges should not shrink or truncate */
  .ticket-card .ticket-item .ticket-badges {
    flex-shrink: 0;
    gap: 4px;
    display: flex !important;
    align-items: center;
    margin: 0 !important;
    padding: 0 !important;
  }

  .ticket-card .ticket-item .ticket-done-badge,
  .ticket-card .ticket-item .ticket-working-badge {
    padding: 2px 6px !important;
    font-size: 9px;
    white-space: nowrap;
    line-height: 1;
    margin: 0 !important;
    gap: 0 !important;
  }

  /* Hide badge text on mobile, show emoji only */
  .ticket-card .ticket-item .ticket-done-badge .badge-text,
  .ticket-card .ticket-item .ticket-working-badge .badge-text {
    display: none;
  }

  /* Working badge - hammer emoji instead of animated dot on mobile */
  .ticket-card .ticket-item.active .ticket-working-badge::before {
    content: "🔨" !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0 !important;
    background: none !important;
    animation: none !important;
    font-size: 10px;
  }

  .ticket-card .ticket-item .ticket-agent {
    padding: 2px 6px !important;
    font-size: 9px;
    line-height: 1;
    margin: 0 !important;
  }

  /* Hide ticket body on mobile for compactness */
  .ticket-card .ticket-item .ticket-body {
    display: none !important;
  }

  /* Hide ticket title (just show name line with badges) */
  .ticket-card .ticket-item .ticket-title {
    display: none !important;
  }

  /* Ticket list with tighter spacing */
  .ticket-card .ticket-list {
    gap: 4px !important;
  }

  /* Dispatch panel full width */
  .ticket-card .ticket-panel {
    width: 100%;
  }

  /* Compact dispatch items on mobile */
  .dispatch-item {
    padding: 0;
  }

  /* Wider collapse bar on mobile for easier touch */
  .dispatch-collapse-bar {
    width: 6px;
  }

  .dispatch-collapse-bar:hover {
    width: 8px;
  }

  .ticket-dispatch-body {
    font-size: 11px;
  }
}

.ticket-card .ticket-errors {
  color: #ffb4a2;
  font-size: 11px;
  line-height: 1.4;
  padding: 4px 8px;
  background: rgba(255, 100, 80, 0.1);
  border-radius: 6px;
  border-left: 2px solid #ff6450;
}

.ticket-card .ticket-lint-errors {
  color: #ffb4a2;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 12px;
  background: rgba(255, 100, 80, 0.15);
  border-radius: 8px;
  border-left: 3px solid #ff6450;
  margin-bottom: 12px;
}

.ticket-card .ticket-lint-errors>div {
  margin: 4px 0;
}

.ticket-card .ticket-lint-errors>div:first-child {
  margin-top: 0;
}

.ticket-card .ticket-lint-errors>div:last-child {
  margin-bottom: 0;
}

.ticket-card .ticket-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ticket-card .ticket-attachments a {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(111, 137, 255, 0.12);
  color: #e3e8ff;
}

.ticket-card .ticket-attachments a:hover {
  background: rgba(111, 137, 255, 0.24);
}

.ticket-card .ticket-flow-reason {
  display: inline;
}

/* Live Agent Output Panel - Compact inline design */
.ticket-live-output-panel {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(10, 12, 18, 0.4);
  overflow: hidden;
}

.ticket-live-output-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
  border-bottom: 1px solid var(--border);
}

.ticket-live-output-spacer {
  flex: 1;
  min-width: 4px;
}

.ticket-live-output-title {
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.ticket-live-output-status {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  flex-shrink: 0;
}

.ticket-live-output-status.connected {
  background: rgba(63, 185, 80, 0.15);
  color: #3fb950;
}

.ticket-live-output-status.streaming {
  background: rgba(108, 245, 216, 0.15);
  color: var(--accent);
  animation: pulse-running 1.5s ease-in-out infinite;
}

/* Simple toggle button */
.ticket-live-output-view-toggle {
  background: none;
  border: 1px solid rgba(108, 245, 216, 0.25);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
  line-height: 1.2;
}

.ticket-live-output-view-toggle:hover {
  background: rgba(108, 245, 216, 0.1);
  border-color: rgba(108, 245, 216, 0.4);
}

.ticket-live-output-view-toggle.active {
  background: rgba(108, 245, 216, 0.15);
  border-color: var(--accent);
}

/* Compact summary - max 3 lines */
.ticket-live-output-compact {
  margin: 0;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #a8adb8;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  max-height: calc(3 * 1.4em + 12px);
  /* 3 lines + padding */
}

.ticket-live-output-compact:empty::before {
  content: "Ready. Agent output will appear here.";
  color: var(--muted);
  font-style: italic;
}

.ticket-live-output-compact.hidden {
  display: none;
}

/* Detail view (full output) */
.ticket-live-output-detail {
  max-height: 280px;
  overflow: auto;
  border-top: 1px solid var(--border);
}

.ticket-live-output-detail.hidden {
  display: none;
}

.ticket-live-output-text {
  margin: 0;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c3c8d4;
  min-height: 40px;
}

.ticket-live-output-text:empty::before {
  content: "Ready. Agent output will appear here.";
  color: var(--muted);
  font-style: italic;
}

.ticket-live-output-events {
  padding: 6px 8px 4px;
  border-bottom: 1px solid var(--border);
}

.ticket-live-output-events.hidden {
  display: none;
}

.ticket-live-output-events-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 10px;
}

.ticket-live-output-events-count {
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 9px;
}

.chat-events-compact {
  margin: 0;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  background: rgba(10, 12, 18, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Review card */
.review-card .review-grid {
  display: grid;
  gap: 8px;
  margin: 10px 6px;
}

.review-card .review-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 8px;
  align-items: center;
}

.review-card .review-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 12px;
}

.review-card .review-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-card .review-controls {
  margin-top: 10px;
}

.review-card .review-inputs {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.review-card .review-input-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: center;
}

.review-card .review-inputs input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

.review-card .review-inputs input:focus {
  outline: none;
  border-color: var(--accent);
}

.review-card .review-buttons {
  display: flex;
  gap: 6px;
}

.review-card .review-artifacts {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.review-card .review-artifacts .review-link {
  flex: 1;
}

/* Docs nav */
.doc-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.doc-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(108, 245, 216, 0.08);
}

.doc-banner.error {
  border-left-color: var(--error);
  background: rgba(255, 85, 102, 0.08);
}

.doc-banner.warn {
  border-left-color: var(--warning);
  background: rgba(255, 209, 102, 0.08);
}

.doc-banner.hidden {
  display: none;
}

.doc-banner-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.doc-banner-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.doc-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-banner-detail {
  word-break: break-word;
}

.legacy-runner {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.legacy-runner summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}

.legacy-runner summary::-webkit-details-marker {
  display: none;
}

.legacy-runner[open] summary {
  color: var(--text);
}

.spec-issue-import {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
  flex-wrap: wrap;
}

.spec-issue-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.spec-issue-input-row.hidden {
  display: none;
}

.spec-issue-import input {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  min-width: 200px;
}

.doc-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip {
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  color: var(--text);
  border-color: var(--muted);
}

.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 245, 216, 0.08);
}

.chip.has-draft::after {
  content: "•";
  margin-left: 6px;
  font-size: 12px;
  color: var(--accent-2);
}

.chip.previewing {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

/* Editor textarea */
.doc-editor textarea {
  width: 100%;
  min-height: calc(100vh - 140px);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.doc-editor textarea::-webkit-scrollbar {
  width: 6px;
}

.doc-editor textarea::-webkit-scrollbar-track {
  background: transparent;
}

.doc-editor textarea::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.doc-editor textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.doc-editor textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.doc-editor textarea.doc-preview {
  background: rgba(108, 168, 255, 0.08);
  border-color: var(--accent-2);
  cursor: default;
}

/* Workspace layout */
.contextspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.contextspace-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contextspace-title {
  margin: 0;
  font-size: 15px;
}

.contextspace-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

#workspace-status.dirty {
  color: var(--warning);
}

#workspace-status.error {
  color: var(--error);
}

.contextspace-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.contextspace-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

/* Workspace/contextspace content textarea - dark mode styling */
#workspace-content,
#contextspace-content {
  flex: 1;
  min-height: 300px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
}

#workspace-content:focus,
#contextspace-content:focus {
  outline: none;
  border-color: var(--accent);
}

#workspace-content::placeholder,
#contextspace-content::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.contextspace-file-browser {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 100%;
}

.contextspace-file-mobile {
  display: none;
}

/* Mobile workspace toolbar - hidden on desktop, shown above compose on mobile */
.contextspace-mobile-toolbar {
  display: none;
}

.contextspace-mobile-menu {
  position: relative;
}

.contextspace-mobile-dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  padding: 6px;
  min-width: 170px;
  z-index: 30;
}

.contextspace-mobile-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 6px;
  font-size: 13px;
}

.contextspace-mobile-item:hover,
.contextspace-mobile-item:active {
  background: rgba(108, 245, 216, 0.1);
}

/* Mobile file selector button - clean, square aesthetic */
.contextspace-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.contextspace-file-btn:hover,
.contextspace-file-btn:focus {
  border-color: var(--accent);
  background: rgba(108, 245, 216, 0.05);
  outline: none;
}

.contextspace-file-btn:active {
  background: rgba(108, 245, 216, 0.1);
}

.contextspace-file-btn-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.contextspace-mobile-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.contextspace-file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.contextspace-file-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 2px 4px;
}

.contextspace-file-row {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease;
}

.contextspace-file-row:hover {
  border-color: var(--border);
}

.contextspace-file-row.pinned {
  font-weight: 600;
}

.contextspace-file-row.active {
  border-color: var(--accent);
  background: rgba(108, 245, 216, 0.08);
}

.contextspace-file-divider {
  border-top: 1px dashed var(--border);
  margin: 4px 0;
}

.contextspace-breadcrumbs {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  min-height: 32px;
}

.contextspace-breadcrumbs-inner {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.contextspace-breadcrumbs button {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
}

.contextspace-breadcrumbs button:hover {
  text-decoration: underline;
}

.contextspace-breadcrumbs span {
  color: var(--muted);
  margin: 0 2px;
}

.contextspace-tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 6px 8px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.contextspace-tree-row:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.contextspace-tree-row.active {
  border-color: var(--accent);
  background: rgba(108, 245, 216, 0.08);
}

.contextspace-tree-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.contextspace-tree-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.contextspace-tree-name {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-align: left;
  display: inline-flex;
  align-items: center;
}

.contextspace-tree-name.pinned {
  font-weight: 600;
}

.contextspace-tree-caret,
.contextspace-tree-dot {
  color: var(--muted);
  width: 14px;
  display: inline-flex;
  justify-content: center;
}

.contextspace-tree-meta {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.contextspace-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.contextspace-tree-row:hover .contextspace-item-actions {
  opacity: 1;
}

.contextspace-item-actions .danger {
  color: var(--error);
  border-color: var(--error);
}

.contextspace-download-btn {
  color: var(--muted);
  opacity: 0.7;
}

.contextspace-download-btn:hover {
  color: var(--primary);
  opacity: 1;
}

.contextspace-create-dialog {
  max-width: 420px;
  width: 90vw;
}

.contextspace-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.contextspace-confirm-dialog {
  max-width: 360px;
}

.contextspace-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.contextspace-path-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.contextspace-path-row .contextspace-breadcrumbs {
  flex: 1;
}

.contextspace-download-all-btn {
  flex-shrink: 0;
  font-size: 1rem;
  padding: 4px 8px;
  opacity: 0.7;
}

.contextspace-download-all-btn:hover {
  opacity: 1;
  color: var(--primary);
}

.file-picker-actions {
  margin-left: auto;
}

.file-picker-actions .danger {
  color: var(--error);
}

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

  .contextspace-file-mobile {
    display: block;
  }

  .contextspace-file-list {
    display: none;
  }

  .contextspace-item-actions {
    opacity: 1;
  }

  .contextspace-breadcrumbs {
    padding: 6px 8px;
  }
}

/* Removed .snapshot-editor - snapshot now uses shared doc editor */

.doc-patch-main {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-patch-main.hidden {
  display: none;
}

.doc-patch-main.previewing {
  border-color: var(--accent-2);
}

.doc-patch-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.doc-patch-info {
  flex: 1;
  min-width: 0;
}

.doc-patch-legend {
  display: flex;
  gap: 12px;
  font-size: 9px;
  color: var(--muted);
  margin-top: 6px;
}

.doc-patch-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-patch-legend-add::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border-radius: 2px;
  font-weight: 600;
  font-size: 10px;
}

.doc-patch-legend-del::before {
  content: "−";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border-radius: 2px;
  font-weight: 600;
  font-size: 10px;
}

.doc-patch-summary {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
}

.doc-patch-meta {
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.doc-patch-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.doc-patch-actions button.active {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.doc-patch-body {
  background: #0d1117;
  color: #d6dbe0;
  border-radius: var(--radius);
  padding: 0;
  max-height: 320px;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1;
  border: 1px solid #21262d;
}

/* Diff syntax highlighting - line-by-line with gutters */
.diff-view {
  display: flex;
  flex-direction: column;
}

.diff-line {
  display: flex;
  align-items: stretch;
  min-height: 1.5em;
  line-height: 1.5;
}

.diff-gutter {
  flex: 0 0 36px;
  text-align: right;
  padding-right: 8px;
  color: #6e7681;
  font-size: 10px;
  user-select: none;
  border-right: 1px solid #21262d;
  background: #161b22;
}

.diff-gutter-add {
  background: rgba(46, 160, 67, 0.2);
  color: #7ee787;
}

.diff-gutter-del {
  background: rgba(248, 81, 73, 0.2);
  color: #f97583;
}

.diff-gutter-ctx {
  background: #161b22;
}

.diff-gutter-hunk {
  background: rgba(56, 139, 253, 0.1);
  color: #58a6ff;
  text-align: center;
  padding-right: 0;
}

.diff-sign {
  flex: 0 0 16px;
  text-align: center;
  font-weight: 600;
  user-select: none;
}

.diff-add .diff-sign {
  color: #3fb950;
  background: rgba(46, 160, 67, 0.15);
}

.diff-del .diff-sign {
  color: #f85149;
  background: rgba(248, 81, 73, 0.15);
}

.diff-ctx .diff-sign {
  color: transparent;
}

.diff-content {
  flex: 1;
  padding-left: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Line type backgrounds */
.diff-line.diff-add {
  background: rgba(46, 160, 67, 0.12);
}

.diff-line.diff-add .diff-content {
  color: #aff5b4;
}

.diff-line.diff-del {
  background: rgba(248, 81, 73, 0.12);
}

.diff-line.diff-del .diff-content {
  color: #ffc1c8;
}

.diff-line.diff-hunk {
  background: rgba(56, 139, 253, 0.08);
  border-top: 1px solid rgba(56, 139, 253, 0.3);
  border-bottom: 1px solid rgba(56, 139, 253, 0.3);
  margin-top: 4px;
}

.diff-line.diff-hunk:first-child {
  margin-top: 0;
}

.diff-line.diff-hunk .diff-content {
  color: #a5d6ff;
  font-weight: 600;
  padding-left: 8px;
}

.diff-line.diff-file {
  background: transparent;
}

.diff-line.diff-file .diff-content {
  color: #d2a8ff;
  font-weight: 500;
}

.diff-line.diff-ctx .diff-content {
  color: #8b949e;
}

.diff-line.diff-meta .diff-content {
  color: #6e7681;
  font-style: italic;
  padding-left: 60px;
  /* Align with content after gutter + sign */
}

/* Empty line marker - visible symbol for blank lines */
.diff-empty-marker {
  color: #6e7681;
  background: rgba(110, 118, 129, 0.15);
  padding: 0 4px;
  border-radius: 2px;
  font-size: 10px;
  font-style: italic;
}

.diff-add .diff-empty-marker {
  color: #56d364;
  background: rgba(46, 160, 67, 0.25);
}

.diff-del .diff-empty-marker {
  color: #f97583;
  background: rgba(248, 81, 73, 0.25);
}

.doc-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.doc-actions.hidden {
  display: none;
}

/* Shared compose panel styling (terminal + doc chat) */
.compose-panel {
  margin-top: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compose-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.compose-row textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 56px;
  max-height: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.3;
  resize: vertical;
  overflow-y: auto;
}

.compose-row textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.compose-row textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.compose-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}

.compose-buttons button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 10px;
}

.compose-buttons .voice-button svg {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  fill: none;
}

/* Doc chat panel - compact inline design */
.doc-chat-panel {
  flex-shrink: 0;
}

.doc-chat-compose {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Shared agent controls styling (docs, terminal, ticket flow) */
.doc-agent-controls,
.agent-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.doc-agent-controls select,
.doc-agent-controls .agent-model-input,
.agent-controls select,
.agent-controls .agent-model-input {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
  max-width: 140px;
}

.doc-agent-controls select:hover,
.doc-agent-controls .agent-model-input:hover,
.agent-controls select:hover,
.agent-controls .agent-model-input:hover {
  border-color: var(--accent);
}

.doc-agent-controls select:focus,
.doc-agent-controls .agent-model-input:focus,
.agent-controls select:focus,
.agent-controls .agent-model-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 245, 216, 0.15);
}

.doc-agent-controls select:disabled,
.doc-agent-controls .agent-model-input:disabled,
.agent-controls select:disabled,
.agent-controls .agent-model-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== TERMINAL TOOLBAR ===== */
.terminal-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.terminal-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-toolbar-main {
  flex-wrap: nowrap;
}

.terminal-status {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.terminal-status.connected {
  color: var(--accent);
}

.terminal-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-toolbar-config {
  flex-wrap: nowrap;
}

.terminal-agent-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.terminal-agent-controls select,
.terminal-agent-controls .agent-model-input {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
  max-width: 180px;
}

.terminal-agent-controls select:hover,
.terminal-agent-controls .agent-model-input:hover {
  border-color: var(--accent);
}

.terminal-agent-controls select:focus,
.terminal-agent-controls .agent-model-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 245, 216, 0.15);
}

.terminal-agent-controls select:disabled,
.terminal-agent-controls .agent-model-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.terminal-toolbar-extras {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-text-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 28px;
  min-height: 28px;
  padding: 4px 8px !important;
}

.terminal-text-toggle svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.terminal-text-toggle-label {
  display: none;
}

.terminal-text-toggle[aria-expanded="true"] {
  background: rgba(108, 245, 216, 0.12);
  border-color: rgba(108, 245, 216, 0.3);
  color: var(--accent);
}

.terminal-toolbar .terminal-voice {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-toolbar .terminal-voice .voice-button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
}

.terminal-toolbar .terminal-voice .voice-button svg {
  width: 14px;
  height: 14px;
}

.terminal-toolbar .voice-status {
  white-space: nowrap;
  font-size: 10px;
}

.voice-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.voice-button svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  stroke: currentColor;
  flex-shrink: 0;
}

.voice-button.voice-recording {
  background: #b3261e;
  color: #fff;
  border-color: #b3261e;
  box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.2);
}

.voice-button.voice-sending {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.voice-button.voice-sending .voice-spinner {
  animation: voice-spin 0.8s linear infinite;
}

@keyframes voice-spin {
  to {
    transform: rotate(360deg);
  }
}

.voice-button.voice-sending svg {
  opacity: 0.35;
}

.voice-button.voice-sending::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: voice-spin 0.8s linear infinite;
  pointer-events: none;
}

@keyframes voice-spin {
  to {
    transform: rotate(360deg);
  }
}

.voice-button.voice-error {
  border-color: #d35400;
  color: #d35400;
}

.voice-button.voice-retry {
  background: #fff7e6;
  border-color: #e0c080;
  color: #8c5b00;
}

.voice-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.voice-button.voice-disconnected {
  opacity: 0.65;
}

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

/* Audio level meter visualization - positioned relative to parent */
.voice-level-meter {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
  padding: 0 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.voice-level-meter.voice-level-stop {
  cursor: pointer;
}

.voice-level-bar {
  width: 3px;
  min-height: 3px;
  height: 15%;
  background: var(--accent);
  border-radius: 1px;
  transition: height 0.05s ease-out;
  opacity: 0.4;
}

.voice-level-bar.active {
  opacity: 1;
  background: #4ade80;
}

.doc-chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0;
  font-size: 10px;
}

.doc-chat-meta-left,
.doc-chat-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.doc-chat-meta-left {
  flex: 1 1 auto;
  min-width: 0;
}

.doc-chat-meta-right {
  flex: 0 0 auto;
}

.doc-chat-cancel-inline {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  font-size: 11px;
  border-radius: 8px;
}

#doc-chat-new-thread.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.doc-chat-meta .loading {
  color: var(--accent);
}

.doc-chat-meta .loading::before {
  content: "●";
  display: inline-block;
  margin-right: 4px;
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

.doc-chat-patch-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 8px;
  max-height: 240px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-chat-patch-wrapper.hidden {
  display: none;
}

.doc-chat-patch-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.spacer {
  flex: 1;
}

.doc-chat-patch {
  background: #0f1116;
  color: #d6dbe0;
  border-radius: var(--radius);
  padding: 8px;
  overflow: auto;
  max-height: 160px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
}

.doc-chat-error {
  margin-top: 6px;
  color: var(--error);
  font-size: 11px;
}

/* ===== Unified Chat Stream ===== */
.doc-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Hide chat stream when it only contains the hidden error element */
.doc-chat-stream:has(> .doc-chat-error.hidden:only-child) {
  display: none;
}

/* Also hide when completely empty */
.doc-chat-stream:empty {
  display: none;
}

.doc-chat-stream::-webkit-scrollbar {
  width: 5px;
}

.doc-chat-stream::-webkit-scrollbar-track {
  background: transparent;
}

.doc-chat-stream::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.doc-chat-stream::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Doc chat stream sections */
.doc-chat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-chat-section-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.doc-chat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 9px;
  color: var(--muted);
}

.doc-chat-events,
.doc-chat-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-chat-events.hidden {
  display: none;
}

.chat-history-empty {
  display: none;
}

.doc-chat-events-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-chat-event {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 6px 8px;
  display: grid;
  gap: 2px;
  font-size: 10px;
}

.doc-chat-event-title {
  font-weight: 600;
  color: var(--text);
}

.doc-chat-event-summary {
  color: var(--text);
  opacity: 0.85;
}

.doc-chat-event-detail,
.doc-chat-event-meta {
  color: var(--muted);
  font-size: 9px;
}

.doc-chat-event.thinking {
  border-color: rgba(108, 245, 216, 0.3);
  background: rgba(108, 245, 216, 0.08);
}

.doc-chat-event.command {
  border-color: rgba(255, 166, 77, 0.35);
}

.doc-chat-event.file {
  border-color: rgba(241, 250, 140, 0.35);
}

.doc-chat-event.error {
  border-color: rgba(255, 85, 102, 0.35);
  background: rgba(255, 85, 102, 0.08);
}

.doc-chat-events-empty,
.doc-chat-empty {
  text-align: center;
  color: var(--muted);
  padding: 10px 8px;
  font-size: 10px;
  opacity: 0.7;
}

.doc-chat-message {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}

.doc-chat-message-role {
  font-weight: 600;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.doc-chat-message-content {
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.45;
}

.doc-chat-message-meta {
  font-size: 9px;
  color: var(--muted);
}

.doc-chat-message.assistant.streaming .doc-chat-message-content {
  color: var(--accent);
}

.doc-chat-message.assistant.final .doc-chat-message-role {
  color: var(--accent);
}

.doc-chat-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}

.doc-chat-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.doc-chat-entry-header .prompt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.doc-chat-entry-header .prompt {
  color: var(--text);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-prompt-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  border-radius: 6px;
  font-size: 11px;
  padding: 0;
}

.copy-prompt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.doc-chat-entry-header .meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
}

.doc-chat-entry-header .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.doc-chat-entry.running .status-dot {
  background: var(--accent);
}

.doc-chat-entry.error .status-dot {
  background: var(--error);
}

.doc-chat-entry.interrupted .status-dot {
  background: var(--accent-2);
}

.doc-chat-entry-response {
  color: var(--text);
  white-space: pre-wrap;
  font-size: 11px;
  line-height: 1.4;
}

.doc-chat-entry-response.streaming {
  color: var(--accent);
}

.doc-chat-entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 9px;
  color: var(--muted);
}

/* Empty state */
.chat-empty {
  text-align: center;
  color: var(--muted);
  padding: 16px 10px;
  font-size: 11px;
  opacity: 0.7;
}

/* Message pair container */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-message:not(:last-child) {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Chat bubbles */
.chat-bubble {
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 100%;
  word-break: break-word;
}

.chat-bubble.user {
  background: linear-gradient(135deg, rgba(108, 168, 255, 0.12), rgba(108, 168, 255, 0.06));
  border: 1px solid rgba(108, 168, 255, 0.2);
  border-radius: 8px 8px 8px 2px;
}

.chat-bubble.assistant {
  background: rgba(108, 245, 216, 0.05);
  border: 1px solid rgba(108, 245, 216, 0.12);
  border-radius: 8px 8px 2px 8px;
}

/* User prompt */
.chat-prompt {
  color: var(--text);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Compact chat header with timestamp */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.chat-time {
  font-size: 9px;
  color: var(--muted);
  opacity: 0.6;
}

.chat-copy-btn {
  padding: 1px 4px;
  font-size: 9px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.chat-bubble.user:hover .chat-copy-btn {
  opacity: 0.5;
}

.chat-copy-btn:hover {
  opacity: 1 !important;
  color: var(--accent-2);
  border-color: var(--accent-2);
  background: rgba(108, 168, 255, 0.1);
}

/* Assistant response */
.chat-response {
  color: var(--text);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.chat-response.streaming {
  color: var(--accent);
  position: relative;
}

.chat-response.streaming::after {
  content: "▋";
  animation: blink 0.8s infinite;
  margin-left: 2px;
}

@keyframes blink {

  0%,
  50% {
    opacity: 1;
  }

  51%,
  100% {
    opacity: 0;
  }
}

.chat-response.error {
  color: var(--error);
}

.chat-response.interrupted {
  color: var(--accent-2);
  opacity: 0.8;
}

/* Thinking preview - like Telegram */
.chat-thinking,
.chat-status-text {
  font-size: 10px;
  color: var(--accent);
  font-style: italic;
  padding: 4px 6px;
  background: rgba(108, 245, 216, 0.06);
  border-radius: 4px;
  margin-bottom: 4px;
  line-height: 1.3;
}

.thinking-indicator {
  display: inline-block;
  margin-right: 4px;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Waiting / typing indicator */
.chat-waiting {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Tool call pills */
.chat-tool-calls {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 4px;
}

.chat-tool-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 10px;
  background: rgba(139, 233, 253, 0.1);
  border: 1px solid rgba(139, 233, 253, 0.25);
  color: #8be9fd;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-tool-pill.command {
  background: rgba(255, 166, 77, 0.1);
  border-color: rgba(255, 166, 77, 0.25);
  color: #ffcc80;
  font-family: "JetBrains Mono", monospace;
}

.chat-tool-pill.file {
  background: rgba(241, 250, 140, 0.1);
  border-color: rgba(241, 250, 140, 0.25);
  color: #f1fa8c;
}

.chat-tool-pill.muted {
  background: var(--bg);
  border-color: var(--border);
  color: var(--muted);
}

/* Updated doc tags */
.chat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(108, 245, 216, 0.08);
}

.chat-tag {
  padding: 1px 6px;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(108, 245, 216, 0.1);
  border: 1px solid rgba(108, 245, 216, 0.2);
  border-radius: 8px;
  color: var(--accent);
}

/* Status variants for messages */
.chat-message.running .chat-bubble.assistant {
  border-color: rgba(108, 245, 216, 0.3);
  animation: gentle-pulse 2s ease-in-out infinite;
}

@keyframes gentle-pulse {

  0%,
  100% {
    border-color: rgba(108, 245, 216, 0.3);
    box-shadow: 0 0 0 0 rgba(108, 245, 216, 0);
  }

  50% {
    border-color: rgba(108, 245, 216, 0.5);
    box-shadow: 0 0 8px rgba(108, 245, 216, 0.1);
  }
}

.chat-message.error .chat-bubble.assistant {
  border-color: rgba(255, 85, 102, 0.3);
  background: rgba(255, 85, 102, 0.06);
}

.chat-message.interrupted .chat-bubble.assistant {
  border-color: rgba(108, 168, 255, 0.3);
  background: rgba(108, 168, 255, 0.06);
}

.card .row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Inputs */
input[type="number"],
input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 6px;
  font-size: 11px;
  font-family: inherit;
  width: 60px;
}

input[type="number"]::placeholder,
input[type="text"]::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  user-select: none;
}

/* Inline toolbar for Logs/Terminal - super compact */
.inline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.inline-toolbar .terminal-voice {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-toolbar .terminal-voice .voice-button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  flex-shrink: 0;
}

.inline-toolbar .terminal-voice .voice-button svg {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
}

.inline-toolbar .terminal-voice .voice-status {
  white-space: nowrap;
}

/* Log viewer - maximize height (accounts for nav + toolbar + legend) */
.log-viewer {
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 8px;
  color: #b0c0d8;
  height: calc(100vh - 130px);
  overflow: auto;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.4;
  margin: 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.log-viewer:empty::before,
.log-viewer.empty::before {
  content: "(no logs)";
  color: var(--muted);
  font-style: italic;
}

.log-viewer::-webkit-scrollbar {
  width: 6px;
}

.log-viewer::-webkit-scrollbar-track {
  background: transparent;
}

.log-viewer::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.log-viewer::-webkit-scrollbar-thumb:hover {
  background: #2a3450;
}

/* ========== LOG LINE TYPES ========== */

.log-line {
  padding: 1px 4px;
  border-radius: 2px;
  margin: 1px 0;
  position: relative;
}

/* Icons before certain line types */
.log-line[data-icon]::before {
  content: attr(data-icon);
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  opacity: 0.8;
}

/* Run boundaries - prominent separators */
.log-line.log-run-start,
.log-line.log-run-end {
  background: linear-gradient(90deg, rgba(108, 245, 216, 0.15) 0%, transparent 100%);
  border-left: 3px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  padding: 6px 8px;
  margin: 12px 0 8px 0;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.log-line.log-run-end {
  background: linear-gradient(90deg, rgba(108, 168, 255, 0.12) 0%, transparent 100%);
  border-left-color: var(--accent-2);
  color: var(--accent-2);
  margin: 8px 0 12px 0;
}

/* Thinking/reasoning - italicized, muted */
.log-line.log-thinking-label {
  color: #9b7aff;
  font-style: italic;
  opacity: 0.7;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

.log-line.log-thinking {
  color: #b8a3ff;
  font-style: italic;
  padding-left: 20px;
  border-left: 2px solid rgba(155, 122, 255, 0.3);
  background: rgba(155, 122, 255, 0.05);
}

/* Tool execution - highlighted */
.log-line.log-exec-label {
  color: #ffa64d;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
  margin-top: 6px;
}

.log-line.log-exec-command {
  color: #ffcc80;
  background: rgba(255, 166, 77, 0.08);
  border-left: 2px solid rgba(255, 166, 77, 0.4);
  padding-left: 20px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* File updates */
.log-line.log-file-update-label {
  color: #4dc9ff;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
  margin-top: 6px;
}

.log-line.log-file-modified {
  color: #80d4ff;
  background: rgba(77, 201, 255, 0.08);
  border-left: 2px solid rgba(77, 201, 255, 0.4);
  padding-left: 20px;
}

/* Diff styling */
.log-line.log-diff-header {
  color: #d2a8ff;
  font-size: 10px;
  opacity: 0.7;
}

.log-line.log-diff-hunk {
  color: #58a6ff;
  background: rgba(56, 139, 253, 0.08);
  font-weight: 500;
}

.log-line.log-diff-add {
  color: #7ee787;
  background: rgba(46, 160, 67, 0.12);
  border-left: 2px solid #3fb950;
  padding-left: 20px;
}

.log-line.log-diff-del {
  color: #f97583;
  background: rgba(248, 81, 73, 0.12);
  border-left: 2px solid #f85149;
  padding-left: 20px;
}

/* Prompt/context markers - dimmed, collapsible appearance */
.log-line.log-prompt-marker,
.log-line.log-prompt-marker-end {
  color: #6e7681;
  font-size: 10px;
  opacity: 0.5;
  font-style: italic;
}

.log-line.log-prompt-context {
  color: #6e7681;
  opacity: 0.4;
  font-size: 10px;
  padding-left: 12px;
  border-left: 1px dashed rgba(110, 118, 129, 0.3);
}

/* System messages */
.log-line.log-system {
  color: #6e7681;
  font-size: 10px;
  opacity: 0.6;
}

.log-line.log-tokens {
  color: #a371f7;
  font-size: 10px;
  background: rgba(163, 113, 247, 0.08);
  border-radius: 3px;
  padding: 2px 6px;
  display: inline-block;
  margin: 4px 0;
}

/* Success/exit status */
.log-line.log-success {
  color: #56d364;
}

.log-line.log-exit-code {
  color: #8b949e;
  font-size: 10px;
}

/* Agent output - most prominent! This is the final answer */
.log-line.log-agent-output {
  color: var(--text);
  background: linear-gradient(90deg, rgba(108, 245, 216, 0.12) 0%, rgba(108, 168, 255, 0.08) 100%);
  border: 1px solid rgba(108, 245, 216, 0.3);
  border-radius: 4px;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.5;
}

/* Regular output */
.log-line.log-output {
  color: #b0c0d8;
}

/* Test output */
.log-line.log-test-output {
  color: #58a6ff;
  font-size: 10px;
}

/* Error/traceback output */
.log-line.log-error-output {
  color: #f97583;
  background: rgba(248, 81, 73, 0.08);
  border-left: 2px solid #f85149;
  padding-left: 20px;
}

/* Blank lines */
.log-line.log-blank {
  height: 8px;
}

/* ========== LOG STREAM STATUS ========== */
.log-stream-status {
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 10px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  font-weight: 500;
  border: 1px solid transparent;
  margin-left: 8px;
}

.log-stream-status.status-connecting {
  border-color: var(--accent-2);
  background: rgba(108, 168, 255, 0.08);
  color: var(--accent-2);
}

.log-stream-status.status-connected {
  border-color: var(--accent);
  background: rgba(108, 245, 216, 0.08);
  color: var(--accent);
}

.log-stream-status.status-reconnecting {
  border-color: var(--accent-2);
  background: rgba(108, 168, 255, 0.08);
  color: var(--accent-2);
  animation: pulse-reconnecting 1.5s ease-in-out infinite;
}

@keyframes pulse-reconnecting {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

.log-stream-status.status-stopped {
  border-color: var(--border);
  background: var(--bg);
  color: var(--muted);
}

/* ========== LOG LEGEND ========== */
.log-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 9px;
  align-items: center;
}

.log-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.log-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.log-legend-dot.thinking {
  background: #9b7aff;
}

.log-legend-dot.exec {
  background: #ffa64d;
}

.log-legend-dot.file {
  background: #4dc9ff;
}

.log-legend-dot.diff-add {
  background: #3fb950;
}

.log-legend-dot.diff-del {
  background: #f85149;
}

.log-legend-dot.output {
  background: var(--accent);
}

.log-legend-dot.context {
  background: #6e7681;
  opacity: 0.5;
}

/* ========== COLLAPSIBLE CONTEXT BLOCKS ========== */
.log-context-block {
  margin: 4px 0;
  border: 1px solid rgba(110, 118, 129, 0.2);
  border-radius: 4px;
  background: rgba(110, 118, 129, 0.05);
}

.log-context-block[open] {
  background: rgba(110, 118, 129, 0.08);
}

.log-context-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 10px;
  color: #6e7681;
  user-select: none;
  list-style: none;
}

.log-context-summary::-webkit-details-marker {
  display: none;
}

.log-context-summary:hover {
  color: #8b949e;
  background: rgba(110, 118, 129, 0.1);
}

.log-context-icon {
  font-size: 8px;
  transition: transform 0.15s ease;
}

.log-context-block[open] .log-context-icon {
  transform: rotate(90deg);
}

.log-context-count {
  opacity: 0.6;
  font-size: 9px;
}

.log-context-content {
  padding: 4px 8px 8px;
  border-top: 1px solid rgba(110, 118, 129, 0.15);
  max-height: 200px;
  overflow-y: auto;
  font-size: 10px;
}

.log-context-content .log-line {
  margin: 0;
  padding: 1px 4px;
}

/* ========== RUN SECTION STYLING ========== */
.log-run-section {
  margin: 8px 0;
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

/* ========== LOG CONTAINER WITH JUMP BUTTON ========== */
.log-container {
  position: relative;
  height: calc(100vh - 130px);
}

.log-container .log-viewer {
  height: 100%;
}

.analytics-logs summary {
  cursor: pointer;
}

.analytics-logs.open summary {
  color: var(--accent);
}

.log-load-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  z-index: 10;
  transition: all 0.15s ease;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.log-load-btn:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.log-load-btn:hover {
  border-color: rgba(108, 245, 216, 0.5);
  color: var(--accent);
}

.log-jump-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
  transition: all 0.15s ease;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.log-jump-btn:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.log-jump-btn:hover {
  background: #5de6c9;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.log-jump-btn:active {
  transform: translateY(0);
}

/* Terminal panel - flex layout to fill available space */
#terminal.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Terminal - maximize space using flex */
.terminal-container {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  flex: 1 1 auto;
  min-height: 200px;
  overflow: hidden;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

/* ===== MOBILE TERMINAL CONTROLS ===== */
/* Hidden by default - only shown on touch devices */
.terminal-mobile-controls {
  display: none;
}

.terminal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg);
  color: var(--muted);
  z-index: 2;
  padding: 40px 20px;
  gap: 16px;
}

.terminal-overlay p {
  font-size: 14px;
  line-height: 1.6;
  max-width: 400px;
  margin: 0;
}

.terminal-overlay .terminal-overlay-hint {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

.terminal-container .xterm {
  padding: 6px;
}

.terminal-container .xterm-viewport {
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.terminal-jump-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(108, 245, 216, 0.12);
  border: 1px solid rgba(108, 245, 216, 0.3);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, opacity 0.15s ease;
  z-index: 4;
}

.terminal-jump-btn:hover {
  background: rgba(108, 245, 216, 0.2);
  transform: translateY(-1px);
}

.terminal-jump-btn:active {
  transform: translateY(0);
}

/* ===== TERMINAL TEXT INPUT (optional panel) ===== */

#terminal.composer-sticky .terminal-text-input {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + var(--vv-bottom, 0px));
  z-index: 8;
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.45);
}

.terminal-text-input-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: none;
  /* Hide on mobile, show on desktop */
}

.terminal-text-input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-text-input-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 10px;
}

.terminal-text-input-buttons .voice-button,
.terminal-text-input-buttons .terminal-text-image,
.terminal-text-send-icon {
  padding: 0;
}

.terminal-text-input-buttons .terminal-text-image {
  font-size: 11px;
  letter-spacing: 0.2px;
}

button.terminal-text-send-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0b0f14;
  background: var(--accent);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

button.terminal-text-send-icon.disconnected {
  opacity: 0.55;
}

.terminal-text-input-buttons .voice-level-meter {
  width: 34px;
  height: 34px;
  padding: 4px 2px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: rgba(108, 245, 216, 0.12);
  cursor: pointer;
}

/* When the text input panel is open, terminal still uses flex but may need more space for controls */
#terminal.text-input-open .terminal-container {
  flex: 1 1 auto;
  min-height: 180px;
}

/* Toast */
.toast {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px) + var(--vv-top, 0px));
  right: 8px;
  bottom: auto;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateY(8px);
  z-index: 10000;
  pointer-events: none;
  user-select: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: var(--error);
  color: #ffaab5;
}

/* Screen reader only */
.sr-only {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}

/* Confirmation Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

#confirm-modal,
#input-modal {
  z-index: 3000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-7);
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-dialog p {
  margin: 0 0 var(--sp-6);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: var(--sp-4);
  justify-content: flex-end;
}

.modal-actions button {
  min-width: 72px;
}

/* Input modal */
.modal-input {
  max-width: 420px;
}

.modal-input p {
  margin: 0 0 12px;
}

.modal-input input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  margin-bottom: 16px;
  box-sizing: border-box;
}

.modal-input input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-input input[type="text"]::placeholder {
  color: var(--muted);
}

/* Reason details modal */
.reason-modal-dialog {
  max-width: 600px;
  max-height: 80vh;
}

.reason-modal-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.reason-modal-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  max-height: 50vh;
  overflow: auto;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  color: var(--text);
}

/* Clickable reason field */
#ticket-flow-reason.has-details {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

#ticket-flow-reason.has-details:hover {
  color: var(--accent);
}

/* Ingest spec modal */
.modal-ingest {
  max-width: 480px;
}

.modal-ingest p {
  margin: 0 0 12px;
}

.ingest-modal-refinement {
  margin-bottom: 16px;
}

.ingest-modal-refinement.hidden {
  display: none;
}

.ingest-modal-refinement textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
  resize: vertical;
  min-height: 80px;
  max-height: 200px;
}

.ingest-modal-refinement textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.ingest-modal-refinement textarea::placeholder {
  color: var(--muted);
}

/* Create repo modal */
.modal-create-repo {
  max-width: 440px;
}

.modal-header {
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.modal-header .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
}

/* File Picker Modal */
.file-picker-modal.modal-overlay {
  padding: 0;
  z-index: 3100;
}

.file-picker-dialog {
  width: 100%;
  max-width: 400px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.file-picker-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.file-picker-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: color 0.15s ease, background 0.15s ease;
}

.file-picker-close:hover {
  color: var(--text);
  background: rgba(108, 245, 216, 0.1);
}

.file-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.file-picker-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 8px 8px;
  color: var(--muted);
}

.file-picker-crumbs button {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  padding: 0 2px;
}

.file-picker-crumbs span {
  color: var(--muted);
}

.file-picker-section {
  margin-bottom: 12px;
}

.file-picker-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 6px;
}

.file-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.file-picker-item:hover,
.file-picker-item:focus {
  background: rgba(108, 245, 216, 0.08);
  outline: none;
}

.file-picker-item.active {
  background: rgba(108, 245, 216, 0.15);
  color: var(--accent);
}

.file-picker-item.active::before {
  content: "✓";
  margin-right: -4px;
  font-size: 12px;
  color: var(--accent);
}

.file-picker-item.folder {
  font-weight: 600;
}

.file-picker-empty {
  padding: 12px 14px;
  color: var(--muted);
}

.file-picker-item-icon {
  font-size: 16px;
  opacity: 0.7;
}

.file-picker-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile: Full screen bottom sheet style */
@media (max-width: 640px) {
  .file-picker-modal.modal-overlay {
    align-items: flex-end;
  }

  .file-picker-dialog {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .file-picker-header {
    padding: 16px 20px;
  }

  .file-picker-title {
    font-size: 16px;
  }

  .file-picker-body {
    padding: 8px 12px 24px;
  }

  .file-picker-item {
    padding: 14px 16px;
    font-size: 15px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-group label {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
}

.form-group .required {
  color: var(--error);
}

.form-group .optional {
  color: var(--muted);
  font-weight: 400;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-hint {
  font-size: 10px;
  color: var(--muted);
}

.form-checkbox {
  flex-direction: row;
  align-items: center;
}

.form-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Loading button state */
button.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

button.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Runner pid info */
#runner-pid {
  margin: 6px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .grid-two {
    grid-template-columns: repeat(2, 1fr);
  }

  .hub-hero {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    overflow-x: auto;
  }

  .hub-hero-text {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: nowrap;
  }

  .hub-hero-actions {
    justify-content: flex-start;
    gap: 3px;
    flex-wrap: nowrap;
  }

  .hub-mode-toggle {
    justify-self: end;
  }

  .hub-version {
    max-width: 120px;
  }

  .hub-stats-inline {
    gap: var(--sp-3);
  }

  /* Compact repo cards on tablet */
  .hub-repo-row {
    flex-wrap: wrap;
    gap: var(--sp-3);
  }

  .hub-repo-center {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
  }

  .hub-repo-open-indicator {
    display: none;
  }

  /* Better action buttons layout on tablet */
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .actions button {
    flex: 1 1 auto;
    min-width: 70px;
  }

  /* Cards get better spacing on tablet */
  .card {
    padding: 12px;
  }

  /* Status card header more compact */
  .card-header {
    flex-wrap: wrap;
    gap: 6px;
  }

  .card-header-left {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Runner config on one line */
  .runner-config {
    flex-wrap: wrap;
  }
}

/* Mobile: 640px and below */
@media (max-width: 640px) {
  :root {
    --mobile-top-pad: max(4px, env(safe-area-inset-top));
    --mobile-bottom-nav: calc(52px + env(safe-area-inset-bottom, 0px));
    --mobile-input-font-size: 16px;
  }

  html.mobile-chrome-hidden {
    --mobile-bottom-nav: env(safe-area-inset-bottom, 0px);
  }

  /* Safe area support for notches */
  .app-shell {
    padding: 4px;
    padding-top: var(--mobile-top-pad);
    padding-bottom: var(--mobile-bottom-nav);
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Hub mobile styles - compact layout */
  .hub-shell {
    padding: var(--sp-2);
    padding-top: max(var(--sp-2), env(safe-area-inset-top));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    gap: var(--sp-2);
  }

  /* Hero: 2-row grid on mobile – title+toggle top, actions below */
  .hub-hero {
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-2);
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .hub-hero-text {
    grid-column: 1;
    grid-row: 1;
    gap: var(--sp-2);
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .hub-hero h1 {
    font-size: 12px;
    flex-shrink: 0;
  }

  /* Hide version and scan pill on mobile to save header space */
  .hub-hero-text .hub-version,
  .hub-hero-text .pill {
    display: none;
  }

  .hub-mode-toggle {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
  }

  .hub-hero-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: var(--sp-2);
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .hub-hero-actions button {
    padding: 3px 7px;
    font-size: 10px;
  }

  .hub-mode-btn {
    padding: 3px 7px;
    font-size: 9px;
  }

  .hub-mode-long {
    display: none;
  }

  .hub-mode-short {
    display: inline;
  }

  .hub-stats-inline {
    margin: 0;
    padding: 0 var(--sp-2);
    gap: var(--sp-3);
    font-size: 9px;
  }

  .hub-stat-inline .hub-stat-value {
    font-size: 10px;
  }

  .hub-repo-panel {
    padding: var(--sp-2);
  }

  .hub-panel-header {
    margin-bottom: var(--sp-2);
    flex-direction: column;
    gap: var(--sp-2);
  }

  .hub-panel-title {
    width: 100%;
    gap: 6px;
  }

  .hub-panel-summary {
    padding: 3px 6px;
  }

  /* Search-on-top, filters-below (grid for explicit row control) */
  .hub-repo-controls {
    width: 100%;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: var(--sp-2);
    padding-bottom: 0;
    align-items: center;
  }

  .hub-repo-search-control {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    min-width: 0;
    width: 100%;
  }

  .hub-repo-search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
  }

  .hub-repo-control {
    font-size: 9px;
    gap: 4px;
  }

  .hub-repo-select {
    width: auto;
    min-width: 0;
    max-width: none;
    font-size: 9px;
    padding: 3px 16px 3px 6px;
  }

  .hub-repo-list {
    gap: 2px;
  }

  .hub-chat-binding-main {
    gap: 4px;
    flex-wrap: wrap;
  }

  .hub-chat-binding-meta {
    white-space: normal;
  }

  /* Repo cards: compact layout on mobile */
  .hub-repo-card {
    padding: var(--sp-2) var(--sp-3);
  }

  .hub-repo-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--sp-1) var(--sp-2);
    align-items: start;
  }

  .hub-repo-left {
    display: none;
  }

  .hub-repo-center {
    grid-column: 1;
    min-width: 0;
    overflow: hidden;
    gap: 1px;
  }

  .hub-repo-mainline {
    flex-wrap: wrap;
    gap: var(--sp-1);
  }

  .hub-repo-title {
    font-size: 11px;
  }

  .hub-repo-right {
    grid-column: 2;
    grid-row: 1 / -1;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
    margin-left: 0;
    opacity: 1;
  }

  .hub-repo-right button {
    padding: 2px 5px;
    font-size: 8px;
    white-space: nowrap;
  }

  .hub-repo-meta-inline {
    flex-wrap: wrap;
  }

  .hub-repo-info-line {
    font-size: 9px;
    max-width: 100%;
  }

  .hub-repo-subline {
    max-width: 100%;
    overflow: hidden;
  }

  .hub-repo-note {
    font-size: 9px;
    margin-top: 2px;
  }

  .hub-repo-subline {
    gap: 4px;
    font-size: 9px;
  }

  .hub-repo-flow-line {
    gap: 4px;
    margin-top: 1px;
  }

  .hub-flow-bar {
    width: 40px;
    min-width: 40px;
  }

  .hub-flow-text {
    font-size: 9px;
  }

  /* Compact usage on mobile */
  .hub-usage-compact {
    padding: 6px 8px;
    margin: 6px 0;
  }

  .hub-usage-header {
    gap: 6px;
    margin-bottom: 4px;
  }

  .hub-usage-path {
    font-size: 10px;
  }

  .hub-usage-grid {
    gap: 3px;
  }

  .hub-usage-chip {
    padding: 3px 6px;
    font-size: 9px;
    gap: 4px;
  }

  .hub-usage-chip-name {
    max-width: 70px;
  }

  .hub-usage-chip-total {
    font-size: 10px;
  }

  .hub-usage-chip-meta {
    font-size: 10px;
  }

  /* Per-repo usage compact on mobile */
  .usage-card-compact {
    padding: 6px 8px;
  }

  .usage-header {
    gap: 6px;
    margin-bottom: 4px;
  }

  .usage-total-badge {
    font-size: 11px;
    padding: 2px 6px;
  }

  .usage-events-badge {
    font-size: 9px;
    padding: 1px 4px;
  }

  .usage-breakdown {
    gap: 2px;
    margin-bottom: 4px;
  }

  .usage-stat {
    padding: 3px 1px;
  }

  .usage-stat-val {
    font-size: 10px;
  }

  .usage-stat-lbl {
    font-size: 10px;
  }

  .usage-footer {
    font-size: 10px;
    padding-top: 3px;
  }

  /* Usage chart more compact on mobile */
  .usage-chart {
    padding: 4px;
    margin-bottom: 4px;
  }

  .usage-chart-canvas {
    height: 70px;
  }

  /* Usage rates visual more compact on mobile */
  .usage-rates-visual {
    gap: 3px;
    margin-bottom: 3px;
  }

  .usage-rate-row {
    gap: 4px;
  }

  .usage-rate-label {
    font-size: 9px;
    min-width: 55px;
  }

  /* Modal on mobile */
  .modal-create-repo {
    max-width: 100%;
    margin: 8px;
  }

  .modal-body {
    gap: 12px;
  }

  .form-group input[type="text"] {
    font-size: 13px;
    padding: var(--sp-4) var(--sp-5);
  }

  /* Hide brand and repo name on mobile */
  .nav-brand,
  .nav-repo-name {
    display: none;
  }

  /* Show back button on mobile */
  .hub-back-btn {
    padding: 10px 12px;
    font-size: 10px;
    min-height: 44px;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    background: var(--panel);
  }

  /* Bottom navigation - thumb friendly */
  .nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: linear-gradient(to top, var(--panel) 0%, rgba(16, 19, 28, 0.98) 100%);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
    z-index: 1900;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.18s ease;
  }

  html.mobile-chrome-hidden .nav-bar {
    transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)));
  }

  html.mobile-chrome-hidden #terminal .terminal-mobile-controls,
  html.mobile-chrome-hidden #terminal .terminal-text-input-actions {
    display: none;
  }

  html.mobile-chrome-hidden #docs #doc-chat-voice,
  html.mobile-chrome-hidden #docs #doc-chat-cancel,
  html.mobile-chrome-hidden #docs .doc-chat-meta {
    display: none;
  }

  html.mobile-compose-fixed #terminal .terminal-text-input,
  html.mobile-compose-fixed #docs .doc-chat-panel {
    position: fixed;
    left: 4px;
    right: 4px;
    bottom: max(var(--mobile-bottom-nav), var(--vv-bottom, 0px));
    margin: 0;
    z-index: 120;
  }

  /* Also fix-position mobile controls above the text input when compose is open */
  html.mobile-compose-fixed #terminal .terminal-mobile-controls {
    position: fixed;
    left: 4px;
    right: 4px;
    /* Position above the text input using dynamically measured height */
    bottom: calc(var(--compose-input-height, 100px) + max(var(--mobile-bottom-nav), var(--vv-bottom, 0px)));
    margin: 0;
    z-index: 119;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 4px;
  }

  /* When compose is fixed, shrink terminal container so it stops above the fixed elements */
  html.mobile-compose-fixed #terminal .terminal-container {
    margin-bottom: var(--compose-total-height, 180px);
  }

  html.mobile-compose-fixed #docs.panel.active {
    padding-bottom: calc(var(--doc-compose-height, 100px) + max(var(--mobile-bottom-nav), var(--vv-bottom, 0px)));
  }

  .tabs {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
    gap: 0;
  }

  /* Larger touch targets - min 44px */
  .tab {
    padding: 14px 8px;
    min-height: 48px;
    font-size: 10px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: color 0.15s ease, background 0.15s ease;
  }

  /* Subtle divider between tabs */
  .tab:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: var(--border);
    opacity: 0.5;
  }

  .tab:active:not(.active) {
    background: rgba(108, 245, 216, 0.08);
  }

  .tab.active {
    color: var(--accent);
    background: rgba(108, 245, 216, 0.12);
    border-top: 2px solid var(--accent);
    font-weight: 600;
  }

  /* Hide divider next to active tab */
  .tab.active::after,
  .tab.active+.tab::before {
    opacity: 0;
  }

  /* Inactive tabs on mobile - ensure readable */
  .tab:not(.active) {
    color: var(--muted);
  }

  .tab:not(.active):hover {
    color: var(--text);
  }

  /* Content area */
  main {
    padding-bottom: 8px;
  }

  /* Ticket flow mobile - overflow menu and collapsible meta */
  .ticket-desktop-only {
    display: none !important;
  }

  .ticket-overflow-menu {
    display: block;
  }

  /* Compact ticket header on mobile */
  .ticket-card .card-header {
    padding-bottom: 4px;
    margin-bottom: 4px;
    gap: 4px;
  }

  .ticket-card .ticket-header-left {
    gap: 6px;
  }

  .ticket-card .ticket-header-left .label {
    font-size: 10px;
  }

  .ticket-card .ticket-header-left .ticket-mono {
    font-size: 9px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Compact action buttons on mobile */
  .ticket-card .ticket-flow-actions {
    gap: 4px;
    margin: 2px 0;
  }

  .ticket-card .ticket-flow-actions button {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 11px;
  }

  .ticket-card .ticket-flow-meta {
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: transparent;
    border: none;
  }

  /* Always show details on mobile (simplified critical info only) */
  .ticket-card .ticket-meta-details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 4px 8px;
    margin-top: 0;
    background: rgba(16, 21, 33, 0.3);
    border-radius: 4px;
    font-size: 10px;
  }

  /* Hide secondary (non-critical) meta rows on mobile */
  .ticket-card .ticket-meta-details .ticket-meta-secondary {
    display: none;
  }

  /* Show critical meta rows inline on mobile */
  .ticket-card .ticket-meta-details .ticket-meta-critical {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
  }

  /* Compact panel headers on mobile */
  .ticket-card .ticket-panel-header {
    padding: 2px 4px 4px;
    margin-bottom: 0;
  }

  .ticket-card .ticket-panel-header .muted,
  .ticket-card .ticket-panel-header .small {
    font-size: 10px;
  }

  /* Hide empty agent selects on mobile */
  select.mobile-hide-empty:empty {
    display: none;
  }

  /* Workspace mobile - hide desktop header, show bottom toolbar */
  .contextspace-header-desktop {
    display: none;
  }

  .contextspace-mobile-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    margin: 0;
  }

  .contextspace-mobile-menu {
    margin-left: auto;
  }

  .contextspace-mobile-dropdown {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  }

  /* Tighten spacing around toolbar */
  #contextspace-content {
    margin-bottom: 0;
  }

  .contextspace-mobile-toolbar+.compose-panel {
    margin-top: 2px;
  }

  .contextspace-grid {
    grid-template-columns: 1fr;
  }

  .contextspace-file-browser {
    display: none;
  }

  #contextspace.panel.active {
    display: flex;
    flex-direction: column;
  }

  #contextspace .contextspace-main {
    flex: 1;
    min-height: 0;
  }

  #contextspace-content {
    min-height: 150px;
    font-size: 14px;
  }

  .grid-two {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .grid-two>div {
    padding: 8px 10px;
  }

  /* Hide empty metrics on mobile */
  .grid-two>div.metric-empty {
    display: none;
  }

  .grid-two .muted {
    font-size: 10px;
  }

  .metric {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
  }

  /* Larger action buttons - min 44px touch targets */
  .actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 12px;
  }

  .actions button {
    min-width: 0;
    min-height: 44px;
    padding: 10px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .actions button:active {
    transform: scale(0.95);
    opacity: 0.8;
  }

  /* Primary action buttons get full width on first row */
  .actions button.primary {
    grid-column: span 1;
  }

  /* Icon buttons should be smaller */
  .actions button.icon-btn {
    grid-column: span 1;
    min-width: 44px;
  }

  .card {
    padding: 10px;
    overflow: hidden;
  }

  .card-header {
    padding-bottom: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .card-header-left {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Analytics panel mobile improvements */
  #analytics .cards {
    padding: 0;
    gap: 6px;
  }

  /* Mobile typography - minimum readable sizes */
  .usage-stat-lbl,
  .usage-footer,
  .usage-rate-label,
  .usage-progress-label,
  .hub-usage-path,
  .hub-usage-chip-meta,
  .pill-small,
  .ticket-live-output-status,
  .ticket-live-output-events-count,
  .doc-patch-legend,
  .doc-chat-event-detail,
  .doc-chat-event-meta,
  .doc-chat-message-meta,
  .doc-chat-entry-header .meta,
  .doc-chat-entry-tags,
  .chat-time,
  .chat-copy-btn,
  .chat-tag {
    font-size: 10px;
  }

  .usage-chart-label,
  .muted.small {
    font-size: 10px;
  }

  /* Ensure body text minimum */
  .ticket-body,
  .dispatch-item,
  .messages-thread,
  .inbox-item {
    font-size: 12px;
  }

  /* Runner config compact on mobile */
  .runner-config {
    margin-top: 8px;
    padding-top: 8px;
    gap: 6px;
  }

  .runner-config-label {
    font-size: 10px;
  }

  .runner-config-value {
    font-size: 11px;
  }

  /* Runner PID info more compact */
  #runner-pid {
    margin-top: 8px;
    font-size: 10px;
  }

  /* Compact inline toolbar for mobile - flex row */
  .inline-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    margin: 0 -4px 4px;
    border-radius: 0;
    align-items: center;
  }

  .inline-toolbar label {
    font-size: 9px;
    gap: 2px;
    flex-shrink: 0;
  }

  .inline-toolbar label:has(input[type="number"]) {
    display: none;
    /* Hide Run/Tail labels on mobile, show just inputs */
  }

  /* Runs toolbar - hide label text, show only controls */
  .runs-toolbar {
    gap: 6px;
  }

  .runs-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0;
    /* Hide label text */
    flex: 1 1 auto;
    min-width: 0;
  }

  .runs-toolbar label::before {
    content: none;
    /* Remove any pseudo-element labels */
  }

  .runs-toolbar select,
  .runs-toolbar input[type="text"] {
    font-size: 11px;
    min-height: 36px;
    padding: 6px 8px;
    width: 100%;
    min-width: 0;
  }

  .runs-toolbar input[type="text"] {
    flex: 1;
  }

  .runs-toolbar input[type="text"]::placeholder {
    font-size: 10px;
  }

  .inline-toolbar input[type="number"] {
    width: 50px;
    min-height: 32px;
    padding: 4px 6px;
    font-size: var(--mobile-input-font-size);
    flex-shrink: 0;
  }

  .inline-toolbar button {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 10px;
    flex-shrink: 0;
  }

  /* Checkbox toggles - fixed width */
  .inline-toolbar .chip {
    padding: 4px 8px;
    font-size: 9px;
    min-height: 28px;
    flex-shrink: 0;
    flex-grow: 0;
  }

  .inline-toolbar .chip span {
    display: none;
    /* Hide label text, show just checkbox */
  }

  .inline-toolbar .chip::after {
    content: attr(data-short);
    font-size: 9px;
  }

  /* Logs/Terminal - account for bottom nav and compact toolbar */
  .log-container {
    height: calc(100vh - 130px);
    height: calc(100dvh - 130px);
  }

  .log-viewer {
    font-size: 10px;
    padding: 4px;
  }

  /* Hide log legend on mobile - too cluttered */
  .log-legend {
    display: none;
  }

  /* Simplified log line styling on mobile */
  .log-line {
    padding: 1px 2px;
    font-size: 10px;
  }

  .log-line[data-icon]::before {
    display: none;
  }

  .log-line.log-run-start,
  .log-line.log-run-end {
    padding: 3px 6px;
    margin: 6px 0 3px 0;
    font-size: 10px;
  }

  .log-line.log-agent-output {
    padding: 4px 6px;
    margin: 4px 0;
    font-size: 10px;
  }

  .log-line.log-thinking,
  .log-line.log-exec-command {
    padding-left: 8px;
  }

  /* Collapsible blocks more compact */
  .log-context-block {
    margin: 2px 0;
  }

  .log-context-summary {
    padding: 2px 4px;
    font-size: 9px;
  }

  .log-context-content {
    padding: 2px 4px;
    max-height: 100px;
    font-size: 9px;
  }

  /* Jump button on mobile */
  .log-jump-btn {
    bottom: 10px;
    right: 10px;
    padding: 6px 10px;
    font-size: 9px;
  }

  #terminal.panel.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--mobile-top-pad) - var(--mobile-bottom-nav));
    overflow: hidden;
  }

  #terminal .terminal-container {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Terminal toolbar mobile - clean two-row layout */
  #terminal .terminal-toolbar {
    padding: 6px 8px;
    gap: 6px;
    margin: 0 -4px 4px;
    border-radius: 0;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  #terminal .terminal-toolbar-row {
    gap: 6px;
  }

  #terminal .terminal-status {
    font-size: 11px;
  }

  #terminal .terminal-actions {
    gap: 4px;
  }

  #terminal .terminal-actions button {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 11px;
  }

  #terminal .terminal-agent-controls {
    gap: 4px;
  }

  #terminal .terminal-agent-controls select,
  #terminal .terminal-agent-controls .agent-model-input {
    min-height: 32px;
    padding: 4px 6px;
    font-size: 11px;
    max-width: none;
  }

  #terminal .terminal-toolbar-extras {
    gap: 4px;
  }

  #terminal .terminal-text-toggle {
    min-height: 32px;
    min-width: 32px;
    padding: 6px !important;
  }

  #terminal .terminal-toolbar .terminal-voice {
    display: none;
  }

  #terminal.text-input-open .terminal-container {
    height: auto;
  }

  #terminal .terminal-mobile-controls,
  #terminal .terminal-text-input {
    flex: 0 0 auto;
  }

  .compose-row textarea {
    min-height: 52px;
    max-height: 100px;
    font-size: 16px;
    line-height: 1.3;
    resize: none;
  }

  .compose-row {
    gap: 4px;
  }

  .compose-buttons {
    gap: 4px;
  }

  .compose-buttons button {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    border-radius: 8px;
  }

  .terminal-text-input-buttons .terminal-text-image {
    font-size: 10px;
  }

  .compose-buttons .voice-button svg {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
  }

  .terminal-text-input-buttons .voice-level-meter {
    width: 30px;
    height: 30px;
    padding: 3px 2px;
    border-radius: 8px;
  }

  .terminal-text-input-actions {
    gap: 6px;
  }

  html.mobile-compose-fixed #terminal .terminal-text-input {
    position: fixed;
    bottom: max(var(--mobile-bottom-nav), var(--vv-bottom, 0px));
  }

  html.mobile-compose-fixed #terminal .terminal-mobile-controls {
    position: fixed;
    left: 4px;
    right: 4px;
    bottom: calc(var(--compose-input-height, 100px) + max(var(--mobile-bottom-nav), var(--vv-bottom, 0px)));
    z-index: 119;
    margin: 0;
  }

  html.mobile-compose-fixed #terminal .terminal-container {
    margin-bottom: var(--compose-total-height, 180px);
  }

  /* Mobile terminal control bar */
  .terminal-mobile-controls {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
  }

  .tmb-row {
    display: flex;
    gap: 3px;
    align-items: center;
  }

  .tmb-key {
    flex: 1;
    min-height: 34px;
    padding: 6px 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: all 0.08s ease;
    text-transform: none;
    letter-spacing: 0;
  }

  .tmb-key:active {
    background: rgba(108, 245, 216, 0.2);
    border-color: var(--accent);
    transform: scale(0.94);
  }

  /* Modifier keys (Ctrl/Alt) - toggle state */
  .tmb-mod {
    flex: 1;
    background: var(--bg);
    color: var(--muted);
  }

  .tmb-mod.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
  }

  /* Arrow keys - fixed width, larger icon */
  .tmb-arrow {
    flex: 0 0 32px;
    font-size: 14px;
    padding: 5px 3px;
    order: 3;
  }

  /* Enter key - primary action */
  .tmb-primary {
    background: rgba(108, 245, 216, 0.12);
    border-color: rgba(108, 245, 216, 0.3);
    color: var(--accent);
    font-weight: 600;
  }

  .tmb-primary:active {
    background: rgba(108, 245, 216, 0.3);
    border-color: var(--accent);
  }

  /* Ctrl combos - danger styled for interrupt signals */
  .tmb-ctrl-combo {
    flex: 0 0 auto;
    min-width: 32px;
    order: 1;
    background: rgba(255, 85, 102, 0.08);
    border-color: rgba(255, 85, 102, 0.25);
    color: #ff8899;
    font-weight: 600;
  }

  .tmb-bksp {
    order: 2;
  }

  .tmb-ctrl-combo:active {
    background: rgba(255, 85, 102, 0.25);
    border-color: #ff5566;
  }

  /* Hide terminal voice from toolbar on mobile - it's in the mobile controls */
  .inline-toolbar .terminal-voice,
  .terminal-toolbar .terminal-voice {
    display: none;
  }

  /* Mobile terminal voice button - integrated into mobile controls */
  .tmb-voice {
    flex: 0 0 auto;
    min-width: 34px;
    background: var(--bg);
    border-color: var(--border);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 6px;
  }

  .tmb-voice svg {
    width: 14px;
    height: 14px;
    min-width: 14px;
    min-height: 14px;
    flex-shrink: 0;
  }

  .tmb-voice.voice-recording {
    background: #b3261e;
    color: #fff;
    border-color: #b3261e;
    animation: tmb-voice-pulse 1s ease-in-out infinite;
  }

  @keyframes tmb-voice-pulse {

    0%,
    100% {
      opacity: 1;
    }

    50% {
      opacity: 0.7;
    }
  }

  .tmb-voice.voice-sending {
    background: rgba(108, 245, 216, 0.2);
    color: var(--accent);
    border-color: var(--accent);
  }

  .tmb-voice.voice-error {
    border-color: #d35400;
    color: #d35400;
  }

  .tmb-voice.disabled,
  .tmb-voice.voice-disconnected {
    opacity: 0.4;
  }

  /* Level meter in mobile controls - more compact */
  .tmb-row .voice-level-meter {
    height: 16px;
    padding: 0 2px;
    gap: 1px;
  }

  .tmb-row .voice-level-bar {
    width: 2px;
  }

  /* Docs nav - compact chips on mobile */
  .doc-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin-bottom: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .doc-nav .chip {
    padding: 8px 10px;
    min-height: 36px;
    font-size: 10px;
    flex-shrink: 0;
  }

  .doc-nav .chip:active {
    transform: scale(0.95);
  }

  #doc-status {
    display: none;
  }

  .doc-editor textarea {
    /* Let the editor consume usable vertical space (no arbitrary cap). */
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    font-size: var(--mobile-input-font-size);
    padding: 10px;
    resize: none;
  }

  /* Make Docs panel a fill-the-screen flex layout (avoids wasted space). */
  #docs.panel.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--mobile-top-pad) - var(--mobile-bottom-nav));
    overflow: hidden;
  }

  #docs.panel.active .doc-editor {
    flex: 1 1 auto;
    min-height: 0;
  }

  #doc-content {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Patch view should also fill space when active. */
  .doc-patch-main {
    flex: 1 1 auto;
    min-height: 0;
  }

  .doc-patch-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  /* Larger tap targets for icon-only buttons (refresh, etc.) */
  button.icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 18px;
  }

  .doc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    align-items: stretch;
  }

  .doc-actions button {
    flex: 1 1 calc(33.333% - 6px);
    min-height: 44px;
    padding: 10px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    justify-content: center;
  }

  /* Use short labels on mobile */
  .doc-actions button[data-short] {
    font-size: 0;
  }

  .doc-actions button[data-short]::after {
    content: attr(data-short);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* Chat panel - mobile meta/response sizing */
  .doc-chat-compose {
    gap: 2px;
  }

  .doc-agent-controls,
  .agent-controls {
    gap: 4px;
    margin-bottom: 4px;
  }

  .doc-agent-controls select,
  .doc-agent-controls .agent-model-input,
  .agent-controls select,
  .agent-controls .agent-model-input {
    min-height: 30px;
    padding: 4px 6px;
    font-size: 11px;
    max-width: none;
  }

  .doc-chat-meta {
    font-size: 9px;
    gap: 4px;
  }

  /* Hide hint text on mobile - too cluttered */
  #doc-chat-hint {
    display: none;
  }

  /* Hide voice status text on mobile when not actively recording */
  .doc-chat-meta .voice-status:not(.recording) {
    display: none;
  }

  /* Keep only essential controls in meta row on mobile */
  .doc-chat-meta-left {
    flex: 0 0 auto;
  }

  .doc-chat-meta-right {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  /* Unified chat stream mobile - hide when empty */
  .doc-chat-stream {
    max-height: 200px;
    padding: 6px;
    gap: 10px;
  }

  .doc-chat-stream:empty {
    display: none;
  }

  /* When chat stream only has the error div but it's hidden, collapse */
  .doc-chat-stream:has(> .doc-chat-error.hidden:only-child) {
    display: none;
  }

  .chat-message:not(:last-child) {
    padding-bottom: 10px;
  }

  .chat-bubble {
    padding: 8px 10px;
    border-radius: 10px;
  }

  .chat-prompt {
    font-size: 11px;
  }

  .chat-response {
    font-size: 11px;
  }

  .chat-meta {
    margin-top: 4px;
    padding-top: 4px;
  }

  .chat-copy-btn {
    opacity: 0.6;
    /* Always visible on mobile for touch */
    padding: 4px 8px;
    font-size: 12px;
  }

  .chat-thinking,
  .chat-status-text {
    font-size: 10px;
    padding: 4px 6px;
  }

  .chat-tool-pill {
    font-size: 9px;
    padding: 2px 6px;
  }

  .chat-tags {
    margin-top: 6px;
    padding-top: 6px;
  }

  .chat-tag {
    font-size: 10px;
    padding: 2px 6px;
  }

  .chat-empty {
    padding: 16px 8px;
    font-size: 11px;
  }

  /* Patch wrapper on mobile */
  .doc-chat-patch-wrapper {
    padding: 6px;
  }

  .doc-chat-patch {
    max-height: 60px;
    font-size: 10px;
  }

  .doc-chat-patch-actions {
    font-size: 9px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .doc-chat-patch-actions button {
    font-size: 9px;
    padding: 6px 10px;
  }

  /* Main patch panel on mobile - stacked layout */
  .doc-patch-main {
    padding: 10px;
    gap: 10px;
  }

  .doc-patch-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .doc-patch-info {
    order: 1;
  }

  .doc-patch-summary {
    font-size: 12px;
    line-height: 1.4;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
  }

  .doc-patch-legend {
    display: none;
    /* Hide on mobile - the colors are self-explanatory */
  }

  .doc-patch-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    order: 2;
  }

  .doc-patch-actions button {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 12px;
    justify-content: center;
    width: 100%;
  }

  .doc-patch-actions button.primary {
    order: -1;
    /* Move Apply button to top */
  }

  .doc-patch-body {
    max-height: 300px;
    padding: 0;
    font-size: 11px;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    overflow: auto;
  }

  /* Diff line adjustments for mobile */
  .diff-gutter {
    flex: 0 0 28px;
    font-size: 9px;
    padding-right: 4px;
  }

  .diff-sign {
    flex: 0 0 14px;
    font-size: 10px;
  }

  .diff-content {
    padding-left: 6px;
    font-size: 11px;
  }

  .diff-line.diff-hunk .diff-content {
    font-size: 10px;
  }

  .diff-empty-marker {
    font-size: 9px;
    padding: 0 3px;
  }

  /* Toast below top safe area */
  .toast {
    left: 8px;
    right: 8px;
    top: calc(8px + var(--mobile-top-pad) + var(--vv-top, 0px));
    bottom: auto;
    text-align: center;
  }

  /* Checklist items - larger touch area */
  .checklist li {
    padding: 10px 12px;
    gap: 10px;
    min-height: 44px;
  }

  .checklist .box {
    width: 18px;
    height: 18px;
  }

  .checklist .box.done::after {
    font-size: 14px;
    top: 0;
    left: 2px;
  }

  /* ===== MOBILE TERMINAL TALL VIEW ===== */
  /* Mirrors the terminal buffer while the text input is focused on mobile.
     Keeps scrolling easy without sending keystrokes to the TUI. */
  .mobile-terminal-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 100;
    /* Below input (z-index 120) */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    padding-bottom: calc(var(--compose-total-height, 120px) + env(safe-area-inset-bottom) + var(--vv-bottom, 0px));
    font-family: "JetBrains Mono", monospace;
    font-size: 10px;
    line-height: 1.15;
    letter-spacing: 0;
    font-variant-ligatures: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }

  .mobile-terminal-view.hidden {
    display: none;
  }

  .mobile-terminal-view .ansi-bold {
    font-weight: 600;
  }

  .mobile-terminal-view .ansi-fg-30 {
    color: #000000;
  }

  .mobile-terminal-view .ansi-fg-31 {
    color: #ff5566;
  }

  .mobile-terminal-view .ansi-fg-32 {
    color: #6cf5d8;
  }

  .mobile-terminal-view .ansi-fg-33 {
    color: #f1fa8c;
  }

  .mobile-terminal-view .ansi-fg-34 {
    color: #6ca8ff;
  }

  .mobile-terminal-view .ansi-fg-35 {
    color: #bd93f9;
  }

  .mobile-terminal-view .ansi-fg-36 {
    color: #8be9fd;
  }

  .mobile-terminal-view .ansi-fg-37 {
    color: #e5ecff;
  }

  .mobile-terminal-view .ansi-fg-90 {
    color: #6272a4;
  }

  .mobile-terminal-view .ansi-fg-91 {
    color: #ff6e6e;
  }

  .mobile-terminal-view .ansi-fg-92 {
    color: #69ff94;
  }

  .mobile-terminal-view .ansi-fg-93 {
    color: #ffffa5;
  }

  .mobile-terminal-view .ansi-fg-94 {
    color: #d6acff;
  }

  .mobile-terminal-view .ansi-fg-95 {
    color: #ff92df;
  }

  .mobile-terminal-view .ansi-fg-96 {
    color: #a4ffff;
  }

  .mobile-terminal-view .ansi-fg-97 {
    color: #ffffff;
  }

  /* Match xterm's bold-bright mapping for base colors. */
  .mobile-terminal-view .ansi-bold.ansi-fg-30 {
    color: #6272a4;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-31 {
    color: #ff6e6e;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-32 {
    color: #69ff94;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-33 {
    color: #ffffa5;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-34 {
    color: #d6acff;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-35 {
    color: #ff92df;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-36 {
    color: #a4ffff;
  }

  .mobile-terminal-view .ansi-bold.ansi-fg-37 {
    color: #ffffff;
  }

  .mobile-terminal-view .ansi-bg-40 {
    background-color: #000000;
  }

  .mobile-terminal-view .ansi-bg-41 {
    background-color: #ff5566;
  }

  .mobile-terminal-view .ansi-bg-42 {
    background-color: #6cf5d8;
  }

  .mobile-terminal-view .ansi-bg-43 {
    background-color: #f1fa8c;
  }

  .mobile-terminal-view .ansi-bg-44 {
    background-color: #6ca8ff;
  }

  .mobile-terminal-view .ansi-bg-45 {
    background-color: #bd93f9;
  }

  .mobile-terminal-view .ansi-bg-46 {
    background-color: #8be9fd;
  }

  .mobile-terminal-view .ansi-bg-47 {
    background-color: #e5ecff;
  }

  .mobile-terminal-view .ansi-bg-100 {
    background-color: #6272a4;
  }

  .mobile-terminal-view .ansi-bg-101 {
    background-color: #ff6e6e;
  }

  .mobile-terminal-view .ansi-bg-102 {
    background-color: #69ff94;
  }

  .mobile-terminal-view .ansi-bg-103 {
    background-color: #ffffa5;
  }

  .mobile-terminal-view .ansi-bg-104 {
    background-color: #d6acff;
  }

  .mobile-terminal-view .ansi-bg-105 {
    background-color: #ff92df;
  }

  .mobile-terminal-view .ansi-bg-106 {
    background-color: #a4ffff;
  }

  .mobile-terminal-view .ansi-bg-107 {
    background-color: #ffffff;
  }

  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="email"],
  input[type="url"],
  textarea,
  select {
    font-size: var(--mobile-input-font-size);
  }

}

/* Ultra-small screens */
@media (max-width: 400px) {
  .terminal-container {
    flex: 1 1 auto;
    min-height: 100px;
  }

  #terminal.text-input-open .terminal-container {
    flex: 1 1 auto;
    min-height: 80px;
  }

  .terminal-mobile-controls {
    padding: 3px;
    gap: 2px;
  }

  .tmb-row {
    gap: 2px;
  }

  .tmb-key {
    min-height: 30px;
    padding: 4px 3px;
    font-size: 9px;
  }

  .tmb-arrow {
    flex: 0 0 26px;
    font-size: 12px;
  }

  .tmb-ctrl-combo {
    min-width: 28px;
    font-size: 9px;
  }

  .tmb-voice {
    min-width: 30px;
    padding: 3px 4px;
  }

  .tmb-voice svg {
    width: 11px;
    height: 11px;
    min-width: 11px;
    min-height: 11px;
  }

  .tab {
    padding: 12px 4px;
    font-size: 9px;
    letter-spacing: 0;
  }

  .tab.active {
    color: var(--accent);
    font-weight: 600;
  }

  .metric {
    font-size: 11px;
  }

  .grid-two {
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
  }

  .grid-two>div {
    padding: 5px 6px;
  }

  .grid-two .muted {
    font-size: 10px;
  }

  .actions {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .actions button {
    font-size: 10px;
    min-height: 40px;
    padding: 8px 4px;
  }

  /* Ultra-compact logs toolbar */
  .inline-toolbar {
    gap: 3px;
    padding: 4px;
  }

  .inline-toolbar input[type="number"] {
    width: 45px;
    min-height: 28px;
    font-size: var(--mobile-input-font-size);
  }

  .inline-toolbar button {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 9px;
  }

  .inline-toolbar .chip {
    padding: 2px 6px;
    min-height: 24px;
  }

  .inline-toolbar .chip::after {
    font-size: 10px;
  }

  .log-container {
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);
  }

  .log-viewer {
    font-size: 9px;
    padding: 3px;
  }

  .log-line {
    font-size: 9px;
  }

  .log-line.log-run-start,
  .log-line.log-run-end {
    font-size: 9px;
    padding: 2px 4px;
    margin: 4px 0 2px 0;
  }

  .log-line.log-agent-output {
    font-size: 9px;
    padding: 3px 4px;
    margin: 3px 0;
  }

  .log-jump-btn {
    padding: 4px 8px;
    font-size: 10px;
    bottom: 8px;
    right: 8px;
  }

  .doc-nav .chip {
    padding: 6px 8px;
    min-height: 32px;
    font-size: 9px;
  }

  .doc-actions button {
    flex: 1 1 calc(50% - 4px);
    min-height: 40px;
    padding: 8px 6px;
  }

  .doc-actions button[data-short]::after {
    font-size: 11px;
  }

  .doc-chat-panel {
    padding: 4px;
  }

  /* Runs toolbar ultra-compact on small screens */
  .runs-toolbar {
    gap: 4px;
    flex-wrap: wrap;
  }

  .runs-toolbar select,
  .runs-toolbar input[type="text"] {
    font-size: 10px;
    min-height: 32px;
    padding: 4px 6px;
  }

  /* Doc chat meta - even more compact */
  .doc-chat-meta {
    gap: 3px;
  }

  .doc-chat-meta-right button {
    padding: 4px 6px;
    font-size: 10px;
  }


  /* Patch panel for ultra-small screens */
  .doc-patch-main {
    padding: 8px;
    gap: 8px;
  }

  .doc-patch-summary {
    font-size: 11px;
    padding: 6px;
  }

  .doc-patch-legend {
    display: none;
  }

  .doc-patch-actions button {
    min-height: 40px;
    padding: 10px 12px;
    font-size: 11px;
  }

  .doc-patch-body {
    max-height: 220px;
  }

  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="email"],
  input[type="url"],
  textarea,
  select {
    font-size: var(--mobile-input-font-size);
  }

  .diff-gutter {
    flex: 0 0 24px;
    font-size: 8px;
    padding-right: 3px;
  }

  .diff-sign {
    flex: 0 0 12px;
    font-size: 9px;
  }

  .diff-content {
    padding-left: 4px;
    font-size: 10px;
  }

  .diff-empty-marker {
    font-size: 8px;
    padding: 0 2px;
  }
}

/* Very narrow phones (iPhone SE, compact devices) */
@media (max-width: 360px) {
  .cards {
    gap: 4px;
  }

  .card {
    padding: 8px;
  }

  .card-header {
    margin-bottom: 6px;
    padding-bottom: 6px;
    gap: 4px;
  }

  .grid-two {
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
  }

  .grid-two>div {
    padding: 4px 5px;
  }

  .grid-two .muted {
    font-size: 10px;
    letter-spacing: 0;
  }

  .metric {
    font-size: 10px;
  }

  .actions {
    gap: 3px;
  }

  .actions button {
    font-size: 10px;
    min-height: 38px;
    padding: 6px 2px;
    letter-spacing: 0;
  }

  .runner-config {
    gap: 4px;
  }

  .runner-config-label {
    font-size: 10px;
  }

  .runner-config-value {
    font-size: 10px;
  }

  .usage-header {
    gap: 4px;
    flex-wrap: wrap;
  }

  .usage-total-badge {
    font-size: 10px;
    padding: 1px 5px;
  }

  .usage-events-badge {
    font-size: 8px;
    padding: 1px 3px;
  }

  .usage-stat-val {
    font-size: 9px;
  }

  .usage-stat-lbl {
    font-size: 6px;
  }

  .usage-chart-canvas {
    height: 60px;
  }

  .usage-rate-label {
    font-size: 8px;
    min-width: 50px;
  }

  .todo-preview .checklist li {
    font-size: 10px;
    padding: 3px 4px;
    gap: 4px;
  }

  .checklist .box {
    width: 10px;
    height: 10px;
  }

  .github-card .github-row {
    grid-template-columns: 40px 1fr;
    gap: 4px;
    font-size: 10px;
  }

  .github-card .github-link,
  .github-card .github-mono {
    font-size: 10px;
  }

  .github-card .github-flow-grid {
    grid-template-columns: 80px 1fr;
    gap: 4px 6px;
  }

  .github-card .github-flow-row {
    grid-template-columns: 40px 1fr;
    gap: 4px;
    font-size: 10px;
  }

  .github-card .muted {
    font-size: 9px;
  }

  #runner-pid {
    font-size: 8px;
  }

  /* Runs toolbar - stack vertically on very narrow screens */
  .runs-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .runs-toolbar label {
    width: 100%;
  }

  .runs-toolbar select,
  .runs-toolbar input[type="text"] {
    font-size: 11px;
    min-height: 36px;
  }

  .runs-toolbar button {
    width: 100%;
  }

  /* Doc chat meta - minimal on very narrow screens */
  .doc-chat-meta {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .doc-chat-meta-left {
    display: none;
  }

  #doc-chat-new-thread {
    font-size: 8px;
    padding: 3px 5px;
  }
}

/* Landscape phone - side-by-side layout */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  :root {
    --mobile-input-font-size: 16px;
  }

  .app-shell {
    padding-bottom: 4px;
  }

  .nav-bar {
    position: static;
    margin-bottom: 4px;
  }

  /* Compact logs for landscape */
  .inline-toolbar {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 4px;
    margin-bottom: 4px;
  }

  .inline-toolbar label:has(input[type="number"]) {
    display: flex;
  }

  .inline-toolbar input[type="number"] {
    width: 45px;
    min-height: 26px;
  }

  .inline-toolbar button {
    min-height: 26px;
    padding: 4px 8px;
  }

  .inline-toolbar .chip {
    padding: 2px 4px;
    min-height: 24px;
  }

  .inline-toolbar .chip span {
    display: inline;
  }

  .inline-toolbar .chip::after {
    content: none;
  }

  .log-legend {
    display: flex;
    padding: 2px 6px;
    margin-bottom: 4px;
    font-size: 7px;
  }

  .log-container {
    height: calc(100vh - 90px);
  }

  .log-viewer {
    font-size: 9px;
    padding: 4px;
  }

  .tabs {
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .tab {
    min-height: 36px;
    padding: 8px;
    border-radius: var(--radius);
  }

  /* Landscape retains solid accent background with dark text for high contrast */
  .tab.active {
    border-top: none;
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
  }

  .tab:not(.active) {
    color: var(--muted);
  }

  .log-viewer {
    height: calc(100vh - 80px);
  }

  #terminal.panel.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 120px);
    overflow: hidden;
  }

  #terminal .terminal-container {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  #terminal.text-input-open .terminal-container {
    height: auto;
  }

  .compose-panel {
    padding: 4px;
    gap: 3px;
  }

  .compose-row textarea {
    min-height: 52px;
    max-height: 70px;
    padding: 4px;
    font-size: 16px;
    line-height: 1.3;
    resize: none;
  }

  .compose-row {
    gap: 4px;
  }

  .compose-buttons {
    gap: 4px;
  }

  .compose-buttons button {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 8px;
  }

  .terminal-text-input-buttons .terminal-text-image {
    font-size: 9px;
  }

  .compose-buttons .voice-button svg {
    width: 11px;
    height: 11px;
    min-width: 11px;
    min-height: 11px;
  }

  .terminal-text-input-buttons .voice-level-meter {
    width: 28px;
    height: 28px;
    padding: 3px 2px;
    border-radius: 8px;
  }

  .terminal-text-input-actions {
    gap: 4px;
  }

  .terminal-text-input-hint {
    display: none;
  }

  .terminal-text-input #terminal-text-send {
    font-size: 14px;
  }

  /* Compact mobile controls in landscape - single row */
  .terminal-mobile-controls {
    display: flex;
    flex-direction: row;
    gap: 3px;
    padding: 3px 4px;
    margin-top: 3px;
  }

  .tmb-row {
    flex: 1;
    gap: 2px;
  }

  .tmb-key {
    min-height: 26px;
    padding: 3px 2px;
    font-size: 9px;
  }

  .tmb-arrow {
    flex: 0 0 24px;
    font-size: 11px;
  }

  .tmb-ctrl-combo {
    min-width: 24px;
    font-size: 9px;
  }

  .tmb-voice {
    min-width: 26px;
    padding: 3px;
  }

  .tmb-voice svg {
    width: 10px;
    height: 10px;
  }

  .doc-editor textarea {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  #docs.panel.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 90px);
    overflow: hidden;
  }

  #docs.panel.active .doc-editor {
    flex: 1 1 auto;
    min-height: 0;
  }

  #doc-content {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Compact chat for landscape */
  .doc-chat-panel {
    padding: 4px;
    gap: 2px;
  }

  .doc-chat-stream {
    max-height: 120px;
    padding: 4px;
    gap: 6px;
  }

  .doc-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .doc-actions button {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 6px 10px;
  }

  .doc-actions button[data-short] {
    font-size: 0;
  }

  .doc-actions button[data-short]::after {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }

  /* Patch panel in landscape */
  .doc-patch-main {
    padding: 6px;
    gap: 6px;
  }

  .doc-patch-header {
    flex-direction: row;
    align-items: center;
  }

  .doc-patch-summary {
    font-size: 10px;
    padding: 4px 6px;
  }

  .doc-patch-legend {
    display: none;
  }

  .doc-patch-actions {
    flex-direction: row;
    gap: 4px;
  }

  .doc-patch-actions button {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 10px;
    width: auto;
  }

  .doc-patch-body {
    max-height: 140px;
  }

  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="email"],
  input[type="url"],
  textarea,
  select {
    font-size: var(--mobile-input-font-size);
  }

  .diff-gutter {
    flex: 0 0 28px;
    font-size: 9px;
  }

  .diff-content {
    font-size: 10px;
  }
}

/* ===== Repo Settings Extensions ===== */
.repo-settings-dialog {
  max-width: 480px;
}

.repo-settings-dialog .modal-header {
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
}

.repo-settings-dialog .modal-header .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.repo-settings-dialog .modal-body {
  gap: 0;
}

.repo-settings-dialog .form-group {
  padding: var(--sp-5) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.repo-settings-dialog .form-group:first-child {
  padding-top: 0;
}

.repo-settings-dialog .form-group:last-child {
  border-bottom: none;
  padding-bottom: var(--sp-2);
}

.repo-settings-dialog .form-group > label:first-child {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-1);
}

.repo-settings-dialog .form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  padding: var(--sp-4);
  line-height: 1.5;
}

.repo-settings-dialog .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-section-danger {
  border-bottom: none !important;
}

.settings-section-danger > label:first-child {
  color: var(--error) !important;
}

.settings-section-danger .danger {
  margin-top: var(--sp-3);
}

.repo-settings-dialog .modal-actions {
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-2);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-5);
  margin-top: var(--sp-3);
}

.settings-toggle-row {
  margin-top: var(--sp-4);
}

.settings-actions {
  display: flex;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
  align-items: center;
  flex-wrap: wrap;
}

.hub-destination-settings-pill {
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 10px;
}

.form-hint.warning {
  color: var(--warning);
}

.thread-tools-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.thread-tool-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
}

.thread-tool-label {
  color: var(--muted);
}

.thread-tool-value {
  font-family: var(--mono);
  color: var(--text);
}

.thread-tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* ===== Template repos settings ===== */
.template-repos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.template-repo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
}

.template-repo-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.template-repo-id {
  font-family: var(--mono);
  color: var(--text);
}

.template-repo-url {
  color: var(--muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-repo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.template-repo-form {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
}

.template-repo-form.hidden {
  display: none;
}

/* ===== Runs Panel ===== */
.runs-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
}

.runs-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.runs-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.runs-table th,
.runs-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.runs-row {
  cursor: pointer;
  transition: background 0.2s ease;
}

.runs-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.runs-empty {
  text-align: center;
  color: var(--muted);
  padding: 16px 8px;
}

.runs-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.runs-pill-ok {
  background: rgba(88, 214, 141, 0.15);
  color: var(--success);
}

.runs-pill-error {
  background: rgba(255, 107, 107, 0.15);
  color: var(--error);
}

.runs-pill-running {
  background: rgba(255, 209, 102, 0.15);
  color: var(--warning);
}

.runs-todo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
}

.runs-todo-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.runs-todo-text {
  font-weight: 500;
}

.runs-todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  align-items: center;
}

.runs-todo-runs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.runs-chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

/* ===== Run Details Modal ===== */
.run-details-modal {
  width: min(1120px, 94vw);
  max-width: 1120px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.run-details-modal .modal-body {
  overflow: auto;
  min-height: 0;
}

.run-details-modal .modal-actions {
  margin-top: auto;
}

.run-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.run-details-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run-details-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.run-details-artifact {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 320px;
  overflow: auto;
  font-size: 11px;
  color: var(--text);
}

.run-details-actions {
  align-items: center;
}

@media (max-width: 720px) {
  #run-details-modal.modal-overlay {
    padding: 0;
  }

  .run-details-modal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}

@media (max-width: 900px) {
  .runs-layout {
    grid-template-columns: 1fr;
  }
}

/* Hub inbox */
.hub-inbox {
  margin: 12px 0;
}

.hub-inbox-list {
  display: grid;
  gap: 10px;
}

.hub-inbox-item {
  display: block;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  color: var(--text);
}

.hub-inbox-item:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.hub-inbox-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.hub-inbox-title {
  font-weight: 600;
  font-size: 13px;
}

.hub-inbox-next {
  margin-top: 4px;
  font-size: 11px;
}

/* Inbox / Messages panel */
#inbox.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#inbox .cards {
  grid-template-columns: 1fr;
  flex: 1;
  min-height: 0;
}

#inbox .card {
  max-width: none;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.messages-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.messages-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages-thread-list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  position: relative;
}

.messages-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages-detail-header {
  display: none;
}

.messages-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.messages-detail-status {
  font-size: 10px;
}

.messages-detail-counts {
  font-size: 11px;
  white-space: nowrap;
}

.messages-back-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.messages-thread {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--panel);
  cursor: pointer;
}

.messages-thread:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.messages-thread-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 12px;
  flex-wrap: wrap;
}

.messages-thread-subtitle {
  font-size: 11px;
  margin-top: 4px;
}

.messages-thread-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.messages-thread-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f5a623;
  flex-shrink: 0;
}

.messages-thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.messages-thread-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}

.messages-thread-counts {
  flex: 1;
}

.messages-thread-time {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.messages-thread-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  position: relative;
}

.messages-failure-banner {
  border: 1px solid rgba(232, 94, 92, 0.45);
  background: rgba(232, 94, 92, 0.12);
  color: #f3c1bf;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
  margin-bottom: 12px;
}

.messages-thread-list.refreshing::after,
.messages-thread-detail.refreshing::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  opacity: 0.8;
  pointer-events: none;
}

/* Empty state styling */
.messages-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  height: 100%;
  min-height: 200px;
}

.messages-empty-state .muted {
  font-size: 13px;
}

.messages-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.messages-empty-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.messages-empty-hint {
  font-size: 12px;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.5;
}

/* Ticket list empty state styling */
.ticket-list:empty::before,
.ticket-list:only-child:not(:has(.ticket-item)):not(:has(.dispatch-item))::after {
  display: block;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Sidebar empty state */
.messages-sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.01);
  flex: 1;
}

.messages-sidebar-empty .muted {
  font-size: 12px;
}

/* Session row styling for thread list */
.messages-session-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 12px;
}

.messages-session-row:hover {
  border-color: rgba(255, 255, 255, 0.16);
  cursor: pointer;
}

.messages-session-id {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.messages-session-stats {
  font-size: 11px;
  color: var(--muted);
}

.messages-thread-history {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.messages-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel);
  margin-top: 10px;
  transition: border-color 0.15s ease, background 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: row;
}

.messages-entry:first-child {
  margin-top: 0;
}

/* Reddit-style thin collapse bar on the left */
.messages-collapse-bar {
  flex-shrink: 0;
  width: 4px;
  min-height: 100%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius) 0 0 var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, width 0.1s ease;
}

.messages-collapse-bar:hover {
  background: var(--accent);
  width: 6px;
}

.messages-collapse-bar:active {
  background: var(--accent-hover, var(--accent));
}

/* Collapsed state - bar is dimmer */
.messages-entry.collapsed .messages-collapse-bar {
  background: rgba(255, 255, 255, 0.08);
}

.messages-entry.collapsed .messages-collapse-bar:hover {
  background: var(--accent);
  width: 6px;
}

/* Messages content wrapper */
.messages-content-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Hide old collapse button - replaced by bar */
.messages-collapse-btn {
  display: none;
}

/* Messages entry body wrapper */
.messages-entry-body {
  padding: 0 12px 10px 12px;
  margin-top: 8px;
}

.messages-entry.collapsed .messages-entry-body {
  display: none;
}

.messages-entry.messages-entry-reply {
  margin-left: 20px;
  background: rgba(108, 168, 255, 0.04);
}

/* User reply collapse bar is blue */
.messages-entry.messages-entry-reply .messages-collapse-bar {
  background: rgba(108, 168, 255, 0.4);
}

.messages-entry.messages-entry-reply .messages-collapse-bar:hover {
  background: rgba(108, 168, 255, 0.7);
}

/* Pause/handoff dispatch styling - red */
.messages-entry.dispatch-pause {
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.04);
}

.messages-entry.dispatch-pause:hover {
  border-color: rgba(248, 81, 73, 0.6);
  background: rgba(248, 81, 73, 0.08);
}

.messages-entry.dispatch-pause .messages-collapse-bar {
  background: rgba(248, 81, 73, 0.5);
}

.messages-entry.dispatch-pause .messages-collapse-bar:hover {
  background: rgba(248, 81, 73, 0.8);
}

/* Notify dispatch styling - orange */
.messages-entry.dispatch-notify {
  border-color: rgba(255, 163, 68, 0.4);
  background: rgba(255, 163, 68, 0.04);
}

.messages-entry.dispatch-notify:hover {
  border-color: rgba(255, 163, 68, 0.6);
  background: rgba(255, 163, 68, 0.08);
}

.messages-entry.dispatch-notify .messages-collapse-bar {
  background: rgba(255, 163, 68, 0.5);
}

.messages-entry.dispatch-notify .messages-collapse-bar:hover {
  background: rgba(255, 163, 68, 0.8);
}

/* Turn summary dispatch styling - green */
.messages-entry.dispatch-turn {
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.04);
}

.messages-entry.dispatch-turn:hover {
  border-color: rgba(63, 185, 80, 0.6);
  background: rgba(63, 185, 80, 0.08);
}

.messages-entry.dispatch-turn .messages-collapse-bar {
  background: rgba(63, 185, 80, 0.5);
}

.messages-entry.dispatch-turn .messages-collapse-bar:hover {
  background: rgba(63, 185, 80, 0.8);
}

.messages-entry-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 12px;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.messages-entry-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.messages-entry-seq {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.messages-entry-title {
  flex: 1;
}

.messages-entry-time {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

.messages-reply-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.messages-reply-indicator::before {
  content: "↳";
  font-size: 14px;
}

.messages-body {
  white-space: pre-wrap;
  font-size: 12px;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--text);
}

.messages-markdown p {
  margin: 0 0 6px;
}

.messages-markdown ul {
  margin: 0 0 6px 16px;
  padding: 0;
}

.messages-markdown li {
  margin: 0;
}

.messages-markdown code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
}

.messages-markdown pre {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 8px;
  overflow-x: auto;
}

.messages-file {
  display: flex;
  align-items: center;
  gap: 6px;
}

.messages-file-icon {
  font-size: 12px;
}

.messages-file-size {
  margin-left: 4px;
}

/* Footer bar (session ID, status, stats) - sticky at bottom of scroll area */
.messages-thread-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 10px;
  font-size: 11px;
  flex-wrap: nowrap;
  position: sticky;
  bottom: 0;
  background: var(--panel);
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
}

.messages-thread-footer code {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  flex-shrink: 0;
}

.messages-footer-stats {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* Thread header (title + status) used in thread list items */
/* Note: .messages-thread-header is now actively used, not deprecated */

.messages-header-info {
  display: none;
}

.messages-header-info code {
  display: none;
}

.messages-stats-line {
  display: none;
}

.messages-stats-line .pill {
  display: none;
}

/* Legacy stat grid - deprecated but kept for compatibility */
.messages-thread-meta {
  display: none;
}

.messages-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.messages-meta-item .metric {
  font-size: 16px;
  font-weight: 600;
}

.messages-compose {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.messages-attachments {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-files-row,
.pma-files-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
}

.pma-files-hint {
  margin-left: 2px;
}

.chat-files-label,
.pma-files-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  min-width: 20px;
  flex-shrink: 0;
}

.chat-filebox-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.chat-icon-btn,
.pma-icon-btn-small {
  width: 16px;
  height: 16px;
  padding: 0;
  font-size: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-icon-btn:hover,
.pma-icon-btn-small:hover {
  color: var(--text);
}

.messages-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.messages-reply-body {
  width: 100%;
  min-height: 64px;
  max-height: 200px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-family: inherit;
  line-height: 1.4;
}

.messages-input-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.messages-attach-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.messages-attach-summary {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filebox-card {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px 8px;
  background: var(--panel);
  margin: 6px 0;
}

.filebox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.filebox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filebox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, max-content));
  gap: 6px;
  justify-content: start;
}

.filebox-card.filebox-stacked .filebox-header {
  justify-content: flex-end;
}

.filebox-card.filebox-stacked .filebox-grid {
  grid-template-columns: 1fr;
}

.filebox-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0;
}

.filebox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.filebox-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  margin: 0;
}

.filebox-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}

.filebox-link {
  font-weight: 500;
  font-size: 10px;
  color: var(--text);
  text-decoration: none;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 18px;
  word-break: normal;
}

.filebox-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.filebox-meta {
  display: none;
}

.filebox-empty {
  padding: 0;
  font-size: 10px;
  line-height: 18px;
}

button.filebox-delete {
  width: 12px;
  height: 12px;
  min-width: 12px;
  min-height: 12px;
  padding: 0;
  font-size: 10px;
  line-height: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  opacity: 0.7;
}

button.filebox-delete:hover {
  color: var(--error);
  opacity: 1;
}

/* Archive panel */
#archive.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#archive .cards {
  grid-template-columns: 1fr;
  flex: 1;
  min-height: 0;
}

#archive .card {
  max-width: none;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.archive-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.archive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.archive-list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.archive-list-section {
  display: grid;
  gap: 8px;
}

.archive-list-header {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  padding: 0 4px;
}

.archive-list-empty {
  padding: 4px 6px;
}

.archive-snapshot {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel);
  cursor: pointer;
}

.archive-snapshot:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.archive-snapshot.active {
  border-color: rgba(80, 250, 123, 0.5);
  box-shadow: 0 0 0 1px rgba(80, 250, 123, 0.35) inset;
}

.archive-snapshot-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
}

.archive-snapshot-meta {
  font-size: 11px;
}

.archive-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.archive-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.archive-detail-title {
  font-weight: 600;
  font-size: 14px;
}

.archive-detail-subtitle {
  font-size: 12px;
}

.archive-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  margin-bottom: 16px;
}

.archive-meta-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.archive-meta-value {
  font-size: 12px;
}

.archive-summary-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  background: var(--panel);
}

.archive-summary-block pre {
  white-space: pre-wrap;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
  font-size: 11px;
  margin: 0;
}

.archive-section-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}

.archive-file-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.archive-file-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.archive-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.archive-file-path-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.archive-file-grid {
  flex: 1;
  min-height: 0;
}

.archive-file-browser {
  min-height: 0;
}

.archive-file-browser .contextspace-file-list {
  max-height: none;
  flex: 1;
}

.archive-file-main {
  min-height: 0;
}

.archive-file-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.archive-file-title {
  font-weight: 600;
  font-size: 12px;
}

.archive-file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.archive-file-content {
  flex: 1;
  min-height: 180px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  white-space: pre-wrap;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
  font-size: 12px;
  overflow: auto;
}

.archive-file-empty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.archive-empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.archive-empty-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.archive-empty-hint {
  font-size: 12px;
}

/* Archive Sub-tabs */
.archive-subtabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.archive-subtab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.archive-subtab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.archive-subtab.active {
  color: var(--accent);
  background: var(--panel);
  box-shadow: inset 0 -2px 0 var(--accent), 0 1px 3px rgba(0, 0, 0, 0.2);
}

.archive-tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.archive-tab-content.active {
  display: flex;
}

/* Snapshot tab content - scrollable */
.archive-tab-snapshot {
  overflow-y: auto;
  padding-right: 4px;
}

/* Files tab content - fill height (only when active) */
.archive-tab-files.active {
  flex-direction: column;
}

.archive-tab-files .archive-file-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.archive-tab-files .archive-file-grid {
  flex: 1;
  min-height: 200px;
}

.archive-tab-files .contextspace-grid {
  height: 100%;
}

.archive-tab-files .contextspace-file-browser {
  max-height: none;
  height: 100%;
}

.archive-tab-files .contextspace-file-list {
  max-height: none;
  height: 100%;
  overflow-y: auto;
}

.archive-tab-files .contextspace-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.archive-tab-files .archive-file-content {
  flex: 1;
  min-height: 200px;
  max-height: none;
  overflow: auto;
}

@media (max-width: 900px) {

  /* Inbox mobile - fill height and scroll */
  .messages-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
  }

  .messages-sidebar {
    flex-shrink: 0;
  }

  .messages-thread-list {
    max-height: 180px;
    overflow-y: auto;
  }

  .messages-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .messages-thread-detail {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  #inbox .card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  #inbox.panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
  }

  .archive-layout {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
  }

  .archive-list {
    max-height: 180px;
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  .messages-layout {
    display: block;
    gap: 0;
    flex: 1;
    min-height: 0;
  }

  /* Wider collapse bar on mobile for easier touch */
  .messages-collapse-bar {
    width: 6px;
  }

  .messages-collapse-bar:hover {
    width: 8px;
  }

  .messages-sidebar {
    display: block;
    height: 100%;
  }

  .messages-main {
    display: none;
    height: 100%;
  }

  .messages-layout.viewing-detail .messages-sidebar {
    display: none;
  }

  .messages-layout.viewing-detail .messages-main {
    display: flex;
    flex-direction: column;
  }

  .messages-detail-header {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    gap: 8px;
  }

  .messages-back-btn {
    min-height: 44px;
    padding: 8px 16px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .messages-detail-meta {
    flex: 1;
    justify-content: flex-end;
  }

  /* Hide footer on mobile since info is in header */
  .messages-thread-footer {
    display: none;
  }

  .messages-thread-list {
    max-height: none;
    height: calc(100vh - 120px);
  }

  .messages-thread-detail {
    flex: 1;
    min-height: 0;
  }
}

/* ===== Ticket Editor Modal - Full Screen ===== */
#ticket-editor-modal {
  z-index: 2500;
}

#ticket-editor-modal.hidden {
  display: none;
}

.ticket-editor-modal {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: none;
  border-radius: 0;
}

/* Compact header with frontmatter inline */
.ticket-editor-header {
  padding: 6px 12px !important;
  margin-bottom: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--panel);
  flex-shrink: 0;
}

.ticket-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ticket-header-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ticket-header-actions .ticket-nav-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--radius);
}

.ticket-header-actions .ticket-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.ticket-header-row .ticket-fm-select {
  padding: 5px 8px;
  font-size: 11px;
  min-width: 80px;
}

.ticket-header-row .ticket-fm-input {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
  min-width: 0;
}

.ticket-header-row .ticket-fm-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
  padding: 6px 8px;
  margin: 0;
  position: relative;
  z-index: 1;
  touch-action: manipulation;
}

.ticket-header-row .ticket-fm-toggle-label {
  font-size: 11px;
}

.ticket-header-row .ticket-fm-toggle input[type="checkbox"] {
  width: 12px;
  height: 12px;
}

.ticket-editor-modal #ticket-editor-close {
  font-size: 16px;
  line-height: 1;
  padding: 0;
  margin: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  touch-action: manipulation;
}

.ticket-editor-error {
  margin: 8px 16px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255, 100, 100, 0.12);
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff6b6b;
  font-size: 12px;
  line-height: 1.4;
  flex-shrink: 0;
}

.ticket-editor-error.hidden {
  display: none;
}

.ticket-editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ticket-editor-textarea,
.ticket-patch-main {
  z-index: 1;
}

.ticket-chat-panel {
  z-index: 2;
}

.ticket-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.ticket-editor-toolbar button {
  font-size: 10px;
  padding: 3px 8px;
}

.ticket-editor-toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ticket-autosave-status {
  margin-left: auto;
  font-size: 10px;
}

.ticket-autosave-status.error {
  color: #ff6b6b;
}

.ticket-editor-textarea {
  flex: 1;
  margin: 8px 12px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
  min-height: 0;
}

.ticket-editor-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.ticket-editor-textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* ===== Ticket Frontmatter Form (inline in header) ===== */
.ticket-fm-select {
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 80px;
}

.ticket-fm-input {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.ticket-fm-select:focus,
.ticket-fm-input:focus {
  outline: none;
  border-color: var(--accent);
}

.ticket-fm-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.ticket-fm-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
  padding: 6px 8px;
  margin: -6px 0;
}

.ticket-fm-toggle input[type="checkbox"] {
  width: 12px;
  height: 12px;
  cursor: pointer;
  accent-color: var(--accent);
}

.ticket-fm-toggle-label {
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 600px) {
  .ticket-editor-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .ticket-header-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-items: center;
  }

  .ticket-header-row .ticket-fm-select {
    width: 100%;
  }

  .ticket-header-row .ticket-fm-input {
    grid-column: 1 / -1;
    order: 10;
    width: 100%;
  }

  .ticket-header-actions {
    grid-column: 1 / -1;
    order: 20;
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .ticket-header-row #ticket-editor-close {
    order: 30;
  }
}

/* Clickable ticket items */
.ticket-item.clickable {
  cursor: pointer;
}

.ticket-item.clickable:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

.ticket-item.clickable:active {
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Ticket Chat Panel (matches Docs chat) ===== */
.ticket-chat-panel {
  margin: 8px 16px 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  flex-shrink: 0;
}

.ticket-chat-compose {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-chat-agent-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.ticket-chat-agent-controls select,
.ticket-chat-agent-controls .agent-model-input {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  min-width: 100px;
}

.ticket-chat-agent-controls select:disabled,
.ticket-chat-agent-controls .agent-model-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ticket-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.ticket-chat-input {
  flex: 1;
  min-height: 36px;
  max-height: 100px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
}

.ticket-chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.ticket-chat-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.ticket-chat-input-buttons,
.doc-chat-input-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ticket-chat-input-buttons .voice-button,
.doc-chat-input-buttons .voice-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: transparent;
}

.ticket-chat-input-buttons .voice-button.recording,
.doc-chat-input-buttons .voice-button.recording {
  background: rgba(255, 100, 100, 0.2);
  color: #ff6b6b;
}

.ticket-chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 0;
  font-size: 10px;
}

.ticket-chat-meta-left,
.ticket-chat-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ticket-chat-meta-left {
  flex: 1 1 auto;
  min-width: 0;
}

.ticket-chat-meta-right {
  flex: 0 0 auto;
}

.ticket-chat-hint {
  color: var(--muted);
  font-size: 10px;
}

.ticket-chat-voice-status {
  color: var(--muted);
  font-size: 10px;
}

.ticket-chat-voice-status.recording {
  color: #ff6b6b;
}

.ticket-chat-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
}

.ticket-chat-status.running {
  color: var(--accent);
}

.ticket-chat-status.error {
  color: #ff6b6b;
}

.ticket-chat-cancel-inline {
  width: 24px;
  height: 24px;
  min-width: 24px;
  padding: 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.ticket-chat-cancel-inline.hidden {
  display: none;
}

.ticket-chat-stream {
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.ticket-chat-stream.hidden {
  display: none;
}

.ticket-chat-stream:empty {
  display: none;
}

/* ===== Ticket Chat Events (Agent Activity) ===== */
.ticket-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ticket-chat-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ticket-chat-events.hidden,
.ticket-chat-events:empty {
  display: none;
}

.ticket-chat-events-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
}

.ticket-chat-events-list:empty {
  display: none;
}

/* Pulsing animation for waiting state */
@keyframes ticket-chat-pulse {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

.ticket-chat-events-waiting {
  animation: ticket-chat-pulse 1.5s ease-in-out infinite;
}

.ticket-chat-event {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 6px 8px;
  display: grid;
  gap: 2px;
  font-size: 10px;
}

.ticket-chat-event-title {
  font-weight: 600;
  color: var(--text);
}

.ticket-chat-event-summary {
  color: var(--text);
  opacity: 0.85;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow-y: auto;
}

.ticket-chat-event-detail,
.ticket-chat-event-meta {
  color: var(--muted);
  font-size: 9px;
}

/* Event kind-based styling */
.ticket-chat-event.thinking {
  border-color: rgba(108, 245, 216, 0.3);
  background: rgba(108, 245, 216, 0.08);
}

.ticket-chat-event.thinking .ticket-chat-event-title::before {
  content: "🧠 ";
}

.ticket-chat-event.tool {
  border-color: rgba(139, 148, 245, 0.35);
}

.ticket-chat-event.tool .ticket-chat-event-title::before {
  content: "🔧 ";
}

.ticket-chat-event.command {
  border-color: rgba(255, 166, 77, 0.35);
}

.ticket-chat-event.command .ticket-chat-event-title::before {
  content: "⚡ ";
}

.ticket-chat-event.file {
  border-color: rgba(241, 250, 140, 0.35);
}

.ticket-chat-event.file .ticket-chat-event-title::before {
  content: "📄 ";
}

.ticket-chat-event.output {
  border-color: rgba(80, 250, 123, 0.35);
}

.ticket-chat-event.error {
  border-color: rgba(255, 85, 102, 0.35);
  background: rgba(255, 85, 102, 0.08);
}

.ticket-chat-event.error .ticket-chat-event-title::before {
  content: "❌ ";
}

.ticket-chat-events-empty {
  text-align: center;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-left: 0;
  margin-right: auto;
  max-width: 85%;
}

/* ===== Ticket Chat Messages (History) ===== */
.ticket-chat-messages {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.ticket-chat-message {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.4;
  max-width: 85%;
  position: relative;
}

/* Message role label */
.ticket-chat-message-role {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ticket-chat-message.user .ticket-chat-message-role {
  color: rgba(0, 0, 0, 0.6);
}

.ticket-chat-message.assistant .ticket-chat-message-role {
  color: var(--muted);
}

.ticket-chat-message.user {
  background: var(--accent);
  color: #000;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.ticket-chat-message.assistant {
  background: var(--panel);
  border: 1px solid var(--border);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.ticket-chat-message.assistant.final {
  border-color: rgba(80, 250, 123, 0.4);
  border-left: 3px solid rgba(80, 250, 123, 0.6);
  background: linear-gradient(90deg, rgba(80, 250, 123, 0.06) 0%, var(--panel) 20%);
}

.ticket-chat-message.assistant.final .ticket-chat-message-role {
  color: rgba(80, 250, 123, 0.8);
}

.ticket-chat-message.assistant.thinking {
  opacity: 0.85;
  border-color: rgba(108, 245, 216, 0.3);
  border-left: 3px solid rgba(108, 245, 216, 0.5);
  background: linear-gradient(90deg, rgba(108, 245, 216, 0.06) 0%, var(--panel) 20%);
}

.ticket-chat-message.assistant.thinking .ticket-chat-message-role {
  color: rgba(108, 245, 216, 0.8);
}

.ticket-chat-message.assistant.thinking .ticket-chat-message-content {
  font-style: italic;
}

.ticket-chat-message-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.ticket-chat-message-meta {
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
}

.ticket-chat-message.user .ticket-chat-message-meta {
  color: rgba(0, 0, 0, 0.5);
}

/* ===== Ticket Patch Preview ===== */
.ticket-patch-main {
  margin: 8px 16px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Fill available vertical space when shown */
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ticket-patch-main.hidden {
  display: none;
}

.ticket-patch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.ticket-patch-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ticket-patch-status {
  font-size: 10px;
  color: var(--muted);
}

.ticket-patch-body {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  /* Fill available space instead of fixed max-height */
  flex: 1;
  min-height: 100px;
  overflow-y: auto;
  padding: 12px;
  background: #0f1116;
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.ticket-patch-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.ticket-patch-actions button {
  font-size: 11px;
  padding: 6px 12px;
}

/* ===== Ticket Chat Large Screen (Telegram-style left-aligned messages) ===== */
@media (min-width: 900px) {

  /* Both user and assistant messages align left like Telegram */
  .ticket-chat-message.user {
    margin-left: 0;
    margin-right: auto;
  }
}

/* ===== Ticket Editor Mobile ===== */
@media (max-width: 600px) {
  .ticket-editor-header {
    padding: 4px 8px !important;
  }

  .ticket-editor-toolbar {
    padding: 3px 8px;
    gap: 4px;
  }

  .ticket-editor-toolbar button {
    font-size: 9px;
    padding: 2px 6px;
  }

  .ticket-editor-textarea {
    margin: 6px 8px;
    padding: 8px;
    font-size: 14px;
  }

  .ticket-chat-panel {
    margin: 4px 8px 0;
    padding: 4px;
  }

  .ticket-chat-agent-controls select,
  .ticket-chat-agent-controls .agent-model-input {
    font-size: 10px;
    min-width: 80px;
  }

  .ticket-chat-input {
    font-size: 14px;
  }

  .ticket-chat-meta-left {
    display: none;
  }

  .ticket-patch-main {
    margin: 6px 12px;
    padding: 8px;
  }

  .ticket-patch-body {
    min-height: 80px;
    font-size: 10px;
  }

  /* Template modal mobile styles */
  .ticket-template-modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .ticket-template-header {
    padding: 12px 16px;
  }

  .ticket-template-body {
    padding: 16px;
    gap: 12px;
  }

  .ticket-template-preview {
    max-height: 150px;
    font-size: 0.8rem;
  }
}

/* ===== Hamburger Menu ===== */
.hamburger-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 2002;
  flex-shrink: 0;
}

.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  /* Ensure entire button is clickable */
  position: relative;
  overflow: hidden;
  z-index: 2001;
}

.hamburger-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.hamburger-btn:active,
.hamburger-btn.active {
  color: var(--accent);
  border-color: rgba(108, 245, 216, 0.4);
  background: rgba(108, 245, 216, 0.08);
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 14px;
  pointer-events: none;
}

.hamburger-icon span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
  pointer-events: none;
}

.hamburger-menu {
  position: fixed;
  top: 50px;
  right: 8px;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 4px;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
}

.hamburger-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.hamburger-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.hamburger-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.hamburger-item:active {
  background: rgba(108, 245, 216, 0.12);
}

.hamburger-item.active {
  color: var(--accent);
  background: rgba(108, 245, 216, 0.1);
}

.hamburger-item-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
  opacity: 0.7;
}

.hamburger-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* Mobile hamburger menu - bottom sheet style */
@media (max-width: 640px) {
  .hamburger-wrapper {
    position: relative;
    z-index: 2002;
  }

  .hamburger-btn {
    min-height: 48px;
    min-width: 48px;
    width: auto;
    height: auto;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  .hamburger-btn.active {
    background: rgba(108, 245, 216, 0.12);
    border-top: 2px solid var(--accent);
  }

  .hamburger-menu {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    right: 8px;
    top: auto;
    min-width: auto;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    transform: translateY(16px);
  }

  .hamburger-menu.open {
    transform: translateY(0);
  }

  .hamburger-item {
    padding: 14px 16px;
    font-size: 14px;
    min-height: 48px;
  }

  .hamburger-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
  }

  .hamburger-backdrop.open {
    opacity: 1;
    visibility: visible;
  }
}

/* ===== PMA (Project Management Agent) ===== */

/* PMA Header - compact, clean */
.pma-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.pma-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pma-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.pma-back-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.pma-back-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.pma-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* PMA Chat Section */
.pma-chat-section {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

/* PMA Dispatches */
.pma-dispatches-section {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pma-dispatches-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pma-dispatches-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.pma-dispatches-content {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 1.4fr);
  gap: 12px;
  min-height: 180px;
}

.pma-dispatches-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(8, 10, 16, 0.4);
  padding: 8px;
}

.pma-dispatch-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: rgba(15, 18, 28, 0.7);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pma-dispatch-item:hover {
  border-color: rgba(108, 245, 216, 0.4);
}

.pma-dispatch-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(108, 245, 216, 0.2);
}

.pma-dispatch-item.resolved {
  opacity: 0.6;
}

.pma-dispatch-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pma-dispatch-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.pma-dispatches-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(8, 10, 16, 0.4);
  padding: 12px;
  min-height: 180px;
}

.pma-dispatch-detail-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.pma-dispatch-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.pma-dispatch-detail-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 12px;
}

.pma-dispatch-detail-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.pma-dispatch-detail-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.pma-dispatch-detail-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 900px) {
  .pma-dispatches-content {
    grid-template-columns: 1fr;
  }
  .pma-dispatches-list {
    max-height: 220px;
  }
}

.pma-chat-main {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Compose area */
.pma-chat-compose {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.pma-chat-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.pma-chat-agent-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pma-chat-agent-controls select,
.pma-chat-agent-controls .agent-model-input {
  height: 26px;
  padding: 0 6px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  min-width: 0;
  max-width: 110px;
}

.pma-chat-agent-controls select:hover,
.pma-chat-agent-controls .agent-model-input:hover {
  border-color: rgba(108, 245, 216, 0.4);
}

.pma-chat-agent-controls select:focus,
.pma-chat-agent-controls .agent-model-input:focus {
  outline: none;
  border-color: var(--accent);
}

.pma-chat-agent-controls select:disabled,
.pma-chat-agent-controls .agent-model-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pma-chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pma-new-thread-btn {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: lowercase;
}

.pma-new-thread-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

.pma-status-pill {
  padding: 2px 8px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.pma-status-pill.running,
.pma-status-pill[data-status="running"] {
  color: var(--accent);
  border-color: var(--accent);
  animation: pulse-running 1.5s ease-in-out infinite;
}

/* Input row */
.pma-chat-input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.pma-chat-input {
  flex: 1 1 0;
  min-height: 38px;
  max-height: 150px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}

.pma-chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.pma-chat-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.pma-send-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #000;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.pma-send-btn:hover {
  opacity: 0.85;
}

.pma-send-btn:active {
  opacity: 0.7;
}

/* Subtle hint */
.pma-chat-hint {
  padding-top: 2px;
}

.pma-chat-hint .muted.small {
  font-size: 10px;
  opacity: 0.6;
}

/* Chat stream container */
.pma-chat-stream {
  margin-top: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1 1 0;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.pma-chat-stream::-webkit-scrollbar {
  width: 5px;
}

.pma-chat-stream::-webkit-scrollbar-track {
  background: transparent;
}

.pma-chat-stream::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.pma-chat-stream::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Error display */
.pma-chat-error {
  padding: 8px 10px;
  background: rgba(255, 85, 102, 0.1);
  border: 1px solid rgba(255, 85, 102, 0.3);
  border-radius: var(--radius);
  color: #ff8899;
  font-size: 12px;
  margin-bottom: 8px;
}

.pma-chat-error.hidden {
  display: none;
}

/* Inline Thinking */
.chat-thinking-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.chat-thinking-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: chat-spin 1s linear infinite;
  opacity: 0.7;
}

.chat-thinking-steps {
  font-size: 11px;
  opacity: 0.8;
}

.chat-thinking-details-btn {
  margin-left: auto;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  font-size: 11px;
  color: var(--muted);
}

.chat-thinking-details-btn:hover {
  color: var(--text);
}

.chat-thinking-steps-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.chat-thinking-steps-list li {
  margin: 4px 0;
}

.chat-thinking-step-title {
  color: var(--text);
  opacity: 0.9;
  font-style: normal;
}

.chat-thinking-step-summary {
  opacity: 0.75;
  font-style: normal;
}

@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Events section */
.pma-chat-events {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(108, 245, 216, 0.15);
}

.pma-chat-events.hidden {
  display: none !important;
}

.pma-events-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.pma-events-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.pma-events-count {
  font-size: 9px;
  color: var(--muted);
  background: rgba(108, 245, 216, 0.1);
  padding: 1px 5px;
  border-radius: 8px;
}

.pma-chat-events-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pma-chat-events-list:empty {
  display: none;
}

/* History section header - subtle */
.pma-history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
}

.pma-history-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  opacity: 0.7;
}

/* PMA chat events - compact styling */
.chat-event {
  padding: 5px 8px;
  background: rgba(108, 245, 216, 0.04);
  border-left: 2px solid rgba(108, 245, 216, 0.4);
  border-radius: 0 2px 2px 0;
  font-size: 11px;
}

.chat-event-title {
  font-weight: 600;
  color: var(--accent);
  font-size: 10px;
}

.chat-event-summary {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.9;
}

.chat-event-detail {
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-event-meta {
  color: var(--muted);
  font-size: 9px;
  margin-top: 2px;
  opacity: 0.7;
}

/* PMA chat messages - cleaner bubbles */
.pma-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}

.pma-chat-messages:empty::before {
  content: "Start a conversation...";
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 16px;
  opacity: 0.6;
}

/* Override global chat-message rules for PMA - use high specificity */
.pma-chat-stream .pma-chat-messages .chat-message,
.pma-chat-stream .pma-chat-messages .chat-message:not(:last-child),
.pma-chat-stream .pma-chat-messages .chat-message:last-child {
  padding: 10px 12px;
  border-radius: 6px;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.5;
  overflow: visible;
  margin-bottom: 0;
}

/* PMA chat message variants */
.pma-chat-messages .chat-message-user {
  background: var(--accent);
  color: #000;
  align-self: flex-end;
  border: none;
  border-radius: 6px 6px 2px 6px;
}

.pma-chat-messages .chat-message-user .chat-message-role {
  color: rgba(0, 0, 0, 0.5);
}

.pma-chat-messages .chat-message-user .chat-message-content {
  color: #000;
}

.pma-chat-messages .chat-message-user .chat-message-meta {
  color: rgba(0, 0, 0, 0.4);
}

.pma-chat-messages .chat-message-assistant {
  background: var(--bg);
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: 6px 6px 6px 2px;
}

.pma-chat-messages .chat-message-assistant-thinking {
  border: 1px solid rgba(108, 245, 216, 0.2);
  background: rgba(108, 245, 216, 0.03);
}

.pma-chat-messages .chat-message-assistant-thinking .chat-message-content {
  font-style: italic;
  opacity: 0.85;
}

.pma-chat-messages .chat-message-assistant-final {
  border: 1px solid rgba(80, 250, 123, 0.3);
}

/* Override global .chat-message:not(:last-child) separator - must come last and be specific */
.pma-chat-stream .pma-chat-messages .chat-message.chat-message-assistant:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.pma-chat-stream .pma-chat-messages .chat-message.chat-message-assistant-thinking:not(:last-child) {
  border-bottom: 1px solid rgba(108, 245, 216, 0.2);
}

.pma-chat-stream .pma-chat-messages .chat-message.chat-message-assistant-final:not(:last-child) {
  border-bottom: 1px solid rgba(80, 250, 123, 0.3);
}

.pma-chat-messages .chat-message-role {
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  opacity: 0.8;
}

.pma-chat-messages .chat-message-content {
  color: var(--text);
  word-break: break-word;
  line-height: 1.5;
}

/* Reset white-space for markdown content */
.pma-chat-messages .chat-message-content.messages-markdown {
  white-space: normal;
}

.pma-chat-messages .chat-message-content:not(.messages-markdown) {
  white-space: pre-wrap;
}

.pma-chat-messages .chat-message-meta {
  font-size: 9px;
  color: var(--muted);
  margin-top: 6px;
  opacity: 0.6;
}

/* Markdown styling for PMA chat */
.pma-chat-messages .messages-markdown p {
  margin: 0 0 8px;
}

.pma-chat-messages .messages-markdown p:last-child {
  margin-bottom: 0;
}

.pma-chat-messages .messages-markdown strong {
  font-weight: 600;
  color: var(--accent);
}

.pma-chat-messages .messages-markdown em {
  font-style: italic;
}

.pma-chat-messages .messages-markdown ul,
.pma-chat-messages .messages-markdown ol {
  margin: 6px 0;
  padding-left: 18px;
}

.pma-chat-messages .messages-markdown li {
  margin: 3px 0;
}

.pma-chat-messages .messages-markdown code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.pma-chat-messages .messages-markdown pre.md-code {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 8px 0;
}

.pma-chat-messages .messages-markdown pre.md-code code {
  background: none;
  padding: 0;
  font-size: 11px;
}

.pma-chat-messages .messages-markdown a {
  color: var(--accent);
  text-decoration: none;
}

.pma-chat-messages .messages-markdown a:hover {
  text-decoration: underline;
}

/* Make PMA file links look like downloadable "pills" */
.pma-chat-messages .messages-markdown a.pma-file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 11px;
  line-height: 18px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pma-chat-messages .messages-markdown a.pma-file-link::before {
  content: "↓";
  font-size: 11px;
  color: var(--muted);
}

.pma-chat-messages .messages-markdown a.pma-file-link:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

.pma-chat-messages .messages-markdown a.pma-file-link:hover::before {
  color: var(--accent);
}

/* Higher-contrast file pills inside user bubbles */
.pma-chat-messages .chat-message-user .messages-markdown a.pma-file-link {
  /* Frosted look on teal bubble, keep text readable */
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(0, 0, 0, 0.18);
  color: rgba(0, 0, 0, 0.92);
  font-weight: 650;
}

.pma-chat-messages .chat-message-user .messages-markdown a.pma-file-link::before {
  color: rgba(0, 0, 0, 0.55);
}

.pma-chat-messages .chat-message-user .messages-markdown a.pma-file-link:hover {
  background: rgba(255, 255, 255, 0.36);
  border-color: rgba(0, 0, 0, 0.26);
  color: rgba(0, 0, 0, 0.95);
}

.pma-chat-messages .chat-message-user .messages-markdown a.pma-file-link:hover::before {
  color: rgba(0, 0, 0, 0.75);
}

/* User messages don't need accent color for bold */
.pma-chat-messages .chat-message-user .messages-markdown strong {
  color: inherit;
  font-weight: 700;
}

/* PMA Inbox section */
.pma-inbox-section {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pma-inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pma-inbox-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.pma-inbox-refresh-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pma-inbox-refresh-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.pma-inbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.pma-inbox-list::-webkit-scrollbar {
  width: 4px;
}

.pma-inbox-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.pma-inbox-list>.muted {
  font-size: 11px;
  padding: 8px;
  text-align: center;
  opacity: 0.7;
}

.pma-inbox-item {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  padding: 2px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 10px;
  white-space: nowrap;
  max-width: 180px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pma-inbox-item > * {
  display: inline-flex;
  align-items: center;
}

.pma-inbox-item:hover {
  border-color: var(--accent);
}

.pma-inbox-repo {
  font-weight: 600;
  margin-right: 3px;
  color: var(--accent);
}

.pma-inbox-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pma-inbox-excerpt,
.pma-inbox-item-header,
.pma-inbox-item-header .pill,
.pma-inbox-actions {
  display: none;
}

.pma-upload-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.pma-upload-btn:hover {
  color: var(--text);
  border-color: var(--text);
  background: var(--bg-subtle);
}

/* PMA responsive adjustments */
@media (max-width: 640px) {
  .pma-header {
    padding: 8px 10px;
    gap: 10px;
  }

  .pma-back-btn {
    padding: 3px 8px;
    font-size: 11px;
  }

  .pma-title {
    font-size: 13px;
  }

  .pma-chat-section {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
  }

  .pma-chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .pma-chat-stream {
    flex: 1;
    min-height: 0;
    padding: 10px;
    margin-top: 0;
    border: none;
    border-radius: 0;
  }

  .pma-chat-compose {
    padding: 8px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
  }

  .pma-chat-controls-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
  }

  .pma-chat-agent-controls {
    gap: 4px;
  }

  .pma-chat-agent-controls select,
  .pma-chat-agent-controls .agent-model-input {
    max-width: 80px;
    font-size: 10px;
    padding: 2px 4px;
    height: 24px;
  }

  .pma-chat-actions {
    gap: 4px;
  }

  .pma-new-thread-btn {
    font-size: 10px;
    padding: 2px 6px;
    height: 24px;
  }

  .pma-status-pill {
    font-size: 9px;
    padding: 1px 4px;
  }

  .pma-chat-input-row {
    gap: 6px;
  }

  .pma-chat-input {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 14px;
    /* Prevent zoom on iOS */
  }

  .pma-send-btn,
  .pma-upload-btn {
    width: 36px;
    height: 36px;
  }

  .pma-chat-hint {
    display: none;
  }

  .pma-inbox-section {
    padding: 6px 10px;
  }

  .pma-inbox-list {
    max-height: none;
  }

  .pma-inbox-item {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    padding: 2px 6px;
    font-size: 10px;
  }

  .pma-inbox-item > * {
    display: inline-flex;
    align-items: center;
  }

  .pma-inbox-excerpt,
  .pma-inbox-item-header,
  .pma-inbox-item-header .pill,
  .pma-inbox-actions {
    display: none;
  }

  .pma-thread-info {
    flex-direction: row;
    padding: 4px 8px;
    gap: 4px;
  }

  .pma-thread-info-details {
    flex-direction: row;
    gap: 4px;
  }

  .pma-thread-info-row {
    flex-direction: row;
    gap: 2px;
  }

  .chat-message {
    max-width: 95%;
    font-size: 13px;
  }
}

/* PMA Attachments Area */
.pma-attachments-area {
  padding: 8px 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pma-inbox-section,
.pma-outbox-section {
  padding: 0;
  border: none;
  background: transparent;
}

.pma-inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.pma-inbox-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.pma-inbox-refresh-btn {
  width: 16px;
  height: 16px;
  padding: 0;
  font-size: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.7;
}

.pma-inbox-refresh-btn:hover {
  opacity: 1;
  color: var(--text);
}

.pma-inbox-list {
  max-height: 80px;
  overflow-y: auto;
  margin-bottom: 4px;
}

/* PMA Top Bar */
.pma-top-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pma-dispatches-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.pma-paused-runs-bar {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel);
  max-height: none;
}

.pma-thread-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.pma-thread-info-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pma-thread-info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.pma-thread-info-details {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.pma-thread-info-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pma-thread-info-key {
  font-size: 10px;
  min-width: auto;
}

.pma-thread-info-value {
  font-size: 10px;
  font-family: monospace;
  color: var(--text);
  cursor: pointer;
  transition: color 0.15s ease;
}

.pma-thread-info-value:hover {
  color: var(--accent);
}

.pma-repo-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.pma-view-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.pma-view-tab {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.pma-view-tab:hover {
  color: var(--text);
  background: var(--hover-bg);
}

.pma-view-tab.active {
  color: var(--text);
  background: var(--primary-bg);
  border-color: var(--border);
}

.pma-inbox-list {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  align-items: center;
  margin: 0;
  max-height: none;
}

.pma-dispatches-section .pma-paused-runs-bar {
  flex-direction: column;
  align-items: stretch;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pma-dispatches-section .pma-inbox-list {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.pma-dispatches-section .pma-inbox-item {
  max-width: none;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.pma-dispatches-section .pma-inbox-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.pma-dispatches-section .pma-inbox-title {
  display: block;
}

.pma-dispatches-section .pma-inbox-excerpt {
  display: block;
}

.pma-dispatches-section .pma-inbox-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pma-dispatches-section .pma-inbox-item-header .pill {
  display: inline-flex;
}

.pma-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
}

.pma-view-btn {
  height: 22px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.pma-view-btn:hover {
  color: var(--text);
}

.pma-view-btn.active,
.pma-view-btn[aria-selected="true"] {
  background: rgba(108, 245, 216, 0.16);
  color: var(--accent);
}

.hub-shell[data-pma-view="chat"] #pma-docs-section {
  display: none !important;
}

.hub-shell[data-pma-view="memory"] #pma-chat-section {
  display: none !important;
}

.notification-bell {
  position: relative;
  overflow: visible;
}

.notification-bell-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}

.notification-bell:hover .notification-bell-icon {
  stroke: var(--accent);
}

.notification-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #031311;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg);
}

.notification-dialog {
  max-width: 640px;
}

.notification-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.notification-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notification-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notification-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-repo {
  font-weight: 600;
  color: var(--accent);
}

.notification-title {
  font-weight: 600;
  font-size: 13px;
}

.notification-excerpt {
  font-size: 12px;
  color: var(--muted);
}

.notification-next {
  font-size: 11px;
  color: var(--muted);
}

.notification-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.notification-actions .notification-action {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
}

.notification-actions .notification-action:hover {
  color: var(--text);
  border-color: rgba(108, 245, 216, 0.4);
}

.pma-clear-btn {
  margin-left: 2px;
}

.pma-inbox-item {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  max-width: 200px;
}

.pma-inbox-item > * {
  display: inline-flex;
  align-items: center;
}

.pma-inbox-item:hover {
  border-color: var(--accent);
}

.pma-inbox-repo {
  font-weight: 600;
  margin-right: 4px;
  color: var(--accent);
}

.pma-inbox-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pma-inbox-excerpt,
.pma-inbox-item-header .pill,
.pma-inbox-item-header,
.pma-inbox-actions {
  display: none;
}

/* Inline Thinking Indicator */
.chat-thinking-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 0;
  font-style: italic;
}

.chat-thinking-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  opacity: 0.7;
}

.chat-thinking-steps {
  font-size: 11px;
  opacity: 0.8;
  font-weight: 500;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.pma-chat-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pma-inbox-list .muted {
  font-size: 11px;
  padding: 4px 0;
}

.pma-docs-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--panel-bg);
}

.pma-docs-section.hidden {
  display: none;
}

.pma-docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.pma-docs-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.pma-docs-tabs {
  display: flex;
  gap: 4px;
}

.pma-docs-tab {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.pma-docs-tab:hover {
  color: var(--text);
  background: var(--hover-bg);
}

.pma-docs-tab.active {
  color: var(--text);
  background: var(--primary-bg);
  font-weight: 600;
}

.pma-docs-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pma-docs-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--card-bg);
  border-radius: 6px;
  font-size: 11px;
}

.pma-docs-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pma-docs-editor-wrapper {
  flex: 1;
  min-height: 0;
  background: var(--card-bg);
  border-radius: 6px;
  overflow: hidden;
}

.pma-docs-editor {
  width: 100%;
  height: 100%;
  min-height: 300px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: none;
  resize: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", Monaco, Consolas, monospace;
}

.pma-docs-editor:focus {
  outline: none;
}

.pma-docs-editor:disabled,
.pma-docs-editor[readonly] {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.8;
}

.pma-docs-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.pma-docs-history {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.pma-docs-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pill-caution {
  background: #f59e0b;
  color: #fff;
}

.pill-caution.pill-small {
  font-size: 9px;
  padding: 2px 6px;
}
