/* BioUI Web — Default Theme
 * Override any variable to customize. No Shadow DOM — normal CSS selectors work.
 */

:root {
  /* Primary palette */
  --bio-primary: #5a8a6a;
  --bio-primary-hover: #4a7a5a;
  --bio-primary-fg: #ffffff;
  --bio-accent: #6bbfb0;
  --bio-accent-fg: #ffffff;

  /* Surface */
  --bio-surface: #ffffff;
  --bio-surface-fg: #1a1a1a;
  --bio-surface-muted: #f8fafc;
  --bio-surface-muted-fg: #64748b;
  --bio-border: #e2e8f0;

  /* Radius & spacing */
  --bio-radius: 8px;
  --bio-radius-lg: 12px;
  --bio-spacing-xs: 4px;
  --bio-spacing-sm: 8px;
  --bio-spacing-md: 16px;
  --bio-spacing-lg: 24px;
  --bio-spacing-xl: 32px;

  /* Typography */
  --bio-font: 'system-ui', -apple-system, sans-serif;
  --bio-font-size-xs: 0.75rem;
  --bio-font-size-sm: 0.875rem;
  --bio-font-size-base: 1rem;
  --bio-font-size-lg: 1.125rem;
  --bio-font-size-xl: 1.25rem;
  --bio-font-weight-normal: 400;
  --bio-font-weight-medium: 500;
  --bio-font-weight-bold: 600;

  /* Mood colors */
  --bio-mood-great: #22c55e;
  --bio-mood-good: #84cc16;
  --bio-mood-okay: #eab308;
  --bio-mood-bitoff: #f97316;
  --bio-mood-notbest: #ef4444;

  /* Status/readiness */
  --bio-status-green: #22c55e;
  --bio-status-yellow: #eab308;
  --bio-status-red: #ef4444;

  /* Trend */
  --bio-trend-improving: #22c55e;
  --bio-trend-stable: #64748b;
  --bio-trend-declining: #ef4444;

  /* Shadows */
  --bio-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --bio-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --bio-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --bio-transition: 150ms ease;

  /* Editorial typography + pill radius (added for program-builder; reusable
     across any widget that wants a serif headline, mono accents, or a
     fully-rounded radius). */
  --bio-font-serif: 'Newsreader', 'Source Serif Pro', Georgia, serif;
  --bio-font-mono: 'DM Mono', 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
  --bio-radius-pill: 9999px;
}

/* Base widget styles */
bio-provider {
  display: contents;
}

[data-bio-widget] {
  font-family: var(--bio-font);
  font-size: var(--bio-font-size-base);
  color: var(--bio-surface-fg);
  line-height: 1.5;
  box-sizing: border-box;
}

[data-bio-widget] *, [data-bio-widget] *::before, [data-bio-widget] *::after {
  box-sizing: inherit;
}

/* Loading state — legacy attribute (still works) */
[data-bio-loading] {
  opacity: 0.6;
  pointer-events: none;
}

/* Error state — legacy attribute (still works) */
[data-bio-error] {
  border: 1px solid var(--bio-status-red);
  padding: var(--bio-spacing-md);
  border-radius: var(--bio-radius);
  color: var(--bio-status-red);
  font-size: var(--bio-font-size-sm);
}

/* ========================================
   Shared loading indicator (skeleton shimmer)
   ======================================== */
.bio-loading-container {
  padding: var(--bio-spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-sm);
}

.bio-loading-shimmer {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--bio-color-surface-alt, #f0f0f0) 25%,
    var(--bio-color-surface, #e0e0e0) 50%,
    var(--bio-color-surface-alt, #f0f0f0) 75%
  );
  background-size: 200% 100%;
  animation: bio-shimmer 1.5s ease-in-out infinite;
}

.bio-loading-shimmer-short {
  width: 40%;
}

.bio-loading-shimmer-medium {
  width: 70%;
}

@keyframes bio-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================
   Shared error indicator (friendly, not alarming)
   ======================================== */
.bio-error-container {
  display: flex;
  align-items: flex-start;
  gap: var(--bio-spacing-sm);
  padding: var(--bio-spacing-md);
  border-radius: var(--bio-radius);
  background: var(--bio-color-surface-alt, #f9fafb);
  border: 1px solid var(--bio-color-border, #e5e7eb);
  color: var(--bio-color-text-secondary, #6b7280);
  font-size: var(--bio-font-size-sm);
}

.bio-error-icon {
  flex-shrink: 0;
  color: var(--bio-color-text-secondary, #9ca3af);
  margin-top: 1px;
}

.bio-error-message {
  margin: 0;
  line-height: 1.4;
}

/* Mood widget */
.bio-mood-buttons {
  display: flex;
  justify-content: center;
  gap: var(--bio-spacing-sm);
}

.bio-mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bio-spacing-xs);
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  border-radius: var(--bio-radius-lg);
  border: 2px solid transparent;
  background: var(--bio-surface);
  cursor: pointer;
  transition: all var(--bio-transition);
}

.bio-mood-btn:hover {
  background: color-mix(in srgb, var(--mood-color) 15%, var(--bio-surface));
}

.bio-mood-selected {
  background: color-mix(in srgb, var(--mood-color) 20%, var(--bio-surface));
  border-color: var(--mood-color);
}

.bio-mood-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.bio-mood-status {
  text-align: center;
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  margin-top: var(--bio-spacing-sm);
}

/* Check-in summary (completed state) */
.bio-checkin-summary {
  background: var(--bio-surface);
  border-radius: var(--bio-radius-lg);
  padding: var(--bio-spacing-lg);
  box-shadow: var(--bio-shadow-md);
}

.bio-checkin-summary h3 {
  font-size: var(--bio-font-size-lg);
  font-weight: var(--bio-font-weight-bold);
  margin: 0 0 var(--bio-spacing-md) 0;
  color: var(--bio-primary);
}

.bio-checkin-results {
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-sm);
  margin-bottom: var(--bio-spacing-md);
}

.bio-checkin-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  background: var(--bio-surface-muted);
  border-radius: var(--bio-radius);
}

.bio-checkin-result-item span:first-child {
  text-transform: capitalize;
  font-weight: var(--bio-font-weight-medium);
}

.bio-checkin-score {
  font-size: var(--bio-font-size-xl);
  font-weight: var(--bio-font-weight-bold);
  color: var(--bio-primary);
  min-width: 2ch;
  text-align: center;
}

.bio-checkin-trend {
  margin-left: var(--bio-spacing-sm);
  font-size: var(--bio-font-size-lg);
}

.bio-checkin-trend[data-trend="increasing"] {
  color: var(--bio-trend-improving);
}

.bio-checkin-trend[data-trend="stable"] {
  color: var(--bio-trend-stable);
}

.bio-checkin-trend[data-trend="decreasing"] {
  color: var(--bio-trend-declining);
}

.bio-checkin-submitted-at {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  margin-bottom: var(--bio-spacing-md);
}

.bio-checkin-update-btn {
  display: inline-flex;
  align-items: center;
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  border-radius: var(--bio-radius);
  border: 1px solid var(--bio-border);
  background: var(--bio-surface);
  color: var(--bio-surface-fg);
  font-size: var(--bio-font-size-sm);
  font-weight: var(--bio-font-weight-medium);
  cursor: pointer;
  transition: all var(--bio-transition);
}

.bio-checkin-update-btn:hover {
  border-color: var(--bio-primary);
  color: var(--bio-primary);
}

/* Check-in overlay (pending/active state) */
.bio-checkin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--bio-spacing-md);
}

