/* ============================================================
   demo.css — the interactive app demo on the homepage

   Everything is prefixed .ttd- so it can never collide with the
   page. Colours come from site.css / home.css tokens; the few
   values defined here are the ones the desktop app fixes in its
   own stylesheet (terminal palette, chrome surfaces).

   Sections:
     1. Section shell + tokens   8. Launch deck
     2. Title bar + tabs         9. Kanban board
     3. Summary bar             10. Overlay: modal, drawer, toast
     4. Splits + tiles          11. Tour strip
     5. Terminal                12. Shared chips, pills, type
     6. Agent tiles             13. Responsive
     7. Web tile                14. Reduced motion
   ============================================================ */

/* ── 1. Section shell + tokens ───────────────────────────── */
.demo-section {
  max-width: calc(var(--shell-max) + 80px);
  margin: 0 auto;
  padding: clamp(56px, 7vw, 88px) var(--shell-pad) 0;
}

.ttd {
  /* Terminal palette, matching the app's VTE colours. */
  --ttd-term-bg: #0f1724;
  --ttd-term-fg: #d7dde8;
  --ttd-cursor: #f2b35f;
  --ttd-red: #ef7c86;
  --ttd-green: #91be78;
  --ttd-yellow: #e6bb6a;
  --ttd-blue: #8fa7ff;
  --ttd-magenta: #c8a6f6;
  --ttd-teal: #7ccad7;

  /* Chrome surfaces. */
  --ttd-copper: #cd6228;
  --ttd-gap: 6px;
  --ttd-stage-h: clamp(430px, 60vh, 660px);

  position: relative;
  font-family: var(--font-sans);
}

.ttd-window {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--win-border);
  border-radius: var(--radius-lg);
  background: var(--win-chrome);
  box-shadow: var(--shadow-lg), 0 0 80px rgba(240, 179, 75, 0.05);
  overflow: hidden;
}

.ttd-stage {
  position: relative;
  height: var(--ttd-stage-h);
  background: #060607;
  overflow: hidden;
}

.ttd-panels,
.ttd-tabpanel,
.ttd-view {
  height: 100%;
}

.ttd-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.ttd-view-deck,
.ttd-view-board {
  overflow: auto;
}

/* Expanded ("Fullscreen") mode stays inside the page. Sits above
   the sticky site nav (z-index 100) and below the site account
   modal (1000). */
.ttd.is-expanded {
  position: fixed;
  inset: 16px;
  z-index: 500;
}
.ttd.is-expanded .ttd-window { height: 100%; }
.ttd.is-expanded .ttd-stage { height: auto; flex: 1; }
.ttd.is-expanded .ttd-tour { display: none; }

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

/* The real focus target for terminal typing. */
.ttd-keyboard {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── 2. Title bar + tabs ─────────────────────────────────── */
.ttd-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 3px 10px;
  border-bottom: 1px solid var(--win-border);
  background:
    linear-gradient(180deg, rgba(16, 16, 20, 0.96), rgba(10, 10, 13, 0.94)),
    radial-gradient(circle at top, rgba(240, 179, 75, 0.05), transparent 32%);
}

