@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-base: #050508;
  --bg-bokeh-magenta: #d1248b;
  --bg-bokeh-purple: #633991;
  --bg-bokeh-coral: #e86d5a;
  --bg-bokeh-maroon: #4a1525;
  --surface: rgba(12, 12, 16, 0.72);
  --surface-elevated: rgba(18, 16, 24, 0.88);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.62);
  --accent-coral: #ff8a65;
  --accent-magenta: #d1248b;
  --accent-purple: #7c4dbf;
  --active-bg: rgba(209, 36, 139, 0.18);
  --active-border: #c0127c;
  --active-text: #ffb8df;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 1.5rem;
  color: var(--text);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 120% 80% at 85% 15%, rgba(209, 36, 139, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 95% 45%, rgba(99, 57, 145, 0.38) 0%, transparent 50%),
    radial-gradient(ellipse 100% 90% at 15% 10%, rgba(74, 21, 37, 0.55) 0%, transparent 45%),
    radial-gradient(ellipse 80% 70% at 92% 88%, rgba(232, 109, 90, 0.35) 0%, transparent 48%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(75, 42, 133, 0.2) 0%, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

h1 {
  margin-top: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

h3 {
  font-weight: 600;
  color: var(--accent-coral);
  font-size: 0.95rem;
  margin-top: 0;
}

input,
select,
textarea {
  font-family: inherit;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
}

input::placeholder {
  color: var(--text-muted);
}

.upload-section {
  background: var(--surface);
  padding: 1rem 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  margin-bottom: 1.5rem;
}

.settings-header {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-coral);
}

.upload-controls {
  padding-top: 1rem;
}

.upload-section label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-muted); }
.upload-section .row { margin-bottom: 0.75rem; }

.message {
  color: var(--text-muted);
}

.message.error {
  color: #ff8a80;
}

.viz-container {
  background: var(--surface);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  min-height: 200px;
  margin-bottom: 1.5rem;
}

.filter-row { 
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
}

#spiral-svg { display: block; margin: 0 auto; }

.spiral-layout {
  display: flex;
  align-items: flex-start;
  gap: var(--spiral-col-gap, 1rem);
  --spiral-controls-w: 190px;
  --spiral-col-gap: 1rem;
}

.spiral-controls-col {
  width: var(--spiral-controls-w);
  flex: 0 0 var(--spiral-controls-w);
}

.spiral-chart-col {
  flex: 1;
  position: relative;
}

.spiral-settings-col {
  width: 240px;
  flex: 0 0 240px;
}

.mode-toggle-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--surface-elevated);
}

.mode-toggle-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.mode-toggle-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.85;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.mode-toggle-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mode-toggle-btn {
  width: 100%;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.42rem 0.55rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}

.mode-toggle-emoji {
  display: block;
  font-size: 1.05rem;
  line-height: 1.1;
  margin-bottom: 0.12rem;
}

.mode-toggle-label {
  display: block;
}

.mode-toggle-btn:hover {
  background: rgba(209, 36, 139, 0.12);
  border-color: rgba(209, 36, 139, 0.35);
  color: var(--text);
}

.mode-toggle-btn.is-active {
  border-color: var(--active-border);
  background: var(--active-bg);
  color: var(--active-text);
  font-weight: 600;
}

.mode-toggle-btn.is-active.is-inverted {
  border-style: dashed;
  opacity: 0.92;
}

.spiral-controls-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--surface-elevated);
}

.spiral-controls-title {
  font-weight: 600;
  margin-bottom: 0.55rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.spiral-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.spiral-slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.45rem;
  align-items: center;
}

.spiral-slider-row label {
  margin-bottom: 0;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-muted);
}

.spiral-slider-value {
  font-size: 0.8rem;
  color: var(--accent-coral);
}

.spiral-slider-row input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent-magenta);
}

.spiral-range-box {
  margin-top: 0.8rem;
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}

.spiral-range-title {
  font-weight: 600;
  font-size: 0.87rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.spiral-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.spiral-range-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 0.45rem;
}

.spiral-range-selected {
  position: absolute;
  top: 0;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-magenta));
}

.spiral-range-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.spiral-range-sliders input[type='range'] {
  width: 100%;
  accent-color: var(--accent-magenta);
}

.bg-toggle-panel {
  position: absolute;
  /* Align with .mode-toggle-panel: offset by controls column + flex gap (positioning context is .spiral-chart-col) */
  left: calc(-1 * (var(--spiral-controls-w) + var(--spiral-col-gap)));
  bottom: 3.2rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(10, 10, 14, 0.88);
  backdrop-filter: blur(10px);
  padding: 0.5rem;
  z-index: 3;
  width: 175px;
}

.bg-toggle-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.bg-toggle-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.bg-toggle-btn {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.3rem 0.4rem;
  line-height: 1.1;
  text-align: center;
  color: var(--text-muted);
  font-family: inherit;
}

.bg-toggle-btn:hover {
  background: rgba(209, 36, 139, 0.12);
  border-color: rgba(209, 36, 139, 0.35);
  color: var(--text);
}

.bg-toggle-btn.is-active {
  border-color: var(--active-border);
  background: var(--active-bg);
  color: var(--active-text);
  font-weight: 600;
}

.bg-toggle-emoji {
  display: block;
  font-size: 0.96rem;
}

.bg-toggle-label {
  display: block;
}

.legend {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.legend-filter-note,
.legend-focus-note {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.swatch-active {
  background: #a78bfa;
  box-shadow: 0 0 8px rgba(209, 36, 139, 0.5);
}

.swatch-inactive {
  background: #666;
  opacity: 0.5;
}

.tooltip {
  position: fixed;
  display: none;
  padding: 0.5rem 0.75rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  pointer-events: none;
  z-index: 1000;
  color: var(--text);
  font-family: inherit;
}

.tooltip-date {
  color: var(--accent-coral);
  font-weight: 500;
}

.tooltip-duration {
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.debug-out {
  white-space: pre-wrap;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

@media (max-width: 980px) {
  .spiral-layout {
    flex-direction: column;
  }

  .spiral-controls-col {
    width: 100%;
    flex: 0 0 auto;
  }

  .bg-toggle-panel {
    left: 0.85rem;
  }

  .spiral-settings-col {
    width: 100%;
    flex: 0 0 auto;
  }

  .mode-toggle-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .mode-toggle-btn {
    width: auto;
  }
}