.bio-checkin-modal {
  background: var(--bio-surface);
  border-radius: var(--bio-radius-lg);
  padding: var(--bio-spacing-lg);
  box-shadow: var(--bio-shadow-lg);
  width: 100%;
  max-width: 400px;
}

.bio-checkin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--bio-spacing-md);
}

.bio-checkin-step {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  font-weight: var(--bio-font-weight-medium);
}

.bio-checkin-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--bio-surface-muted-fg);
  padding: 0;
  line-height: 1;
}

.bio-checkin-close:hover {
  color: var(--bio-surface-fg);
}

.bio-checkin-question {
  font-size: var(--bio-font-size-lg);
  font-weight: var(--bio-font-weight-bold);
  margin: 0 0 var(--bio-spacing-sm) 0;
}

.bio-checkin-prior {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  margin-bottom: var(--bio-spacing-md);
}

.bio-checkin-scale {
  display: flex;
  gap: var(--bio-spacing-xs);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--bio-spacing-sm);
}

.bio-checkin-scale-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--bio-border);
  background: var(--bio-surface);
  cursor: pointer;
  font-weight: var(--bio-font-weight-medium);
  font-size: var(--bio-font-size-sm);
  transition: all var(--bio-transition);
}

.bio-checkin-scale-btn:hover {
  border-color: var(--bio-primary);
  background: color-mix(in srgb, var(--bio-primary) 10%, var(--bio-surface));
  color: var(--bio-primary);
}

.bio-checkin-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--bio-font-size-xs);
  color: var(--bio-surface-muted-fg);
}

.bio-checkin-done-btn {
  display: block;
  width: 100%;
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  margin-top: var(--bio-spacing-md);
  border-radius: var(--bio-radius);
  border: none;
  background: var(--bio-primary);
  color: var(--bio-primary-fg);
  font-weight: var(--bio-font-weight-medium);
  cursor: pointer;
  transition: background var(--bio-transition);
}

.bio-checkin-done-btn:hover {
  background: var(--bio-primary-hover);
}

/* Progress ring */
.bio-progress-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bio-spacing-xs);
}

.bio-progress-ring-label {
  display: flex;
  gap: var(--bio-spacing-xs);
  align-items: baseline;
}

.bio-progress-ring-day {
  font-size: var(--bio-font-size-xl);
  font-weight: var(--bio-font-weight-bold);
}

.bio-progress-ring-total {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

.bio-progress-ring-adherence {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

.bio-progress-ring-streak {
  font-size: var(--bio-font-size-sm);
  font-weight: var(--bio-font-weight-medium);
  color: var(--bio-status-yellow);
}

/* Health metrics widget */
.bio-hm {
  font-family: var(--bio-font);
  color: var(--bio-surface-fg);
}

.bio-hm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bio-spacing-md);
  padding: var(--bio-spacing-xl);
  border: 2px dashed var(--bio-border);
  border-radius: var(--bio-radius-lg);
  text-align: center;
}

.bio-hm-empty-icon {
  font-size: 2.5rem;
  opacity: 0.6;
}

.bio-hm-empty-title {
  font-size: var(--bio-font-size-lg);
  font-weight: var(--bio-font-weight-bold);
}

.bio-hm-empty-desc {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

.bio-hm-connect-btn {
  padding: var(--bio-spacing-sm) var(--bio-spacing-lg);
  border-radius: var(--bio-radius);
  border: none;
  background: var(--bio-primary);
  color: var(--bio-primary-fg);
  font-weight: var(--bio-font-weight-medium);
  cursor: pointer;
  transition: background var(--bio-transition);
}

.bio-hm-connect-btn:hover {
  background: var(--bio-primary-hover);
}

/* Provider selection */
.bio-hm-providers {
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-sm);
  padding: var(--bio-spacing-md);
}

.bio-hm-provider {
  display: flex;
  align-items: center;
  gap: var(--bio-spacing-md);
  padding: var(--bio-spacing-md);
  border: 1px solid var(--bio-border);
  border-radius: var(--bio-radius);
  background: var(--bio-surface);
  cursor: pointer;
  transition: all var(--bio-transition);
  text-align: left;
}

.bio-hm-provider:hover {
  border-color: var(--bio-primary);
  background: var(--bio-surface-muted);
}

.bio-hm-provider-connecting {
  opacity: 0.7;
  pointer-events: none;
}

.bio-hm-provider-icon {
  font-size: 1.5rem;
}

.bio-hm-provider-name {
  font-weight: var(--bio-font-weight-medium);
}

.bio-hm-provider-desc {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

.bio-hm-provider-status {
  margin-left: auto;
  font-size: var(--bio-font-size-sm);
  color: var(--bio-primary);
}

.bio-hm-back-btn {
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  border: 1px solid var(--bio-border);
  border-radius: var(--bio-radius);
  background: var(--bio-surface);
  cursor: pointer;
  font-size: var(--bio-font-size-sm);
}

/* Connected header */
.bio-hm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--bio-spacing-xs);
}

.bio-hm-device {
  display: flex;
  align-items: center;
  gap: var(--bio-spacing-sm);
}

.bio-hm-device-icon {
  font-size: 1.25rem;
}

.bio-hm-device-name {
  font-weight: var(--bio-font-weight-bold);
}

.bio-hm-actions {
  display: flex;
  gap: var(--bio-spacing-xs);
}

.bio-hm-refresh-btn,
.bio-hm-settings-btn {
  background: none;
  border: 1px solid var(--bio-border);
  border-radius: var(--bio-radius);
  padding: var(--bio-spacing-xs) var(--bio-spacing-sm);
  cursor: pointer;
  font-size: var(--bio-font-size-base);
  transition: all var(--bio-transition);
}

.bio-hm-refresh-btn:hover,
.bio-hm-settings-btn:hover {
  border-color: var(--bio-primary);
  color: var(--bio-primary);
}

.bio-hm-sync-status {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  margin-bottom: var(--bio-spacing-md);
}

/* Metrics grid */
.bio-hm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--bio-spacing-md);
}

.bio-hm-grid-compact {
  grid-template-columns: repeat(2, 1fr);
}

.bio-hm-metric {
  padding: var(--bio-spacing-md);
  background: var(--bio-surface-muted);
  border-radius: var(--bio-radius);
}

.bio-hm-metric-skeleton {
  height: 100px;
  opacity: 0.4;
  animation: bio-hm-pulse 1.5s ease-in-out infinite;
}

@keyframes bio-hm-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.2; }
}