.ttd-lights { display: flex; gap: 6px; flex-shrink: 0; }
.ttd-light { width: 10px; height: 10px; border-radius: 50%; }
.ttd-light.r { background: #f16056; }
.ttd-light.y { background: #f5bf4f; }
.ttd-light.g { background: #52c22c; }

.ttd-title-action {
  min-height: 24px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: 600 10px/1 var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ttd-title-action:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-amber);
  color: var(--text-primary);
}
.ttd-title-action.is-cued {
  border-color: var(--border-amber-strong);
  background: var(--accent-amber-bg);
  color: var(--text-amber);
}

.ttd-title-tools { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }

.ttd-tabs {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  flex: 1;
  min-width: 0;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.ttd-tabs::-webkit-scrollbar { display: none; }

.ttd-tab {
  display: inline-flex;
  align-items: center;
  min-width: 128px;
  max-width: 190px;
  border-radius: 10px 10px 0 0 / 7px 7px 0 0;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ttd-tab.is-active {
  background:
    linear-gradient(180deg, rgba(34, 26, 22, 0.98), rgba(21, 16, 13, 0.98)),
    radial-gradient(circle at top, rgba(205, 98, 40, 0.14), transparent 58%);
  border: 1px solid rgba(205, 98, 40, 0.28);
  border-bottom: 2px solid rgba(240, 179, 75, 0.9);
}
.ttd-tab.is-inactive {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.ttd-tab.is-inactive:hover { background: rgba(255, 255, 255, 0.06); }

.ttd-tab-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  min-height: 26px;
  padding: 1px 4px 1px 10px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: 600 11px/1 var(--font-sans);
}
.ttd-tab-select .ttd-icon { color: var(--text-faint); flex-shrink: 0; }
.ttd-tab-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Icon-only controls keep their label for screen readers only. */
.ttd-tab-add .ttd-btn-label,
.ttd-tab-close .ttd-btn-label,
.ttd-tile-action .ttd-btn-label,
.ttd-modal-close .ttd-btn-label,
.ttd-title-action.is-icon .ttd-btn-label,
.ttd-summary-btn.is-icon .ttd-btn-label,
.ttd-pill.is-icon .ttd-btn-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.ttd-tab-close {
  min-width: 20px;
  min-height: 20px;
  margin-right: 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  opacity: 0;
}
.ttd-tab:hover .ttd-tab-close,
.ttd-tab-close:focus-visible { opacity: 1; }
.ttd-tab-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }

.ttd-tab-add {
  min-width: 26px;
  min-height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}
.ttd-tab-add:hover { border-color: var(--border-amber); color: var(--text-amber); }

/* ── 3. Summary bar ──────────────────────────────────────── */
.ttd-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 4px 8px;
  border-bottom: 1px solid var(--win-border);
  background:
    linear-gradient(180deg, rgba(20, 20, 25, 0.96), rgba(10, 10, 14, 0.96)),
    radial-gradient(circle at left, rgba(240, 179, 75, 0.05), transparent 38%);
}

.ttd-ws-name {
  font: 700 12px/1 var(--font-sans);
  color: var(--text-primary);
  white-space: nowrap;
}

.ttd-ws-path {
  margin-left: auto;
  font: 400 10px/1 var(--font-mono);
  color: var(--term-comment);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34%;
}

.ttd-summary-group { display: inline-flex; align-items: center; gap: 4px; }

.ttd-summary-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.ttd-summary-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font: 600 10px/1 var(--font-sans);
}
.ttd-summary-btn:hover { border-color: var(--border-amber); color: var(--text-amber); }
.ttd-summary-btn:disabled { opacity: 0.4; }
.ttd-summary-btn.is-icon { padding: 0 5px; }
.ttd-summary-btn.is-hot { border-color: var(--border-amber-strong); color: var(--text-amber); }
.ttd-summary-btn.is-cued { background: var(--accent-amber-bg); border-color: var(--border-amber-strong); }

.ttd-broadcast-chip.is-off {
  background: transparent;
  border-color: transparent;
  color: var(--text-faint);
}
.ttd-broadcast-chip.is-on {
  background: rgba(240, 179, 75, 0.1);
  border-color: rgba(240, 179, 75, 0.35);
  color: var(--accent-amber);
}

.ttd-select,
.ttd-input {
  min-height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font: 500 10px/1 var(--font-sans);
}
.ttd-input { font-family: var(--font-mono); min-width: 130px; }
.ttd-select:focus-visible,
.ttd-input:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: 1px; }
.ttd-select option { background: var(--win-chrome); color: var(--text-primary); }

/* ── 4. Splits + tiles ───────────────────────────────────── */
.ttd-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  padding: var(--ttd-gap);
  background: #060607;
}

/* Splits and panes share one sizing contract so the renderer can
   set flex-grow on either without caring which it is. */
.ttd-split,
.ttd-pane {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
}
.ttd-split.is-h { flex-direction: row; }
.ttd-split.is-v { flex-direction: column; }
.ttd-pane { overflow: hidden; }
.ttd-pane > * { flex: 1; min-width: 0; }

