/* ══════════════════════════════════════════════════════════════════
   Train Station — Modal CSS  (Protocol v3.3, regal-stationing-roundhouse S2)
   Visualizes the live train registry. .ts-* namespace mirrors .eo-*.
   ══════════════════════════════════════════════════════════════════ */

/* ── Overlay & Modal Shell ────────────────────────────────────────── */

.ts-overlay {
  position: fixed;
  top: var(--nav-height, 60px);
  left: var(--side-nav-width, 60px);
  right: 0;
  bottom: 0;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.45);
  animation: tsFadeIn 0.2s ease;
}

@keyframes tsFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ts-modal {
  background: #fff;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  animation: tsSlideUp 0.25s ease;
}

@keyframes tsSlideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Header ───────────────────────────────────────────────────────── */

.ts-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.75rem;
  background: linear-gradient(135deg, #0f3057 0%, #1f5f8b 50%, #2c7a9c 100%);
  color: #fff;
  flex-shrink: 0;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.ts-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.ts-header-glyph {
  width: 240px;
  height: 40px;
  flex-shrink: 0;
  position: relative;
  display: none;
}

@media (min-width: 720px) {
  .ts-header-glyph { display: block; }
}

.ts-track-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ts-track-line {
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.5;
}

.ts-tie {
  fill: rgba(255, 255, 255, 0.18);
}

.ts-train-glyph {
  animation: tsTrainSlide 14s linear infinite;
  transform-origin: center;
}

.ts-train-body {
  fill: #ffd166;
  stroke: #f8a01e;
  stroke-width: 1;
}

.ts-train-window {
  fill: #1e3a5f;
}

.ts-train-wheel {
  fill: #2c2c3e;
  stroke: #ffd166;
  stroke-width: 1;
}

.ts-train-stack {
  fill: #ffd166;
}

@keyframes tsTrainSlide {
  0%   { transform: translateX(-40px); }
  100% { transform: translateX(280px); }
}

@media (prefers-reduced-motion: reduce) {
  .ts-train-glyph { animation: none; transform: translateX(120px); }
}

.ts-header-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ts-modal-title {
  margin: 0 0 0.15rem;
  font-size: calc(1.25rem * var(--type-scale, 1));
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.ts-modal-subtitle {
  margin: 0;
  font-size: calc(0.82rem * var(--type-scale, 1));
  color: rgba(255, 255, 255, 0.78);
}

.ts-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.ts-refresh-btn,
.ts-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: calc(1.05rem * var(--type-scale, 1));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.ts-refresh-btn:hover,
.ts-close-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.ts-close-btn {
  font-size: calc(1.4rem * var(--type-scale, 1));
  line-height: 1;
}

/* ── Body ─────────────────────────────────────────────────────────── */

.ts-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem 2rem;
  background: linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
}

.ts-loading,
.ts-empty {
  text-align: center;
  color: #475569;
  padding: 3rem 1rem;
  font-size: calc(0.95rem * var(--type-scale, 1));
}

.ts-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  color: #7f1d1d;
}

.ts-error pre {
  margin: 0.5rem 0 0;
  font-size: calc(0.78rem * var(--type-scale, 1));
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Sections ─────────────────────────────────────────────────────── */

.ts-section {
  margin-bottom: 2rem;
}

.ts-section-title {
  margin: 0 0 0.85rem;
  font-size: calc(0.92rem * var(--type-scale, 1));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #cbd5e1;
}

.ts-section-historical .ts-section-title { color: #64748b; }

/* ── Card Grid ────────────────────────────────────────────────────── */

.ts-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 720px) {
  .ts-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .ts-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Card ─────────────────────────────────────────────────────────── */

.ts-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #cbd5e1;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.ts-card:hover {
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
  transform: translateY(-2px);
}

.ts-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Top row of the card header: status badge (left) + Copy control (right). */
.ts-card-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Copy-to-clipboard control — present on EVERY train card (not admin-gated).
   Copies codename + description + scope/footprint. (Joe directive 2026-06-17.) */
.ts-card-copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: calc(0.72rem * var(--type-scale, 1));
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  opacity: 0.82;
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, opacity 0.15s ease;
}

