:root {
  --bg: #111719;
  --panel: #192123;
  --inset: #11191a;
  --raised: #273532;
  --head: #202c29;
  --line: #344143;
  --control-line: #42514f;
  --text: #e2ece8;
  --soft: #c6d8d0;
  --muted: #a6b9b2;
  --accent: #9ae5c2;
  --accent-text: #a5edc7;
  --accent-dim: #5c8a76;
  --accent-ink: #10271e;
  --on-air: #e1b673;
  --danger: #ffb1a2;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font-family: "Barlow", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0;
}
header,
main {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 25px 26px;
  border-bottom: 1px solid var(--line);
}
main {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 12px 26px 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.brand i {
  display: inline-block;
  width: 13px;
  height: 22px;
  background: repeating-linear-gradient(
    90deg,
    #8ee4bc 0 3px,
    transparent 3px 5px
  );
  transform: skewY(-22deg);
}
.brand span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
}
h1,
h2 {
  font-size: 20px;
  margin: 0 0 14px;
  letter-spacing: 0.02em;
}
h2 {
  font-size: 18px;
}
small,
label,
.section-title span,
output {
  color: var(--muted);
  font-size: 13px;
}
output {
  display: block;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

button,
input,
select {
  font: inherit;
  border-radius: 5px;
  border: 1px solid var(--control-line);
  background: var(--inset);
  color: var(--text);
  min-height: 38px;
  padding: 7px 11px;
}
input,
select {
  width: 100%;
}
button {
  cursor: pointer;
  background: var(--raised);
  font-weight: 550;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}
[data-send],
[data-action="send"],
#sendRecording {
  border-color: var(--accent-dim);
  color: var(--accent-text);
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #b0f1ca;
  outline-offset: 2px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
}
label.check {
  flex-direction: row;
  align-items: center;
  align-self: center;
}
.check input {
  width: 18px;
  min-height: 18px;
}
.fields,
.actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.fields > label {
  flex: 1;
  min-width: 95px;
}
.tuning > label {
  min-width: 140px;
}
.panel > label,
.actions {
  margin-top: 12px;
}
.toolbar {
  align-items: center;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 0 27px;
}
.summary div {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.summary strong {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 21px 22px;
}
.bench {
  overflow: hidden;
}
.tabs {
  display: flex;
  align-items: stretch;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs button {
  flex: none;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 12px 13px;
  font-weight: 500;
  white-space: nowrap;
}
.tabs button[aria-pressed="true"] {
  color: var(--accent-text);
  border-bottom-color: var(--accent-text);
}
.tabs button:focus-visible {
  outline-offset: -2px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-title span {
  font-family: Consolas, monospace;
}
.bench-title {
  margin: 20px 0 14px;
}
.bench-title h1 {
  margin: 0;
}
#sessionState[data-live="true"] {
  color: var(--accent-text);
}
#reference {
  color: var(--muted);
  font: 12px var(--mono);
  overflow-wrap: anywhere;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 21px 0;
  border-block: 1px solid var(--line);
  padding: 14px 0;
}
.metrics div {
  display: grid;
  gap: 5px;
}
.metrics strong {
  font: 500 19px var(--mono);
}
[data-loss="true"] {
  color: #ffc293;
}
canvas {
  display: block;
  width: 100%;
  height: 215px;
  background: #101818;
  border-radius: 4px;
  margin-bottom: 16px;
}

#rawScope {
  touch-action: pan-y;
  cursor: crosshair;
  margin-bottom: 10px;
}
#rawScope:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}
.raw-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 10px;
}
.raw-layers {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--control-line);
  border-radius: 6px;
}
.raw-layers button {
  min-height: 30px;
  padding: 4px 12px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.raw-layers button[aria-pressed="true"] {
  background: #30483c;
  color: #c9f3d8;
}
#rawReading {
  font: 12px var(--mono);
  color: #bdd2c6;
  font-variant-numeric: tabular-nums;
}
.raw-inspect {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
#rawLocate {
  min-height: 28px;
  font-size: 12px;
  padding: 3px 8px;
}
.raw-tools,
.zoom-tools,
.wave-key,
#readPages {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.raw-tools {
  justify-content: space-between;
}
.raw-tools .raw-pan {
  flex: 1 1 130px;
  display: flex;
  flex-direction: row;
  align-items: center;
  white-space: nowrap;
  margin: 0 8px;
}
.raw-pan input {
  min-width: 72px;
  min-height: 30px;
  accent-color: var(--accent);
  padding: 0;
}
#rawRange,
#readPage,
.wave-key {
  font-size: 12px;
  color: var(--muted);
}
#rawRange {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.wave-key {
  gap: 16px;
  margin-top: 8px;
}
#rawFiltered::before,
#rawLost::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  background: #8c7340;
}
#rawLost::before {
  background: #b57060;
}
#rawFiltered[data-line="true"]::before {
  width: 16px;
  height: 0;
  background: none;
  border-top: 2px dashed #d9ac5c;
  vertical-align: middle;
}