.ttd-divider {
  flex: 0 0 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  cursor: col-resize;
  touch-action: none;
}
.ttd-split.is-v > .ttd-divider { cursor: row-resize; }
.ttd-divider:hover,
.ttd-divider.is-dragging { background: var(--accent-amber-bg-strong); }
.ttd-divider:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: -1px; }

.ttd-stack {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--ttd-gap);
  min-height: 0;
  overflow-y: auto;
}
/* Stacked tiles get a fixed height so each one scrolls its own
   scrollback instead of stretching the column. */
.ttd-stack > .ttd-pane { flex: 0 0 auto; height: 252px; }

.ttd-tile {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, rgba(16, 18, 23, 0.98), rgba(9, 10, 14, 0.98));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12), inset 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
  transition: border-color var(--t-fast) var(--ease);
}
.ttd-tile:not(.is-active):hover { border-color: rgba(255, 255, 255, 0.14); }
.ttd-tile.is-active { border-color: rgba(240, 179, 75, 0.55); }
.ttd-tile.is-swap-target { border-color: var(--accent-amber); background: rgba(240, 179, 75, 0.06); }
.ttd-tile:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: -2px; }

.ttd-tile-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    radial-gradient(circle at top left, rgba(240, 179, 75, 0.04), transparent 42%);
  font: 500 10.5px/1 var(--font-sans);
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
}
.ttd-tile.is-active .ttd-tile-header {
  border-bottom-color: rgba(240, 179, 75, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.03)),
    radial-gradient(circle at top left, rgba(240, 179, 75, 0.08), transparent 44%);
}
.is-swapping .ttd-tile-header { cursor: grabbing; }

.ttd-tile-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.58);
  font-size: 11.5px;
}
.ttd-tile.is-active .ttd-tile-title { color: rgba(255, 255, 255, 0.82); }

.ttd-tile-ctx {
  color: var(--term-comment);
  font-family: var(--font-mono);
  font-size: 9.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ttd-tile-header .ttd-chip-muted {
  padding: 1px 6px;
  font-size: 9px;
  flex-shrink: 0;
}

/* Narrow tiles drop header extras before they eat the title. */
@container (max-width: 430px) {
  .ttd-tile-header .ttd-chip-muted { display: none; }
}
@container (max-width: 330px) {
  .ttd-tile-ctx { display: none; }
}

.ttd-tile-actions { display: inline-flex; gap: 3px; opacity: 0; }
.ttd-tile:hover .ttd-tile-actions,
.ttd-tile:focus-within .ttd-tile-actions { opacity: 1; }

.ttd-tile-action {
  min-width: 20px;
  min-height: 20px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.66);
}
.ttd-tile-action:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }

.ttd-tile-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--ttd-term-bg);
}

/* Role accents drive the badge fill, as in the app. */
.ttd-badge {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.82);
  font: 600 9.5px/1.35 var(--font-sans);
  white-space: nowrap;
}
.accent-cyan .ttd-badge { background: rgba(89, 212, 226, 0.18); color: #bdeef4; }
.accent-violet .ttd-badge { background: rgba(157, 123, 255, 0.18); color: #d8caff; }
.accent-rose .ttd-badge { background: rgba(255, 122, 162, 0.18); color: #ffd0de; }
.accent-amber .ttd-badge { background: rgba(240, 179, 75, 0.18); color: #ffe0a3; }

/* ── 5. Terminal ─────────────────────────────────────────── */
.ttd-term {
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--ttd-term-bg);
  color: var(--ttd-term-fg);
  font: 400 12px/1.65 var(--font-mono);
  scrollbar-width: thin;
}
.ttd-term::-webkit-scrollbar { width: 6px; }
.ttd-term::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
}

.ttd-line { white-space: pre-wrap; word-break: break-word; }

.ttd-s-usr { color: var(--term-green); }
.ttd-s-path { color: var(--term-cyan); }
.ttd-s-cmt, .ttd-s-dim { color: var(--term-comment); }
.ttd-s-dollar { color: var(--text-amber); }
.ttd-s-out { color: var(--text-muted); }
.ttd-s-ok, .ttd-s-add { color: var(--term-green); }
.ttd-s-err, .ttd-s-del { color: var(--ttd-red); }
.ttd-s-warn, .ttd-s-amber { color: var(--accent-amber); }
.ttd-s-cyan { color: var(--ttd-teal); }
.ttd-s-violet { color: var(--ttd-magenta); }
.ttd-s-rose { color: var(--accent-rose); }
.ttd-s-inv { background: rgba(39, 64, 95, 0.9); }

.ttd-s-caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: var(--ttd-cursor);
  vertical-align: text-bottom;
  animation: ttd-blink 1s steps(1) infinite;
}

@keyframes ttd-blink { 50% { opacity: 0; } }

.ttd-block {
  margin: 4px 0;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}
.ttd-block-agent-banner { border-color: var(--border-amber); }
.ttd-block-agent-ghost {
  margin: 2px 0;
  padding: 3px 9px;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.035);
}