.ts-card-copy:hover {
  opacity: 1;
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.ts-card-copy:active {
  transform: translateY(1px);
}

.ts-card-copy.ts-copy-ok {
  opacity: 1;
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}

.ts-copy-glyph {
  font-size: calc(0.95rem * var(--type-scale, 1));
  line-height: 1;
}

.ts-card-codename {
  margin: 0;
  font-size: calc(1rem * var(--type-scale, 1));
  font-weight: 600;
  color: #0f172a;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
}

.ts-card-purpose {
  margin: 0;
  font-size: calc(0.85rem * var(--type-scale, 1));
  line-height: 1.45;
  color: #334155;
}

/* D3-B: card title/purpose are click-through into the detail modal. */
.ts-card-clickable {
  cursor: pointer;
  transition: color 0.12s ease;
}

.ts-card-clickable:hover {
  color: #0f3057;
  text-decoration: underline;
  text-decoration-color: rgba(15, 48, 87, 0.35);
  text-underline-offset: 2px;
}

.ts-card-codename.ts-card-clickable:hover {
  color: #2c7a9c;
}

/* Whole-card click-to-detail (the entire panel opens the train detail pop-up).
   Child interactive elements (Launch/Delete buttons, session pills) call
   stopPropagation so they don't also fire this. */
.ts-card-clickable-panel {
  cursor: pointer;
}
.ts-card-clickable-panel:hover {
  box-shadow: 0 2px 14px rgba(15, 48, 87, 0.14);
  transform: translateY(-1px);
  transition: box-shadow 0.14s ease, transform 0.14s ease;
}

/* Clickable session pills (live status panel) → per-session work-plan pop-up. */
.ts-asp-session-clickable {
  cursor: pointer;
}
.ts-asp-session-clickable:hover {
  filter: brightness(1.06);
  outline: 1.5px solid rgba(44, 122, 156, 0.55);
  outline-offset: 1px;
}
.ts-asp-session-clickable:focus-visible {
  outline: 2px solid #2c7a9c;
  outline-offset: 1px;
}

/* ── Badges (Location vocabulary) ─────────────────────────────────── */

.ts-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: calc(0.72rem * var(--type-scale, 1));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: fit-content;
}

.ts-badge-glyph {
  font-size: calc(0.95rem * var(--type-scale, 1));
  line-height: 1;
}