.scroll {
  overflow: auto;
  max-height: 310px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font: 13px var(--mono);
  white-space: nowrap;
}
th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 8px 11px;
}
th {
  position: sticky;
  top: 0;
  background: var(--head);
  color: var(--muted);
  font-weight: 500;
}
td.empty {
  text-align: center;
  padding: 26px;
  color: var(--muted);
}
#records button {
  min-height: 28px;
  padding: 3px 8px;
}
#records button + button {
  margin-left: 6px;
}
#recordList[data-mode="Read"] tr > :last-child:not([colspan]) {
  position: sticky;
  right: 0;
  background: var(--head);
  box-shadow: -1px 0 var(--line);
  text-align: center;
}
#recordList[data-mode="Read"] th:last-child {
  z-index: 2;
}
#readPages {
  justify-content: flex-end;
  margin-top: 8px;
}
.history {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 15px;
}
.history select {
  min-width: 0;
  text-overflow: ellipsis;
}

#packetView .packet-input {
  margin-top: 16px;
  max-width: 580px;
}
#packetCounts {
  font: 13px var(--mono);
  color: var(--muted);
}

#signalList {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
.saved-signal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.saved-signal .identity {
  display: grid;
  gap: 5px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.saved-signal .actions {
  margin: 0;
}
#libraryStatus {
  color: var(--muted);
  font-size: 13px;
}

dialog {
  color: inherit;
  background: var(--panel);
  border: 1px solid #53695d;
}
dialog::backdrop {
  background: #091011b5;
}
#signalDialog {
  width: min(360px, 90vw);
  border-radius: 9px;
  padding: 22px;
}
#signalDialog input {
  min-width: 0;
}
#sendDialog {
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border-radius: 12px;
  overscroll-behavior: contain;
}
.sheet {
  display: grid;
  gap: 16px;
  padding: 20px 22px 16px;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
#sendTitle {
  margin: 0;
  font: 500 17px/1.35 var(--mono);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
#sendDetail {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
#sendClose {
  flex: none;
  width: 38px;
  margin: -6px -8px 0 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.send-power {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.send-power select {
  width: auto;
  min-width: 132px;
}
#sendHold {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 7px;
  width: 100%;
  min-height: 136px;
  padding: 18px;
  border-color: var(--accent-dim);
  border-radius: 10px;
  background: linear-gradient(#22312d, #1c2826);
  box-shadow:
    inset 0 1px 0 #ffffff0d,
    0 2px 0 #0b1112;
  color: #c9f3d8;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#sendHold strong {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
#sendHold small {
  color: inherit;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}
#sendHold i {
  width: 128px;
  height: 14px;
  background: repeating-linear-gradient(
    90deg,
    currentColor 0 3px,
    transparent 3px 6px,
    currentColor 6px 14px,
    transparent 14px 20px,
    currentColor 20px 23px,
    transparent 23px 32px
  );
  opacity: 0.5;
  mask-image: linear-gradient(90deg, transparent, #000 25% 75%, transparent);
}
#sendHold[aria-pressed="true"] {
  transform: translateY(2px);
  border-color: var(--on-air);
  background: linear-gradient(#3a301f, #2c2518);
  box-shadow:
    inset 0 2px 6px #00000080,
    0 0 0 3px #e1b67326;
  color: #f3d7a4;
}
#sendHold[aria-pressed="true"] i {
  opacity: 1;
}
.send-count {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.stepper {
  display: flex;
  flex: none;
}
.stepper button {
  width: 42px;
  padding: 0;
  border-radius: 5px 0 0 5px;
  font-size: 18px;
}
.stepper button:last-child {
  border-radius: 0 5px 5px 0;
}
.stepper input {
  width: 64px;
  border-inline: 0;
  border-radius: 0;
  font-family: var(--mono);
  text-align: center;
  appearance: textfield;
}
.stepper input::-webkit-inner-spin-button {
  appearance: none;
}
#sendUnit {
  color: var(--muted);
  font-size: 13px;
}
#sendCount {
  flex: 0 1 104px;
  margin-left: auto;
}
#sendDialog[data-mode="count"] #sendCount {
  border-color: #a86a5f;
  background: transparent;
  color: var(--danger);
}
#sendProgress {
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 2px;
  background: var(--inset);
  appearance: none;
  overflow: hidden;
}
#sendProgress::-webkit-progress-bar {
  background: var(--inset);
}
#sendProgress::-webkit-progress-value {
  background: var(--accent);
}
#sendStatus,
#message {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}
#sendStatus::before,
#message::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5d7168;
}
#sendStatus {
  min-height: 38px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
#sendStatus[data-tone="live"]::before {
  background: var(--on-air);
  box-shadow: 0 0 0 3px #e1b67333;
}
#sendStatus[data-tone="error"],
#message[data-error="true"] {
  color: var(--danger);
}
#sendStatus[data-tone="error"]::before,
#message[data-error="true"]::before {
  background: var(--danger);
}

