:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #f3eef9;
  background: #161421;
  --muted: #bcb4ca;
  --line: #3b334d;
  --panel: #211c31;
  --plum: #d1baff;
  --accent: #ffb28e;
  --number-font: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, p, dl, dd, figure { margin: 0; }

.page { max-width: 1040px; margin: 0 auto; padding: 44px 24px 56px; }
.page-header, .section-heading, .identity { display: flex; align-items: center; }
.page-header, .section-heading { justify-content: space-between; gap: 10px; }
.page-header { margin-bottom: 25px; }
.identity { gap: 12px; }
h1 { font-size: 27px; letter-spacing: -.035em; }
h2 { font-size: 18px; font-weight: 700; }

.mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #483664;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.mark i { width: 3px; height: 9px; border-radius: 4px; background: var(--accent); }
.mark i:nth-child(even) { height: 15px; }
.mark i:nth-child(3) { height: 23px; }
.status {
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
  white-space: nowrap;
}
.status::before {
  content: "";
  display: inline-block;
  margin-right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #807a8c;
}
.status[data-active="true"] { color: #ffd4be; background: #462b34; border-color: #764751; }
.status[data-active="true"]::before { background: #ffac83; }

.layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; align-items: start; }
.panel { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); }
.monitor .section-heading { flex-wrap: wrap; }
.monitor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.timer { margin-inline-start: auto; font: 600 15px var(--number-font); color: var(--muted); }
.meter {
  margin-top: 16px;
  background: #171426;
  border: 1px solid #3b334d;
  color: #fff9f4;
  border-radius: 16px;
  padding: 18px 18px 14px;
}
.reading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-family: var(--number-font); }
.adjusted-reading { min-width: 0; overflow-wrap: anywhere; color: var(--accent); font-size: clamp(32px, 7vw, 60px); font-weight: 600; line-height: 1.1; }
.adjusted-reading .unit { display: block; margin-top: 4px; }
.raw-reading { font-size: clamp(15px, 3vw, 24px); white-space: nowrap; }
.unit { color: #e0d7eb; font-size: 12px; font-weight: 400; }
.plot {
  display: grid;
  grid-template-columns: minmax(24px, max-content) minmax(0, 1fr) 24px;
  grid-template-rows: 108px;
  column-gap: 8px;
  margin-top: 16px;
}
.plot canvas {
  grid-area: 1 / 2;
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(to bottom, #4c455e 0 1px, transparent 1px 100%);
  background-size: 100% calc(100% / 3);
  border-bottom: 1px solid #4c455e;
}
.ticks {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: -5px 0;
  color: #e0d7eb;
  font: 11px/1 var(--number-font);
}
.ticks-adjusted { grid-area: 1 / 1; color: var(--accent); }
.ticks-raw { grid-area: 1 / 3; text-align: right; }
figcaption { margin-top: 10px; font-size: 12px; color: #e0d7eb; }
.calibration-fields, .filter-fields { display: grid; gap: 8px; padding: 0 12px 10px; }
.calibration-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.calibration-fields label, .filter-fields label { font-size: 12px; }
.calibration-fields input, .filter-fields input {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171426;
  color: inherit;
  font: 16px var(--number-font);
}
.dropdown-content .hint { margin: 0 12px 12px; }
.dropdown-content .calibration-error { color: #ffb5a8; }
#filter-count { color: var(--muted); font-size: 12px; }
.threshold-controls { padding: 0 12px 8px; }
#threshold { display: block; width: 100%; height: 41px; margin: 0; accent-color: var(--plum); cursor: pointer; }
.capture-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.primary { width: 100%; min-height: 49px; border: 0; border-radius: 12px; background: var(--plum); color: #231636; font-weight: 700; }
.primary.manual { background: #ffb292; color: #381827; }
.primary[data-active="true"] { grid-column: 1 / -1; }
.primary[data-stopping="true"] { background: #ffb292; color: #381827; }
.secondary { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--plum); font-size: 13px; }
.history .section-heading { flex-wrap: wrap; }
.history-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.history-actions select { padding-inline: 8px; font-family: inherit; cursor: pointer; }
.danger { color: #ffb5a8; }
.batch-controls:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.record-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.record-selection:not([hidden]) { display: grid; place-items: center; min-width: 36px; min-height: 44px; cursor: pointer; }
.record-select { width: 18px; height: 18px; margin: 0; accent-color: var(--plum); }
.record-delete { padding-inline: 9px; }
.dropdown > summary {
  display: flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > .threshold-trigger { justify-content: center; gap: 6px; }
.threshold-trigger output { color: var(--accent); font: 600 12px var(--number-font); }
.dropdown[open] > summary, .dropdown[data-filtered="true"] > summary {
  border-color: var(--plum);
  background: #352848;
}
.dropdown-content {
  position: fixed;
  z-index: 10;
  width: min(22rem, calc(100vw - 16px));
  max-height: min(26rem, 70vh);
  padding-top: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #574969;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 30px #100d1aa8;
}
.filter-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 12px; }
.feedback, .note, .hint, .queue { color: var(--muted); font-size: 13px; line-height: 1.55; }
.feedback { margin-top: 10px; }
.feedback[data-error="true"], .queue[data-error="true"] { color: #ffb5a8; }
.note { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.queue { margin-top: 8px; }
.history-message:not([hidden]) { margin-top: 14px; padding: 20px 14px; border: 1px dashed #574969; border-radius: 12px; color: var(--muted); font-size: 14px; }
.record-list { list-style: none; padding: 0; margin: 0; }
.history-scroll {
  max-height: min(30rem, 50vh);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #8875a6 transparent;
}
.history-scroll:empty { display: none; }
.history-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.record-list li { border-top: 1px solid var(--line); padding: 14px 0; }
.record-list li:first-child { margin-top: 10px; }
.record-list li:last-child { padding-bottom: 0; }
.record-list time { font-size: 14px; font-weight: 700; }
.record-list p { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 5px; }
.record-list audio { display: block; width: 100%; min-width: 0; margin-top: 8px; }
.record-list details { margin-top: 8px; }
.record-list summary { cursor: pointer; color: var(--plum); font-size: 14px; padding: 7px 0; }
.audio-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.audio-actions a { color: var(--plum); font-size: 13px; padding: 11px 0; }
.more { margin-top: 12px; width: 100%; }
.archive { margin-top: 18px; }

@media (max-width: 760px) {
  .page { max-width: 520px; padding: 20px 14px 36px; }
  .page-header { margin-bottom: 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .panel { padding: 16px; border-radius: 18px; }
  .identity { gap: 8px; }
  .mark { width: 36px; height: 36px; }
  h1 { font-size: 23px; }
}

@media (max-width: 360px) {
  h1 { font-size: 19px; }
  .history .section-heading, .history-actions { gap: 4px; }
  .history-actions > .secondary, .history-actions .dropdown > summary, .monitor-actions .dropdown > summary { padding-inline: 6px; }
  .filter-wide { grid-column: 1 / -1; }
}

