/* One stylesheet. Class colours come from colors.css, which build.py generates
   out of sprsound.viz so the dashboard cannot drift from the report's figures. */

:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --border: #d8dce3;
  --text: #16191d;
  --muted: #5c646f;
  --accent: #2563eb;
  --warn-bg: #fff4e5;
  --warn-border: #b45309;
  --error: #b91c1c;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1d2127;
    --border: #2f353e;
    --text: #e9ecf1;
    --muted: #9aa3b0;
    --warn-bg: #2e2415;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header { padding: 24px 0 8px; }
h1 { margin: 0 0 4px; font-size: 1.5rem; }
h3 { margin: 24px 0 8px; font-size: 1.1rem; }
h4 { margin: 16px 0 4px; font-size: .95rem; color: var(--muted); }
.muted { color: var(--muted); font-weight: 400; }
.mono { font-family: var(--mono); font-size: .85em; }
a { color: var(--accent); }

/* Filter bar */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
  padding: 12px; margin: 8px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.control { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.control legend { padding: 0 0 2px; font-size: .75rem; text-transform: uppercase;
                  letter-spacing: .04em; color: var(--muted); }
.control--range { flex-direction: row; align-items: center; gap: 4px; flex-wrap: wrap; }
.control--range legend { width: 100%; }
.control--range input { width: 5.5em; }
.check { display: flex; gap: 5px; align-items: center; font-size: .9rem; white-space: nowrap; }
select[multiple] { min-width: 14em; }
input, select, button { font: inherit; color: inherit; background: var(--bg);
                        border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.is-selected { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; color: var(--muted); }

.counts { margin: 4px 0 12px; color: var(--muted); }
.counts strong { color: var(--text); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }

/* Tiles */
.tiles { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tile { flex: 1 1 140px; padding: 10px 12px; background: var(--surface);
        border: 1px solid var(--border); border-radius: var(--radius); }
.tile__value { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.tile__label { display: block; font-size: .75rem; color: var(--muted); }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.charts--stacked { grid-template-columns: 1fr; }
.chart { padding: 8px; background: var(--surface); border: 1px solid var(--border);
         border-radius: var(--radius); overflow-x: auto; }

/* Notices */
.notice { padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--border);
          background: var(--surface); margin: 8px 0; }
.notice--error { border-color: var(--error); }
.notice--warn { background: var(--warn-bg); border-color: var(--warn-border); }
.notice--info { color: var(--muted); font-size: .9rem; }

/* Explore */
.explore { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; }
.events-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--border);
               border-radius: var(--radius); }
table.events { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.events th { position: sticky; top: 0; background: var(--surface); text-align: left;
                  padding: 6px 8px; border-bottom: 1px solid var(--border); font-weight: 600; }
table.events td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
table.events tbody tr { cursor: pointer; }
table.events tbody tr:hover { background: var(--surface); }
table.events tbody tr.is-selected { background: color-mix(in srgb, var(--accent) 18%, transparent); }

.detail { min-width: 0; }
.detail__columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: .85rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-variant-numeric: tabular-nums; }

.spectrograms { display: flex; flex-direction: column; gap: 10px; }
.spectrograms figure { margin: 0; }
.spectrograms figcaption { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.spectro { width: 100%; height: auto; image-rendering: pixelated; background: #000;
           border: 1px solid var(--border); border-radius: 4px; }
.spectro--crop { max-height: 150px; }
.spectro--full { max-height: 110px; }
.spectro--thumb { max-height: 90px; }

.player { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.player__status { font-size: .8rem; color: var(--muted); }

/* Listen */
.listen__bar { display: flex; gap: 12px; align-items: center; justify-content: space-between;
               flex-wrap: wrap; }
.listen__class { margin-bottom: 20px; }
.listen__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.listen__card { margin: 0; padding: 6px; background: var(--surface);
                border: 1px solid var(--border); border-radius: var(--radius); }
.listen__card figcaption { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.listen__stem { overflow-wrap: anywhere; color: var(--muted); }

/* Models */
.runs { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.runs__group { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px;
               display: flex; flex-wrap: wrap; gap: 6px; }
.runs__group legend { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
                      color: var(--muted); }
.warn-dot { color: var(--warn-border); }

/* Figures */
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.figures__card { margin: 0; padding: 8px; background: var(--surface);
                 border: 1px solid var(--border); border-radius: var(--radius); }
.figures__card img { width: 100%; height: auto; border-radius: 4px; background: #fff; }
.figures__card figcaption { display: flex; flex-direction: column; gap: 3px; margin-top: 6px;
                            font-size: .8rem; }

footer { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--border);
         font-size: .8rem; color: var(--muted); }
footer p { margin: 2px 0; }

@media (max-width: 860px) {
  .explore { grid-template-columns: 1fr; }
  .events-wrap { max-height: 40vh; }
}