/* ── 6. Agent tiles ──────────────────────────────────────── */
.ttd-agent-prompt {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 8px 4px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font: 400 12px/1.5 var(--font-mono);
  color: var(--ttd-term-fg);
}
.ttd-agent-prompt.is-focused { border-color: var(--border-amber-strong); }
.ttd-agent-prompt.is-running { opacity: 0.6; }
.ttd-agent-glyph { color: var(--accent-amber); }
.ttd-agent-field { flex: 1; min-width: 0; word-break: break-word; }
.ttd-agent-placeholder { color: var(--term-comment); }
.ttd-agent-caret {
  display: none;
  width: 7px;
  height: 1em;
  background: var(--ttd-cursor);
  vertical-align: text-bottom;
  animation: ttd-blink 1s steps(1) infinite;
}
.ttd-agent-prompt.is-focused .ttd-agent-caret { display: inline-block; }

.ttd-agent-status {
  padding: 0 10px 6px;
  font: 400 10px/1.4 var(--font-mono);
  color: var(--term-comment);
}

/* ── 7. Web tile ─────────────────────────────────────────── */
.ttd-tile-web .ttd-tile-body { background: #0b0b0f; }
.ttd-web-bar {
  padding: 5px 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font: 400 10px/1 var(--font-mono);
  color: var(--term-comment);
}
.ttd-web-page { padding: 14px; }
.ttd-web-title { font: 600 13px/1.4 var(--font-sans); color: var(--text-primary); }

/* ── 8. Launch deck ──────────────────────────────────────── */
.ttd-deck { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.ttd-deck-stack { display: flex; flex-direction: column; gap: 12px; }

.ttd-panel {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ttd-deck-header { display: flex; align-items: center; gap: 12px; }
.ttd-deck-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-amber);
  border-radius: var(--radius-sm);
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  flex-shrink: 0;
}
.ttd-deck-header-copy { flex: 1; min-width: 0; }
.ttd-deck-meta { display: flex; gap: 5px; flex-wrap: wrap; }

.ttd-deck-hero { display: flex; align-items: center; gap: 12px; }
.ttd-deck-hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.ttd-menu-anchor { position: relative; }
.ttd-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 232px;
  padding: 5px;
  border: 1px solid var(--border-subtle-hover);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}
/* popover.js positions open menus at the viewport so scroll
   containers (Kanban columns, the deck) can never clip them. */
.ttd-menu.is-floating {
  position: fixed;
  right: auto;
  top: auto;
  z-index: 45;
}

.ttd-menu-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}
.ttd-menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.ttd-menu-title { font: 600 12px/1.3 var(--font-sans); color: var(--text-primary); }

.ttd-section-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }

