:root {
  --bg: #16130f;
  --panel: #211c16;
  --border: #3a3227;
  --text: #e8e0d0;
  --muted: #9a8f7a;
  --accent: #e8a33d;
  --ok: #7bc46a;
  --err: #e06c5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  line-height: 1.5;
}

header {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.1rem; margin: 0; color: var(--accent); }
header nav a { color: var(--muted); text-decoration: none; margin-right: 1rem; }
header nav a.active, header nav a:hover { color: var(--text); }

main { max-width: 1100px; margin: 0 auto; padding: 1.2rem; }
main.narrow { max-width: 640px; }

h2 { font-size: 1rem; color: var(--accent); }

textarea, input, select, button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font: inherit;
}

textarea { width: 100%; resize: vertical; }
label { display: block; margin: 0.8rem 0 0.3rem; color: var(--muted); }

button {
  background: var(--accent);
  color: #1a1408;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
}
button:disabled { opacity: 0.4; cursor: default; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0;
}

.help { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--err); }
.ok { color: var(--ok); }
.banner { background: var(--err); color: #fff; padding: 0.5rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.hidden { display: none; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.8rem;
  margin-bottom: 1.2rem;
}
.filters label { margin: 0; font-size: 0.85rem; }
.filters input, .filters select { display: block; margin-top: 0.2rem; width: 9rem; }
#count { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

.charts { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.8rem;
}
.chart-head { display: flex; gap: 1rem; margin-bottom: 0.5rem; }
.chart-head label { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

#view3d-section { position: relative; margin: 1.2rem 0; }
#view3d-section button { margin-top: 0; }
#view3d-body { margin-top: 0.8rem; }
#view3d-body .chart-head label { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); }
#view3d-body .axis-toggles { margin-left: auto; display: inline-flex; gap: 0.8rem; }
#view3d-canvas { width: 100%; height: auto; cursor: grab; touch-action: none; }
#view3d-tooltip {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  pointer-events: none;
  white-space: pre;
  z-index: 1;
}

.mode-toggle { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.mode-toggle button { opacity: 0.6; }
.mode-toggle button.active { opacity: 1; }
.duration-row { display: flex; gap: 0.5rem; }
.duration-row input { width: 8rem; }

.combobox { position: relative; }
.combobox-panel {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  max-height: 14rem; overflow-y: auto;
  background: var(--panel); border: 1px solid #3a3227; border-radius: 4px;
}
.combobox-panel .option { padding: 0.4rem 0.6rem; cursor: pointer; }
.combobox-panel .option.active, .combobox-panel .option:hover { background: #3a3227; }
.combobox-panel .group {
  padding: 0.3rem 0.6rem; color: var(--muted);
  font-size: 0.75rem; text-transform: uppercase;
}