.bio-hm-metric-header {
  display: flex;
  align-items: center;
  gap: var(--bio-spacing-xs);
  margin-bottom: var(--bio-spacing-sm);
}

.bio-hm-metric-icon {
  font-size: var(--bio-font-size-base);
}

.bio-hm-metric-label {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  font-weight: var(--bio-font-weight-medium);
}

.bio-hm-metric-value {
  font-size: var(--bio-font-size-xl);
  font-weight: var(--bio-font-weight-bold);
}

.bio-hm-metric-unit {
  font-size: var(--bio-font-size-sm);
  font-weight: var(--bio-font-weight-normal);
  color: var(--bio-surface-muted-fg);
}

.bio-hm-metric-detail {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  margin-top: var(--bio-spacing-xs);
}

.bio-hm-metric-progress {
  height: 6px;
  background: var(--bio-border);
  border-radius: 3px;
  margin-top: var(--bio-spacing-sm);
  overflow: hidden;
}

.bio-hm-metric-progress-bar {
  height: 100%;
  background: var(--bio-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.bio-hm-metric-badge {
  display: inline-block;
  padding: 2px var(--bio-spacing-sm);
  border-radius: 9999px;
  font-size: var(--bio-font-size-xs);
  font-weight: var(--bio-font-weight-medium);
  text-transform: capitalize;
  margin-top: var(--bio-spacing-xs);
}

.bio-hm-metric-badge[data-level="excellent"],
.bio-hm-metric-badge[data-level="low"] {
  background: color-mix(in srgb, var(--bio-status-green) 15%, transparent);
  color: var(--bio-status-green);
}

.bio-hm-metric-badge[data-level="good"] {
  background: color-mix(in srgb, var(--bio-primary) 15%, transparent);
  color: var(--bio-primary);
}

.bio-hm-metric-badge[data-level="fair"],
.bio-hm-metric-badge[data-level="moderate"] {
  background: color-mix(in srgb, var(--bio-status-yellow) 15%, transparent);
  color: var(--bio-status-yellow);
}

.bio-hm-metric-badge[data-level="poor"],
.bio-hm-metric-badge[data-level="high"] {
  background: color-mix(in srgb, var(--bio-status-red) 15%, transparent);
  color: var(--bio-status-red);
}

.bio-hm-metric-sub {
  font-size: var(--bio-font-size-xs);
  color: var(--bio-surface-muted-fg);
  margin-top: var(--bio-spacing-xs);
}

/* Settings panel */
.bio-hm-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--bio-spacing-md);
  background: var(--bio-surface-muted);
  border-radius: var(--bio-radius);
  margin-bottom: var(--bio-spacing-md);
}

.bio-hm-settings-provider {
  display: flex;
  align-items: center;
  gap: var(--bio-spacing-sm);
}

.bio-hm-settings-status {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-status-green);
}

.bio-hm-disconnect-btn {
  padding: var(--bio-spacing-xs) var(--bio-spacing-md);
  border: 1px solid var(--bio-status-red);
  border-radius: var(--bio-radius);
  background: none;
  color: var(--bio-status-red);
  font-size: var(--bio-font-size-sm);
  cursor: pointer;
  transition: all var(--bio-transition);
}

.bio-hm-disconnect-btn:hover {
  background: color-mix(in srgb, var(--bio-status-red) 10%, transparent);
}

/* Journal widget */
.bio-journal {
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-sm);
}

.bio-journal-prompt {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  font-style: italic;
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  background: var(--bio-surface-muted);
  border-radius: var(--bio-radius);
  border-left: 3px solid var(--bio-primary);
}

.bio-journal-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--bio-spacing-md);
  border: 1px solid var(--bio-border);
  border-radius: var(--bio-radius);
  background: var(--bio-surface);
  color: var(--bio-surface-fg);
  font-family: var(--bio-font);
  font-size: var(--bio-font-size-base);
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--bio-transition);
}

.bio-journal-textarea:focus {
  outline: none;
  border-color: var(--bio-primary);
}

.bio-journal-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bio-journal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bio-journal-status {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

.bio-journal-saved {
  color: var(--bio-status-green);
}

.bio-journal-actions {
  display: flex;
  gap: var(--bio-spacing-sm);
}

.bio-journal-save-btn {
  padding: var(--bio-spacing-sm) var(--bio-spacing-lg);
  border-radius: var(--bio-radius);
  border: none;
  background: var(--bio-primary);
  color: var(--bio-primary-fg);
  font-weight: var(--bio-font-weight-medium);
  font-size: var(--bio-font-size-sm);
  cursor: pointer;
  transition: background var(--bio-transition);
}

.bio-journal-save-btn:hover {
  background: var(--bio-primary-hover);
}

.bio-journal-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bio-journal-history-btn {
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  border-radius: var(--bio-radius);
  border: 1px solid var(--bio-border);
  background: var(--bio-surface);
  color: var(--bio-surface-fg);
  font-size: var(--bio-font-size-sm);
  font-weight: var(--bio-font-weight-medium);
  cursor: pointer;
  transition: all var(--bio-transition);
}

.bio-journal-history-btn:hover {
  border-color: var(--bio-primary);
  color: var(--bio-primary);
}

/* Journal history */
.bio-journal-history {
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-sm);
  margin-top: var(--bio-spacing-sm);
  padding-top: var(--bio-spacing-md);
  border-top: 1px solid var(--bio-border);
}

.bio-journal-history-loading,
.bio-journal-history-empty {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  text-align: center;
  padding: var(--bio-spacing-md);
}

.bio-journal-history-entry {
  padding: var(--bio-spacing-sm) var(--bio-spacing-md);
  background: var(--bio-surface-muted);
  border-radius: var(--bio-radius);
}

.bio-journal-history-meta {
  display: flex;
  gap: var(--bio-spacing-sm);
  font-size: var(--bio-font-size-xs);
  color: var(--bio-surface-muted-fg);
  margin-bottom: var(--bio-spacing-xs);
}

.bio-journal-history-text {
  font-size: var(--bio-font-size-sm);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Trend card widget */
.bio-trend-card {
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-xs);
  padding: var(--bio-spacing-md);
  background: var(--bio-surface-muted);
  border-radius: var(--bio-radius);
}

.bio-trend-card-skeleton {
  height: 80px;
  opacity: 0.4;
  animation: bio-hm-pulse 1.5s ease-in-out infinite;
}

.bio-trend-card-empty {
  opacity: 0.6;
}

.bio-trend-card-label {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
  font-weight: var(--bio-font-weight-medium);
  text-transform: capitalize;
}

.bio-trend-card-value-row {
  display: flex;
  align-items: baseline;
  gap: var(--bio-spacing-sm);
}

.bio-trend-card-value {
  font-size: var(--bio-font-size-xl);
  font-weight: var(--bio-font-weight-bold);
}

