/* ==========================================================================
   Relay — Command Center Copilot Midnight Palette + Antigravity UI Craft (UIC-001..009)
   Palette: Deep Midnight Ink (#050B16), Top Sapphire Radial Glow,
   Stepped Sapphire Gradients (#0C1930 -> #091325), Cobalt Pill Accents
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Standalone Copilot Midnight Surfaces (immune to preload.js host theme-change bleed) */
  --canvas: #050B16;
  --header-bg: #071020;
  --surface-1: #0A1529;
  --surface-2: #0E1D38;
  --surface-3: #14284B;
  --surface-card-grad: linear-gradient(180deg in oklab, #0C1930 0%, #091325 100%);
  --surface-elev-grad: linear-gradient(180deg in oklab, #10213F 0%, #0B172D 100%);
  --surface-capsule: #0B172C;
  --surface-pill: rgb(15 31 58 / 0.78);
  --surface-pill-hover: rgb(25 50 92 / 0.86);
  --surface-input: #081224;
  --surface-track: #112240;

  /* Copilot Typography Hierarchy */
  --fg: #F4F8FF;
  --fg-project: #DCEAFF;
  --fg-secondary: #9BB4D6;
  --fg-section: #6E95C5;
  --fg-sun: #82C2FF;
  --fg-muted: #7994BA;
  --fg-subtle: #5D789E;

  /* Sky-Sapphire Tinted Hairlines & Specular Top Rim (UIC-002 + UIC-007) */
  --border-subtle: rgb(116 170 255 / 0.09);
  --border-card: rgb(116 170 255 / 0.14);
  --border-control: oklch(0.68 0.095 252 / 0.62);
  --border-focus: rgb(130 194 255 / 0.78);
  --focus-ring: rgb(77 163 255 / 0.34);
  --rim-top: inset 0 1px 0 rgb(168 208 255 / 0.08);
  --rim-pill: inset 0 1px 0 rgb(173 212 255 / 0.12);

  /* Static Perceptual Copilot Semantic Palette (UIC-003) */
  --cobalt: oklch(0.55 0.215 262);
  --cobalt-deep: oklch(0.49 0.215 263);
  --cobalt-grad: linear-gradient(180deg in oklch, oklch(0.56 0.215 262) 0%, oklch(0.49 0.215 263) 100%);
  --cobalt-bright: oklch(0.62 0.205 260);
  --cobalt-soft: rgb(33 73 138 / 0.52);
  --accent-sky: #82C2FF;
  --sky: oklch(0.76 0.148 235);
  --sky-soft: oklch(0.76 0.148 235 / 0.15);
  --emerald: oklch(0.73 0.19 150);
  --emerald-ok: oklch(0.73 0.19 150);
  --emerald-soft: oklch(0.73 0.19 150 / 0.15);
  --amber: oklch(0.83 0.165 84);
  --amber-soft: oklch(0.83 0.165 84 / 0.15);
  --coral: oklch(0.64 0.22 26);
  --coral-soft: oklch(0.64 0.22 26 / 0.16);
  --slate-flag: oklch(0.65 0.045 254);

  /* Concentric Radii & Single Left Edge (UIC-001) */
  --gutter: 16px;
  --max-w: 760px;
  --r-sheet: 22px;
  --r-card: 18px;
  --r-inner: 11px;
  --r-chip: 8px;
  --r-pill: 999px;

  /* Floating Overlay Shadows Only — Neutral Dark Elevation (UIC-007) */
  --shadow-float: 0 22px 54px rgb(0 0 0 / 0.72), 0 4px 14px rgb(2 6 16 / 0.50);
  --shadow-fab: 0 14px 34px rgb(0 0 0 / 0.68), 0 4px 12px rgb(2 6 16 / 0.54), inset 0 1px 0 rgb(173 212 255 / 0.22);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 390px) {
  :root {
    --gutter: 14px;
  }
}

@media (prefers-contrast: more) {
  :root {
    --border-card: rgb(140 190 255 / 0.58);
    --border-control: rgb(160 205 255 / 0.85);
  }
}

/* Base Reset, Sleek Midnight Scrollbars & Typography */
*,
*::before,
*::after {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgb(104 130 166 / 0.26) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgb(104 130 166 / 0.26);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgb(130 194 255 / 0.42);
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  overflow-x: clip;
  background-color: var(--canvas) !important;
  color: var(--fg);
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100%;
  overflow-x: clip;
  background-color: #050B16 !important;
  color: var(--fg) !important;
  font-family: var(--font-sans) !important;
  font-size: 14px;
  line-height: 1.44;
}

/* Unified viewport-fixed ambient sapphire glow shared 1:1 with .chrome:
   Centered at y=230px with ry=210px so y=0..20px is 100% pure #050B16 — matching iOS's #050B16 native status-bar band with 0 RGB seam! */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #050B16;
  background-image: radial-gradient(95% 210px at 50% 230px in oklab, rgb(37 99 235 / 0.12), transparent 100%);
  background-position: top center;
  background-size: 100% 640px;
  background-repeat: no-repeat;
}

/* UIC-009: Prose orphan protection (never applied to single-line rows) */
p {
  margin: 0;
  text-wrap: pretty;
}

li {
  text-wrap: pretty;
}

h1, h2, h3, h4 {
  margin: 0;
  text-wrap: balance;
}

/* UIC-012: Themed Browser Selection, Caret & Tabular Numerals */
::selection {
  background: oklch(0.62 0.205 260 / 0.36);
  color: #FFFFFF;
}

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

input,
textarea,
[contenteditable="true"] {
  caret-color: var(--accent-sky);
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

a,
[role="button"],
summary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
.tab-btn,
.pill-btn,
.out-chip,
.sheet-grabber {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 1.5px solid var(--border-focus);
  outline-offset: 2px;
}

input:focus,
input:focus-visible,
textarea:focus,
textarea:focus-visible {
  outline: none;
}

.tab-badge,
.section-count,
.deck-kicker,
.deck-nav,
.agent-time,
.agent-att-badge,
.space-count-sub,
.project-progress,
.clock-sched,
.clock-meta-row,
.cal-day,
.cal-preset-date,
.wheel-item,
.out-chip,
.builder-att-file-meta,
.health-tile strong {
  font-variant-numeric: tabular-nums;
}

/* Optical Alignment & Cap-Height Trimming (UIC-020 / precise-text-alignment)
   Never apply text-box: trim-both cap alphabetic or line-height: 1 directly to
   elements carrying overflow: hidden / text-overflow: ellipsis, or descenders
   (g, j, p, q, y) below the alphabetic baseline will clip. */
.pill-btn,
.date-seg-btn,
.owner-pill,
.out-chip,
.tab-btn,
.agent-space-pill,
.state-pill,
.tab-badge,
.section-label,
.fold-trigger,
.handoff-eyebrow {
  line-height: 1;
}

.pill-btn > span:not([style*="overflow"]),
.date-seg-btn > span:not([style*="overflow"]),
.owner-pill > span:not([style*="overflow"]),
.out-chip > span:not([style*="overflow"]),
.tab-btn > span:not([style*="overflow"]),
.handoff-eyebrow > span:not([style*="overflow"]),
.fold-trigger > span:not([style*="overflow"]),
.agent-space-pill:not([style*="overflow"]),
.state-pill:not([style*="overflow"]),
.tab-badge:not([style*="overflow"]),
.section-label:not([style*="overflow"]) {
  text-box: trim-both cap alphabetic;
}

/* Crisp 20px Line Icons (UIC-005 Stroke Pairing) */
.ico {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.ico-sm {
  width: 16px;
  height: 16px;
  stroke-width: 2.0;
}

.ico-xs {
  width: 14px;
  height: 14px;
  stroke-width: 2.15;
}

.ico-fab {
  width: 22px;
  height: 22px;
  stroke-width: 2.25;
}

/* Rotating Single SVG Chevron */
.chev {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.0;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.is-collapsed .chev,
.chev.is-collapsed {
  transform: rotate(-90deg);
}

/* UIC-006: Micro-State Icon Swap Physics & Reduced-Motion Guard */
.icon-swap-enter {
  opacity: 1;
  transition: opacity 160ms ease-out;
}

.icon-swap-exit {
  opacity: 0;
  transition: opacity 160ms ease-out;
}

@media (prefers-reduced-motion: no-preference) {
  .icon-swap-exit {
    scale: 0.82;
    filter: blur(4px);
    transition: opacity 160ms ease-out, scale 160ms ease-out, filter 160ms ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ptr-indicator.is-refreshing .ptr-ico,
  #btn-reload.is-refreshing .ico,
  .spin-ico {
    animation: none;
  }
  .chev,
  .tgl-thumb {
    transition: none;
  }
  .icon-btn,
  .pill-btn,
  .fab-btn,
  .conv-ico-btn,
  .status-circle,
  .row-col-btn,
  .pulse-seg,
  .builder-send-btn {
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), opacity 140ms var(--ease-out);
  }
}

/* ==========================================================================
   App Shell & Sticky Opaque Top Chrome (UIC-025)
   ========================================================================== */

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  padding-top: 8px;
  padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
  background: transparent;
}

/* Sticky Opaque Top Chrome (UIC-025):
   In-flow position: sticky; top: 0 with solid #050B16 backing, zero mask-image,
   adaptive safe-area cushion, and crisp 1px bottom hairline. */
.chrome {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 40;
  pointer-events: none;
  padding-top: calc(14px + env(safe-area-inset-top, 0px) + min(24px, env(safe-area-inset-top, 0px)));
  padding-bottom: 10px;
  background-color: #050B16;
  background-image: radial-gradient(95% 210px at 50% 230px in oklab, rgb(37 99 235 / 0.12), transparent 100%);
  background-position: top center;
  background-size: 100% 640px;
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--border-subtle);
  transition: border-bottom-color 140ms var(--ease-out);
}

.chrome.is-scrolled {
  border-bottom-color: var(--border-card);
}

.chrome-inner {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar,
.tabbar,
.search-row {
  pointer-events: auto;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 40px;
  padding-top: 0;
}

#btn-settings {
  justify-self: start;
}

.brand-center {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.topbar-right {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  #btn-reload.is-refreshing .ico {
    animation: spin360 0.85s linear infinite;
  }
}

.brand-logo {
  width: 25px;
  height: 25px;
  flex-shrink: 0;
  display: block;
}

.brand-title {
  font-size: 22px;
  font-weight: 740;
  letter-spacing: -0.025em;
  color: #FFFFFF;
  user-select: none;
}

@media (max-width: 480px) {
  .brand-logo {
    width: 23px;
    height: 23px;
  }
  .brand-title {
    font-size: 20px;
  }
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--fg-secondary);
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 110ms ease;
}