.ttd-board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.ttd-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.ttd-card-head { display: flex; align-items: center; gap: 8px; }
.ttd-card-title { font: 700 12.5px/1.35 var(--font-sans); color: #f5f5f1; flex: 1; min-width: 0; }
.ttd-card-meta { font: 400 11px/1.5 var(--font-sans); color: rgba(255, 255, 255, 0.56); }
.ttd-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.ttd-card-path {
  flex: 1 1 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.ttd-card-actions { display: inline-flex; gap: 5px; }

.ttd-ws-list { display: flex; flex-direction: column; }
.ttd-ws-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.ttd-ws-row:last-child { border-bottom: 0; }
.ttd-ws-row-path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 11px/1.4 var(--font-mono);
  color: var(--text-faint);
}
.ttd-ws-row-actions { display: inline-flex; gap: 5px; opacity: 0; }
.ttd-ws-row:hover .ttd-ws-row-actions,
.ttd-ws-row:focus-within .ttd-ws-row-actions { opacity: 1; }

.ttd-wizard-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.ttd-step-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font: 600 10.5px/1 var(--font-sans);
}
.ttd-step-chip.is-active {
  border-color: var(--border-amber-strong);
  background: var(--accent-amber-bg);
  color: var(--text-amber);
}
.ttd-step-index {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-size: 9px;
}

.ttd-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 9px;
  margin-top: 8px;
}
.ttd-template {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
}
.ttd-template:hover { border-color: var(--border-subtle-hover); }
.ttd-template.is-active { border-color: var(--border-amber-strong); background: rgba(240, 179, 75, 0.07); }
.ttd-template-label { font: 600 12px/1.3 var(--font-sans); color: var(--text-primary); }
.ttd-template-preview {
  display: grid;
  gap: 3px;
  height: 52px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: #08080a;
}
.ttd-template-cell { background: rgba(240, 179, 75, 0.16); border-radius: 2px; }

.ttd-review {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 5px 14px;
  margin: 8px 0 12px;
}
.ttd-review-value { font: 500 12px/1.4 var(--font-mono); color: var(--text-secondary); }

/* ── 9. Kanban board ─────────────────────────────────────── */
.ttd-board { display: flex; flex-direction: column; gap: 10px; padding: 12px; height: 100%; }

.ttd-board-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ttd-board-title { font: 700 15px/1.2 var(--font-display); color: var(--text-primary); }
.ttd-board-actions { display: inline-flex; gap: 5px; margin-left: auto; flex-wrap: wrap; }