.bio-trend-card-no-data {
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

.bio-trend-card-arrow {
  font-size: var(--bio-font-size-lg);
  font-weight: var(--bio-font-weight-bold);
}

.bio-trend-card-arrow[data-trend="improving"] {
  color: var(--bio-trend-improving);
}

.bio-trend-card-arrow[data-trend="stable"] {
  color: var(--bio-trend-stable);
}

.bio-trend-card-arrow[data-trend="declining"] {
  color: var(--bio-trend-declining);
}

.bio-trend-card-change {
  font-size: var(--bio-font-size-sm);
  font-weight: var(--bio-font-weight-medium);
}

.bio-trend-card-change[data-trend="improving"] {
  color: var(--bio-trend-improving);
}

.bio-trend-card-change[data-trend="stable"] {
  color: var(--bio-trend-stable);
}

.bio-trend-card-change[data-trend="declining"] {
  color: var(--bio-trend-declining);
}

.bio-trend-card-stats {
  display: flex;
  justify-content: space-between;
  font-size: var(--bio-font-size-xs);
  color: var(--bio-surface-muted-fg);
}

/* Trend chart widget */
.bio-trend-chart {
  display: flex;
  flex-direction: column;
  gap: var(--bio-spacing-sm);
}

.bio-trend-chart-skeleton {
  height: 200px;
  opacity: 0.4;
  animation: bio-hm-pulse 1.5s ease-in-out infinite;
}

.bio-trend-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bio-trend-chart-label {
  font-size: var(--bio-font-size-sm);
  font-weight: var(--bio-font-weight-medium);
  color: var(--bio-surface-muted-fg);
}

.bio-trend-chart-period {
  font-size: var(--bio-font-size-xs);
  color: var(--bio-surface-muted-fg);
}

.bio-trend-chart svg {
  width: 100%;
  overflow: visible;
}

.bio-trend-chart-line {
  fill: none;
  stroke: var(--bio-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bio-trend-chart-area {
  fill: color-mix(in srgb, var(--bio-primary) 10%, transparent);
}

.bio-trend-chart-dot {
  fill: var(--bio-primary);
  stroke: var(--bio-surface);
  stroke-width: 2;
}

.bio-trend-chart-bar {
  fill: var(--bio-primary);
  rx: 2;
}

.bio-trend-chart-grid {
  stroke: var(--bio-border);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.bio-trend-chart-axis-label {
  font-size: 10px;
  fill: var(--bio-surface-muted-fg);
  font-family: var(--bio-font);
}

.bio-trend-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  font-size: var(--bio-font-size-sm);
  color: var(--bio-surface-muted-fg);
}

/* ========================================
   Program Builder (W7.1 Hero — chat phase + spec card layered in by W7.3/W7.4)
   Styles translated 1:1 from the prototype `.pb-*` selectors. The `--pb-*`
   palette is scoped to the program-builder elements via :where() so it does
   not leak into the global token surface.
   ======================================== */

:where(bio-program-builder, bio-program-builder-input, bio-program-spec-card) {
  --pb-bg: #050c19;
  --pb-surface: #051629;
  --pb-surface-2: rgba(255, 255, 255, 0.035);
  --pb-text: #ffffff;
  --pb-text-mute: rgb(197, 209, 231);
  --pb-text-dim: rgb(138, 164, 206);
  --pb-border: rgba(79, 118, 182, 0.28);
  --pb-border-soft: rgba(79, 118, 182, 0.16);
  --pb-accent: var(--bio-accent, rgb(15, 115, 218));
  --pb-accent-bright: rgb(0, 152, 255);
  --pb-accent-soft: rgba(0, 152, 255, 0.12);
  --pb-accent-light: rgb(162, 216, 255);
  --pb-on-accent: #ffffff;
  /* Dark code-block surface for the W7.4 spec card (L2 brief §8). The
     integrator can override --bio-surface-code at the host level to flip the
     code/output surfaces for a light theme; the spec-card-internal default
     is the deep navy that matches the prototype's `.pb-code` / `.pb-json`. */
  --bio-surface-code: #051629;
}

:where(bio-program-builder, bio-program-builder-input, bio-program-spec-card)[data-theme='light'] {
  --pb-bg: rgb(232, 238, 246);
  --pb-surface: #ffffff;
  --pb-surface-2: rgba(5, 22, 41, 0.025);
  --pb-text: rgb(35, 42, 56);
  --pb-text-mute: rgb(99, 111, 135);
  --pb-text-dim: rgb(99, 111, 135);
  --pb-border: rgb(197, 209, 231);
  --pb-border-soft: rgba(197, 209, 231, 0.55);
}

bio-program-builder {
  display: block;
  min-height: 100vh;
  background: var(--pb-bg);
  color: var(--pb-text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 280ms cubic-bezier(0.2, 0.8, 0.2, 1), color 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bio-program-builder-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  line-height: 0;
}
.bio-program-builder-ico svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}
.bio-program-builder-ico svg path,
.bio-program-builder-ico svg g {
  fill: currentColor;
}

/* Hero (centered, pre-chat) */
.bio-program-builder-hero {
  text-align: center;
  padding: 72px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1000px;
  margin: 0 auto;
}

.bio-program-builder-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--bio-font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pb-accent);
  margin-bottom: 22px;
}
.bio-program-builder-eyebrow::before {
  content: '';
  width: 18px;
  height: 1px;
  background: var(--pb-accent);
}
bio-program-builder[data-theme='dark'] .bio-program-builder-eyebrow {
  color: var(--pb-accent-light);
}

.bio-program-builder-eyebrow-em {
  font-style: normal;
}

.bio-program-builder-hero-h1 {
  font-family: var(--bio-font-serif);
  font-weight: 300;
  font-size: clamp(40px, 5.6vw, 68px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0;
  max-width: 16ch;
  text-wrap: balance;
  color: var(--pb-text);
}

.bio-program-builder-hero-sub {
  font-family: inherit;
  font-size: 20px;
  line-height: 1.5;
  letter-spacing: -0.03em;
  color: var(--pb-text-mute);
  margin: 22px 0 0;
  max-width: 60ch;
  text-wrap: pretty;
}

.bio-program-builder-rotword {
  color: var(--pb-accent);
  font-weight: 500;
}
bio-program-builder[data-theme='dark'] .bio-program-builder-rotword {
  color: var(--pb-accent-light);
}

.bio-program-builder-hero-em {
  font-style: normal;
  color: var(--pb-accent);
  font-weight: 400;
}
bio-program-builder[data-theme='dark'] .bio-program-builder-hero-em {
  color: var(--pb-accent-light);
}

/* Chat input pill (the inline form; W7.2 extracts this to its own element) */
.bio-program-builder-input-block {
  width: 100%;
  max-width: 760px;
  margin: 40px auto 0;
}

.bio-program-builder-input {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgb(42, 55, 83);
  border-radius: 28px;
  padding: 12px 12px 12px 24px;
  box-shadow: 0 18px 50px -18px rgba(0, 9, 26, 0.7);
}
bio-program-builder[data-theme='light'] .bio-program-builder-input {
  background: #ffffff;
  box-shadow: 0 4px 20px 0 rgba(0, 45, 128, 0.12);
}

.bio-program-builder-input textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 18px;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: var(--pb-text);
  padding: 13px 0;
  max-height: 168px;
  overflow-y: hidden;
}
.bio-program-builder-input textarea::placeholder {
  color: var(--pb-text-dim);
}

.bio-program-builder-send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--bio-radius-pill);
  background: var(--pb-accent);
  color: var(--pb-on-accent);
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms, transform 140ms;
}
.bio-program-builder-send:hover {
  filter: brightness(1.08);
}
.bio-program-builder-send:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}
.bio-program-builder-send .bio-program-builder-ico {
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
}