.icon-btn-compact {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

@media (max-width: 720px), (pointer: coarse) {
  .icon-btn {
    min-width: 36px;
    min-height: 36px;
  }
  .icon-btn::after {
    content: "";
    position: absolute;
    inset: -5px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover {
    background: rgb(120 175 255 / 0.08);
    color: var(--fg);
  }
}

.icon-btn:active {
  transform: scale(0.94);
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(116 170 255 / 0.15);
  background: rgb(13 27 51 / 0.68);
  color: #8BA7CC;
}

@media (hover: hover) and (pointer: fine) {
  .topbar-btn:hover {
    background: rgb(25 50 92 / 0.82);
    border-color: rgb(118 175 255 / 0.30);
    color: #E2EFFF;
  }
}

.topbar-btn.is-active {
  border-radius: 11px;
  background: rgb(20 44 82 / 0.86);
  border-color: rgb(96 165 250 / 0.52);
  color: #EFF6FF;
}

@media (max-width: 720px), (pointer: coarse) {
  .topbar-btn {
    width: 38px;
    height: 38px;
  }
  .topbar-btn::after {
    content: "";
    position: absolute;
    inset: -4px;
  }
}

.status-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--cobalt-bright);
  box-shadow: 0 0 0 2px var(--canvas);
}

.status-dot.tone-red {
  background: var(--coral);
}

.status-dot.tone-amber {
  background: var(--amber);
}

.status-dot.tone-working {
  background: var(--sky);
}

@keyframes skyBreathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.36; }
}

@media (prefers-reduced-motion: no-preference) {
  .status-dot.is-pulsing {
    animation: skyBreathe 2s ease-in-out infinite;
  }
}

/* ==========================================================================
   Sliding-Lens 4-Tab Bar
   ========================================================================== */

.tabbar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  padding: 3px;
  border-radius: var(--r-pill);
  background: rgb(8 18 36 / 0.82);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 1px 2px rgb(2 6 15 / 0.45);
  user-select: none;
}

.tab-lens {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 4);
  border-radius: var(--r-pill);
  background: linear-gradient(180deg in oklab, rgb(36 80 152 / 0.58) 0%, rgb(25 58 115 / 0.50) 100%);
  border: 1px solid rgb(99 166 255 / 0.32);
  box-shadow: 0 4px 14px rgb(4 12 28 / 0.42), inset 0 1px 0 rgb(145 198 255 / 0.15);
  pointer-events: none;
  will-change: transform;
}

.tab-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding-inline: 6px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-muted);
  transition: color 150ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .tab-btn {
    height: 38px;
    font-size: 14px;
  }
  .tab-btn::after {
    content: "";
    position: absolute;
    inset: -4px 0;
  }
}

@media (hover: hover) and (pointer: fine) {
  .tab-btn:hover {
    color: #A8C4E8;
  }
}

.tab-btn.is-active {
  color: var(--accent-sky);
  font-weight: 640;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding-inline: 5px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 650;
  background: rgb(56 189 248 / 0.18);
  color: #A5DBFF;
  border: 1px solid rgb(125 200 255 / 0.34);
}

/* ==========================================================================
   Integrated Search + Filter Funnel
   ========================================================================== */

.search-row {
  position: relative;
  width: 100%;
}

.search-suggest-tray {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface-2);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: var(--shadow-float), var(--rim-top);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.search-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding-inline: 12px 6px;
  border-radius: 12px;
  background: var(--surface-capsule);
  border: 1px solid var(--border-control);
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.search-shell:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgb(77 163 255 / 0.20);
  background: #0C1A33;
}

@media (max-width: 720px), (pointer: coarse) {
  .search-shell {
    height: 46px;
    padding-inline: 12px 4px;
  }
}

.search-ico {
  width: 16px;
  height: 16px;
  stroke-width: 2.0;
  color: var(--fg-muted);
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 14px;
  color: var(--fg);
}

.search-input::placeholder {
  color: var(--fg-muted);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

@media (max-width: 720px) {
  .search-input,
  .field-input,
  .field-textarea,
  .quick-input,
  .inline-edit-input,
  .step-title-input,
  #builder-file-input {
    font-size: 16px !important;
  }
}

.search-clear-btn,
.search-filter-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  flex-shrink: 0;
}

@media (max-width: 720px), (pointer: coarse) {
  .search-clear-btn,
  .search-filter-btn {
    width: 40px;
    height: 40px;
  }
}

.filter-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--cobalt-bright);
  box-shadow: 0 0 0 2px var(--surface-input);
}

/* ==========================================================================
   Touch Pull-to-Refresh Indicator & Horizontal Swipe Pager
   ========================================================================== */

.ptr-indicator {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  z-index: 65;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding-inline: 13px;
  border-radius: var(--r-pill);
  background: var(--surface-elev-grad);
  border: 1px solid rgb(118 175 255 / 0.34);
  box-shadow: var(--shadow-float), var(--rim-pill);
  color: var(--accent-sky);
  font-size: 12.5px;
  font-weight: 620;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-50%, -56px, 0) scale(0.92);
}

.ptr-indicator:not(.is-active):not(.is-refreshing) {
  display: none;
}

.ptr-ico {
  transition: transform 90ms linear;
}

.ptr-indicator.is-refreshing .ptr-ico {
  animation: spin360 0.78s linear infinite;
}

.pager-viewport {
  flex: 1;
  width: 100%;
  overflow-x: clip;
  position: relative;
}

.pager-track {
  width: 100%;
  will-change: transform;
}

.pager-track.is-swiping {
  display: flex;
  align-items: flex-start;
  width: 400%;
}

.pager-track.is-swiping > .tab-panel {
  display: block !important;
  width: 25%;
  flex: 0 0 25%;
}

.tab-panel {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-top: 1px;
  padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
}

/* Freshness Line (left-aligned along search spine, hugging 5px under Search Focus with 13px separation above content) */
.freshness-row {
  display: flex;
  justify-content: flex-start;
  padding-left: 2px;
  margin-bottom: 0;
}

.freshness-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  padding-block: 0;
  margin-bottom: 0;
  font-size: 11.5px;
  line-height: 1.2;
  color: var(--fg-muted);
  border-radius: 6px;
  transition: color 140ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .freshness-bar {
    min-width: 44px;
    min-height: 18px;
  }
  .freshness-bar::after {
    content: "";
    position: absolute;
    inset: -4px -8px -22px -8px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .freshness-bar:hover {
    color: var(--fg-section);
  }
}

.fresh-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--emerald-ok);
  flex-shrink: 0;
}

.fresh-dot.is-amber {
  background: var(--amber);
}

.fresh-dot.is-red {
  background: var(--coral);
}

@keyframes spin360 {
  to { transform: rotate(360deg); }
}

.spin-ico {
  width: 13px;
  height: 13px;
  animation: spin360 0.85s linear infinite;
}

/* ==========================================================================
   Section Headers, Fold Summaries & Flat Hierarchy (One Exact Left Edge)
   ========================================================================== */

.section-block {
  margin-top: 18px;
}

.section-block:first-child {
  margin-top: 8px;
}

.freshness-row + .section-block {
  margin-top: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
  margin-bottom: 6px;
}

.section-title-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--fg-section);
}

.section-count {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-muted);
}

/* Elevated Surface Cards (ONLY decks, Agents & threads, Clock, Health) */
.elev-card {
  background: var(--surface-card-grad);
  border: 1px solid var(--border-card);
  border-radius: var(--r-card);
  box-shadow: var(--rim-top);
  padding: 12px 14px;
}

/* ==========================================================================
   Toolbar Pills, Outlink Chips & iOS Switches (.tgl)
   ========================================================================== */

.pill-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding-inline: 12px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-pill);
  color: #B4CBE9;
  border: 1px solid rgb(116 170 255 / 0.16);
  box-shadow: var(--rim-pill);
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 110ms var(--ease-out);
}

.pill-btn:has(> svg:first-child:not(:only-child)) {
  padding-inline: 10px 13px;
}

.pill-btn:has(> svg:last-child:not(:first-child)) {
  padding-inline: 13px 10px;
}

@media (hover: hover) and (pointer: fine) {
  .pill-btn:hover {
    background: var(--surface-pill-hover);
    border-color: rgb(118 175 255 / 0.30);
    color: var(--fg);
  }
}

.pill-btn:active {
  transform: scale(0.96);
}

@media (max-width: 720px), (pointer: coarse) {
  .pill-btn {
    min-width: 44px;
    height: 34px;
    padding-inline: 13px;
  }
  .pill-btn:has(> svg:first-child:not(:only-child)) {
    padding-inline: 11px 14px;
  }
  .pill-btn:has(> svg:last-child:not(:first-child)) {
    padding-inline: 14px 11px;
  }
  .pill-btn::after {
    content: "";
    position: absolute;
    inset: -5px -2px;
  }
}

.pill-btn.is-primary {
  background: var(--cobalt-grad);
  border-color: rgb(135 195 255 / 0.38);
  color: #FFFFFF;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.22);
}

@media (hover: hover) and (pointer: fine) {
  .pill-btn.is-primary:hover {
    background: linear-gradient(180deg in oklch, oklch(0.60 0.21 261) 0%, oklch(0.53 0.215 262) 100%);
    border-color: rgb(155 208 255 / 0.50);
  }
}

.pill-btn.is-active {
  background: var(--cobalt-soft);
  border-color: rgb(99 166 255 / 0.34);
  color: var(--accent-sky);
}

.pill-btn.is-danger {
  background: var(--coral-soft);
  border-color: oklch(0.65 0.21 26 / 0.42);
  color: oklch(0.78 0.16 25);
}

.pill-btn.is-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--fg-section);
}

@media (hover: hover) and (pointer: fine) {
  .pill-btn.is-ghost:hover {
    background: rgb(255 255 255 / 0.06);
    color: var(--fg);
  }
}

/* Combined Start -> End Date Range Pill (Task Details) */
.date-range-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--surface-pill);
  border: 1px solid rgb(116 170 255 / 0.16);
  box-shadow: var(--rim-pill);
  transition: border-color 140ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .date-range-pill:hover {
    border-color: rgb(118 175 255 / 0.30);
  }
}

.date-seg-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5.5px;
  height: 100%;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--fg-muted);
  border-radius: var(--r-pill);
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.date-seg-start {
  padding-inline: 10px 7px;
}

.date-seg-end {
  padding-inline: 7px 12px;
}

.date-seg-btn.has-val {
  color: #B4CBE9;
}

.date-range-pill.has-dates .date-seg-start svg {
  color: var(--accent-sky);
}

.date-seg-btn.is-overdue {
  color: oklch(0.78 0.16 25);
}

@media (hover: hover) and (pointer: fine) {
  .date-seg-btn:hover {
    background: rgb(118 175 255 / 0.14);
    color: var(--fg);
  }
}

.date-seg-btn:active {
  background: rgb(118 175 255 / 0.22);
}

.date-range-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  padding-inline: 2px;
  pointer-events: none;
}

