:root {
  font: 14px Arial, sans-serif;
  color: #263744;
  background: #fff;
  font-synthesis: none;
  --accent: #087bff;
  --ink: #263744;
  --muted: #526978;
  --line: #e2e9ed;
}

* { box-sizing: border-box; }
body { margin: 16px; }
.app-shell { max-width: 2100px; margin: auto; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 7px 0; }
h3 { font-size: 14px; margin: 0; }
p { line-height: 1.5; }
.page-header p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
button, input, select { font: inherit; }
button, select, input[type=number] {
  border: 1px solid #999;
  border-radius: 3px;
  padding: 6px 11px;
  background: #f3f3f3;
  color: var(--ink);
  font-size: 14px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { background: #e7eff8; }
button:disabled, select:disabled { opacity: .4; cursor: default; }
select { background: #fff; cursor: pointer; max-width: 100%; }
input[type=number] { background: #fff; font-variant-numeric: tabular-nums; }
input[type=range], input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, canvas:focus-visible, summary:focus-visible {
  outline: 2px solid #075cbb;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.parameter-bar, .field, .selection-counts, .metric, .selection-actions, .families, .view-actions, .point-size-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.parameter-bar { margin-bottom: 12px; gap: 10px; }
.field { gap: 6px; }
.metric { gap: 4px; }
.metric strong { font-weight: normal; font-variant-numeric: tabular-nums; }
.time-panel { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.time-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.time-controls { display: grid; gap: 5px; flex: 1; min-width: 340px; }
.time-control { display: grid; grid-template-columns: 86px 34px minmax(70px,1fr) 34px 76px; gap: 8px; align-items: center; }
.time-control input[type=range] { width: 100%; min-width: 0; margin: 0; }
.time-control input[type=number] { width: 100%; min-width: 0; padding: 4px 6px; text-align: right; }
.step-button { padding: 4px; font-size: 18px; height: 29px; line-height: 1; touch-action: manipulation; }
#play { min-width: 70px; }
#interval-label { font-weight: bold; white-space: nowrap; font-variant-numeric: tabular-nums; }
.view-actions { margin-bottom: 12px; }
.point-size-control { gap: 6px; flex-wrap: nowrap; }
#point-size { width: 130px; min-width: 70px; margin: 0; }
#point-size-value { min-width: 3em; font-variant-numeric: tabular-nums; }
.app-status { display: flex; align-items: center; gap: 8px; min-height: 23px; margin-bottom: 8px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.app-status.error { background: #fff4de; border-left: 3px solid #bd7a21; padding: 9px 12px; color: #864a12; }
.retry-button { padding: 3px 8px; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.plots { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px 14px; }
.plot-panel { min-width: 0; }
.plot-panel h2 { text-align: center; margin: 7px 0 5px; }
.plot-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; align-content: start; gap: 8px 12px; min-height: 72px; margin-bottom: 4px; font-size: 14px; }
.plot-controls label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.trajectory-view-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; }
.canvas-wrap { position: relative; width: 100%; aspect-ratio: 1; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
canvas.dragging { cursor: grabbing; }
.plot-footer { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); line-height: 1.5; margin: 3px 0 10px; }
.plot-footer > span { display: inline-flex; align-items: center; gap: 5px; }
.view-mode.manual { color: #864a12; }
.point-key { display: inline-block; width: 8px; height: 8px; border: 1px solid var(--muted); border-radius: 50%; }
.end-key { display: inline-block; width: 8px; height: 8px; background: var(--muted); border-radius: 50%; margin-left: 6px; }
.plot-empty { position: absolute; left: 50%; top: 46%; transform: translate(-50%,-50%); text-align: center; background: #fffffff0; color: var(--muted); max-width: 80%; padding: 10px 12px; font-size: 14px; line-height: 1.5; pointer-events: none; }
.plot-tooltip { position: absolute; pointer-events: none; background: #fff; color: var(--ink); border: 1px solid #999; padding: 8px 10px; border-radius: 3px; font-size: 12px; line-height: 1.6; box-shadow: 0 2px 8px #2637441a; z-index: 3; max-width: 290px; min-width: 150px; }
.tooltip-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; white-space: nowrap; }
.tooltip-row span:first-child { display: flex; align-items: center; gap: 5px; }
.tooltip-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.plot-progress { position: absolute; top: 5px; right: 12px; padding: 6px 9px; border: 1px solid #dce4e8; background: #fffffff0; color: var(--muted); font-size: 13px; pointer-events: none; }

.methods-section, details { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.selection-heading { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.selection-heading h2 { margin: 0; }
.method-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px 12px; }
.method-option { display: flex; align-items: center; gap: 6px; border: 1px solid #dce4e8; border-left: 5px solid var(--model-color); padding: 6px; cursor: pointer; min-width: 0; }
.method-option:hover { background: #f4f8fc; }
.method-option input { margin: 0; width: 14px; height: 14px; flex-shrink: 0; }
.method-swatch { width: 18px; border-top: 2px solid var(--model-color); flex-shrink: 0; }
.method-option.reference .method-swatch { border-top-style: dashed; }
.method-name { overflow-wrap: anywhere; }
.method-reference { font-size: 12px; color: var(--muted); margin-left: auto; }
.method-option.unavailable { opacity: .45; cursor: default; }
.selection-note { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 8px 0 0; }
summary { cursor: pointer; font-weight: bold; }
.particles-section > .selection-actions { margin: 12px 0; }
.particle-actions .families { display: contents; }
.particle-actions button[aria-pressed=true] { background: #dcecff; border-color: #075cbb; color: #064b97; }
.particle-actions button[aria-pressed=mixed] { background: #eef5fc; border-color: #075cbb; border-style: dashed; }
.particle-options { display: grid; grid-template-columns: repeat(auto-fill,minmax(85px,1fr)); gap: 6px; margin-top: 12px; }
.particle-option { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #dce4e8; border-left: 5px solid var(--particle-color, var(--particle)); padding: 6px; cursor: pointer; min-width: 0; }
.particle-option:hover { background: #f4f8fc; }
.particle-option input { margin: 0; flex-shrink: 0; }
.particle-option.analyzed { outline: 1px solid #075cbb; outline-offset: 1px; }
.reading-notes p { color: var(--muted); font-size: 13px; margin: 12px 0; }
.page-footer { padding: 16px 0 4px; font-size: 13px; color: var(--muted); }
.page-footer p { margin: 4px 0; }

@media (max-width: 1050px) {
  .method-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 900px) {
  #interval-label { width: 100%; text-align: right; }
}
@media (max-width: 680px) {
  .plots { grid-template-columns: 1fr; gap: 20px; }
  .plot-controls { min-height: 32px; }
  .time-controls { order: 2; flex-basis: 100%; min-width: 0; }
  #interval-label { order: 3; }
}
@media (max-width: 520px) {
  body { margin: 10px; }
  .plots { grid-template-columns: 1fr; gap: 20px; }
  .plot-controls { min-height: 32px; }
  .parameter-bar { align-items: stretch; gap: 10px; }
  .field { flex: 1 1 100%; justify-content: space-between; }
  .field select { max-width: 57%; }
  .time-control { grid-template-columns: 80px 29px minmax(24px,1fr) 29px 68px; gap: 5px; }
  .time-control input[type=number] { padding: 4px; }
  .point-size-control { flex-basis: 100%; }
  #point-size { flex: 1; max-width: 200px; }
  .plot-controls { gap: 7px; }
  .method-options { grid-template-columns: 1fr; }
  .selection-counts { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