.ts-badge-trainstation {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.ts-badge-muted { opacity: 0.78; }

.ts-badge-enroute {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.ts-badge-arriving {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.ts-badge-arrived {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.ts-badge-paused {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}

.ts-badge-blocked {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.ts-badge-abandoned {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.ts-badge-unknown {
  background: #f9fafb;
  color: #6b7280;
  border: 1px dashed #d1d5db;
}

/* Card left-border tinting per badge family */
.ts-badge-trainstation-card { border-left-color: #3b82f6; }
.ts-badge-enroute-card      { border-left-color: #10b981; }
.ts-badge-arriving-card     { border-left-color: #f59e0b; }
.ts-badge-arrived-card      { border-left-color: #64748b; }
.ts-badge-paused-card       { border-left-color: #a855f7; }
.ts-badge-blocked-card      { border-left-color: #ef4444; }
.ts-badge-abandoned-card    { border-left-color: #94a3b8; }

/* ── Progress Strip ───────────────────────────────────────────────── */

.ts-progress-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.1rem 0 0.2rem;
}

.ts-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  font-size: calc(0.74rem * var(--type-scale, 1));
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
  border: 1px solid transparent;
}

.ts-pill-done {
  background: #d1fae5;
  color: #047857;
  border-color: #a7f3d0;
}

.ts-pill-running {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
  animation: tsPulse 1.6s ease-in-out infinite;
}

.ts-pill-pending {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
}

@keyframes tsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35); }
  50%      { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .ts-pill-running { animation: none; }
}

.ts-card-next {
  margin: 0;
  font-size: calc(0.78rem * var(--type-scale, 1));
  color: #475569;
  font-style: italic;
}

/* ── Card Footer ──────────────────────────────────────────────────── */

.ts-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.55rem;
  border-top: 1px dashed #e2e8f0;
}

.ts-meta-chip {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: calc(0.7rem * var(--type-scale, 1));
  color: #475569;
}

.ts-meta-plan {
  margin-left: auto;
  font-size: calc(0.7rem * var(--type-scale, 1));
  color: #94a3b8;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
  word-break: break-all;
}

/* ── Footer ───────────────────────────────────────────────────────── */

.ts-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1.75rem;
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
  font-size: calc(0.75rem * var(--type-scale, 1));
  color: #64748b;
  flex-shrink: 0;
  gap: 1rem;
}

.ts-footer-meta { font-weight: 500; }
.ts-footer-spec { opacity: 0.85; }

/* ── Parse failures (debug) ───────────────────────────────────────── */

.ts-parse-failures {
  margin-top: 1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  color: #92400e;
  font-size: calc(0.78rem * var(--type-scale, 1));
}

.ts-parse-failures pre {
  margin: 0.5rem 0 0;
  font-size: calc(0.72rem * var(--type-scale, 1));
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Mobile adjustments ───────────────────────────────────────────── */

/* embracing-iphone-immersion S1 D6 (2026-05-12) — Train Station migrates onto
   the universal modal chrome contract. Pre-S1: .ts-overlay sat at top:0 on
   mobile (bespoke full-bleed) which painted the in-modal `.ts-modal-header`
   directly into the iOS status-bar / Dynamic Island gutter, clipping the
   "🚉 Train Station" title behind the Dynamic Island. Post-S1: the overlay
   starts at --mobile-top-bar-total-height (below the FFA top band, which
   itself paints into the safe-area with the TS-blue palette per the body
   [data-modal-palette="train-station"] rule in mobile.css) and ends at
   --mobile-tab-bar-total-height (above the FFA TabBar). The FFA top band
   carries the canonical title "Train Station"; the in-modal `.ts-modal-title`
   text is suppressed on mobile (the band is the title surface, the in-modal
   header still hosts the train glyph + refresh/close buttons as a sub-toolbar
   beneath the band). Train glyph is also hidden on mobile (decorative, not
   load-bearing on a narrow viewport — refresh/close buttons preserved). */
@media (max-width: 720px) {
  .ts-overlay {
    left: 0;
    top: var(--mobile-top-bar-total-height, 0);
    bottom: var(--mobile-tab-bar-total-height, 0);
  }
  .ts-modal-header {
    padding: 0.65rem 1rem;
  }
  .ts-modal-title { font-size: calc(1.05rem * var(--type-scale, 1)); }
  .ts-modal-subtitle { font-size: calc(0.74rem * var(--type-scale, 1)); }
  .ts-modal-body { padding: 1rem 1rem 1.5rem; }
  .ts-card { padding: 0.85rem 0.95rem; }
  .ts-modal-footer { padding: 0.6rem 1rem; font-size: calc(0.7rem * var(--type-scale, 1)); }

  /* D6: title text moved to FFA top band (.mobile-view-title). The in-modal
     header retains the glyph + refresh/close as a sub-toolbar, and the
     subtitle is suppressed because the band's "Train Station" already
     conveys the surface identity. */
  .ts-modal-title { display: none; }
  .ts-modal-subtitle { display: none; }
  .ts-header-text {
    flex: 0 0 auto;
  }
}

/* ── Train Station launcher button (FFA Enrichment tab) ───────────── */

.ts-launcher-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}

.ts-launcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background: var(--ffvr-surface-raised, #fff);
  border: 1px solid var(--ffvr-rule, #cbd5e1);
  border-left: 3px solid #2c7a9c;
  border-radius: 6px;
  color: var(--ffvr-ink, #0f172a);
  font-size: calc(0.84rem * var(--type-scale, 1));
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.ts-launcher-btn:hover {
  background: var(--ffvr-surface, #f1f5f9);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.ts-launcher-btn .ts-launcher-glyph {
  font-size: calc(1rem * var(--type-scale, 1));
  line-height: 1;
}

.ts-launcher-btn--office {
  border-left-color: #1e3a5f;
}

/* ── Card actions (Launch / Delete — admin only) ──────────────────── */
/* steady-mending-anchor S4 — Train Station Half 2.
   Visually quiet by design: confirmation gates are the real protection,
   button color shouldn't bait clicks. */

.ts-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.ts-action {
  flex: 1;
  min-height: 44px;             /* mobile tap target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-size: calc(0.85rem * var(--type-scale, 1));
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, transform 0.1s ease;
}

.ts-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08);
}

.ts-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ts-action-launch {
  border-left: 3px solid #2c7a9c;        /* Enroute teal accent */
}
.ts-action-launch:hover:not(:disabled) {
  background: #ecfeff;
  border-color: #2c7a9c;
  color: #0f3057;
}

.ts-action-delete {
  border-left: 3px solid #b58a8a;        /* muted red — not bright */
  color: #6b3a3a;
}
.ts-action-delete:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #b58a8a;
  color: #7f1d1d;
}

/* Single-button case (no Launch — non-Parked) — let Delete still span row */
.ts-card-actions .ts-action:only-child {
  flex: 1;
}

/* ── Runner-missing actionable error panel (jaunty-chasing-bubble S3) ───── */

.ts-action-error {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: tsFadeIn 0.18s ease;
}

.ts-action-error-card {
  background: #fff;
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  animation: tsSlideUp 0.22s ease;
}

.ts-action-error-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #fde68a;
  background: #fffbeb;
}

.ts-action-error-title {
  margin: 0;
  font-size: calc(1.05rem * var(--type-scale, 1));
  font-weight: 700;
  color: #92400e;
}

.ts-action-error-close {
  background: transparent;
  border: 0;
  font-size: calc(1.5rem * var(--type-scale, 1));
  line-height: 1;
  color: #92400e;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.ts-action-error-close:hover {
  background: rgba(146, 64, 14, 0.1);
}

.ts-action-error-body {
  padding: 1rem 1.25rem 1.25rem;
  color: #1f2937;
  font-size: calc(0.9rem * var(--type-scale, 1));
  line-height: 1.5;
}

.ts-action-error-body p {
  margin: 0 0 0.85rem;
}

.ts-action-error-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 0.85rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
  border-radius: 4px;
  font-size: calc(0.82rem * var(--type-scale, 1));
}

.ts-action-error-meta dt {
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: calc(0.72rem * var(--type-scale, 1));
}

.ts-action-error-meta dd {
  margin: 0;
  color: #1f2937;
}

.ts-action-error-meta code {
  background: #e2e8f0;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-size: calc(0.78rem * var(--type-scale, 1));
}

.ts-action-error-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 6px;
  margin-bottom: 0.85rem;
}

.ts-action-error-sessions-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: calc(0.85rem * var(--type-scale, 1));
  color: #0f3057;
  font-weight: 600;
}

.ts-action-error-sessions-input {
  width: 4rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid #94d2dd;
  border-radius: 4px;
  font-size: calc(0.9rem * var(--type-scale, 1));
  text-align: center;
}

.ts-action-error-cta .ts-action {
  flex: 1;
  min-width: 180px;
}

.ts-action-error-note,
.ts-action-error-mac-note {
  margin: 0.5rem 0 0.85rem;
  font-size: calc(0.8rem * var(--type-scale, 1));
  color: #475569;
  font-style: italic;
}

.ts-action-error-mac-note {
  padding: 0.65rem 0.85rem;
  background: #f3e8ff;
  border-left: 3px solid #a855f7;
  border-radius: 4px;
  font-style: normal;
  color: #6b21a8;
}

.ts-action-error-cmd {
  margin-top: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.ts-action-error-cmd summary {
  cursor: pointer;
  font-size: calc(0.82rem * var(--type-scale, 1));
  font-weight: 600;
  color: #475569;
  user-select: none;
}

.ts-action-error-cmd pre {
  margin: 0.55rem 0 0.5rem;
  padding: 0.55rem 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 4px;
  font-size: calc(0.78rem * var(--type-scale, 1));
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
}

.ts-action-error-copy {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  font-size: calc(0.78rem * var(--type-scale, 1));
  cursor: pointer;
  color: #0f172a;
  font-weight: 600;
}

.ts-action-error-copy:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

@media (max-width: 600px) {
  .ts-action-error-card { border-radius: 8px; }
  .ts-action-error-meta { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .ts-action-error-meta dt { margin-top: 0.45rem; }
}

/* ── Active Status panel (closing-modal-and-zoom-audit S2) ───────────────── */
/*
 * Mobile-first live runner status surface, slotted under .ts-progress-strip
 * on every active-section card. Backend feeds it via 5s polls against
 * GET /api/v1/train-station/active-status/<codename>. Lifecycle owned by
 * train-station-modal.js (_tsStartActiveStatusPolling / _tsStopActiveStatusPolling).
 *
 * Layout discipline: 320px-min readability. Header row wraps when narrow;
 * session strip wraps; log-tail pane scrolls vertically; everything is
 * tap-target friendly without being chrome-heavy.
 */

.ts-active-status-panel {
  margin: 0.45rem 0 0.1rem;
  padding: 0.65rem 0.75rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-left: 3px solid #cbd5e1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: calc(0.82rem * var(--type-scale, 1));
  color: #0f172a;
}

.ts-asp-loading {
  margin: 0;
  font-size: calc(0.78rem * var(--type-scale, 1));
  color: #64748b;
  font-style: italic;
}

.ts-asp-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
}

.ts-asp-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: calc(0.74rem * var(--type-scale, 1));
  font-weight: 600;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ts-asp-indicator-glyph {
  font-size: calc(0.95rem * var(--type-scale, 1));
  line-height: 1;
}

.ts-asp-phase-running {
  background: #d1fae5;
  color: #047857;
  border-color: #a7f3d0;
}

.ts-asp-phase-arriving {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
  animation: tsPulse 1.6s ease-in-out infinite;
}

.ts-asp-phase-complete {
  background: #e2e8f0;
  color: #334155;
  border-color: #cbd5e1;
}

.ts-asp-phase-stopped {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.ts-asp-phase-awaiting {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.ts-asp-phase-error {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.ts-asp-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: calc(0.78rem * var(--type-scale, 1));
  color: #475569;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
}

.ts-asp-meta-muted {
  font-style: italic;
  color: #64748b;
  font-family: inherit;
}

.ts-asp-sep {
  color: #94a3b8;
  font-family: inherit;
}

.ts-asp-pid,
.ts-asp-elapsed {
  white-space: nowrap;
}

/* Session strip — fixed-cell badges showing per-session progress. */
.ts-asp-session-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.ts-asp-session {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  font-size: calc(0.74rem * var(--type-scale, 1));
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
  border: 1px solid transparent;
  min-width: 44px;
  justify-content: center;
}

.ts-asp-session-num { line-height: 1; }
.ts-asp-session-glyph { font-size: calc(0.85rem * var(--type-scale, 1)); line-height: 1; }

.ts-asp-session-done {
  background: #d1fae5;
  color: #047857;
  border-color: #a7f3d0;
}

.ts-asp-session-running {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
  animation: tsPulse 1.6s ease-in-out infinite;
}

.ts-asp-session-failed {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.ts-asp-session-pending {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
}

.ts-asp-session-strip-pending {
  font-style: italic;
}

/* Log tail — fixed-height vertically-scrollable pane. */
.ts-asp-log {
  background: #0f172a;
  border-radius: 5px;
  padding: 0.5rem 0.6rem;
  max-height: 7.2em; /* ~5 lines at 1.3 line-height + padding */
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
}

.ts-asp-log-lines {
  margin: 0;
  font-size: calc(0.72rem * var(--type-scale, 1));
  line-height: 1.4;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

.ts-asp-error-msg {
  margin: 0;
  font-size: calc(0.76rem * var(--type-scale, 1));
  color: #7f1d1d;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 0.4rem 0.55rem;
  word-break: break-word;
}

/* Narrow-viewport tightening — 320px-min readable, session strip + meta
   stack rather than crowd. The panel never causes horizontal overflow on
   the smallest cards. */
@media (max-width: 480px) {
  .ts-active-status-panel {
    padding: 0.55rem 0.6rem;
    gap: 0.5rem;
  }
  .ts-asp-header {
    gap: 0.35rem 0.55rem;
  }
  .ts-asp-meta {
    width: 100%;
    font-size: calc(0.74rem * var(--type-scale, 1));
  }
  .ts-asp-session {
    min-width: 40px;
    padding: 0.12rem 0.38rem;
    font-size: calc(0.7rem * var(--type-scale, 1));
  }
  .ts-asp-log {
    max-height: 6.4em;
    padding: 0.4rem 0.5rem;
  }
  .ts-asp-log-lines {
    font-size: calc(0.68rem * var(--type-scale, 1));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ts-asp-phase-arriving,
  .ts-asp-session-running { animation: none; }
}