@media (max-width: 720px), (pointer: coarse) {
  .date-range-pill {
    height: 34px;
  }
  .date-seg-btn {
    min-width: 44px;
    justify-content: center;
  }
  .date-seg-start {
    padding-inline: 11px 8px;
  }
  .date-seg-end {
    padding-inline: 8px 13px;
  }
  .date-seg-btn::after {
    content: "";
    position: absolute;
    inset: -5px 0;
  }
  .date-range-arrow {
    padding-inline: 4px;
  }
}

/* Uniform Outlink / Convo / Meta Chips — 1:1 Role Exclusivity (UIC-028) */
.out-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5.5px;
  height: 22px;
  padding-inline: 8.5px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 560;
  white-space: nowrap;
  flex-shrink: 0;
}

.out-chip:has(> svg:first-child:not(:only-child)) {
  padding-inline: 7px 9.5px;
}

span.out-chip:not(:has(a, button)) {
  background: rgb(148 184 235 / 0.09);
  border: 1px solid transparent;
  color: var(--fg-muted);
  cursor: default;
}

button.out-chip,
a.out-chip,
.out-chip:has(a, button) {
  background: rgb(16 33 63 / 0.72);
  color: var(--fg-secondary);
  border: 1px solid var(--border-card);
  cursor: pointer;
  transition: background-color 130ms var(--ease-out), color 130ms var(--ease-out), border-color 130ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  button.out-chip:hover,
  a.out-chip:hover,
  .out-chip:has(a, button):hover {
    background: var(--surface-pill-hover);
    color: var(--fg);
  }
}

button.out-chip.tone-convo,
a.out-chip.tone-convo,
.out-chip.tone-convo:has(a, button) {
  color: var(--accent-sky);
  border-color: rgb(99 166 255 / 0.30);
  background: rgb(33 73 138 / 0.34);
}

.out-chip.tone-needs-you {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: transparent;
}

.out-chip.tone-filing {
  color: var(--sky);
  background: var(--sky-soft);
  border-color: transparent;
}

.out-chip.tone-wontdo {
  color: var(--fg-muted);
  background: rgb(255 255 255 / 0.04);
  border-color: transparent;
}

@media (max-width: 560px) {
  .space-row-actions .space-inline-create {
    display: none;
  }
}

@media (max-width: 720px), (pointer: coarse) {
  button.out-chip,
  a.out-chip {
    min-width: 44px;
    height: 26px;
    font-size: 12px;
  }
  button.out-chip[data-task-steps] {
    min-width: 0;
    padding-inline: 8px;
  }
  button.out-chip::after,
  a.out-chip::after {
    content: "";
    position: absolute;
    inset: -4px -2px -14px -2px;
  }
}

/* iOS-Style Switch (.tgl) — Never Checkboxes for On/Off Controls */
.tgl {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 26px;
  padding: 2px;
  border-radius: var(--r-pill);
  background: var(--surface-track);
  border: 1px solid var(--border-control);
  flex-shrink: 0;
  transition: background-color 170ms ease, border-color 170ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .tgl::after {
    content: "";
    position: absolute;
    inset: -9px -2px;
  }
}

.tgl[aria-checked="true"],
.tgl.is-on {
  background: var(--cobalt);
  border-color: rgb(135 195 255 / 0.45);
}

.tgl-thumb {
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.45);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tgl[aria-checked="true"] .tgl-thumb,
.tgl.is-on .tgl-thumb {
  transform: translateX(18px);
}

/* ==========================================================================
   Tab 1: Focus — TO REVIEW Stacked Peeking Card Deck
   ========================================================================== */

.deck-wrap {
  position: relative;
  margin-bottom: 18px;
}

.deck-wrap-multi {
  padding-top: 8px;
}

.deck-wrap:has(> .deck-peek-2) {
  padding-top: 16px;
}

.deck-peek-1,
.deck-peek-2 {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  height: 28px;
  border-radius: var(--r-card);
  background: var(--surface-card-grad);
  border: 1px solid rgb(118 175 255 / 0.22);
  box-shadow: var(--rim-top);
  pointer-events: none;
  z-index: 1;
  opacity: 0.78;
}

.deck-wrap:has(> .deck-peek-2) > .deck-peek-1 {
  top: 8px;
}

.deck-peek-2 {
  left: 20px;
  right: 20px;
  top: 0;
  z-index: 0;
  border-color: rgb(118 175 255 / 0.16);
  opacity: 0.48;
}

.deck-card {
  position: relative;
  z-index: 2;
  background: var(--surface-elev-grad);
  border: 1px solid rgb(118 175 255 / 0.20);
  border-radius: var(--r-card);
  box-shadow: var(--rim-top);
  padding: 12px 14px;
  touch-action: pan-y;
  will-change: transform;
}

.deck-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.deck-kicker {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber);
}

.deck-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
}

.deck-arrow {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-section);
  background: rgb(255 255 255 / 0.04);
}

@media (hover: hover) and (pointer: fine) {
  .deck-arrow:hover {
    background: rgb(255 255 255 / 0.09);
    color: var(--fg);
  }
}

@media (max-width: 720px), (pointer: coarse) {
  .deck-arrow {
    width: 36px;
    height: 36px;
  }
  .deck-arrow::after {
    content: "";
    position: absolute;
    inset: -4px;
  }
}

.deck-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.deck-cat-title {
  font-size: 14.5px;
  font-weight: 620;
  color: var(--fg);
}

.triage-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.triage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 7px 8px;
  margin-inline: -8px;
  border-radius: 11px;
  transition: background-color 130ms var(--ease-out);
}

.triage-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.linked-conv-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-width: 0;
  color: var(--fg-secondary);
}

.linked-conv-line .triage-title {
  width: auto;
  flex: 0 1 auto;
}

@media (max-width: 720px), (pointer: coarse) {
  .triage-main {
    min-height: 44px;
  }
}

.triage-title {
  width: 100%;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.32;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--fg);
}

.triage-sub {
  max-width: 100%;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.36;
  font-size: 12.5px;
  color: var(--fg-muted);
}

.triage-sub-accent {
  font-weight: 640;
}

.triage-sub-accent.tone-amber {
  color: var(--amber);
}

.triage-sub-accent.tone-coral {
  color: var(--coral);
}

.triage-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 1px;
}

.hover-pill {
  opacity: 0;
  pointer-events: none;
  transition: opacity 130ms ease;
}

@media (hover: none) {
  .hover-pill {
    display: none;
  }
}

@media (hover: hover) {
  .triage-row:hover .hover-pill,
  .thread-row:hover .hover-pill,
  .step-row:hover .hover-pill {
    opacity: 1;
    pointer-events: auto;
  }
}

.show-more-btn {
  position: relative;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 560;
  color: var(--sky);
  padding-block: 4px;
}

@media (max-width: 720px), (pointer: coarse) {
  .show-more-btn {
    min-width: 44px;
    min-height: 34px;
  }
  .show-more-btn::after {
    content: "";
    position: absolute;
    inset: -5px -4px;
  }
}

/* ==========================================================================
   Unified Agents & Threads Card
   ========================================================================== */

.agent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-row-wrap {
  position: relative;
  overflow: visible;
}

.agent-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 48px;
  padding: 8px;
  margin-inline: -8px;
  border-radius: 11px;
  will-change: transform;
  touch-action: pan-y;
  transition: background-color 130ms ease;
}

.conv-ico-btn {
  position: relative;
  margin-top: 2px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgb(16 33 63 / 0.78);
  border: 1px solid rgb(116 170 255 / 0.18);
  color: #9BB4D6;
  flex-shrink: 0;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, filter 140ms ease, transform 110ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .conv-ico-btn:hover {
    background: var(--surface-pill-hover);
    border-color: rgb(118 175 255 / 0.32);
    color: var(--accent-sky);
  }
}

.conv-ico-btn.is-agy-tile {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgb(56 128 214 / 0.24);
  border: 1px solid rgb(125 182 255 / 0.24);
  color: #7CC0FF;
  box-shadow: inset 0 1px 0 rgb(185 220 255 / 0.12);
}

@media (hover: hover) and (pointer: fine) {
  .conv-ico-btn.is-agy-tile:hover {
    background: rgb(68 144 235 / 0.34);
    border-color: rgb(148 198 255 / 0.38);
    color: #B4DBFF;
  }
}

.conv-ico-btn:active {
  transform: scale(0.94);
}

@media (max-width: 720px), (pointer: coarse) {
  .conv-ico-btn,
  .conv-ico-btn.is-agy-tile {
    width: 40px;
    height: 40px;
  }
  .conv-ico-btn::after {
    content: "";
    position: absolute;
    inset: -3px;
  }
}

.spark-badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 17px;
  height: 17px;
  border-radius: var(--r-pill);
  background: oklch(0.60 0.185 254);
  border: 1.5px solid oklch(0.80 0.105 252);
  box-shadow: 0 0 0 2px #091325;
  color: #F4F9FF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spark-badge.tone-working,
.spark-badge.tone-needs_you {
  background: oklch(0.60 0.185 254);
  border-color: oklch(0.80 0.105 252);
  color: #F4F9FF;
}

.spark-badge.tone-done {
  background: oklch(0.70 0.165 156);
  border-color: oklch(0.86 0.115 158);
  color: #EEFFF7;
}

.spark-badge.tone-failed {
  background: oklch(0.63 0.20 25);
  border-color: oklch(0.82 0.11 22);
  color: #FFFFFF;
}

.agent-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}

@media (max-width: 720px), (pointer: coarse) {
  .agent-main {
    min-height: 44px;
  }
}

.agent-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.agent-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.32;
  font-size: 14.5px;
  font-weight: 640;
  color: var(--fg);
  transition: color 130ms ease;
}

.agent-sub-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.35;
}

.agent-space-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding-inline: 7px;
  border-radius: var(--r-pill);
  background: rgb(116 170 255 / 0.15);
  border: 1px solid rgb(135 190 255 / 0.22);
  color: #C4DCF9;
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.agent-inline-status {
  font-size: 12.5px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--fg-secondary);
}

.agent-inline-status.tone-done {
  color: var(--emerald);
}

.agent-inline-status.tone-working {
  color: var(--sky);
}

.agent-inline-status.tone-unread {
  color: var(--accent-sky);
}

.agent-inline-status.tone-needs_you {
  color: var(--amber);
}

.agent-inline-status.tone-failed {
  color: var(--coral);
}

.agent-sub-sep {
  color: var(--fg-subtle);
  flex-shrink: 0;
}

.agent-sub {
  flex: 1 1 180px;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.36;
  font-size: 12px;
  color: var(--fg-secondary);
}

@media (max-width: 680px) {
  .agent-sub-sep {
    display: none;
  }
  .agent-sub {
    flex: 1 1 100%;
  }
}

.agent-right-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  align-self: flex-start;
  padding-top: 2px;
  min-width: auto;
}

