* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #0b1021;
  color: #e8ecf1;
  min-width: 1200px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #141b2d;
  border-bottom: 1px solid #1f2a3d;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  font-weight: bold;
  letter-spacing: 0.5px;
  font-size: 15px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls label {
  font-size: 13px;
  white-space: nowrap;
}

.atlas-modes {
  display: flex;
  gap: 4px;
  margin-right: 8px;
}

.run-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px;
  background: rgba(31, 42, 61, 0.5);
  border-radius: 6px;
}

.data-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: rgba(31, 42, 61, 0.35);
  border-radius: 6px;
}

.data-controls input,
.data-controls select {
  background: #0f1628;
  color: #e8ecf1;
  border: 1px solid #1f2a3d;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}

.data-controls input {
  width: 200px;
}

.data-controls input::placeholder {
  color: #6b7280;
}

.mode-btn {
  padding: 6px 12px;
  border: 1px solid #1f2a3d;
  background: #161d30;
  color: #e8ecf1;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.mode-btn.active {
  background: #4fd1c5;
  border-color: #4fd1c5;
  color: #0b1021;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

main {
  display: flex;
  height: calc(100vh - 60px);
}

aside, section {
  padding: 16px;
  overflow-y: auto;
}

#spinesColumn {
  width: 32%;
  border-right: 1px solid #1f2a3d;
}

.spine-legend {
  margin-bottom: 10px;
}

.spine-row {
  display: flex;
  gap: 0;
  position: relative;
}

.spine-row .spine-card {
  flex: 1;
}

.spine-row .spine-card:first-child {
  border-right: 2px solid #4fd1c5;
}

/* Single model mode - full width for Run A */
.spine-row.single-mode .spine-card:first-child {
  border-right: none;
}

#alignmentArcs {
  display: none; /* Hide the SVG arcs, using border instead */
}

.spine-card {
  border: 1px solid #1f2a3d;
  border-radius: 8px;
  padding: 10px;
  background: #10182b;
}

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

.layer-list {
  margin-top: 8px;
}

/* Remove duplicate - already defined above */

.legend {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.delta-legend {
  margin-top: 10px;
  border-top: 1px solid #1f2a3d;
  padding-top: 8px;
}

#geometryCanvas {
  flex: 1;
  border-right: 1px solid #1f2a3d;
}

#inspector {
  width: 28%;
}

.layer-list {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.layer-list .layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  margin-bottom: 2px;
  background: #161d30;
  border: 1px solid #1f2a3d;
  border-radius: 4px;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
  position: relative;
  flex-wrap: nowrap;
  font-size: 11px;
}

.layer-row .diff-chip {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(156, 163, 175, 0.16);
  border: 1px solid #2b9f96;
  border-radius: 10px;
  font-size: 11px;
  padding: 2px 6px;
  color: #cbd5e1;
}

.layer-list .layer-row.active {
  border-color: #4fd1c5;
  background: #1c2740;
}

.span-indicator {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(79, 209, 197, 0.18), rgba(246, 173, 85, 0.25));
  opacity: 0;
  border-radius: 6px;
}

.layer-row .span-indicator.visible {
  opacity: 1;
}

.metric-bars {
  display: flex;
  gap: 4px;
  width: 40%;
  align-items: center;
}

.sparkline {
  width: 40px;
  height: 14px;
  display: none; /* Hide in compact mode */
}

.mode-glyph {
  font-size: 9px;
  color: #94a3b8;
  margin-left: 4px;
}

.mode-glyph.semantic {
  color: #fbbf24;
}

.metric-bar {
  height: 6px;
  background: linear-gradient(90deg, #4fd1c5, #2b9f96);
  border-radius: 3px;
}

.rank-bar {
  height: 4px;
  background: #9f7aea;
  border-radius: 2px;
}

.loss-chip {
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}

.loss-positive { background: #1f8554; }
.loss-negative { background: #8c3232; }

#plotArea {
  background: #10182b;
  border: 1px solid #1f2a3d;
  border-radius: 8px;
  padding: 8px;
  height: 420px;
}

#scatterPlot {
  width: 100%;
  height: 100%;
  background: #0f1626;
}

#objectToolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid #4fd1c5;
  color: #e8ecf1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chip.ghost {
  border-color: #1f2a3d;
  color: #7b8ba8;
}

.hidden {
  display: none !important;
}

#selectedModeMeta {
  margin-left: 0;
  font-size: 12px;
  color: #cbd5e1;
}

.three-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.three-controls label {
  font-size: 0.75rem;
  color: #94a3b8;
}

.three-controls select {
  background: #0f172a;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 4px 6px;
  border-radius: 6px;
}

.three-controls input[type="checkbox"] {
  accent-color: #38bdf8;
}

.three-controls input[type="color"] {
  width: 36px;
  height: 24px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 6px;
  background: transparent;
  padding: 0;
}

.three-container,
.plotly-container {
  width: 100%;
  height: 420px;
  border-radius: 16px;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.1), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.25);
}

#threeLegend {
  margin-top: 8px;
}

#threeLegendScale {
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
}

#threeLegendScale .scale-bar {
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg, #38bdf8, #22c55e, #f97316);
  margin-top: 6px;
}

#threeLegendScale .adapter-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 10px;
  margin-top: 6px;
}

#threeLegendScale .adapter-swatch-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#threeLegendScale .adapter-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

#threeTooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: #e2e8f0;
  z-index: 5;
}

.hidden {
  display: none;
}