.advanced {
  margin: 18px 0;
}
.advanced summary {
  cursor: pointer;
  color: #bbccc3;
}
.device-settings {
  margin-top: 14px;
}
.device-settings > label {
  max-width: 220px;
}
#message {
  position: sticky;
  bottom: 0;
  z-index: 2;
  min-height: 46px;
  margin-top: auto;
  padding: 11px 0 max(11px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@keyframes carrier {
  to {
    background-position-x: 32px;
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}
@media (prefers-reduced-motion: no-preference) {
  #sendDialog[open] {
    animation: sheet-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  #sendHold {
    transition:
      transform 0.06s,
      background-color 0.12s,
      border-color 0.12s;
  }
  #sendHold[aria-pressed="true"] i {
    animation: carrier 0.5s linear infinite;
  }
}
@media (hover: hover) {
  button:hover:enabled {
    border-color: #92c8ad;
  }
}
@media (pointer: coarse) {
  button,
  input,
  select {
    min-height: 44px;
  }
  .raw-layers button,
  #rawLocate,
  #records button {
    min-height: 38px;
  }
  .check input {
    width: 22px;
    min-height: 22px;
  }
}
@media (max-height: 520px) {
  #sendHold {
    min-height: 84px;
  }
}
@media (max-height: 520px) and (min-width: 601px) {
  #sendDialog {
    width: min(720px, calc(100vw - 32px));
  }
  .sheet {
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
    padding: 16px 18px 12px;
  }
  .sheet > * {
    grid-column: 1;
  }
  #sendHold {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
  #sendProgress,
  #sendStatus {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {
  header {
    padding: 16px 15px;
  }
  main {
    padding-inline: 15px;
  }
  .brand {
    font-size: 21px;
  }
  .brand span {
    font-size: 13px;
  }
  .summary {
    grid-template-columns: 1fr 1fr auto;
    gap: 12px 14px;
    padding: 14px 0 18px;
  }
  .summary strong {
    font-size: 15px;
  }
  #refresh {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: start;
  }
  .panel {
    padding: 15px;
  }
  canvas {
    height: 175px;
  }
}
@media (max-width: 600px) {
  .wide {
    display: none;
  }
  .tabs {
    gap: 0;
    justify-content: space-between;
  }
  .tabs button {
    padding: 8px 8px 12px;
    font-size: 13px;
  }
  .metrics {
    gap: 7px;
  }
  .metrics strong {
    font-size: 15px;
  }
  .history > label {
    flex-basis: 100%;
  }
  .history > button {
    flex: 1 1 calc(50% - 5px);
  }
  .saved-signal .actions {
    width: 100%;
  }
  .saved-signal .actions button {
    flex: 1 1 auto;
  }

  #recordList[data-mode="Read"] {
    max-height: none;
  }
  #recordList[data-mode="Read"] thead {
    display: none;
  }
  #recordList[data-mode="Read"] :is(table, tbody) {
    display: block;
  }
  #recordList[data-mode="Read"] tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 14px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
  }
  #recordList[data-mode="Read"] td {
    order: 3;
    padding: 0;
    border: 0;
    color: var(--muted);
    font-size: 12px;
  }
  #recordList[data-mode="Read"] td[data-label]::before {
    content: attr(data-label) " ";
    opacity: 0.7;
  }
  #recordList[data-mode="Read"] td[data-cell="protocol"] {
    order: 1;
    color: var(--accent-text);
    font-size: 13px;
  }
  #recordList[data-mode="Read"] td[data-cell="count"] {
    order: 1;
    margin-left: auto;
  }
  #recordList[data-mode="Read"] td[data-cell="key"] {
    order: 2;
    flex-basis: 100%;
    color: var(--text);
    font-size: 18px;
    overflow-wrap: anywhere;
  }
  #recordList[data-mode="Read"]
    td:is([data-cell="protocol"], [data-cell="key"])::before {
    content: none;
  }
  #recordList[data-mode="Read"] tr > td:last-child:not([colspan]) {
    position: static;
    display: flex;
    order: 4;
    flex-basis: 100%;
    gap: 8px;
    margin-top: 7px;
    background: none;
    box-shadow: none;
  }
  #recordList[data-mode="Read"] td:last-child button {
    flex: 1;
    margin: 0;
  }
  #recordList[data-mode="Read"] td.empty {
    flex-basis: 100%;
    padding: 20px 0;
    font-size: 13px;
    text-align: center;
  }

  #sendDialog {
    width: 100%;
    max-width: 100%;
    max-height: 94dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
  }
  .sheet {
    padding: 10px 18px max(16px, env(safe-area-inset-bottom));
  }
  .sheet::before {
    content: "";
    justify-self: center;
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: var(--control-line);
  }
  #sendHold {
    min-height: 156px;
  }
}
@media (max-width: 380px) {
  .brand span {
    display: none;
  }
  .tabs button {
    padding-inline: 5px;
    font-size: 12px;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}