.agent-time {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-secondary);
  white-space: nowrap;
  transition: opacity 120ms ease;
}

.agent-clear-overlay {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  height: 26px;
  padding-inline: 9px;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 610;
  background: #14284B;
  border: 1px solid rgb(130 185 255 / 0.34);
  color: #EAF3FF;
  box-shadow: -12px 0 14px -4px rgb(0 0 0 / 0.56), var(--rim-pill);
  opacity: 0;
  pointer-events: none;
  transition: opacity 130ms ease, background-color 130ms ease, border-color 130ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .agent-clear-overlay:hover {
    background: #1B3663;
    border-color: rgb(155 205 255 / 0.52);
    color: #FFFFFF;
  }
}

@media (hover: hover) {
  .agent-row:hover .agent-clear-overlay,
  .agent-row:focus-within .agent-clear-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  .agent-row:hover .agent-time,
  .agent-row:focus-within .agent-time {
    opacity: 0;
  }
}

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding-inline: 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 580;
  white-space: nowrap;
  flex-shrink: 0;
}

.state-pill.tone-working {
  background: var(--sky-soft);
  color: var(--sky);
  animation: none;
}

.state-pill.tone-working::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: currentColor;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .state-pill.tone-working::before {
    animation: skyBreathe 2s ease-in-out infinite;
  }
}

.state-pill.tone-needs_you {
  background: var(--amber-soft);
  color: var(--amber);
}

.state-pill.tone-done {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.state-pill.tone-failed {
  background: var(--coral-soft);
  color: var(--coral);
}

.state-pill.tone-idle {
  background: rgb(255 255 255 / 0.05);
  color: var(--fg-muted);
}

/* ==========================================================================
   Flat Task Rows (Single-Line Everywhere, Zero Hover Shading, Zero Rule Lines)
   ========================================================================== */

.task-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto auto;
  align-items: start;
  column-gap: 8px;
  min-height: 40px;
  padding: 5px 8px;
  margin-inline: -8px;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  transition: background-color 130ms ease;
}

.task-row-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

@media (hover: hover) {
  .task-row:hover,
  .triage-row:hover,
  .thread-row:hover,
  .agent-row:hover {
    background: rgb(120 175 255 / 0.065);
  }
  .task-row:hover .task-title,
  .triage-row:hover .triage-title,
  .thread-row:hover .thread-title,
  .agent-row:hover .agent-title {
    color: #FFFFFF;
  }
}

/* Plain Status Circle Toggle */
.status-circle {
  position: relative;
  width: 30px;
  height: 30px;
  margin-left: -5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  color: var(--fg-muted);
  transition: color 140ms ease, transform 110ms ease;
}

.status-circle > svg {
  width: 24px;
  height: 24px;
}

.step-status-btn {
  width: 28px;
  height: 28px;
  margin: 0;
}

.step-status-btn > svg {
  width: 20px;
  height: 20px;
}

@media (hover: hover) and (pointer: fine) {
  .status-circle:hover {
    color: var(--fg);
  }
}

.status-circle:active {
  transform: scale(0.92);
}

.status-circle.is-done {
  color: var(--emerald);
}

.pill-btn.is-done-confirm {
  color: var(--emerald);
  border-color: oklch(0.72 0.165 156 / 0.38);
  background: oklch(0.72 0.165 156 / 0.10);
}

.task-title-ink {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background-image: linear-gradient(var(--fg-muted), var(--fg-muted));
  background-repeat: no-repeat;
  background-position: 0 54%;
  background-size: 0% 1.4px;
}

.task-row.is-completing .task-title,
.triage-row.is-completing .triage-title {
  color: var(--fg-muted);
  transition: color 240ms cubic-bezier(0.22, 1, 0.36, 1) 50ms;
}

.task-row.is-completing .task-title-ink {
  background-size: 100% 1.4px;
  transition: background-size 240ms cubic-bezier(0.22, 1, 0.36, 1) 50ms;
}

.triage-row.is-completing .triage-title {
  text-decoration: line-through;
  text-decoration-color: var(--fg-muted);
}

.task-row.is-completing .task-chips-scroll,
.task-row.is-completing .mobile-subline,
.task-row.is-completing .task-row-tools,
.triage-row.is-completing .triage-sub {
  opacity: 0.42;
  transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1) 40ms;
}

@media (prefers-reduced-motion: reduce) {
  .task-row.is-completing .task-title {
    text-decoration: line-through;
  }
  .task-row.is-completing .task-title-ink {
    background: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes relay-check-pop {
    0% { transform: scale(0.84); }
    58% { transform: scale(1.13); }
    100% { transform: scale(1); }
  }

  @keyframes relay-check-halo {
    0% {
      transform: scale(0.72);
      opacity: 0.52;
    }
    100% {
      transform: scale(1.68);
      opacity: 0;
    }
  }

  @keyframes relay-check-draw {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
  }

  @keyframes relay-done-land {
    from {
      opacity: 0.35;
      transform: translate3d(0, -3px, 0);
    }
    to {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  .status-circle.is-pop::before {
    content: "";
    position: absolute;
    width: 25px;
    height: 25px;
    border-radius: var(--r-pill);
    border: 1.5px solid oklch(0.76 0.155 156 / 0.72);
    pointer-events: none;
    animation: relay-check-halo 340ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .status-circle.is-pop svg {
    animation: relay-check-pop 220ms var(--ease-out) both;
  }

  .status-circle.is-pop .check-draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: relay-check-draw 200ms cubic-bezier(0.22, 1, 0.36, 1) 35ms forwards;
  }

  .task-row.is-collapsing,
  .triage-row.is-collapsing {
    overflow: hidden;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    opacity: 0;
    transform: translate3d(0, -2px, 0);
    pointer-events: none;
    transition:
      height 220ms cubic-bezier(0.22, 1, 0.36, 1),
      padding-top 220ms cubic-bezier(0.22, 1, 0.36, 1),
      padding-bottom 220ms cubic-bezier(0.22, 1, 0.36, 1),
      margin-top 220ms cubic-bezier(0.22, 1, 0.36, 1),
      margin-bottom 220ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 170ms cubic-bezier(0.22, 1, 0.36, 1),
      transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .task-row.is-just-completed {
    animation: relay-done-land 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

.task-body-btn {
  position: relative;
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  min-height: 30px;
  padding-top: 5px;
  cursor: pointer;
  user-select: none;
}

@media (max-width: 720px), (pointer: coarse) {
  .status-circle::after {
    content: "";
    position: absolute;
    inset: -5px;
  }
  .step-status-btn {
    width: 34px;
    height: 34px;
  }
  .task-body-btn::after {
    content: "";
    position: absolute;
    inset: -10px 0;
  }
}

.task-title {
  min-width: 0;
  flex: 1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.32;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition: color 130ms ease;
}

.task-row.is-completed .task-title {
  text-decoration: line-through;
  color: var(--fg-muted);
}

.task-chips-scroll {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  max-width: clamp(260px, 38vw, 400px);
}

.task-chips-scroll::-webkit-scrollbar {
  display: none;
}

/* Narrow Edge Mask Fades ONLY on Edges with Active Scroll Overflow (UIC-004 + Anti-Pattern Guard) */
.has-overflow-right {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(90deg in oklab, #000 calc(100% - 28px), transparent 100%);
}

.has-overflow-left {
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 18px);
  mask-image: linear-gradient(90deg in oklab, transparent 0%, #000 18px);
}

.has-overflow-left.has-overflow-right {
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 18px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(90deg in oklab, transparent 0%, #000 18px, #000 calc(100% - 28px), transparent 100%);
}

.row-col-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  transition: background-color 130ms ease, color 130ms ease, transform 110ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .row-col-btn:hover {
    background: rgb(255 255 255 / 0.06);
    color: var(--fg);
  }
}

.row-col-btn:active {
  transform: scale(0.93);
}

.sun-btn.is-focused {
  color: var(--fg-sun);
}

.sun-btn:not(.is-focused) {
  opacity: 0.35;
}

@media (hover: hover) {
  .task-row:hover .sun-btn:not(.is-focused) {
    opacity: 0.85;
  }
}

/* Priority Flag Colors */
.prio-p0 { color: var(--coral); }
.prio-p1 { color: var(--coral); }
.prio-p2 { color: var(--amber); }
.prio-p3 { color: var(--slate-flag); }
.prio-none { color: var(--fg-subtle); opacity: 0.45; }

.mobile-subline {
  display: none;
}

/* Mobile <= 480px Task Row Layout */
@media (max-width: 560px) {
  .space-row-actions .space-inline-create {
    display: none;
  }
}

@media (max-width: 680px) {
  .task-row {
    grid-template-columns: 38px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 8px;
    padding-block: 7px;
  }

  .task-row > .status-circle {
    width: 38px;
    height: 38px;
    margin-left: -7px;
    margin-top: -9px;
    grid-row: 1 / span 2;
  }

  .task-row > .status-circle > svg {
    width: 25px;
    height: 25px;
  }

  .task-body-btn {
    grid-column: 2;
    grid-row: 1;
    min-height: 20px;
    padding-top: 0;
    align-items: flex-start;
  }
  .task-body-btn::after {
    inset: -13px 0 -3px 0;
  }

  .task-title {
    -webkit-line-clamp: 3;
    line-clamp: 3;
    line-height: 1.36;
  }

  .task-desktop-chips,
  .task-row-tools,
  .task-col-sun,
  .task-col-prio,
  .task-col-more {
    display: none !important;
  }

  .mobile-subline {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 7px;
    min-width: 0;
    margin-top: 3px;
    padding-block: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .mobile-subline::-webkit-scrollbar {
    display: none;
  }

  .mobile-subline > * {
    flex-shrink: 0;
  }

  /* Keep hit-slop inside .mobile-subline's padding-block so iOS Safari never creates a vertical scroll axis */
  .mobile-subline button.out-chip::after,
  .mobile-subline a.out-chip::after,
  .mobile-subline .mobile-prio-flag::after {
    inset: -4px -2px;
  }

  .mobile-prio-flag {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    margin-left: -4px;
    border-radius: 7px;
    flex-shrink: 0;
    transition: background-color 130ms ease, transform 110ms ease;
  }

  .mobile-prio-flag:active {
    background: rgb(255 255 255 / 0.08);
    transform: scale(0.92);
  }

  .mobile-prio-flag::after {
    content: "";
    position: absolute;
    inset: -4px -2px;
  }
}

/* Folds (Completed Today / All Completed / Automation Groups) */
.fold-block {
  margin-top: 14px;
}

.upcoming-section {
  margin-top: 22px;
}

.upcoming-section .section-head {
  margin-bottom: 4px;
}

.upcoming-days-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upcoming-day-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upcoming-day-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  padding: 2px 0 4px;
}

.fold-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-section);
}

@media (hover: hover) and (pointer: fine) {
  .fold-trigger:hover {
    color: var(--fg);
  }
}

@media (max-width: 720px), (pointer: coarse) {
  .fold-trigger {
    min-width: 44px;
    min-height: 34px;
  }
  .fold-trigger::after {
    content: "";
    position: absolute;
    inset: -5px -4px;
  }
}

/* ==========================================================================
   Tab 2: Spaces — Flat 3-Level Hierarchy (Space -> Project -> Task)
   ========================================================================== */

.spaces-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-block: 4px 12px;
}

.space-pills-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 1 1 auto;
  padding-block: 5px;
}

.space-pills-bar > *,
.space-filter-group > * {
  flex-shrink: 0;
}

.space-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.space-pills-bar::-webkit-scrollbar {
  display: none;
}

.spaces-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  margin-left: auto;
}

.space-section {
  margin-bottom: 14px;
}

.space-section:not(.is-collapsed) {
  margin-bottom: 24px;
}

.space-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: 6px 8px;
  margin-inline: -8px;
  border-radius: 14px;
  transition: background-color 140ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .space-head:hover {
    background: rgb(56 124 224 / 0.08);
  }
}

.space-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  min-height: 44px;
  text-align: left;
  cursor: pointer;
  color: var(--fg);
}