/* Starter chips */
.bio-program-builder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}
.bio-program-builder-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--bio-radius-pill);
  border: 1px solid var(--pb-border);
  background: var(--pb-surface-2);
  color: var(--pb-text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: border-color 140ms, background 140ms, transform 140ms;
}
.bio-program-builder-chip:hover {
  border-color: var(--pb-accent);
  background: var(--pb-accent-soft);
  transform: translateY(-1px);
}
.bio-program-builder-chip .bio-program-builder-ico {
  width: 16px;
  height: 16px;
  color: var(--pb-accent);
}
bio-program-builder[data-theme='dark'] .bio-program-builder-chip .bio-program-builder-ico {
  color: var(--pb-accent-light);
}

.bio-program-builder-explore {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 22px;
  background: transparent;
  border: 0;
  color: var(--pb-text-mute);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.02em;
  cursor: pointer;
}
.bio-program-builder-explore:hover {
  color: var(--pb-text);
}
.bio-program-builder-explore .bio-program-builder-ico {
  width: 14px;
  height: 14px;
  transition: transform 200ms;
}
.bio-program-builder-explore.is-open .bio-program-builder-ico {
  transform: rotate(180deg);
}

/* Trust tags under hero input */
.bio-program-builder-trusttags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  margin-top: 40px;
}
.bio-program-builder-trusttag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--pb-border);
  border-radius: var(--bio-radius-pill);
  font-family: var(--bio-font-mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--pb-text-mute);
  white-space: nowrap;
}
.bio-program-builder-trusttag .bio-program-builder-ico {
  width: 13px;
  height: 13px;
  color: var(--pb-accent-bright);
}

@media (prefers-reduced-motion: reduce) {
  .bio-program-builder-chip,
  .bio-program-builder-send,
  .bio-program-builder-explore .bio-program-builder-ico {
    transition: none;
  }
}

/* ========================================
   Program Builder Input element (W7.2)
   Selectors are .bio-pb-input* prefixed so they sit alongside the W7.1
   shell's .bio-program-builder-input* selectors without colliding. The
   element renders to light DOM and the scoping above on
   :where(bio-program-builder-input, ...) carries the --pb-* palette here.
   ======================================== */

bio-program-builder-input {
  display: block;
  width: 100%;
}

.bio-pb-input-wrap {
  position: relative;
}

/* Hero variant: large editorial pill, 760px max, dark panel + 28-px radius.
   The wrap shares the inner panel's 28px radius so the ::after border ring
   and the .bio-pb-input-glow ring (both `border-radius: inherit`) line up
   with the inner panel instead of forming a pill-shaped halo around it. */
.bio-pb-input-wrap.bio-pb-input-hero {
  max-width: 760px;
  margin: 0 auto;
  border-radius: 28px;
}

/* Outer glow ring (presence governed by the `glow` attribute). */
.bio-pb-input-wrap.bio-pb-input-hero .bio-pb-input-glow {
  position: absolute;
  inset: -8px;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 152, 255, 0.22) 0%,
    rgba(0, 152, 255, 0.08) 40%,
    transparent 70%
  );
  filter: blur(14px);
}

/* Subtle border ring above the panel — matches the prototype's
   `.pb-input-wrap::after`. */
.bio-pb-input-wrap.bio-pb-input-hero::after {
  content: '';
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  z-index: 0;
  border: 1.5px solid rgba(138, 164, 206, 0.42);
  pointer-events: none;
}
bio-program-builder-input[data-theme='light'] .bio-pb-input-wrap.bio-pb-input-hero::after,
bio-program-builder[data-theme='light'] .bio-pb-input-wrap.bio-pb-input-hero::after {
  border-color: rgb(197, 209, 231);
}

/* Telemetry wave — scrolling ECG trace behind the input. Hero only. */
.bio-pb-input-telemetry-wave {
  position: absolute;
  top: 50%;
  left: -36%;
  right: -36%;
  height: 78px;
  transform: translateY(-50%);
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
}
.bio-pb-input-telemetry-svg {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  width: 1800px;
  margin-left: -900px;
  opacity: 0.5;
  color: var(--pb-accent-bright);
  filter: drop-shadow(0 0 7px rgba(0, 152, 255, 0.45));
  animation: bio-pb-telemetry-scroll 6s linear infinite;
}
bio-program-builder[data-theme='light'] .bio-pb-input-telemetry-svg,
bio-program-builder-input[data-theme='light'] .bio-pb-input-telemetry-svg {
  opacity: 0.34;
  filter: drop-shadow(0 0 6px rgba(0, 152, 255, 0.3));
}
.bio-pb-input-wrap:focus-within .bio-pb-input-telemetry-svg {
  opacity: 0.82;
  animation-duration: 4s;
}

/* The input panel itself (textarea + send button). */
.bio-pb-input {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgb(42, 55, 83);
  border-radius: 28px;
  padding: 12px 12px 12px 24px;
  box-shadow: 0 18px 50px -18px rgba(0, 9, 26, 0.7);
}
bio-program-builder[data-theme='light'] .bio-pb-input,
bio-program-builder-input[data-theme='light'] .bio-pb-input {
  background: #ffffff;
  box-shadow: 0 4px 20px 0 rgba(0, 45, 128, 0.12);
}

/* Docked variant: condensed, pill-shaped, no glow, no telemetry. */
.bio-pb-input-wrap.bio-pb-input-docked {
  max-width: 820px;
  margin: 0 auto;
  border-radius: var(--bio-radius-pill, 9999px);
}
.bio-pb-input-wrap.bio-pb-input-docked .bio-pb-input {
  padding: 8px 8px 8px 22px;
  border-radius: var(--bio-radius-pill, 9999px);
  box-shadow: 0 14px 44px -16px rgba(0, 9, 26, 0.75);
}
.bio-pb-input-wrap.bio-pb-input-docked .bio-pb-input-textarea {
  font-size: 16px;
}
.bio-pb-input-wrap.bio-pb-input-docked .bio-pb-input-send {
  width: 40px;
  height: 40px;
}

/* Textarea (autosize from 1 to 12 rows; element computes the rows attr). */
.bio-pb-input-textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 18px;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: var(--pb-text);
  padding: 13px 0;
  max-height: 360px;
  overflow-y: auto;
}
.bio-pb-input-textarea::placeholder {
  color: var(--pb-text-dim);
}

