/* Design Search styles. Tokens follow site palette: warm tan accent
   (#c49a6c), card surfaces (#12121a / #1a1a26), borders (#2a2a38). */

.ds-root {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg, 1.5rem);
  padding: var(--space-md, 1rem);
  max-width: 1100px;
  margin: 0 auto;
}

.ds-explainer {
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border, #2a2a38);
  border-left: 3px solid var(--accent, #c49a6c);
  border-radius: 8px;
  padding: var(--space-lg, 1.5rem);
}
.ds-explainer h2 {
  font-family: var(--font-heading, 'Playfair Display', serif);
  margin: 0 0 var(--space-sm, 0.75rem);
  color: var(--text-primary, #e8e6e1);
  font-size: 1.4rem;
}
.ds-explainer p {
  color: var(--text-secondary, #9a9690);
  line-height: 1.55;
  margin: 0 0 var(--space-sm, 0.75rem);
}
.ds-explainer p:last-child { margin-bottom: 0; }
.ds-explainer-line { font-size: 0.92rem; }

/* Controls grid */
.ds-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md, 1rem);
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border, #2a2a38);
  border-radius: 8px;
  padding: var(--space-lg, 1.5rem);
}

.ds-control-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.5rem);
}

.ds-control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary, #e8e6e1);
  font-weight: 500;
  font-size: 0.95rem;
}
.ds-control-value {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--accent, #c49a6c);
  font-size: 0.85rem;
}
.ds-control-meta,
.ds-control-meta-inline {
  font-size: 0.8rem;
  color: var(--text-muted, #5a5854);
}

.ds-extras-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg, 1.5rem);
  align-items: center;
}

.ds-slider-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.75rem);
}