.space-emoji-tile {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.14);
  background: linear-gradient(180deg in oklab, rgb(45 106 214 / 0.34), rgb(30 74 162 / 0.28));
  border: 1px solid rgb(108 168 255 / 0.32);
}

.space-emoji-tile.tone-0 {
  background: linear-gradient(180deg in oklab, rgb(45 106 214 / 0.36), rgb(30 74 162 / 0.28));
  border-color: rgb(108 168 255 / 0.34);
}

.space-emoji-tile.tone-1 {
  background: linear-gradient(180deg in oklab, rgb(128 76 238 / 0.38), rgb(88 48 184 / 0.28));
  border-color: rgb(176 138 255 / 0.36);
}

.space-emoji-tile.tone-2 {
  background: linear-gradient(180deg in oklab, rgb(156 112 72 / 0.34), rgb(110 76 46 / 0.28));
  border-color: rgb(214 168 124 / 0.30);
}

.space-emoji-tile.tone-3 {
  background: linear-gradient(180deg in oklab, rgb(76 108 168 / 0.34), rgb(50 74 124 / 0.28));
  border-color: rgb(142 176 232 / 0.30);
}

.space-title-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.space-title-lg {
  font-size: 16px;
  font-weight: 680;
  letter-spacing: -0.015em;
  line-height: 1.22;
  color: #F4F8FF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.space-count-sub {
  font-size: 12.5px;
  font-weight: 470;
  line-height: 1.24;
  color: var(--fg-secondary);
}

.space-right-cluster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.space-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (hover: hover) {
  .space-section.is-collapsed .space-row-actions {
    opacity: 0;
    pointer-events: none;
    transition: opacity 130ms ease;
  }
  .space-section.is-collapsed .space-head:hover .space-row-actions,
  .space-section.is-collapsed .space-head:focus-within .space-row-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (hover: none) {
  .space-section.is-collapsed .space-row-actions {
    display: none;
  }
}

.space-chev-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 140ms ease, background-color 140ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .space-chev-btn {
    width: 36px;
    height: 36px;
  }
  .space-chev-btn::after {
    content: "";
    position: absolute;
    inset: -4px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .space-head:hover .space-chev-btn {
    color: var(--fg);
  }
}

.space-body {
  padding-left: 8px;
  margin-top: 4px;
}

.repo-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  opacity: 0.85;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .space-row-actions .space-inline-create {
    display: none;
  }
}

@media (max-width: 480px) {
  .space-actions,
  .space-row-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .space-head .pill-btn.is-ghost {
    padding-inline: 7px;
    font-size: 12px;
  }
  .repo-slug-label {
    display: none;
  }
  .space-body {
    padding-left: 4px;
  }
}

.space-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.project-block {
  margin-top: 16px;
}

.project-block:first-child {
  margin-top: 8px;
}

.project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 34px;
  margin-bottom: 4px;
}

.project-title-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
  min-width: 0;
  flex: 1 1 auto;
}

.project-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 30px;
  padding: 2px 7px 2px 4px;
  margin-left: -4px;
  border-radius: 8px;
  color: inherit;
  transition: background-color 130ms ease, color 130ms ease;
}

@media (hover: hover) {
  .project-toggle-btn:hover {
    background: rgb(120 175 255 / 0.08);
  }
  .project-head-actions {
    opacity: 0.62;
    transition: opacity 140ms ease;
  }
  .project-block:hover .project-head-actions,
  .project-block:focus-within .project-head-actions {
    opacity: 1;
  }
}

.project-chev-wrap {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-section);
  flex-shrink: 0;
}

.project-name {
  font-size: 14.5px;
  font-weight: 660;
  letter-spacing: -0.012em;
  line-height: 1.28;
  text-align: left;
  color: #FFFFFF;
  white-space: normal;
  text-wrap: pretty;
}

.project-progress {
  font-size: 11.5px;
  font-weight: 520;
  color: var(--fg-muted);
  white-space: nowrap;
}

/* Nested Project -> Task Tree Stem & Optical Indentation */
.project-task-list {
  margin-left: 9px;
  padding-left: 18px;
  padding-block: 1px;
  border-left: 1.5px solid rgb(116 170 255 / 0.17);
  transition: border-color 150ms ease;
}

@media (hover: hover) {
  .project-block:hover .project-task-list {
    border-left-color: rgb(130 194 255 / 0.30);
  }
}

.project-task-list .task-title {
  font-size: 13.75px;
  color: #DCE8FA;
}

@media (max-width: 720px), (pointer: coarse) {
  .project-toggle-btn {
    min-height: 44px;
  }
}

@media (max-width: 560px) {
  .proj-done-word,
  .repo-slug-chip {
    display: none;
  }
  .project-head-actions {
    margin-left: auto;
  }
  .project-task-list {
    margin-left: 8px;
    padding-left: 14px;
  }
}

/* ==========================================================================
   Tab 3: Threads — Unified Rows, Swipe-to-Dismiss, Select Mode
   ========================================================================== */

.threads-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.thread-row-wrap {
  position: relative;
  overflow: visible;
}

.thread-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 8px;
  margin-inline: -8px;
  border-radius: 10px;
  background: transparent;
  will-change: transform;
  touch-action: pan-y;
  transition: background-color 130ms ease;
}

.thread-select-dot {
  position: relative;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: var(--r-pill);
  border: 1.75px solid var(--border-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #FFFFFF;
}

@media (max-width: 720px), (pointer: coarse) {
  .thread-select-dot {
    width: 26px;
    height: 26px;
  }
  .thread-select-dot::after {
    content: "";
    position: absolute;
    inset: -9px;
  }
}

.thread-select-dot.is-selected {
  background: var(--cobalt);
  border-color: var(--cobalt-bright);
}

.thread-main-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

@media (max-width: 720px), (pointer: coarse) {
  .thread-main-btn {
    min-height: 44px;
  }
}

.thread-sig-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: -1px;
  color: var(--fg-secondary);
}

.thread-sig-pill.tone-amber { color: var(--amber); }
.thread-sig-pill.tone-coral { color: var(--coral); }
.thread-sig-pill.tone-sky { color: var(--accent-sky); }
.thread-sig-pill.tone-emerald { color: var(--emerald); }

.thread-top-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.unread-pip {
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: var(--r-pill);
  background: var(--cobalt-bright);
  flex-shrink: 0;
}

.thread-title {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.32;
  font-size: 14.5px;
  font-weight: 620;
  color: var(--fg);
}

.thread-meta-line {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  text-wrap: pretty;
  line-height: 1.36;
  width: 100%;
  font-size: 12.5px;
  color: var(--fg-muted);
}

.auto-group {
  margin-top: 12px;
}

.auto-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
}

/* Sticky Bulk Bar */
.bulk-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 48;
  width: min(calc(100% - 24px), 560px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 16px;
  background: color-mix(in oklab, var(--surface-2) 92%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--border-control);
  box-shadow: var(--shadow-float), var(--rim-top);
}

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

/* ==========================================================================
   Tab 4: Clock — 48-Run Pulse Bars, Legend, Timeline Cards
   ========================================================================== */

.clock-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--fg-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.swatch-ok { background: var(--emerald-ok); }
.swatch-failed { background: var(--coral); }
.swatch-missed { background: oklch(0.55 0.08 75); }
.swatch-running { background: var(--sky); }
.swatch-empty { background: var(--surface-track); }

.clock-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clock-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.clock-name {
  font-size: 14.5px;
  font-weight: 620;
  color: var(--fg);
}

.clock-sched {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 2px;
}

.clock-pulse-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--fg-secondary);
  margin-bottom: 4px;
}

.clock-sum-fail {
  color: var(--coral);
}

.clock-sum-miss {
  color: var(--fg-muted);
}

.pulse-bars {
  display: grid;
  grid-template-columns: repeat(48, minmax(0, 1fr));
  gap: 2px;
  height: 22px;
  align-items: stretch;
  margin-block: 4px 8px;
}

.pulse-seg {
  border-radius: 2px;
  background: var(--surface-track);
  transition: transform 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .pulse-seg:hover {
    transform: scaleY(1.16);
  }
}

.pulse-seg.is-ok { background: var(--emerald-ok); }
.pulse-seg.is-failed { background: var(--coral); }
.pulse-seg.is-missed { background: oklch(0.55 0.08 75); }
.pulse-seg.is-running,
.pulse-seg.is-degraded { background: var(--sky); }

.clock-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--fg-section);
}

.clock-meta-row .space-actions {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
  gap: 6px;
}

/* ==========================================================================
   Floating Quick Add FAB
   ========================================================================== */

.fab-btn {
  position: fixed;
  right: max(18px, calc((100vw - var(--max-w)) / 2 + 16px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 38;
  width: 52px;
  height: 52px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cobalt-grad);
  color: #FFFFFF;
  border: 1px solid rgb(135 195 255 / 0.42);
  box-shadow: var(--shadow-fab);
  transition: filter 140ms ease, transform 130ms ease, opacity 150ms ease, scale 150ms ease;
}

@media (min-width: 940px) {
  .fab-btn {
    right: calc((100vw - var(--max-w)) / 2 - 68px);
  }
}

html.has-open-sheet .fab-btn,
body:has(#builder-inline-drawer:not([hidden])) .fab-btn,
body:has(#sheet-stack .sheet-layer) .fab-btn {
  opacity: 0;
  pointer-events: none;
  scale: 0.9;
}

@media (hover: hover) and (pointer: fine) {
  .fab-btn:hover {
    filter: brightness(1.08);
  }
}

.fab-btn:active {
  transform: scale(0.93);
}

/* ==========================================================================
   Bottom Sheets (Velocity-Aware Spring Drag, Scrim-Only Fade) & Popovers
   ========================================================================== */

.sheet-stack {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.sheet-stack:empty,
.popover-root:empty,
.toast-stack:empty {
  display: none;
}

.sheet-layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
}

@media (min-width: 680px) {
  .sheet-layer.is-dialog-desktop {
    align-items: center;
    padding: 20px;
  }
}

.sheet-scrim {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Extend through iOS Standalone WebClip bottom safe area (where 100vh stops 34pt early) */
  bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  background: rgb(2 6 16 / var(--scrim-alpha, 0.70));
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  touch-action: none;
  overscroll-behavior: none;
  transition: background-color 180ms ease;
}

.sheet-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 18px);
  display: flex;
  flex-direction: column;
  background: var(--surface-card-grad);
  border: 1px solid rgb(118 175 255 / 0.22);
  border-bottom: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow-float), var(--rim-top);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overscroll-behavior: contain;
}

