* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: #fafafa;
  color: #333;
  padding: 1rem 1.5rem;
}

header {
  margin-bottom: 0.8rem;
}
header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}
.subtitle {
  color: #666;
  font-size: 0.85rem;
}

/* ---- Main layout: sidebar + plots ---- */
.main-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.plots-area {
  flex: 1;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  min-width: 0;
}

/* ---- Control groups ---- */
.control-group {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.7rem;
}

.control-group h3 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #555;
}

/* ---- Gene input ---- */
.gene-input-row {
  display: flex;
  gap: 0.3rem;
  position: relative;
}

#gene-input {
  flex: 1;
  padding: 0.3rem 0.45rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

#add-gene-btn {
  padding: 0.3rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
}
#add-gene-btn:hover { background: #eee; }

.suggestions {
  position: absolute;
  z-index: 100;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  width: 240px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.suggestions .sug-item {
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.suggestions .sug-item:hover, .suggestions .sug-item.active {
  background: #e8f0fe;
}

/* ---- Presets ---- */
.presets {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.preset-label {
  font-size: 0.75rem;
  color: #888;
}
.preset-btn {
  padding: 0.2rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
}
.preset-btn:hover { background: #eee; }

/* ---- Scrolling gene list ---- */
.gene-list-scroll {
  margin-top: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fafafa;
}
.gene-list-empty {
  padding: 0.8rem 0.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: #999;
}

.gene-entry {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid #eee;
  font-size: 0.82rem;
}
.gene-entry:last-child { border-bottom: none; }

.gene-entry.is-group {
  background: #eef4ff;
}
.gene-entry.is-disabled {
  opacity: 0.4;
}

.gene-entry input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: #4a7dca;
}

.gene-entry .gene-entry-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}
.gene-entry .gene-entry-label .group-genes {
  font-size: 0.72rem;
  color: #777;
}

.gene-entry .gene-entry-remove {
  cursor: pointer;
  color: #aaa;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.15rem;
}
.gene-entry .gene-entry-remove:hover { color: #d33; }

/* ---- Radio row ---- */
.radio-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.radio-row label { cursor: pointer; }

/* ---- Dataset selector ---- */
#dataset-select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  background: #fff;
  cursor: pointer;
}
.esed-label {
  font-size: 0.85rem;
  color: #555;
  padding: 0.2rem 0;
  display: block;
}

/* ---- Plot panels ---- */
.plot-panel {
  flex: 1;
  min-width: 460px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.6rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.panel-header h3 {
  font-size: 0.9rem;
  color: #444;
}

.settings-toggle {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.15rem 0.4rem;
  color: #666;
}
.settings-toggle:hover { background: #eee; }

.panel-settings {
  padding: 0.5rem;
  margin-bottom: 0.4rem;
  background: #f5f7fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}
.settings-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
  align-items: center;
  flex-wrap: wrap;
}
.settings-row label {
  font-size: 0.78rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.settings-row input[type="number"] {
  width: 72px;
  padding: 0.2rem 0.3rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.78rem;
}

.apply-btn, .export-btn {
  padding: 0.25rem 0.55rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
}
.apply-btn:hover, .export-btn:hover { background: #eee; }
.apply-btn { font-weight: 600; }

.download-row {
  margin-top: 0.2rem;
  border-top: 1px solid #e0e0e0;
  padding-top: 0.4rem;
}
.download-data-btn {
  padding: 0.3rem 0.6rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f0f4f8;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  color: #444;
  width: 100%;
  text-align: center;
}
.download-data-btn:hover { background: #e2e8f0; }

/* ---- Plot area ---- */
.plot-area {
  position: relative;
  width: 100%;
  height: 480px;
}
.plot-area canvas {
  position: absolute;
  top: 0;
  left: 0;
}
.plot-area svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.plot-area svg .highlight-point,
.plot-area svg .group-crosshair {
  pointer-events: all;
}

/* ---- Tooltip ---- */
.tooltip {
  position: fixed;
  display: none;
  padding: 0.4rem 0.6rem;
  background: rgba(0,0,0,0.85);
  color: #fff;
  border-radius: 4px;
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 200;
  white-space: pre-line;
  max-width: 280px;
}