/* Send button — 44px circle on hero, 40px on docked. */
.bio-pb-input-send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--bio-radius-pill, 9999px);
  background: var(--pb-accent);
  color: var(--pb-on-accent);
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms, transform 140ms;
}
.bio-pb-input-send:hover {
  filter: brightness(1.08);
}
.bio-pb-input-send:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}
.bio-pb-input-send .bio-program-builder-ico {
  width: 20px;
  height: 20px;
  transform: rotate(90deg);
}

@keyframes bio-pb-telemetry-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-200px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bio-pb-input-telemetry-svg,
  .bio-pb-input-telemetry-wave-static .bio-pb-input-telemetry-svg {
    animation: none !important;
  }
  .bio-pb-input-send {
    transition: none;
  }
}

/* ========================================
   Program Builder Chat phase (W7.3)
   Conversation thread, reasoning-trace, sticky followup dock, toast bar.
   Selectors all live inside the existing :where(...) palette scope above so
   the --pb-* tokens flow through. Translated 1:1 from the prototype's
   .pb-convo*, .pb-trace*, .pb-followup*, .pb-toast selectors with the
   AnyBio-prefixed naming.
   ======================================== */

.bio-program-builder-chat {
  display: block;
}

.bio-program-builder-convo {
  max-width: 820px;
  margin: 0 auto;
  /* Reservation matches the dock's max autosize (12 rows × 24px + 38px wrap +
     16px pad ≈ 340px) plus 24px breathing room above the dock; otherwise a
     multi-line draft slides the dock up over the bottom of the conversation.
     At minimum dock height this wastes ~200px of trailing whitespace; a
     measure-and-write CSS-var approach is the cleaner long-term fix and is
     tracked as a P3 follow-up. */
  padding: 28px 24px 360px;
}

.bio-program-builder-convo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--pb-border-soft);
}

.bio-program-builder-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  color: var(--pb-text-mute);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.02em;
  cursor: pointer;
}
.bio-program-builder-back:hover {
  color: var(--pb-text);
}
/* The arrow icon points up; rotating -90deg gives us a left-pointing chevron
   that matches the prototype's "‹ New program" affordance. */
.bio-program-builder-back .bio-program-builder-ico {
  width: 14px;
  height: 14px;
  transform: rotate(-90deg);
}

.bio-program-builder-head-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--bio-radius-pill);
  background: var(--pb-accent-soft);
  color: var(--pb-accent);
  font-family: var(--bio-font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}
bio-program-builder[data-theme='dark'] .bio-program-builder-head-tag {
  color: var(--pb-accent-light);
}
.bio-program-builder-head-tag .bio-program-builder-ico {
  width: 13px;
  height: 13px;
}

.bio-program-builder-turn {
  margin-bottom: 30px;
}

.bio-program-builder-msg-user {
  margin-left: auto;
  max-width: 80%;
  width: fit-content;
  background: var(--pb-surface);
  border: 1px solid var(--pb-border);
  border-radius: 20px 20px 6px 20px;
  padding: 15px 19px;
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--pb-text);
  letter-spacing: -0.02em;
}

/* Reasoning trace */
.bio-program-builder-trace {
  margin: 20px 0 18px;
}
.bio-program-builder-trace-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--pb-text-mute);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.02em;
  cursor: pointer;
}
.bio-program-builder-trace-toggle:hover {
  color: var(--pb-text);
}
.bio-program-builder-trace-toggle .bio-program-builder-ico {
  width: 13px;
  height: 13px;
  color: var(--pb-text-dim);
  transition: transform 200ms;
}
/* The chevron rotates open when the trace is expanded. The leading status
   icon (check / spinner) is positioned first; the chevron is the last icon
   inside the button. */
.bio-program-builder-trace-toggle.is-open .bio-program-builder-ico:last-child {
  transform: rotate(180deg);
}
.bio-program-builder-trace-spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--pb-border);
  border-top-color: var(--pb-accent-bright);
  animation: bio-program-builder-spin 0.7s linear infinite;
  flex: none;
}
.bio-program-builder-trace-steps {
  margin-top: 14px;
  padding-left: 18px;
  margin-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 1px solid var(--pb-border-soft);
}
.bio-program-builder-trace-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--bio-font-mono);
  font-size: 13.5px;
  color: var(--pb-text-mute);
  letter-spacing: 0.01em;
}
.bio-program-builder-trace-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.bio-program-builder-trace-step.is-done .bio-program-builder-trace-dot {
  background: var(--pb-accent-soft);
}
.bio-program-builder-trace-step.is-done .bio-program-builder-trace-dot .bio-program-builder-ico {
  width: 9px;
  height: 9px;
  color: var(--pb-accent-bright);
}
.bio-program-builder-trace-step.is-active .bio-program-builder-trace-dot {
  border: 2px solid var(--pb-border);
  border-top-color: var(--pb-accent-bright);
  animation: bio-program-builder-spin 0.7s linear infinite;
}
.bio-program-builder-trace-step.is-done {
  color: var(--pb-text);
}

/* Agent reply text */
.bio-program-builder-agent-text {
  font-size: 18px;
  line-height: 1.62;
  letter-spacing: -0.02em;
  color: var(--pb-text);
  margin: 0 0 6px;
  text-wrap: pretty;
}
.bio-program-builder-cite {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  margin-left: 5px;
  border-radius: 4px;
  background: var(--pb-surface-2);
  border: 1px solid var(--pb-border-soft);
  font-family: var(--bio-font-mono);
  font-size: 11px;
  color: var(--pb-text-mute);
  vertical-align: middle;
}

/* Sticky followup-dock at the bottom of the chat phase */
.bio-program-builder-followup-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 16px 24px 22px;
  background: linear-gradient(to top, var(--pb-bg) 58%, transparent);
  pointer-events: none;
}
.bio-program-builder-followup {
  max-width: 820px;
  margin: 0 auto;
  pointer-events: auto;
}

/* Renders in the sticky followup-dock slot after the user has claimed.
   Post-claim refinements detach from the minted handoff JWT (it was bound
   to the pre-refinement draft_session_id snapshot); locking the dock is
   the lowest-risk fix until the user completes signup on secure.anybio.io
   and a new authoring session resumes there. */
.bio-program-builder-followup-locked {
  padding: 18px 22px;
  border-radius: 14px;
  background: var(--pb-surface-muted, rgba(255, 255, 255, 0.04));
  border: 1px dashed var(--pb-border);
  color: var(--pb-surface-muted-fg, var(--pb-text));
  font-family: inherit;
  font-size: 14px;
  text-align: center;
  opacity: 0.8;
}

/* Toast bar.
   Uses its own keyframe (bio-program-builder-toast-rise) instead of the
   shared rise-soft. The shared keyframe writes `transform: none` in its `to`
   block with animation-fill-mode: both — that would wipe out the
   translateX(-50%) horizontal centering at the end of the entrance and slide
   the toast off-center for the rest of its dismissal window. The toast-rise
   keyframe preserves translateX(-50%) on every frame. */
