:root{
  --surface:      #fcfcfb;
  --page:         #f9f9f7;
  --ink-primary:  #0b0b0b;
  --ink-secondary:#52514e;
  --ink-muted:    #898781;
  --gridline:     #e1e0d9;
  --baseline:     #c3c2b7;
  --border:       rgba(11,11,11,0.10);
  --accent:       #2fae3d;
  --accent-ink:   #ffffff;
}
@media (prefers-color-scheme: dark){
  :root{
    --surface:      #1a1a19;
    --page:         #0d0d0d;
    --ink-primary:  #ffffff;
    --ink-secondary:#c3c2b7;
    --ink-muted:    #898781;
    --gridline:     #2c2c2a;
    --baseline:     #383835;
    --border:       rgba(255,255,255,0.10);
    --accent:       #3de150;
    --accent-ink:   #0b0b0b;
  }
}

*{ box-sizing: border-box; }
html{ height: 100%; }
body{
  margin: 0;
  height: 100%;
  /* The page itself never scrolls - .sidebar and .main each scroll
     internally within their fixed flex slot instead (min-height:0 below is
     what makes a flex child respect that instead of just growing the
     page). Also what stops a Mac trackpad pinch from falling through to
     the browser's native page-zoom once it's not scrolled/zoomable to
     begin with; app.js additionally intercepts ctrl+wheel over the chart
     itself so pinching there always zooms the chart's window, never the
     page, even before this would otherwise matter. */
  overflow: hidden;
  background: var(--page);
  color: var(--ink-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}

.app-header{
  flex: 0 0 auto;
  padding: 18px 24px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand-logo{
  height: 30px;
  width: auto;
  display: block;
  margin: 0 0 4px;
}

.app-layout{
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.sidebar{
  width: 340px;
  flex: 0 0 340px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px;
  overflow-y: auto;
}

.panel{
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.panel:last-of-type{ border-bottom: none; }

.panel h2{
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  font-weight: 700;
}

.hint{
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 4px 0 8px;
}
.hint code{
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.95em;
}

.field{
  margin-bottom: 10px;
}
.field label{
  display: block;
  font-size: 0.78rem;
  color: var(--ink-secondary);
  margin-bottom: 3px;
}

select, input[type="text"], input[type="datetime-local"]{
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--ink-primary);
  font-size: 0.85rem;
  font-family: inherit;
}
select:disabled{
  opacity: 0.5;
}

.file-picker-btn{
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
}
.file-picker-btn:hover{ filter: brightness(1.08); }

.primary-btn{
  width: 100%;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.primary-btn:hover:not(:disabled){ filter: brightness(1.08); }
.primary-btn:disabled{ opacity: 0.45; cursor: default; }

.secondary-btn{
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: transparent;
  color: var(--ink-primary);
  font-size: 0.85rem;
  cursor: pointer;
}
.secondary-btn:hover{ background: var(--border); }

.btn-row{
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.btn-row .primary-btn{ margin-top: 0; flex: 1; width: auto; }

.render-btn{
  position: sticky;
  bottom: 0;
  margin-top: 10px;
}

.scroll-list{
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.series-row{
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.series-row:last-child{ border-bottom: none; }
.series-row .swatch{
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 10px;
}
.series-row .colname{
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.series-row .group-input{
  width: 74px;
  padding: 2px 4px;
  font-size: 0.72rem;
  border-radius: 4px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--ink-primary);
}
.series-row.categorical .colname{ color: var(--ink-secondary); font-style: italic; }

.filter-row{
  margin-bottom: 8px;
}
.filter-row label{
  display: block;
  font-size: 0.78rem;
  color: var(--ink-secondary);
  margin-bottom: 3px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}

.episode-row{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  cursor: pointer;
}
.episode-row:hover{ background: var(--border); }
.episode-row .ep-id{
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-weight: 600;
  grid-column: 1 / -1;
}
.episode-row .ep-meta{ color: var(--ink-muted); }

.main{
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

.empty-state{
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-top: 40px;
}

.chart-status{
  margin: 0 0 8px;
  text-align: right;
}

#chart{
  flex: 1;
  min-height: 500px;
  width: 100%;
}

.strip-legend{
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 6px 0 4px;
}
.strip-legend-group{
  font-size: 0.76rem;
  color: var(--ink-secondary);
}
.strip-legend-group b{
  color: var(--ink-primary);
}
.strip-legend-swatch{
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
