:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #5d6878;
  --line: #dde2e9;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --sel: #e7f0fb;
  --warn: #9a5b00;
  --err: #b42318;
  --ok: #1f7a3d;
  --mk-o: #c4320a; --mk-p: #175cd3; --mk-s: #9a5b00; --mk-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel: #1a2029;
    --ink: #e6eaf0;
    --muted: #9aa5b4;
    --line: #2d3644;
    --accent: #5aa2ec;
    --accent-ink: #0d1117;
    --sel: #213044;
    --warn: #e0a040;
    --err: #f2786d;
    --ok: #5fc27e;
    --mk-o: #ff8a65; --mk-p: #7cc0ff; --mk-s: #ffc857; --mk-text: #10141a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
a { color: var(--accent); }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-size: 16px; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; margin-left: 6px; }
.modes { display: flex; gap: 4px; }
.mode { border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 6px 14px; border-radius: 6px; cursor: pointer; font: inherit; }
.mode.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mode.lang { margin-left: 8px; font-size: 12px; padding: 6px 10px; }

.layout { flex: 1; display: grid; grid-template-columns: minmax(330px, 420px) 1fr; min-height: 0; }
.side { overflow-y: auto; padding: 12px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.main { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
#map { height: 55vh; min-height: 320px; flex: none; border-bottom: 1px solid var(--line); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.panel.disabled { opacity: .55; pointer-events: none; }
.hidden { display: none !important; }
h2 { font-size: 15px; margin: 0 0 2px; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); flex: 1; }
label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
input, select, button { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
input[type=checkbox] { padding: 0; }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row > span { padding-bottom: 6px; color: var(--muted); }
.row input[type=number] { width: 90px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.btns button { flex: 1; }
.status { font-size: 12px; color: var(--muted); min-height: 1em; }
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.hint { font-size: 12px; color: var(--muted); }

fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0; padding: 6px 8px; }
legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.filters { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.chips label { flex-direction: row; align-items: center; gap: 4px; color: var(--ink); font-size: 13px; flex: none; }

.tablewrap { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.tablewrap.tall { max-height: 320px; }
table.list { width: 100%; border-collapse: collapse; font-size: 12px; }
table.list th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 4px 6px; }
table.list td { padding: 3px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td.wrap { white-space: normal; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--sel); }
table.list tbody tr.on { background: var(--sel); font-weight: 600; }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }

.preview-head { padding: 10px 16px 0; }
#preview { padding: 6px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
#preview sp-seismograph { display: block; height: 120px; }
.unzoom { margin-left: auto; font-size: 12px; padding: 4px 10px; font-weight: 400; }
.trace-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.trace-label b { color: var(--ink); }

.fdsn-help { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.fdsn-help p { margin: 0; }
.fdsn-help pre { margin: 0; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; overflow-x: auto; white-space: pre; }

body.loading .layout, body.loading .modes { pointer-events: none; opacity: .6; }
body:not(.loading) #loading-note { display: none; }

.foot { padding: 6px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }

.leaflet-container { font: inherit; }
.sta-tri { width: 0; height: 0; }

@media (max-width: 860px) {
  /* phones: normal page scrolling instead of a fixed full-height app, footer at the end */
  html, body { height: auto; }
  body { display: block; }
  .layout { display: block; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; padding: 12px 16px; }
  .main { overflow: visible; }
  #map { height: 50vh; }
  #preview { padding: 6px 16px 16px; }
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .modes { flex-wrap: wrap; }
  .foot { line-height: 1.6; padding: 10px 16px 16px; overflow-wrap: anywhere; }
  .fdsn-help pre { white-space: pre-wrap; overflow-wrap: anywhere; }
}