.focus-chip {
  background: linear-gradient(90deg, #4fd1c5, #2b9f96);
  color: #0b1021;
  border: none;
}

#modeAtlas {
  margin-top: 12px;
}

.atlas-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.caption {
  color: #94a3b8;
  margin: 0;
  font-size: 13px;
}

#modesList {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.mode-card {
  padding: 8px;
  border: 1px solid #1f2a3d;
  border-radius: 6px;
  background: #161d30;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.15s ease;
}

.mode-card.active {
  border-color: #4fd1c5;
  transform: translateY(-2px);
}

.mode-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: #cbd5e1;
}

.semantic-category {
  font-size: 11px;
  color: #fbbf24;
  margin-top: 4px;
}

.panel {
  margin-bottom: 16px;
  padding: 12px;
  background: #161d30;
  border: 1px solid #1f2a3d;
  border-radius: 6px;
}

#timeline {
  width: 100%;
  height: 200px;
}

.tooltip {
  position: absolute;
  background: rgba(15, 22, 38, 0.95);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #4fd1c5;
  font-size: 12px;
  pointer-events: none;
}

.hidden { display: none; }

#runDetails, #layerDetails {
  font-size: 14px;
  line-height: 1.5;
}

#modeInspector {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #1f2a3d;
}

#comparisonDetails {
  margin-top: 8px;
  padding: 8px;
  background: #0f1626;
  border: 1px solid #1f2a3d;
  border-radius: 6px;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.diff-card {
  border: 1px solid #1f2a3d;
  border-radius: 6px;
  padding: 6px;
  background: #161d30;
}

.diff-card h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.badge {
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid #1f2a3d;
  background: #0f1626;
  font-size: 12px;
}

.semantic-region {
  background: #0f1626;
  border: 1px dashed #2b9f96;
  border-radius: 8px;
  padding: 8px;
  margin-top: 8px;
}

.semantic-region h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #4fd1c5;
}

.table-list {
  margin-top: 8px;
  padding: 0;
  list-style: none;
}

.table-list li {
  margin-bottom: 4px;
}

/* Tooltip styles */
.info-tooltip {
  position: fixed;
  max-width: 300px;
  padding: 10px 14px;
  background: #1a2235;
  border: 1px solid #4fd1c5;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: #e8ecf1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.info-tooltip.visible {
  opacity: 1;
}

.info-tooltip h4 {
  margin: 0 0 6px 0;
  color: #4fd1c5;
  font-size: 14px;
}

.info-tooltip p {
  margin: 0;
}

/* Help toggle button */
.help-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #4fd1c5;
  color: #0b1021;
  border: none;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 209, 197, 0.4);
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 999;
}

.help-toggle:hover {
  transform: scale(1.1);
  background: #68e0d5;
}

/* Hoverable elements get subtle indicator */
[data-tooltip] {
  cursor: help;
}

[data-tooltip]:hover {
  outline: 1px dashed rgba(79, 209, 197, 0.4);
  outline-offset: 2px;
}

/* Tasks Panel Styles */
.tasks-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #f59e0b;
  color: #0b1021;
  font-weight: 600;
}

.tasks-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.tasks-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 16, 33, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tasks-overlay.hidden {
  display: none;
}

.tasks-panel {
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  background: #141b2d;
  border: 1px solid #1f2a3d;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #161d30;
  border-bottom: 1px solid #1f2a3d;
}

.tasks-header h2 {
  margin: 0;
  font-size: 18px;
  color: #f59e0b;
}

.close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0 8px;
}

.close-btn:hover {
  color: #e8ecf1;
}

.tasks-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #0f1628;
  border-bottom: 1px solid #1f2a3d;
}

.tasks-filters label {
  font-size: 13px;
  color: #94a3b8;
}

.tasks-filters select {
  background: #161d30;
  color: #e8ecf1;
  border: 1px solid #1f2a3d;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
}

.tasks-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.tasks-loading {
  text-align: center;
  color: #94a3b8;
  padding: 40px;
}

.task-card {
  padding: 14px 16px;
  background: #161d30;
  border: 1px solid #1f2a3d;
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.task-card:hover {
  border-color: #f59e0b;
  transform: translateY(-2px);
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.task-card h3 {
  margin: 0;
  font-size: 15px;
  color: #e8ecf1;
}

.task-priority {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.task-priority.high {
  background: #dc2626;
  color: white;
}

.task-priority.medium {
  background: #f59e0b;
  color: #0b1021;
}

.task-priority.low {
  background: #22c55e;
  color: #0b1021;
}

.task-card-desc {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 10px;
  line-height: 1.4;
}

.task-card-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #64748b;
}

.task-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
}

.task-status.open {
  background: #22c55e20;
  color: #22c55e;
  border: 1px solid #22c55e40;
}

.task-status.completed {
  background: #3b82f620;
  color: #3b82f6;
  border: 1px solid #3b82f640;
}

.task-detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.task-detail.hidden {
  display: none;
}

#taskDetailContent h3 {
  margin: 16px 0 8px;
  font-size: 16px;
  color: #f59e0b;
}

#taskDetailContent .task-spec {
  background: #0f1628;
  border: 1px solid #1f2a3d;
  border-radius: 6px;
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
  color: #a5b4fc;
}

#taskDetailContent .task-hypothesis {
  background: #1e1b4b20;
  border: 1px dashed #6366f1;
  border-radius: 6px;
  padding: 12px;
  font-style: italic;
  color: #c4b5fd;
}

.no-tasks {
  text-align: center;
  padding: 40px;
  color: #64748b;
}

.no-tasks p {
  margin: 8px 0;
}