/* Seamless bottom safe-area skirt so mobile bottom sheets bleed to the physical iPhone bezel without a 34pt cutoff */
.sheet-card::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 100%;
  height: calc(env(safe-area-inset-bottom, 0px) + 64px);
  background: #091325;
  border-inline: 1px solid rgb(118 175 255 / 0.22);
  pointer-events: none;
}

@media (min-width: 680px) {
  .sheet-layer.is-dialog-desktop .sheet-card {
    border-bottom: 1px solid rgb(118 175 255 / 0.22);
    border-radius: var(--r-sheet);
    max-height: min(86dvh, 760px);
  }
  .sheet-layer.is-dialog-desktop .sheet-card::after {
    display: none;
  }
  .sheet-layer.is-dialog-desktop .sheet-grabber-zone {
    display: none;
  }
  .sheet-layer.is-dialog-desktop .sheet-head {
    padding-top: 14px;
    cursor: default;
  }
}

.sheet-grabber-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding-block: 11px 6px;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.sheet-grabber-zone:active {
  cursor: grabbing;
}

.sheet-grabber {
  width: 42px;
  height: 5px;
  border-radius: var(--r-pill);
  background: rgb(184 214 255 / 0.28);
  transition: background-color 140ms ease, transform 140ms ease;
}

.sheet-grabber-zone:active .sheet-grabber {
  background: rgb(206 228 255 / 0.44);
}

@media (hover: hover) and (pointer: fine) {
  .sheet-grabber-zone:hover .sheet-grabber {
    background: rgb(206 228 255 / 0.44);
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 16px 10px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
}

.sheet-title {
  font-size: 15.5px;
  font-weight: 640;
  color: var(--fg);
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 4px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sheet-nested-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.sheet-layer[data-sheet-id="add-focus-sheet"] .sheet-card,
.sheet-layer[data-sheet-id="merge-task-sheet"] .sheet-card,
.sheet-layer[data-sheet-id="link-thread-task-sheet"] .sheet-card,
.sheet-layer[data-sheet-id="assign-project-sheet"] .sheet-card {
  height: calc(100dvh - env(safe-area-inset-top, 0px) - 18px);
}

@media (min-width: 680px) {
  .sheet-layer.is-dialog-desktop[data-sheet-id="add-focus-sheet"] .sheet-card,
  .sheet-layer.is-dialog-desktop[data-sheet-id="merge-task-sheet"] .sheet-card,
  .sheet-layer.is-dialog-desktop[data-sheet-id="link-thread-task-sheet"] .sheet-card,
  .sheet-layer.is-dialog-desktop[data-sheet-id="assign-project-sheet"] .sheet-card {
    height: min(620px, 86dvh);
  }
}

.sheet-layer[data-sheet-id="add-focus-sheet"] .sheet-body,
.sheet-layer[data-sheet-id="merge-task-sheet"] .sheet-body,
.sheet-layer[data-sheet-id="link-thread-task-sheet"] .sheet-body,
.sheet-layer[data-sheet-id="assign-project-sheet"] .sheet-body {
  overflow: hidden;
  gap: 12px;
}

.focus-create-slot {
  flex-shrink: 0;
}

.focus-create-btn {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--cobalt-grad);
  border: 1px solid rgb(135 195 255 / 0.38);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.22);
  transition: border-color 140ms var(--ease-out), transform 110ms var(--ease-out);
}

@media (max-width: 720px), (pointer: coarse) {
  .focus-create-btn {
    min-height: 44px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .focus-create-btn:hover {
    background: linear-gradient(180deg in oklch, oklch(0.60 0.21 261) 0%, oklch(0.53 0.215 262) 100%);
    border-color: rgb(155 208 255 / 0.50);
  }
}

.focus-create-btn:active {
  transform: scale(0.985);
}

.focus-create-btn > svg {
  flex-shrink: 0;
}

.focus-create-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  line-height: 1.3;
}

.focus-create-q {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-picker-results,
.sheet-picker-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 4px;
}

.qa-hint-btn {
  min-height: 30px;
  padding-inline: 10px;
  font-size: 12px;
}

@media (max-width: 680px) {
  .qa-hint-btn {
    min-height: 44px;
    padding-inline: 12px;
    font-size: 13px;
  }
}

/* 3-Zone Task Details Sheet Specifics */
.crumb-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  max-width: 100%;
  padding-inline: 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--fg-section);
  background: var(--surface-2);
  border: 1px solid var(--border-card);
}

@media (hover: hover) and (pointer: fine) {
  .crumb-btn:hover {
    color: var(--fg);
    background: var(--surface-pill-hover);
  }
}

.details-head-crumb {
  justify-content: flex-start;
  max-width: 100%;
}

/* Completed emerald pill + tactile stroke-draw & halo burst (UIC-018, UIC-031) */
#details-complete-btn {
  position: relative;
  transition:
    background-color 220ms var(--ease-out),
    border-color 220ms var(--ease-out),
    color 220ms var(--ease-out),
    box-shadow 220ms var(--ease-out),
    transform 140ms var(--ease-out);
}

#details-complete-btn.is-completed {
  background: color-mix(in oklab, var(--emerald) 18%, var(--surface-2));
  border-color: oklch(0.75 0.16 155 / 0.54);
  color: var(--emerald);
  box-shadow: inset 0 1px 0 oklch(0.88 0.12 155 / 0.2);
}

@media (hover: hover) and (pointer: fine) {
  #details-complete-btn.is-completed:hover {
    background: color-mix(in oklab, var(--emerald) 24%, var(--surface-2));
    border-color: oklch(0.78 0.16 155 / 0.72);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes relay-complete-settle {
    0% { transform: scale(0.94); }
    55% { transform: scale(1.03); }
    100% { transform: scale(1); }
  }
  @keyframes relay-complete-halo {
    0% {
      opacity: 0.72;
      box-shadow: 0 0 0 0 oklch(0.75 0.17 155 / 0.52);
    }
    100% {
      opacity: 0;
      box-shadow: 0 0 0 11px oklch(0.75 0.17 155 / 0);
    }
  }
  @keyframes relay-check-draw {
    0% { stroke-dashoffset: 28; }
    100% { stroke-dashoffset: 0; }
  }
  #details-complete-btn.is-just-completed {
    animation: relay-complete-settle 280ms var(--ease-out) both;
  }
  #details-complete-btn.is-just-completed::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
    animation: relay-complete-halo 420ms var(--ease-out) both;
  }
  #details-complete-btn.is-just-completed .details-complete-ico path,
  #details-complete-btn.is-just-completed .details-complete-ico polyline {
    stroke-dasharray: 28;
    animation: relay-check-draw 240ms var(--ease-out) both;
  }
}

.manage-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

@media (min-width: 560px) {
  .manage-delete-btn {
    margin-inline-start: auto;
  }
}

@media (max-width: 559.98px) {
  .manage-delete-btn {
    margin-top: 6px;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 720px), (pointer: coarse) {
  .crumb-btn {
    min-height: 36px;
  }
  .crumb-btn::after {
    content: "";
    position: absolute;
    inset: -4px 0;
  }
}

@media (max-width: 520px) {
  .details-head-crumb {
    padding-inline: 8px 10px;
    font-size: 12.5px;
  }
  #details-complete-btn {
    padding-inline: 9px 11px;
    font-size: 12.5px;
  }
}

.details-title-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 8px;
  margin-inline: -8px;
  font-size: 18px;
  font-weight: 640;
  line-height: 1.3;
  color: var(--fg);
  resize: none;
}

@media (max-width: 720px), (pointer: coarse) {
  .details-title-input {
    min-height: 44px;
  }
}

.details-title-input:focus {
  background: var(--surface-input);
  border-color: var(--border-focus);
  outline: none;
}

.zone-pills-row,
.zone-queue-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 6px;
  padding-block: 2px;
}

.zone-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zone-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Steps Checklist */
.steps-progress-track {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: var(--surface-track);
  overflow: hidden;
}

.steps-progress-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--cobalt-bright);
  transform-origin: left;
  transition: transform 180ms var(--ease-out), background-color 180ms var(--ease-out);
}

.steps-progress-fill.is-complete {
  background: var(--emerald);
}

@media (prefers-reduced-motion: reduce) {
  .steps-progress-fill {
    transition: none;
  }
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 3px 6px;
  margin-inline: -6px;
  border-radius: 9px;
}

.step-row.is-dragging {
  background: var(--surface-2);
  box-shadow: var(--rim-top);
}

.drag-handle {
  width: 20px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  cursor: grab;
  touch-action: none;
}

@media (hover: hover) and (pointer: fine) {
  .drag-handle:hover {
    color: var(--fg-section);
  }
}

.step-row:focus-within {
  background: rgb(120 175 255 / 0.07);
  box-shadow: inset 0 0 0 1px rgb(125 188 255 / 0.26);
}

.step-title-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 13.5px;
  color: var(--fg);
}

@media (max-width: 720px), (pointer: coarse) {
  .step-title-input {
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .steps-list {
    gap: 6px;
  }
  .step-row {
    flex-wrap: wrap;
    row-gap: 2px;
    padding: 5px 6px 6px;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 8px 8px 0 0;
  }
  .step-row:last-child {
    border-bottom: 0;
  }
  .step-row > .step-title-input {
    flex: 1 1 calc(100% - 68px);
    min-height: 44px;
  }
  .step-row > .owner-pill,
  .step-row > .prov-badge {
    margin-left: auto;
  }
  .step-row > .prov-badge ~ .owner-pill {
    margin-left: 0;
  }
  .step-row > .hover-pill {
    display: none;
  }
}

.step-row.is-done .step-title-input {
  text-decoration: line-through;
  color: var(--fg-muted);
}

@keyframes agentSparkle {
  0% { box-shadow: 0 0 0 0 oklch(0.75 0.15 236 / 0.55); background: oklch(0.75 0.15 236 / 0.18); }
  100% { box-shadow: 0 0 0 10px transparent; background: transparent; }
}

@media (prefers-reduced-motion: no-preference) {
  .step-agent-sparkle {
    animation: agentSparkle 1.1s ease-out 1;
  }
}

.owner-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4.5px;
  height: 24px;
  padding-inline: 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 590;
  background: var(--surface-2);
  border: 1px solid var(--border-card);
  color: var(--fg-muted);
}