.bio-program-builder-toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--pb-surface);
  color: var(--pb-text);
  border: 1px solid var(--pb-border);
  border-radius: 10px;
  padding: 13px 18px;
  font-family: inherit;
  font-size: 14px;
  box-shadow: 0 24px 60px -28px rgba(0, 9, 26, 0.7);
  animation: bio-program-builder-toast-rise 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.bio-program-builder-toast .bio-program-builder-ico {
  width: 15px;
  height: 15px;
  color: var(--pb-accent-bright);
}

/* Error variant. Re-colors the icon + border to the warning palette so the
   user reads "error" instead of "saved" on API failure paths (P2 #5). The
   warning color is inline (no --pb-warn token in the palette) because we
   only need it on this one selector; promoting to a token in W7.5 would be
   premature without a second error-surface consumer. */
.bio-program-builder-toast--error {
  border-color: rgba(232, 90, 76, 0.6);
}
.bio-program-builder-toast--error .bio-program-builder-ico {
  color: rgb(232, 90, 76);
}

/* Per-turn rise-from-below entrance. Applied via the .bio-program-builder-
   rise-soft modifier on .bio-program-builder-turn; reduced-motion drops the
   class entirely (the widget skips the animation marker in TS, not CSS, so
   the @media block below is belt-and-suspenders for any element that picks
   up the class through a non-W7.3 path). */