.ttd-kcolumns {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.ttd-kcol {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
}
.ttd-kcol.is-drop-target { border-color: var(--accent-amber); background: rgba(240, 179, 75, 0.08); }

.ttd-kcol-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.ttd-kdot { width: 7px; height: 7px; background: rgba(255, 255, 255, 0.45); flex-shrink: 0; }
.is-progress .ttd-kdot { background: var(--accent-amber); }
.is-review .ttd-kdot { background: var(--ttd-copper); }
.is-complete .ttd-kdot { background: #7ac67a; }
.is-cancelled .ttd-kdot { background: #ff6868; }

.ttd-count {
  margin-left: auto;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
  font: 600 10px/1.5 var(--font-sans);
}

.ttd-kcol-body { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; min-height: 40px; }
.ttd-kcol-empty { padding: 6px 2px; }

.ttd-kcard {
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.03);
  cursor: grab;
  touch-action: none;
}
.ttd-kcard.is-progress { border-left-color: var(--accent-amber); }
.ttd-kcard.is-review { border-left-color: var(--ttd-copper); }
.ttd-kcard.is-complete { border-left-color: #7ac67a; }
.ttd-kcard.is-cancelled { border-left-color: #ff6868; }
.ttd-kcard:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: -2px; }
.ttd-kcard.is-dragging { opacity: 0.35; }

.ttd-kcard-ghost {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  opacity: 0.92;
}

.ttd-kcard-body {
  margin: 4px 0 6px;
  font: 400 11px/1.5 var(--font-sans);
  color: rgba(255, 255, 255, 0.56);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ttd-kcard-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.ttd-assignee {
  padding: 1px 6px;
  background: var(--accent-amber);
  color: #111216;
  font: 600 9.5px/1.5 var(--font-mono);
}
.ttd-chip-mini {
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-faint);
  font: 500 9.5px/1.5 var(--font-sans);
}
.ttd-chip-mini.is-lifecycle { color: var(--accent-amber); border-color: var(--border-amber); }

.ttd-kcard-notes { margin-top: 6px; font: 400 10px/1.6 var(--font-mono); }
.ttd-kcard-note { white-space: pre-wrap; }

.ttd-kcard-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ttd-card-menu { min-width: 168px; }

/* ── 10. Overlay: modal, drawer, toast ───────────────────── */
.ttd-modal-layer { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; }
.ttd-scrim { position: absolute; inset: 0; background: rgba(3, 3, 3, 0.72); }

.ttd-modal {
  position: relative;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle-hover);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ttd-modal.is-confirm { width: min(420px, calc(100% - 32px)); }

.ttd-modal-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.ttd-modal-title { font: 700 14px/1.3 var(--font-display); color: var(--text-primary); }
.ttd-modal-sub { margin-top: 3px; font: 400 11px/1.4 var(--font-mono); color: var(--text-faint); }
.ttd-modal-close {
  margin-left: auto;
  min-width: 24px;
  min-height: 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}
.ttd-modal-body { padding: 13px 14px; overflow-y: auto; }
.ttd-modal-copy { font: 400 12.5px/1.6 var(--font-sans); color: var(--text-muted); }
.ttd-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 11px 14px;
  border-top: 1px solid var(--border-subtle);
}

.ttd-mcp-rows { display: flex; flex-direction: column; gap: 6px; }
.ttd-mcp-row,
.ttd-mcp-project {
  display: grid;
  grid-template-columns: 74px 1fr auto auto;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}
.ttd-mcp-label { font: 600 11px/1.3 var(--font-sans); color: var(--text-primary); }
.ttd-mcp-value {
  font: 400 10.5px/1.4 var(--font-mono);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
}
.ttd-mcp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font: 600 9.5px/1.5 var(--font-sans);
  white-space: nowrap;
}
.ttd-mcp-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ttd-mcp-badge.is-ready { color: var(--accent-success); border-color: rgba(74, 222, 128, 0.3); }
.ttd-mcp-badge.is-warn { color: var(--accent-amber); border-color: var(--border-amber); }
.ttd-mcp-badge.is-error { color: var(--accent-rose); border-color: rgba(255, 122, 162, 0.3); }
.ttd-mcp-projects { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }

.ttd-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  width: min(320px, 86%);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle-hover);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--t-med) var(--ease);
}
.ttd-drawer.is-open { transform: none; }
.ttd-drawer-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.ttd-drawer-title { flex: 1; font: 700 12.5px/1.3 var(--font-display); color: var(--text-primary); }
.ttd-drawer-body { padding: 10px 12px; overflow-y: auto; }

.ttd-alert-list { display: flex; flex-direction: column; gap: 7px; list-style: none; }
.ttd-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}
.ttd-alert.is-read { opacity: 0.55; }
.ttd-alert-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ttd-alert-dot.is-info { background: var(--accent-cyan); }
.ttd-alert-dot.is-warning { background: var(--accent-amber); }
.ttd-alert-dot.is-error { background: var(--accent-rose); }
.ttd-alert-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ttd-alert-source { font: 600 10px/1.3 var(--font-mono); color: var(--text-amber); }
.ttd-alert-text { font: 400 11px/1.4 var(--font-sans); color: var(--text-muted); }

.ttd-toasts {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}
.ttd-toast {
  padding: 7px 13px;
  border: 1px solid var(--border-amber);
  border-radius: var(--radius-pill);
  background: rgba(10, 10, 13, 0.96);
  color: var(--text-secondary);
  font: 500 11.5px/1.4 var(--font-sans);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.ttd-toast.is-visible { opacity: 1; transform: none; }

/* ── 11. Tour strip ──────────────────────────────────────── */
.ttd-tour {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 0 4px;
}
.ttd-tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.ttd-tour.is-playing .ttd-tour-dot {
  background: var(--accent-success);
  animation: ttd-pulse 2s ease-in-out infinite;
}
.ttd-tour.is-paused .ttd-tour-dot { background: var(--accent-amber); }

@keyframes ttd-pulse { 50% { opacity: 0.4; } }

.ttd-tour-caption {
  flex: 1;
  min-width: 0;
  font: 500 12px/1.5 var(--font-mono);
  color: var(--text-faint);
}
.ttd-tour-actions { display: inline-flex; gap: 6px; flex-shrink: 0; }

.ttd-hint-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  pointer-events: none;
  padding: 6px 12px;
  border: 1px solid var(--border-amber-strong);
  border-radius: var(--radius-pill);
  background: rgba(10, 10, 13, 0.97);
  color: var(--text-amber);
  font: 500 11.5px/1.4 var(--font-sans);
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

/* ── 12. Shared chips, pills, type ───────────────────────── */
.ttd button,
.ttd .ttd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.ttd button:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: 2px; }