.owner-pill.is-agent {
  padding-inline: 8px 10.5px;
  color: var(--sky);
  background: var(--sky-soft);
  border-color: oklch(0.68 0.15 240 / 0.38);
}

.owner-pill.step-owner-add {
  height: 36px;
  padding-inline: 12px;
  border-radius: 10px;
}

.owner-pill.step-owner-add.is-agent {
  padding-inline: 10px 13px;
}

@media (max-width: 720px), (pointer: coarse) {
  button.owner-pill {
    min-width: 44px;
    height: 32px;
    min-height: 32px;
    padding-inline: 10px;
  }
  button.owner-pill.is-agent {
    padding-inline: 8.5px 11.5px;
  }
  button.owner-pill::after {
    content: "";
    position: absolute;
    inset: -6px -2px;
  }
  .owner-pill.step-owner-add {
    height: 44px;
    min-height: 44px;
    padding-inline: 13px;
    border-radius: 10px;
  }
  .owner-pill.step-owner-add.is-agent {
    padding-inline: 11px 14px;
  }
}

.prov-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  color: var(--sky);
  font-size: 11px;
}

/* Zone 1 Co-Working Handoff Banner & Per-Step Convo Trigger */
.handoff-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg in oklab, rgb(22 48 92 / 0.56), rgb(14 31 62 / 0.48));
  border: 1px solid rgb(104 166 255 / 0.26);
  box-shadow: var(--rim-top);
}

.handoff-card.is-needs-you {
  background: linear-gradient(180deg in oklab, oklch(0.32 0.065 74 / 0.46), oklch(0.23 0.045 72 / 0.38));
  border-color: oklch(0.76 0.155 76 / 0.40);
}

.handoff-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.handoff-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  flex: 1 1 200px;
}

.handoff-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 640;
  color: var(--accent-sky);
}

.handoff-card.is-needs-you .handoff-eyebrow {
  color: var(--amber);
}

.handoff-sub {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--fg-project);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}

.handoff-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.handoff-reply-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.handoff-reply-form .field-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 6px 11px;
  border-radius: 9px;
}

@media (max-width: 720px), (pointer: coarse) {
  .handoff-reply-form .field-input {
    min-height: 44px;
  }
  .handoff-reply-form .pill-btn {
    min-height: 44px;
    padding-inline: 14px;
  }
}

.step-convo-btn {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-sky);
  background: rgb(33 73 138 / 0.30);
  border: 1px solid rgb(99 166 255 / 0.24);
  flex-shrink: 0;
  transition: background-color 130ms var(--ease-out), border-color 130ms var(--ease-out), color 130ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .step-convo-btn:hover {
    background: rgb(45 96 180 / 0.44);
    border-color: rgb(132 190 255 / 0.42);
    color: #EBF5FF;
  }
}

.step-convo-btn.is-unlinked {
  color: var(--fg-secondary);
  background: var(--surface-2);
  border-color: var(--border-card);
}

@media (hover: hover) and (pointer: fine) {
  .step-convo-btn.is-unlinked:hover {
    color: var(--accent-sky);
    border-color: rgb(99 166 255 / 0.32);
  }
}

.step-add-input {
  flex: 1;
  height: 36px;
  padding: 6px 10px;
}

/* Inline Input + Button Form Bars — Uniform Sibling Control Heights & Optical Rail Compensation (UIC-020) */
#add-step-form,
#add-space-form,
#create-rem-form,
#add-url-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

#add-step-form .pill-btn,
#add-space-form .pill-btn,
#create-rem-form .pill-btn,
#add-url-form .pill-btn {
  height: 36px;
  border-radius: 10px;
  padding-inline: 13px;
}

.zone-label-row .pill-btn.is-ghost {
  margin-right: -13px;
}

.zone-block div:has(> #btn-start-linked-thread) {
  margin-left: -13px;
}

.step-row > .icon-btn-compact {
  margin-right: -6px;
}

.sheet-head > .icon-btn:last-child,
#details-custom-head > div:last-child > .icon-btn:last-child {
  margin-right: -8px;
}

@media (max-width: 720px), (pointer: coarse) {
  .space-pills-bar,
  .space-filter-group,
  .spaces-toolbar-actions,
  .zone-pills-row,
  .zone-queue-row,
  .handoff-actions,
  .clock-meta-row .space-actions,
  .triage-actions {
    gap: 8px;
  }
  .zone-label-row .pill-btn.is-ghost {
    margin-right: -14px;
  }
  .step-convo-btn {
    width: 32px;
    height: 32px;
  }
  .step-convo-btn::after {
    content: "";
    position: absolute;
    inset: -6px;
  }
  .step-row > .icon-btn-compact {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    margin-right: -10px;
  }
  .step-row > .icon-btn-compact::after {
    inset: -6px;
  }
  .step-add-input {
    min-height: 44px;
  }
  #add-step-form .pill-btn,
  #add-space-form .pill-btn,
  #create-rem-form .pill-btn,
  #add-url-form .pill-btn {
    height: 44px;
    min-height: 44px;
    border-radius: 10px;
    padding-inline: 14px;
  }
}

@media (max-width: 520px) {
  .step-row {
    gap: 8px;
  }
  .step-row .drag-handle {
    width: 16px;
  }
  .step-row:not(:focus-within) .step-promote-btn {
    display: none;
  }
}

/* Inputs, Notes, Pickers & Calendar Grid */
.field-input,
.field-textarea,
.quick-input {
  width: 100%;
  background: rgb(12 26 50 / 0.72);
  border: 1px solid var(--border-control);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--fg);
  outline: none;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .field-input,
  .quick-input {
    min-height: 44px;
  }
}

.field-input:focus,
.field-textarea:focus,
.quick-input:focus {
  background: rgb(14 31 60 / 0.88);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgb(77 163 255 / 0.20);
}

.field-textarea {
  min-height: 76px;
  resize: vertical;
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.picker-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 8px;
  text-align: left;
  font-size: 13.5px;
  color: var(--fg);
  transition: background-color 120ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .picker-opt {
    min-height: 44px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .picker-opt:hover {
    background: var(--surface-2);
  }
}

.picker-opt.is-selected {
  background: var(--cobalt-soft);
  color: var(--sky);
}

.cal-presets-list {
  gap: 2px;
}

.cal-preset-opt {
  min-height: 42px;
  padding-inline: 10px;
}

.cal-preset-lbl {
  font-weight: 560;
}

.cal-preset-date {
  font-size: 13px;
  color: var(--fg-muted);
}

.cal-preset-opt.is-selected .cal-preset-date {
  color: var(--sky);
}

.cal-divider {
  height: 1px;
  background: var(--border-subtle);
  margin-block: -2px;
}

.cal-month-wrap {
  gap: 10px;
}

.cal-month-label {
  font-size: 15px;
  font-weight: 640;
  color: var(--fg);
}

.cal-nav-arrows {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cal-today-jump {
  height: 26px;
  padding-inline: 10px;
  font-size: 12px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  text-align: center;
  justify-items: center;
}

.cal-dow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  padding-block: 4px;
}

.cal-day {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  transition: background-color 120ms ease, color 120ms ease;
}

@media (max-width: 720px), (pointer: coarse) {
  .cal-day {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .cal-today-jump {
    min-height: 34px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .cal-day:hover {
    background: var(--surface-2);
  }
}

.cal-day.is-outside {
  color: var(--fg-subtle);
  opacity: 0.45;
  pointer-events: none;
}

.cal-day.is-today {
  border: 1px solid var(--border-control);
}

.cal-day.is-selected {
  background: var(--cobalt);
  border-color: transparent;
  color: #FFFFFF;
  font-weight: 640;
}

.cal-day.is-range-endpoint {
  background: var(--cobalt-soft);
  border: 1.5px solid rgb(99 166 255 / 0.56);
  color: var(--sky);
  font-weight: 600;
}

.cal-day.is-in-range {
  background: var(--cobalt-soft);
  color: var(--sky);
}

.cal-hard-row {
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

/* Duration Wheel Picker */
.wheel-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wheel-col {
  max-height: 156px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  background: var(--surface-input);
  border: 1px solid var(--border-control);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wheel-item {
  scroll-snap-align: center;
  min-height: 34px;
  border-radius: 6px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-section);
}

@media (max-width: 720px), (pointer: coarse) {
  .wheel-item {
    min-height: 44px;
  }
}

.wheel-item.is-selected {
  background: var(--cobalt-soft);
  color: var(--sky);
  font-weight: 620;
}

/* Agent Health 2-Col Green Tiles & Action Cards */
.health-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 360px) {
  .health-tiles {
    grid-template-columns: 1fr;
  }
}

.health-tile {
  width: 100%;
  min-height: 54px;
  background: var(--surface-elev-grad);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--rim-top);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  color: var(--fg);
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease;
}

button.health-tile {
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  button.health-tile:hover {
    border-color: rgb(135 190 255 / 0.30);
  }
}

.health-tile.is-expanded {
  grid-column: 1 / -1;
  border-color: rgb(118 178 255 / 0.34);
}

.health-tile-details {
  margin-top: 6px;
  padding-top: 7px;
  width: 100%;
  border-top: 1px solid rgb(118 175 255 / 0.14);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--fg-secondary);
  line-height: 1.45;
}

.health-tile-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.health-attn-card {
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.health-attn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.health-detail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.health-detail-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 0 2px;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
}

.health-detail-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.health-detail-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}

.health-detail-meta {
  font-size: 11.5px;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.health-detail-issue {
  font-size: 12px;
  font-weight: 560;
  color: oklch(0.80 0.15 55);
}

.health-detail-snippet {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: #C7D9F2;
  background: var(--surface-input);
  border: 0;
  border-radius: 6px;
  padding: 7px 9px;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.health-log-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding-inline: 2px;
  font-size: 12px;
  font-weight: 560;
  color: var(--accent-sky);
  transition: color 130ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .health-log-toggle:hover {
    color: #BEE3FF;
  }
}

@media (max-width: 720px), (pointer: coarse) {
  .health-log-toggle {
    min-height: 44px;
  }
}

.health-error-log {
  margin: 4px 0 0;
  max-height: 180px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgb(4 9 20 / 0.86);
  border: 0;
  color: #D4E3F8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}

.health-attn-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

@media (max-width: 680px) {
  .health-attn-actions .pill-btn {
    min-height: 44px;
    padding-inline: 12px;
  }
}

.arrange-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding-block: 4px;
}

.spaces-manage-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.spaces-manage-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.space-icon-input {
  width: 44px;
  text-align: center;
  padding: 6px;
  flex-shrink: 0;
}

@media (max-width: 520px) {
  .spaces-manage-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-block: 10px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .spaces-manage-inputs {
    width: 100%;
  }
  .spaces-manage-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }
}

