/* Trade Detail Drawer Styles */

/* Hide burger menu when drawer is open (CSS has !important, so we need this) */
body.trade-drawer-open > .mobile-menu-toggle {
  display: none !important;
}

/* Overlay - dark backdrop, positions drawer on right */
.trade-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000; /* Higher than nav burger menu */
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 0.2s ease;
}

.trade-drawer-overlay.hidden {
  display: none !important;
}

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

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* Drawer panel - compact width */
.trade-drawer {
  width: 400px;
  max-width: 95vw;
  height: 100%;
  background: var(--bg-surface, #1a1a1a);
  border-left: 1px solid var(--border, #333);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease;
}

/* Drawer header - compact */
.trade-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #333);
  background: var(--bg-card, #1e293b);
}

.trade-drawer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trade-drawer-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  margin: 0;
}

.trade-drawer-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.trade-drawer-close:hover {
  color: var(--text-primary, #f1f5f9);
  background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

/* Drawer body - scrollable content area */
.trade-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Drawer footer - single row, compact */
.trade-drawer-footer {
  display: flex;
  flex-wrap: wrap; /* Round-21 follow-up: allow buttons to wrap on narrow
                      drawers instead of clipping mid-word. The previous
                      flex:1 1 0 + overflow:hidden caused "Duplicate" to
                      show as "uplicat" once the row got too crowded
                      (Edit + Duplicate + Share + Publish + Delete +
                      Journal + Ask Stella + Draft journal entry). */
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border, #333);
  background: var(--bg-card, #1e293b);
}

.trade-drawer-footer .btn {
  flex: 0 1 auto; /* Buttons keep their natural width (no clipping) and
                     wrap to the next line when there is no room. */
  min-width: 0;
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Drawer-specific content adjustments - COMPACT */
.trade-drawer .trade-detail-content {
  padding: 12px;
}

.trade-drawer .trade-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trade-drawer .detail-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 12px;
}

.trade-drawer .detail-section {
  padding: 10px 12px;
}

.trade-drawer .detail-section-header {
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.trade-drawer .detail-section-header h3 {
  font-size: 13px;
}

.trade-drawer .detail-label {
  font-size: 11px;
}

.trade-drawer .detail-value {
  font-size: 13px;
}

.trade-drawer .metric-card {
  padding: 10px;
}

.trade-drawer .metric-value {
  font-size: 16px;
}

.trade-drawer .metric-label {
  font-size: 10px;
}

.trade-drawer .metrics-grid {
  gap: 8px;
}

/* Mobile - ultra compact */
@media (max-width: 480px) {
  .trade-drawer {
    width: 100%;
    max-width: 100%;
  }

  /* Ensure close button is always visible and touchable */
  .trade-drawer-header {
    padding: 12px;
  }

  .trade-drawer-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
  }

  .trade-drawer .trade-detail-content {
    padding: 8px;
  }

  .trade-drawer .detail-section {
    padding: 8px 10px;
    margin-bottom: 6px;
  }

  .trade-drawer .detail-section-header {
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .trade-drawer .detail-section-header h3 {
    font-size: 12px;
  }

  /* 2-column grid for detail items on mobile */
  .trade-drawer .detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
  }

  /* Inline label + value to save vertical space */
  .trade-drawer .detail-item {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 0;
  }

  .trade-drawer .detail-label {
    font-size: 9px;
    margin-bottom: 1px;
  }

  .trade-drawer .detail-value {
    font-size: 12px;
  }

  /* Footer buttons */
  .trade-drawer-footer {
    padding: 8px;
    gap: 4px;
  }

  .trade-drawer-footer .btn {
    padding: 6px 8px;
    font-size: 11px;
    min-height: 36px;
  }
}

/* ============================================
   Legacy modal styles (kept for reference/fallback)
   ============================================ */

/* Base modal container (from trade-detail.js) */
.modal-container.trade-detail-modal {
  background: var(--bg-surface, #1a1a1a);
  border-radius: var(--radius-xl, 16px);
  border: 1px solid var(--border, #333);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.trade-detail-modal {
  max-width: 1200px;
  width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.trade-detail-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.trade-status-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.trade-status-badge.success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.trade-status-badge.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.trade-status-badge.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.trade-detail-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.trade-detail-content {
  padding: var(--space-6);
}

.trade-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-6);
}

.detail-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.detail-section.full-width {
  grid-column: 1 / -1;
}

.detail-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.detail-section-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.trade-id {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.detail-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

.detail-value {
  font-size: var(--text-base);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.detail-value.symbol {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
}

.detail-value.side {
  text-transform: uppercase;
  font-weight: var(--font-bold);
}

.detail-value.side.buy {
  color: var(--success);
}

.detail-value.side.sell {
  color: var(--error);
}

.detail-value.price {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
}

.detail-value.pnl {
  font-weight: var(--font-bold);
  font-family: var(--font-mono);
}

.detail-value.pnl.positive {
  color: var(--success);
}

.detail-value.pnl.negative {
  color: var(--error);
}

/* P&L Breakdown */
.pnl-breakdown {
  grid-column: 1 / -1;
  padding: 8px 12px;
  margin-top: -4px;
  background: var(--bg-muted, rgba(255,255,255,0.03));
  border-radius: var(--radius-sm, 4px);
  border-left: 2px solid var(--border, rgba(255,255,255,0.08));
}

.pnl-breakdown-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.6;
}

.pnl-breakdown-branch {
  font-family: var(--font-mono, monospace);
  color: var(--text-tertiary, #555);
  font-size: 12px;
  width: 12px;
  flex-shrink: 0;
}

.pnl-breakdown-label {
  font-size: 12px;
  color: var(--text-secondary, #888);
}

.pnl-breakdown-value {
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  color: var(--text-secondary, #888);
  margin-left: auto;
}

.pnl-breakdown-note {
  font-size: 11px;
  color: var(--text-tertiary, #666);
  margin-top: 6px;
  line-height: 1.4;
  padding-top: 6px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.06));
}

.detail-value.strategy {
  background: var(--bg-muted);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

/* Strategy and Tags */
.strategy-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.tags-section {
  margin-top: var(--space-4);
}

.trade-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.tag {
  background: var(--bg-muted);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border: 1px solid var(--border);
}

/* Notes */
.notes-content {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* Performance Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.metric-card {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
}

.metric-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  font-family: var(--font-mono);
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

/* Modal Footer */
.trade-detail-modal .modal-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

/* Loading and Error States */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  text-align: center;
}

.loading-state .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-4);
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  text-align: center;
}

.error-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
}

.error-state h3 {
  margin: 0 0 var(--space-2) 0;
  color: var(--text-primary);
}

.error-state p {
  margin: 0 0 var(--space-4) 0;
  color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .trade-detail-grid {
    grid-template-columns: 1fr;
  }
  
  .detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .trade-detail-modal {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  
  .trade-detail-content {
    padding: var(--space-4);
  }
  
  .detail-section {
    padding: var(--space-4);
  }
  
  .trade-detail-modal .modal-header {
    padding: var(--space-4);
  }
  
  .trade-detail-modal .modal-footer {
    padding: var(--space-4);
    flex-wrap: wrap;
  }
  
  .modal-title-group {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .strategy-info {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .trade-detail-modal .modal-footer {
    flex-direction: column;
  }
  
  .trade-detail-modal .modal-footer .btn {
    width: 100%;
  }
}

/* Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* ──────────────────────────────────────────────────────────────────
 * A3 Stella Inline — "Stella Read" section inside trade-drawer-body.
 * Reuses .sa-card / .sa-cards / .sa-ask-disabled-panel from
 * stella-ambient.css for visual consistency with the page-level
 * Ambient drawer. Wrapper styles below are local — header eyebrow +
 * title, surrounding chrome, "Open full Stella" link.
 *
 * Section starts hidden (`hidden` attr in HTML). Footer Stella button
 * unhides + scrollIntoView. hide() on drawer close re-hides for the
 * next trade.
 * ────────────────────────────────────────────────────────────────── */

.trade-stella-section {
  margin: 24px 0 8px;
  padding: 18px 20px 16px;
  background: linear-gradient(180deg,
    rgba(20, 23, 30, 0.55) 0%,
    rgba(13, 15, 20, 0.55) 100%);
  border: 1px solid rgba(94, 173, 184, 0.22);
  border-radius: 12px;
  position: relative;
}
.trade-stella-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--brand, #5eadb8) 50%,
    transparent 100%);
  opacity: 0.6;
  border-radius: 12px 12px 0 0;
}
.trade-stella-section[hidden] {
  display: none;
}

.trade-stella-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.trade-stella-eyebrow {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand, #5eadb8);
  opacity: 0.85;
}
.trade-stella-section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.25;
}

#tradeStellaCards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.trade-stella-ask {
  margin-bottom: 12px;
}

/* Round-19 A1 + Round-21 follow-up: trade-detail footer "Ask Stella"
   matches the nav-rail pill (.sa-pill-desktop) recipe — same affordance
   = same look. Subtle brand tint + bordered outline, NOT a solid
   gradient. Behaviour unchanged: clicking still calls revealStellaInline(). */
.trade-stella-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-primary, #e2e8f0);
  background: linear-gradient(180deg,
    rgba(94, 173, 184, 0.10) 0%,
    rgba(94, 173, 184, 0.04) 100%);
  border: 1px solid rgba(94, 173, 184, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.trade-stella-cta:hover {
  background: linear-gradient(180deg,
    rgba(94, 173, 184, 0.18) 0%,
    rgba(94, 173, 184, 0.08) 100%);
  border-color: rgba(94, 173, 184, 0.45);
}
.trade-stella-cta:active { transform: translateY(1px); }
.trade-stella-cta:focus-visible {
  outline: 2px solid var(--brand, #5eadb8);
  outline-offset: 2px;
}
.trade-stella-cta-icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--brand, #5eadb8);
}
.trade-stella-cta-label { white-space: nowrap; }

/* Round-18 canary fix #3: inline trade-drawer Ask — conversation + chips. */
.ti-conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.ti-conversation:empty {
  display: none;
}
.ti-qa {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}
.ti-qa-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ti-qa-row + .ti-qa-row {
  margin-top: 4px;
}
.ti-qa-tag {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-tertiary, #64748b);
}
.ti-qa-stella .ti-qa-tag {
  color: var(--brand, #5eadb8);
}
.ti-qa-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary, #e2e8f0);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ti-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.ti-suggestion {
  font-family: inherit;
  font-size: 11.5px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(94, 173, 184, 0.06);
  border: 1px solid rgba(94, 173, 184, 0.18);
  color: var(--text-primary, #e2e8f0);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ti-suggestion:hover {
  background: rgba(94, 173, 184, 0.12);
  border-color: rgba(94, 173, 184, 0.32);
}

/* Round-20 D/F: per-Stella-answer "Draft journal entry from this" mini-action. */
.ti-qa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 6px;
}
.ti-qa-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(94, 173, 184, 0.06);
  border: 1px solid rgba(94, 173, 184, 0.2);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ti-qa-action:hover {
  background: rgba(94, 173, 184, 0.14);
  color: var(--text-primary, #e2e8f0);
}

/* Round-20 D: primary "Draft journal entry" CTA — separate row below
   the Ask form so it doesn't get visually folded in with chips. */
.ti-draft-cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.ti-draft-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--brand-text, #001216);
  background: linear-gradient(180deg,
    var(--brand, #5eadb8) 0%,
    color-mix(in srgb, var(--brand, #5eadb8) 82%, #000) 100%);
  border: 1px solid color-mix(in srgb, var(--brand, #5eadb8) 55%, transparent);
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15) inset;
}
.ti-draft-cta:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.ti-draft-cta-sub {
  font-size: 11.5px;
  color: var(--text-tertiary, #64748b);
}

/* Round-20 D: editable draft preview panel. */
.ti-draft-panel[hidden] {
  display: none;
}
.ti-draft-panel {
  margin-top: 12px;
}
.ti-draft-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: rgba(94, 173, 184, 0.04);
  border: 1px solid rgba(94, 173, 184, 0.18);
  border-radius: 10px;
}
.ti-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ti-draft-eyebrow {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--brand, #5eadb8);
}
.ti-draft-confidence {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary, #64748b);
}
.ti-draft-conf-low { color: #ef4444; border-color: rgba(239, 68, 68, 0.28); background: rgba(239, 68, 68, 0.06); }
.ti-draft-conf-medium { color: #fbbf24; border-color: rgba(251, 191, 36, 0.28); background: rgba(251, 191, 36, 0.06); }
.ti-draft-conf-high { color: #34d399; border-color: rgba(52, 211, 153, 0.28); background: rgba(52, 211, 153, 0.06); }
.ti-draft-disclaimer {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-tertiary, #64748b);
}
.ti-draft-saveline {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-tertiary, #64748b);
  font-style: italic;
}
.ti-draft-label {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary, #64748b);
}
.ti-draft-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #e2e8f0);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
  resize: vertical;
}
.ti-draft-input:focus {
  border-color: rgba(94, 173, 184, 0.45);
  background: rgba(94, 173, 184, 0.06);
}
.ti-draft-row {
  display: flex;
  gap: 10px;
}
.ti-draft-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ti-draft-col-narrow {
  flex: 0 1 86px;
}
.ti-draft-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.ti-draft-action-primary {
  flex: 1 1 auto;
  height: 32px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-text, #001216);
  background: linear-gradient(180deg,
    var(--brand, #5eadb8) 0%,
    color-mix(in srgb, var(--brand, #5eadb8) 82%, #000) 100%);
  border: 1px solid color-mix(in srgb, var(--brand, #5eadb8) 55%, transparent);
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.ti-draft-action-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.ti-draft-action-ghost {
  height: 32px;
  font-family: inherit;
  font-size: 13px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary, #94a3b8);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ti-draft-action-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary, #e2e8f0);
}
.ti-draft-status {
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  padding: 8px 0;
}
.ti-draft-status-error {
  color: #ef4444;
}

.trade-stella-section-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.trade-stella-fullpage {
  font-size: 12.5px;
  color: var(--brand, #5eadb8);
  text-decoration: none;
  font-weight: 500;
}
.trade-stella-fullpage:hover {
  text-decoration: underline;
}

/* ── Round 22A: trade-drawer Debrief composer ─────────────────────── */
/* Secondary CTA next to "Draft journal entry" in the inline Stella
   section. Same bordered-tint recipe as nav-rail Ask Stella so it reads
   as "another path", not a fancier alternative. */
.td-debrief-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-primary, #e2e8f0);
  background: linear-gradient(180deg,
    rgba(94, 173, 184, 0.10) 0%,
    rgba(94, 173, 184, 0.04) 100%);
  border: 1px solid rgba(94, 173, 184, 0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.td-debrief-cta:hover {
  background: linear-gradient(180deg,
    rgba(94, 173, 184, 0.18) 0%,
    rgba(94, 173, 184, 0.08) 100%);
  border-color: rgba(94, 173, 184, 0.45);
}
.td-debrief-cta:active { transform: translateY(1px); }
.td-debrief-cta svg { color: var(--brand, #5eadb8); }

.td-debrief-panel[hidden] { display: none; }
.td-debrief-panel { margin-top: 12px; }
.td-debrief-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  background: rgba(94, 173, 184, 0.04);
  border: 1px solid rgba(94, 173, 184, 0.18);
  border-radius: 10px;
}
.td-debrief-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.td-debrief-eyebrow {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--brand, #5eadb8);
}
.td-debrief-title {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
}
.td-debrief-textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #e2e8f0);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
  resize: vertical;
}
.td-debrief-textarea:focus {
  border-color: rgba(94, 173, 184, 0.45);
  background: rgba(94, 173, 184, 0.06);
}
.td-debrief-voice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.td-debrief-voice-unavailable {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
}
.td-debrief-mic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-primary, #e2e8f0);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.td-debrief-mic:hover {
  background: rgba(94, 173, 184, 0.10);
  border-color: rgba(94, 173, 184, 0.30);
}
.td-debrief-mic-recording {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}
.td-debrief-timer {
  font-family: 'JetBrains Mono', var(--font-mono, monospace);
  font-size: 11.5px;
  color: var(--text-tertiary, #64748b);
}
.td-debrief-voice-status {
  margin-left: auto;
  overflow-wrap: anywhere;
  font-size: 11.5px;
  color: var(--text-secondary, #94a3b8);
}
.td-debrief-voice-error { color: #fecaca; }
.td-debrief-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.td-debrief-primary {
  flex: 1 1 auto;
  height: 32px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-text, #001216);
  background: linear-gradient(180deg, var(--brand, #5eadb8) 0%, color-mix(in srgb, var(--brand, #5eadb8) 82%, #000) 100%);
  border: 1px solid color-mix(in srgb, var(--brand, #5eadb8) 55%, transparent);
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.td-debrief-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.td-debrief-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.td-debrief-ghost {
  height: 32px;
  font-family: inherit;
  font-size: 13px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary, #94a3b8);
  border-radius: 6px;
  cursor: pointer;
}
.td-debrief-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary, #e2e8f0); }
.td-debrief-status {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
  min-height: 1em;
}
.td-debrief-status-error { color: #fecaca; }
.td-debrief-preview[hidden] { display: none; }

/* Round 22B: deterministic Stella action strip rendered alongside the
   existing "Draft journal entry from this" button inside [data-ti-qa-actions].
   Reuses the .sa-action-btn class from stella-ambient.css so both
   surfaces look identical. */
.ti-qa-actions-extra {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 6px;
}
.ti-qa-actions-extra:empty {
  display: none;
  margin-left: 0;
}
.ti-qa-actions-extra .sa-actions {
  display: contents; /* let buttons flow inline next to "Draft from this" */
}

/* Round-28: Stella mobile pass. These rules only touch the newer
   inline Stella surfaces inside the already-mobile trade drawer. */
@media (max-width: 640px) {
  .trade-stella-section {
    margin: 16px 0 6px;
    padding: 14px 12px 12px;
    border-radius: 10px;
  }
  .trade-stella-section-title {
    font-size: 15px;
  }
  .trade-stella-cta,
  .ti-draft-cta,
  .td-debrief-cta,
  .td-debrief-primary,
  .td-debrief-ghost,
  .ti-draft-action-primary,
  .ti-draft-action-ghost {
    min-height: 40px;
  }
  .ti-draft-cta-row,
  .td-debrief-actions,
  .ti-draft-actions,
  .ti-qa-actions {
    align-items: stretch;
  }
  .ti-draft-cta,
  .td-debrief-cta,
  .td-debrief-primary,
  .td-debrief-ghost,
  .ti-draft-action-primary,
  .ti-draft-action-ghost {
    flex: 1 1 100%;
    justify-content: center;
  }
  .ti-draft-cta-sub {
    flex: 1 1 100%;
  }
  .ti-draft-row {
    flex-direction: column;
  }
  .ti-draft-col-narrow {
    flex: 1 1 auto;
  }
  .td-debrief-voice {
    align-items: stretch;
  }
  .td-debrief-mic {
    min-height: 40px;
    justify-content: center;
  }
  .td-debrief-timer,
  .td-debrief-voice-status {
    flex: 1 1 100%;
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .trade-stella-section {
    padding: 12px 10px;
  }
  .ti-suggestions,
  .ti-qa-actions-extra .sa-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .ti-suggestion,
  .ti-qa-action,
  .ti-qa-actions-extra .sa-action-btn {
    width: 100%;
    min-height: 36px;
    justify-content: center;
  }
  .ti-qa-actions {
    justify-content: stretch;
  }
  .ti-qa-actions-extra {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    margin-left: 0;
  }
  .td-debrief-textarea,
  .ti-draft-input {
    font-size: 16px; /* prevent iOS input zoom */
  }
}