/* Author styles beat the UA [hidden] rule, so restate it. */
.ttd [hidden] { display: none; }

.ttd-icon { flex-shrink: 0; }

.ttd-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.82);
  font: 600 10px/1.6 var(--font-sans);
  white-space: nowrap;
}
.ttd-chip-muted { color: rgba(255, 255, 255, 0.56); }
.ttd-chip-kind { color: var(--accent-amber); border-color: var(--border-amber); }

.ttd-pill {
  min-height: 27px;
  padding: 4px 13px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.86);
  font: 600 11px/1.2 var(--font-sans);
}
.ttd-pill:hover { border-color: var(--border-amber); color: var(--text-amber); }
.ttd-pill.is-small { min-height: 22px; padding: 2px 9px; font-size: 10px; }
.ttd-pill.is-icon { padding: 2px 7px; }
.ttd-pill.is-primary {
  background: linear-gradient(180deg, #fffdf7 0%, #f7efd9 48%, #eadcbd 100%);
  border-color: rgba(255, 246, 221, 0.98);
  color: #111216;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(240, 179, 75, 0.16);
}
.ttd-pill.is-primary:hover { color: #111216; filter: brightness(1.04); }
.ttd-pill.is-danger { color: var(--accent-rose); border-color: rgba(255, 122, 162, 0.24); }
.ttd-pill.is-cued { box-shadow: var(--shadow-amber-glow); }

.ttd-eyebrow {
  font: 600 9px/1.6 var(--font-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 224, 163, 0.7);
}
.ttd-hero-title { font: 700 16px/1.3 var(--font-display); color: #f8f7f2; }
.ttd-hero-body,
.ttd-hint { font: 400 11.5px/1.5 var(--font-sans); color: rgba(255, 255, 255, 0.56); }
.ttd-section-title { font: 700 13.5px/1.3 var(--font-display); color: #f5f5f1; }

/* ── 13. Responsive ──────────────────────────────────────── */
@media (max-width: 960px) {
  .ttd-ws-path { display: none; }
  .ttd-kcolumns { grid-template-columns: repeat(3, minmax(200px, 1fr)); overflow-x: auto; }
}

@media (max-width: 760px) {
  .ttd { --ttd-stage-h: clamp(460px, 72vh, 620px); }
  .ttd-title-action .ttd-btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .ttd-tabs { justify-content: flex-start; }
  .ttd-tab { min-width: 104px; }
  .ttd-summary { gap: 4px; }
  .ttd-summary-divider { display: none; }
  .ttd-board-grid { grid-template-columns: 1fr; }
  .ttd-kcolumns {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }
  .ttd-kcol { flex: 0 0 76%; scroll-snap-align: start; }
  .ttd-ws-row { flex-wrap: wrap; }
  .ttd-ws-row-actions { opacity: 1; }
  .ttd-tile-actions { opacity: 1; }
}

@media (max-width: 600px) {
  .ttd-term { font-size: 11.5px; }
  .ttd-tile-header { gap: 5px; }
  .ttd-tile-ctx { display: none; }
  .ttd-tour { flex-wrap: wrap; }
  .ttd-hint-bubble { white-space: normal; max-width: 92vw; }
}

@media (max-width: 480px) {
  .ttd-template-grid { grid-template-columns: repeat(2, 1fr); }
  .ttd-review { grid-template-columns: 1fr; gap: 2px; }
  .ttd-modal { width: calc(100% - 16px); }
}

/* ── 14. Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ttd-s-caret,
  .ttd-agent-caret,
  .ttd-tour.is-playing .ttd-tour-dot { animation: none; }
  .ttd-drawer,
  .ttd-toast,
  .ttd button,
  .ttd .ttd-btn,
  .ttd-tile { transition: none; }
}