.sq-40 {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-card);
  color: var(--fg-section);
}

.spaces-manage-actions .pill-btn {
  height: 40px;
  border-radius: 10px;
}

@media (max-width: 720px), (pointer: coarse) {
  .sq-40 {
    width: 44px;
    height: 44px;
  }
  .spaces-manage-actions .pill-btn {
    height: 44px;
    min-height: 44px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .sq-40:hover {
    background: var(--surface-pill-hover);
    color: var(--fg);
  }
}

/* ==========================================================================
   Anchored Desktop Popovers (>640px), Toasts & Custom Floating Tooltips
   ========================================================================== */

.popover-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.popover-scrim {
  position: fixed;
  inset: 0;
  pointer-events: auto;
}

.popover-card {
  position: fixed;
  pointer-events: auto;
  min-width: 210px;
  max-width: 290px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-elev-grad);
  border: 1px solid var(--border-control);
  box-shadow: var(--shadow-float), var(--rim-top);
  transform-origin: var(--popover-origin, top right);
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes relayPopoverIn {
    from {
      opacity: 0;
      transform: scale(0.96);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
  .popover-card {
    animation: relayPopoverIn 160ms var(--ease-out) both;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .bulk-bar {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface-2);
  }
  .sheet-scrim {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgb(2 6 16 / 0.88);
  }
}

/* Toasts */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 90;
  width: min(calc(100% - 24px), 460px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 13px;
  background: var(--surface-elev-grad);
  border: 1px solid var(--border-control);
  box-shadow: var(--shadow-float), var(--rim-top);
  font-size: 13px;
  color: var(--fg);
}

.toast-item.is-error {
  border-color: oklch(0.65 0.21 26 / 0.55);
}

.toast-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Custom Floating Tooltip (pointer-events: none) */
.floating-tip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 9px;
  background: #0F1F3D;
  border: 1px solid var(--border-control);
  box-shadow: var(--shadow-float), var(--rim-top);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--fg);
}

/* Empty States, Shimmering Skeletons & Formatted Markdown Prose */
.empty-state {
  padding-block: 26px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  color: var(--fg-muted);
}

.empty-state-inline {
  padding-block: 14px 10px;
}

.empty-title {
  font-size: 14px;
  font-weight: 560;
  color: var(--fg-section);
}

/* Shimmering Placeholder Skeletons (GPU-composited translateX) */
@keyframes relayShimmer {
  0% { transform: translate3d(-100%, 0, 0); }
  100% { transform: translate3d(100%, 0, 0); }
}

.skel-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}

.skel-card {
  background: var(--surface-card-grad);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.skel-bar,
.skel-circle,
.skel-pill {
  position: relative;
  overflow: hidden;
  background: rgb(116 170 255 / 0.08);
}

.skel-bar {
  height: 12px;
  border-radius: 6px;
}

.skel-circle {
  width: 20px;
  height: 20px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

.skel-pill {
  height: 24px;
  width: 68px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .skel-bar::after,
  .skel-circle::after,
  .skel-pill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg in oklab, transparent 0%, rgb(148 198 255 / 0.14) 50%, transparent 100%);
    animation: relayShimmer 1.35s ease-in-out infinite;
  }
}

/* Formatted Markdown Prose inside Thread & Builder Sheets */
.md-prose {
  font-size: 13.5px;
  line-height: 1.54;
  color: var(--fg-project);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-wrap: anywhere;
}

.md-prose h1,
.md-prose h2,
.md-prose h3,
.md-prose h4 {
  font-size: 13.5px;
  font-weight: 660;
  color: #FFFFFF;
  margin-top: 4px;
}

.md-prose p {
  margin: 0;
}

.md-prose ul,
.md-prose ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.md-prose li {
  text-wrap: pretty;
}

.md-prose strong {
  color: #FFFFFF;
  font-weight: 640;
}

.md-prose code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1.5px 5px;
  border-radius: 5px;
  background: rgb(15 31 58 / 0.90);
  border: 1px solid rgb(116 170 255 / 0.16);
  color: #BAE0FF;
}

.md-prose pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-input);
  border: 1px solid var(--border-card);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.md-prose pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
}

.md-prose blockquote {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border-card);
  background: rgb(16 33 63 / 0.42);
  border-radius: 8px;
  color: var(--fg-secondary);
}

.md-prose a {
  color: var(--accent-sky);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.md-prose hr {
  border: 0;
  border-top: 1px solid var(--border-card);
  margin-block: 4px;
}

.md-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  border: 1px solid var(--border-card);
  border-radius: 10px;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  overflow-wrap: normal;
  word-break: normal;
}

.md-table th,
.md-table td {
  padding: 6px 9px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  overflow-wrap: normal;
  word-break: normal;
}

.md-table th {
  font-weight: 640;
  color: #FFFFFF;
  background: rgb(15 31 58 / 0.65);
  white-space: nowrap;
}

.md-table tr:last-child td {
  border-bottom: 0;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

/* ==========================================================================
   Convo Command Inline Expandable Builder Card & Upload/Paste Previews
   ========================================================================== */

.builder-inline-drawer {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 8px;
}

.builder-inline-wrap {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.builder-panel-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg in oklab, #0B1A34 0%, #081326 100%);
  border: 1px solid rgb(116 170 255 / 0.16);
  box-shadow: var(--rim-top);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.builder-panel-card.is-dragover {
  border-color: rgb(96 165 250 / 0.62);
  background: linear-gradient(180deg in oklab, #0E2142 0%, #0A1830 100%);
}

.builder-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.builder-inline-textarea {
  width: 100%;
  min-height: 78px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgb(15 34 66 / 0.52);
  border: 1px solid var(--border-control);
  color: var(--fg);
  font-size: 13.5px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  outline: none;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.builder-inline-textarea::placeholder,
.builder-inline-textarea:empty::before {
  content: attr(data-placeholder);
  color: #84A0C6;
  pointer-events: none;
}

.builder-inline-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgb(77 163 255 / 0.20);
  background: rgb(16 37 72 / 0.68);
}

.builder-inline-textarea.is-invalid {
  border-color: oklch(0.66 0.21 26 / 0.78);
}

@media (max-width: 720px) {
  .builder-inline-textarea {
    font-size: 16px !important;
  }
}

.builder-bottom-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
}

.builder-thread-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: min(100%, 380px);
  padding: 4px;
  border-radius: 8px;
  background: rgb(14 32 62 / 0.56);
  border: 0;
}

.builder-thread-open-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  border-radius: 5px;
  text-align: left;
  color: inherit;
  transition: background-color 130ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .builder-thread-open-btn:hover {
    background: rgb(120 175 255 / 0.08);
  }
}

.builder-thread-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #8CAAD2;
  margin-top: 2px;
  flex-shrink: 0;
}

.builder-thread-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.builder-thread-heading {
  font-size: 13px;
  font-weight: 620;
  color: #F4F8FF;
  line-height: 1.3;
}

.builder-thread-sub {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 11.5px;
  color: #8FAAD0;
  line-height: 1.4;
}

.builder-thread-sub-text {
  min-width: 0;
  white-space: normal;
  text-wrap: pretty;
}

.builder-ctx-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  background: var(--emerald);
  transform: translateY(-0.5px);
}

.builder-ctx-dot.is-working {
  background: var(--sky);
}

.builder-new-thread-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 9px;
  border-radius: 8px;
}

.builder-new-thread-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.builder-new-thread-left .builder-thread-ico {
  margin-top: 0;
}

.builder-new-thread-label {
  font-size: 13px;
  font-weight: 560;
  color: #EBF3FF;
}

.builder-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.builder-media-btns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.builder-cta-pair {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.builder-attach-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding-inline: 9px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 540;
  color: #9BB4D6;
  cursor: pointer;
  transition: background-color 130ms ease, color 130ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .builder-attach-link:hover {
    background: rgb(120 175 255 / 0.08);
    color: #F4F8FF;
  }
}

#builder-file-input:focus-visible + .builder-attach-link {
  outline: 1px solid rgb(96 165 250 / 0.54);
  outline-offset: 1px;
}

.builder-cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding-inline: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 540;
  color: #9BB4D6;
  transition: color 130ms ease, background-color 130ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .builder-cancel-btn:hover {
    color: #FFFFFF;
    background: rgb(255 255 255 / 0.05);
  }
}

.builder-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding-inline: 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 620;
  color: #FFFFFF;
  background: linear-gradient(180deg in oklch, oklch(0.57 0.21 260) 0%, oklch(0.50 0.215 262) 100%);
  border: 1px solid rgb(135 195 255 / 0.34);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16);
  transition: filter 130ms ease, transform 110ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .builder-send-btn:hover {
    filter: brightness(1.07);
  }
}

.builder-send-btn:active {
  transform: scale(0.97);
}

@media (max-width: 620px) {
  .builder-bottom-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .builder-thread-box {
    width: 100%;
  }
  .builder-actions-right {
    width: 100%;
    justify-content: space-between;
  }
  .builder-attach-link,
  .builder-cancel-btn,
  .builder-send-btn {
    min-height: 44px;
  }
  .builder-send-btn {
    padding-inline: 18px;
  }
}

.builder-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-att-card {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border-card);
  background: var(--surface-2);
  flex-shrink: 0;
}

.builder-att-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.builder-att-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgb(5 11 22 / 0.84);
  border: 1px solid rgb(168 208 255 / 0.30);
  color: #FFFFFF;
  transition: background-color 120ms ease, transform 110ms ease;
}

.builder-att-remove::after {
  content: "";
  position: absolute;
  inset: -10px;
}

@media (hover: hover) and (pointer: fine) {
  .builder-att-remove:hover {
    background: oklch(0.55 0.20 26 / 0.92);
  }
}

.builder-att-file {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  max-width: 100%;
  padding: 5px 6px 5px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border-card);
  color: var(--fg-project);
  font-size: 12.5px;
}

.builder-att-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.builder-att-file-meta {
  color: var(--fg-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.builder-att-file-remove {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-secondary);
  flex-shrink: 0;
}

.builder-att-file-remove::after {
  content: "";
  position: absolute;
  inset: -8px;
}

@media (hover: hover) and (pointer: fine) {
  .builder-att-file-remove:hover {
    background: rgb(255 255 255 / 0.08);
    color: #FFFFFF;
  }
}

.builder-status-line {
  font-size: 12px;
  color: var(--accent-sky);
  text-wrap: pretty;
}

.builder-status-line.is-error {
  color: oklch(0.76 0.17 26);
}

.builder-detail-att-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-detail-img-link {
  display: block;
  width: 112px;
  height: 112px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-card);
  background: var(--surface-2);
}

.builder-detail-img-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.agent-att-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent-sky);
  font-weight: 560;
  flex-shrink: 0;
}