.bio-program-builder-rise-soft {
  animation: bio-program-builder-rise-soft 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes bio-program-builder-rise-soft {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* Toast-specific entrance keyframe — preserves the translateX(-50%)
   horizontal centering on every frame so the toast does not slide off-center
   after the 240ms entrance. See the .bio-program-builder-toast block above. */
@keyframes bio-program-builder-toast-rise {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
@keyframes bio-program-builder-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   Program Spec Card (W7.4)
   Ports the prototype's `.pb-card / .pb-tabs / .pb-spec-* / .pb-code /
   .pb-out / .pb-json` blocks under the new bio-program-spec-* names. The
   selectors live inside the same scoped --pb-* token block above so the
   card inherits the program-builder palette whether it is mounted inside
   the shell or stood up standalone on a host page.
   ============================================================ */
bio-program-spec-card {
  display: block;
}

.bio-program-spec-card {
  margin-top: 18px;
  background: var(--pb-surface);
  border: 1px solid var(--pb-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px -28px rgba(0, 9, 26, 0.7);
  color: var(--pb-text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  letter-spacing: -0.02em;
}
bio-program-spec-card[data-theme='light'] .bio-program-spec-card,
bio-program-builder[data-theme='light'] .bio-program-spec-card {
  box-shadow: 0 24px 60px -36px rgba(0, 9, 26, 0.18);
}

.bio-program-spec-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--pb-border-soft);
  background: var(--pb-surface-2);
}
.bio-program-spec-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex: none;
  background: var(--pb-accent);
  color: var(--pb-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bio-program-spec-mark .bio-program-builder-ico {
  width: 20px;
  height: 20px;
}
.bio-program-spec-titles {
  flex: 1;
  min-width: 0;
}
.bio-program-spec-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--pb-text);
  margin: 0;
}
.bio-program-spec-sub {
  font-family: var(--bio-font-mono);
  font-size: 11.5px;
  color: var(--pb-text-dim);
  margin-top: 3px;
  letter-spacing: 0.02em;
}

/* Action row: copy + download. Mirrors the prototype's `.pb-card-tools`. */
.bio-program-spec-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.bio-program-spec-tool {
  appearance: none;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--pb-text-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.bio-program-spec-tool:hover {
  background: var(--pb-surface-2);
  color: var(--pb-text);
}
.bio-program-spec-tool .bio-program-builder-ico {
  width: 15px;
  height: 15px;
}
.bio-program-spec-download-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(180deg);
}
.bio-program-spec-action-flash {
  background: var(--pb-accent-soft);
  color: var(--pb-accent-bright);
}
.bio-program-spec-action-flash:hover {
  background: var(--pb-accent-soft);
  color: var(--pb-accent-bright);
}
.bio-program-spec-action-text {
  font-family: var(--bio-font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Tabs */
.bio-program-spec-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 14px 0;
  border-bottom: 1px solid var(--pb-border-soft);
}
.bio-program-spec-tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 10px 14px;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--pb-text-mute);
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}
.bio-program-spec-tab .bio-program-builder-ico {
  width: 14px;
  height: 14px;
}
.bio-program-spec-tab:hover {
  color: var(--pb-text);
}
.bio-program-spec-tab.is-active {
  color: var(--pb-text);
  border-bottom-color: var(--pb-accent-bright);
}

/* Body panel */
.bio-program-spec-panel {
  padding: 22px;
}

/* Spec tab — rows of label + body */
.bio-program-spec-row {
  padding: 16px 0;
  border-bottom: 1px solid var(--pb-border-soft);
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 20px;
  align-items: start;
}
.bio-program-spec-row:first-child {
  padding-top: 2px;
}
.bio-program-spec-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}
.bio-program-spec-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--bio-font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pb-text-dim);
  padding-top: 3px;
}
.bio-program-spec-label .bio-program-builder-ico {
  width: 14px;
  height: 14px;
  color: var(--pb-accent-bright);
}
.bio-program-spec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.bio-program-spec-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--pb-surface-2);
  border: 1px solid var(--pb-border-soft);
  font-size: 13.5px;
  color: var(--pb-text);
}
.bio-program-spec-pill-meta {
  font-family: var(--bio-font-mono);
  font-size: 11px;
  color: var(--pb-text-dim);
}
.bio-program-spec-pill-loinc {
  font-family: var(--bio-font-mono);
  font-size: 10.5px;
  color: var(--pb-accent-bright);
  border-left: 1px solid var(--pb-border-soft);
  padding-left: 8px;
}
.bio-program-spec-lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.bio-program-spec-line {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 14.5px;
  color: var(--pb-text);
  line-height: 1.45;
}
.bio-program-spec-line .bio-program-builder-ico {
  width: 13px;
  height: 13px;
  color: var(--pb-accent-bright);
  position: relative;
  top: 2px;
  flex: none;
}
.bio-program-spec-k {
  font-family: var(--bio-font-mono);
  font-size: 11px;
  color: var(--pb-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-width: 78px;
}
.bio-program-spec-arrow {
  display: inline-flex;
  transform: rotate(90deg);
  color: var(--pb-accent-bright);
}

/* Code tab — dark surface, code-bar with three dots + filename */
.bio-program-spec-code {
  background: var(--bio-surface-code, #051629);
  border-radius: 10px;
  border: 1px solid var(--pb-border-soft);
  overflow: hidden;
}
.bio-program-spec-code-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(79, 118, 182, 0.22);
}
.bio-program-spec-code-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(138, 164, 206, 0.5);
}
.bio-program-spec-code-name {
  margin-left: 8px;
  font-family: var(--bio-font-mono);
  font-size: 11px;
  color: var(--pb-text-dim);
}
.bio-program-spec-code-pre {
  margin: 0;
  padding: 18px 20px;
  font-family: var(--bio-font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: rgb(197, 209, 231);
  white-space: pre;
  overflow-x: auto;
}

/* Output tab — mock device strip + FHIR JSON preview */
.bio-program-spec-output {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.bio-program-spec-strip {
  background: var(--bio-surface-code, #051629);
  border: 1px solid var(--pb-border-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.bio-program-spec-strip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.bio-program-spec-strip-label {
  font-family: var(--bio-font-mono);
  font-size: 11px;
  color: var(--pb-text-dim);
  letter-spacing: 0.04em;
}
.bio-program-spec-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--bio-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--pb-accent-bright);
}
.bio-program-spec-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pb-accent-bright);
  animation: bio-program-spec-live-pulse 1.4s ease-in-out infinite;
}
.bio-program-builder-ecg {
  width: 100%;
  height: 64px;
  display: block;
}
.bio-program-spec-fhir {
  background: var(--bio-surface-code, #051629);
  border: 1px solid var(--pb-border-soft);
  border-radius: 10px;
  overflow: hidden;
}
.bio-program-spec-fhir-bar {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(79, 118, 182, 0.22);
  font-family: var(--bio-font-mono);
  font-size: 11px;
  color: var(--pb-text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bio-program-spec-fhir-bar .bio-program-builder-ico {
  width: 13px;
  height: 13px;
  color: var(--pb-accent-bright);
}
.bio-program-spec-fhir-pre {
  margin: 0;
  padding: 16px 18px;
  font-family: var(--bio-font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: rgb(197, 209, 231);
  white-space: pre;
  overflow-x: auto;
}

@keyframes bio-program-spec-live-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.18);
  }
}

/* ============================================================
   Gate modal + Deploy CTA (W7.6)
   Ports the prototype's .pb-mask / .pb-modal / .pb-cta-row blocks under
   the bio-program-builder-* names. Lives inside the shared scoped --pb-*
   token block above so the modal inherits the program-builder palette.
   ============================================================ */

/* Deploy CTA row below the conversation thread. Click the button to open
   the gate modal; the claimed variant shows the saved affordance. */
.bio-program-builder-deploy-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 22px;
  margin-top: 18px;
  border-radius: 14px;
  border: 1px solid var(--pb-border);
  background: var(--pb-surface);
}
.bio-program-builder-deploy-cta-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.bio-program-builder-deploy-cta-h {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--pb-text);
}
.bio-program-builder-deploy-cta-sub {
  font-size: 13px;
  color: var(--pb-text-mute);
}
.bio-program-builder-deploy-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 0;
  background: var(--pb-accent);
  color: var(--pb-on-accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.bio-program-builder-deploy-cta-btn:hover {
  filter: brightness(1.06);
}
.bio-program-builder-deploy-cta-btn.is-claimed {
  background: transparent;
  color: var(--pb-text);
  border: 1px solid var(--pb-border);
  cursor: default;
}

/* Modal mask — full-viewport dim with backdrop blur. Click-to-close is
   wired in TS via @click and target-identity check. z-index above the
   toast (which uses 120). */
.bio-program-builder-mask {
  position: fixed;
  inset: 0;
  background: rgba(2, 7, 16, 0.66);
  backdrop-filter: blur(3px);
  display: flex;
  /* Top-aligned + scrollable so the modal is reachable on short viewports
     (landscape phone, mobile keyboard open). Centering still happens via
     justify-content + the top/bottom padding. */
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  z-index: 130;
  padding: 48px 24px;
}

/* Modal panel — centered, max 460px, accent-shadowed. The --anim modifier
   carries the entrance keyframe so reduced-motion can skip the marker via
   the TS-side render path. The @media block below is belt-and-suspenders.
   max-height + overflow keep the panel inside the viewport on short screens
   without occluding the close button or CTA. */
.bio-program-builder-modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--pb-surface);
  border: 1px solid var(--pb-border);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 40px 90px -30px rgba(0, 9, 26, 0.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: inherit;
  color: var(--pb-text);
}
.bio-program-builder-modal--anim {
  animation: bio-program-builder-modal-fade-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.bio-program-builder-modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.bio-program-builder-modal-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 7px 13px;
  border-radius: 8px;
  background: var(--pb-accent-soft);
  color: var(--pb-accent);
  font-size: 13px;
  font-weight: 500;
}
bio-program-builder[data-theme='dark'] .bio-program-builder-modal-chip {
  color: var(--pb-accent-bright);
}
.bio-program-builder-modal-chip .bio-program-builder-ico {
  width: 14px;
  height: 14px;
}
.bio-program-builder-modal-close {
  background: transparent;
  border: 0;
  color: var(--pb-text-dim);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.bio-program-builder-modal-close:hover {
  background: var(--pb-surface-2);
  color: var(--pb-text);
}
.bio-program-builder-modal-close .bio-program-builder-ico {
  width: 14px;
  height: 14px;
}
.bio-program-builder-modal-h {
  margin: 0;
  font-family: inherit;
  font-weight: 600;
  font-size: 22px;
  color: var(--pb-text);
}
.bio-program-builder-modal-p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--pb-text-mute);
}
.bio-program-builder-modal-input {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.bio-program-builder-modal-input label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pb-text-dim);
}
.bio-program-builder-modal-input input {
  height: 48px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid var(--pb-border);
  background: var(--pb-bg);
  color: var(--pb-text);
  font-family: inherit;
  font-size: 15px;
  box-sizing: border-box;
}
.bio-program-builder-modal-input input:focus {
  outline: 2px solid var(--pb-accent);
  outline-offset: -1px;
  border-color: var(--pb-accent);
}
.bio-program-builder-modal-input input[aria-invalid='true'] {
  border-color: rgba(232, 90, 76, 0.7);
}
.bio-program-builder-modal-error {
  font-size: 12.5px;
  color: rgb(232, 90, 76);
}
.bio-program-builder-modal-cta {
  height: 48px;
  margin-top: 4px;
  border-radius: 10px;
  border: 0;
  background: var(--pb-accent);
  color: var(--pb-on-accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.bio-program-builder-modal-cta:hover {
  filter: brightness(1.06);
}
.bio-program-builder-modal-cta:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.bio-program-builder-modal-fine {
  margin: 0;
  font-size: 12.5px;
  color: var(--pb-text-dim);
  text-align: center;
}

@keyframes bio-program-builder-modal-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bio-program-builder-rise-soft,
  .bio-program-builder-toast {
    animation: none !important;
  }
  .bio-program-builder-trace-spin,
  .bio-program-builder-trace-step.is-active .bio-program-builder-trace-dot {
    animation: none !important;
  }
  .bio-program-builder-trace-toggle .bio-program-builder-ico {
    transition: none;
  }
  .bio-program-spec-live-dot {
    animation: none !important;
  }
  .bio-program-spec-tool,
  .bio-program-spec-tab {
    transition: none;
  }
  /* W7.6 gate-modal entrance suppression. The TS render path already
     omits the --anim modifier when reduced-motion is active; this block
     guards against any path (theme override, host stylesheet, etc.) that
     might still attach the modifier. */
  .bio-program-builder-modal,
  .bio-program-builder-modal--anim {
    animation: none !important;
  }
}