.ds-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-surface, #1a1a26);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.ds-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent, #c49a6c);
  border-radius: 50%;
  border: 2px solid var(--bg-deep, #0a0a0f);
  cursor: pointer;
}
.ds-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent, #c49a6c);
  border-radius: 50%;
  border: 2px solid var(--bg-deep, #0a0a0f);
  cursor: pointer;
}
.ds-numeric {
  width: 90px;
  background: var(--bg-surface, #1a1a26);
  color: var(--text-primary, #e8e6e1);
  border: 1px solid var(--border, #2a2a38);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.85rem;
}
.ds-slider-unit {
  font-size: 0.8rem;
  color: var(--text-muted, #5a5854);
  font-family: var(--font-mono, monospace);
}

/* Arc slider with marker + chip-driven highlight band */
.ds-arc-track-wrap {
  align-items: center;
}
.ds-arc-track {
  flex: 1;
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
}
.ds-arc-track .ds-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  z-index: 2;
  background: transparent;
}
.ds-arc-highlight {
  position: absolute;
  top: 50%;
  height: 6px;
  margin-top: -3px;
  background: rgba(196, 154, 108, 0.25);
  border-radius: 3px;
  z-index: 1;
  transition: opacity 0.15s ease;
  opacity: 0;
}
.ds-arc-marker {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 18px;
  margin-top: -9px;
  background: var(--accent, #c49a6c);
  z-index: 3;
  pointer-events: none;
}
.ds-arc-marker::after {
  content: '88';
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  color: var(--accent, #c49a6c);
  letter-spacing: 0.05em;
}

/* Chips */
.ds-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs, 0.5rem);
}
.ds-chip {
  background: var(--bg-surface, #1a1a26);
  border: 1px solid var(--border, #2a2a38);
  color: var(--text-secondary, #9a9690);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ds-chip:hover {
  border-color: var(--accent, #c49a6c);
  color: var(--text-primary, #e8e6e1);
}
.ds-chip.active {
  background: rgba(196, 154, 108, 0.18);
  border-color: var(--accent, #c49a6c);
  color: var(--accent, #c49a6c);
  font-weight: 500;
}

/* Confidence range */
.ds-confidence-toggle {
  background: none;
  border: none;
  color: var(--text-secondary, #9a9690);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  padding: 0.25rem 0;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.ds-confidence-toggle:hover { color: var(--accent, #c49a6c); }
.ds-confidence-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.5rem);
  margin-top: var(--space-xs, 0.5rem);
}
.ds-confidence-body[hidden] { display: none; }

/* Result panel */
.ds-result {
  display: flex;
  flex-direction: column;
  gap: var(--space-md, 1rem);
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border, #2a2a38);
  border-radius: 8px;
  padding: var(--space-lg, 1.5rem);
}

.ds-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md, 1rem);
}
.ds-summary-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border, #2a2a38);
  border-radius: 6px;
  background: var(--bg-surface, #1a1a26);
}
.ds-summary-cell span {
  font-size: 0.7rem;
  color: var(--text-muted, #5a5854);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ds-summary-cell strong {
  font-family: var(--font-mono, monospace);
  color: var(--accent, #c49a6c);
  font-size: 1rem;
}

/* Non-standard banner */
.ds-non-standard-banner {
  background: rgba(232, 168, 56, 0.12);
  border: 1px solid rgba(232, 168, 56, 0.4);
  color: #e8a838;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

/* Bodygraph + timelines */
.ds-bodygraph-wrap {
  display: flex;
  justify-content: center;
}
.ds-bodygraph {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1.45;
  position: relative;
}

.ds-timelines {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 0.75rem);
}
.ds-timeline-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.ds-timeline-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #5a5854);
  font-family: var(--font-mono, monospace);
}
.ds-timeline-host {
  border: 1px solid var(--border, #2a2a38);
  border-radius: 6px;
  background: var(--bg-surface, #1a1a26);
  min-height: 110px;
  padding: 0.25rem;
}

/* Actions row */
.ds-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md, 1rem);
  flex-wrap: wrap;
}
.ds-status {
  font-size: 0.85rem;
  color: var(--text-muted, #5a5854);
  font-family: var(--font-mono, monospace);
}
.ds-save-btn {
  background: var(--accent, #c49a6c);
  border: none;
  color: var(--bg-deep, #0a0a0f);
  padding: 0.6rem 1.4rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.ds-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ds-save-btn:not(:disabled):hover {
  filter: brightness(1.1);
}

/* Modal */
.ds-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.ds-modal {
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border, #2a2a38);
  border-radius: 8px;
  padding: var(--space-lg, 1.5rem);
  width: min(420px, 92vw);
}
.ds-modal h3 {
  margin: 0 0 var(--space-sm, 0.75rem);
  color: var(--text-primary, #e8e6e1);
  font-family: var(--font-heading, serif);
}
.ds-modal-meta {
  color: var(--text-secondary, #9a9690);
  font-size: 0.9rem;
  margin: 0 0 var(--space-md, 1rem);
}
.ds-modal-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--text-secondary, #9a9690);
  font-size: 0.85rem;
}
.ds-modal-label input {
  background: var(--bg-surface, #1a1a26);
  color: var(--text-primary, #e8e6e1);
  border: 1px solid var(--border, #2a2a38);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-size: 0.95rem;
}
.ds-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm, 0.75rem);
  margin-top: var(--space-md, 1rem);
}
.ds-modal-cancel {
  background: transparent;
  border: 1px solid var(--border, #2a2a38);
  color: var(--text-secondary, #9a9690);
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
}
.ds-modal-save {
  background: var(--accent, #c49a6c);
  border: none;
  color: var(--bg-deep, #0a0a0f);
  padding: 0.5rem 1.2rem;
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
}
.ds-modal-error {
  color: #c83838;
  font-size: 0.85rem;
  margin-top: var(--space-sm, 0.75rem);
}

/* Auth gate prompt (used by the standalone page) */
.ds-login-prompt {
  max-width: 480px;
  margin: var(--space-2xl, 3rem) auto;
  padding: var(--space-xl, 2rem);
  text-align: center;
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border, #2a2a38);
  border-radius: 8px;
}
.ds-login-prompt h2 {
  font-family: var(--font-heading, serif);
  color: var(--text-primary, #e8e6e1);
  margin-bottom: var(--space-sm, 0.75rem);
}
.ds-login-prompt p {
  color: var(--text-secondary, #9a9690);
}
.ds-login-prompt a {
  color: var(--accent, #c49a6c);
}

/* ─── Mobile (≤480px) ─────────────────────────────────────
   At narrow widths, HdTimeline's planet-row table can extend past the
   viewport, and the side-by-side numeric input in the slider rows pushes
   the row width past 100vw. Constrain the root and let timelines scroll
   their own horizontal overflow inside a contained host. */
@media (max-width: 480px) {
  .ds-root {
    padding: var(--space-sm, 0.75rem);
    max-width: 100%;
    overflow-x: hidden;
  }
  .ds-controls,
  .ds-result {
    padding: var(--space-md, 1rem);
  }
  .ds-slider-row {
    flex-wrap: wrap;
    gap: var(--space-xs, 0.5rem);
  }
  .ds-arc-track-wrap {
    flex-wrap: wrap;
  }
  .ds-arc-track {
    flex: 1 1 100%;
    min-width: 0;
  }
  .ds-numeric {
    width: 70px;
    flex: 0 0 auto;
  }
  .ds-summary {
    gap: var(--space-sm, 0.75rem);
  }
  .ds-summary-cell {
    flex: 1 1 calc(50% - var(--space-sm, 0.75rem));
    min-width: 0;
  }
  /* Timelines: keep the host inside the viewport, scroll inner content
     horizontally on its own. */
  .ds-timeline-host {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ds-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .ds-save-btn {
    width: 100%;
  }
}
