:root {
  color-scheme: light;
  --page-background: #f3f5f3;
  --card-background: #fff;
  --ink: #182d2e;
  --muted: #53686a;
  --line: #d6dfdb;
  --green: #11665a;
  --nums: "IBM Plex Mono",Consolas,"SFMono-Regular",monospace;
}

#fwcode {
  width: 6em;
}

.connection-help {
  padding: 0 2px 12px;
  color: var(--muted);
  font-size: 14px;
}

.connection-help a {
  color: var(--green);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-background);
  color: var(--ink);
  font: 16px/1.5 Inter,-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
}

main {
  width: min(100%,710px);
  margin: auto;
  padding: clamp(20px,5vw,44px) clamp(12px,4vw,24px) max(26px,env(safe-area-inset-bottom));
}

header,.heading,.rolebar,.bar,.pair,.switches,.readout,.status,.status-group {
  display: flex;
  align-items: center;
}

header,.bar,.rolebar {
  justify-content: space-between;
  gap: 8px;
}

header {
  margin: 0 2px 17px;
}

.heading {
  gap: 12px;
}

.identity {
  display: grid;
  gap: 4px;
}

.brand {
  font: 800 italic 23px/1 Inter,Arial,sans-serif;
  letter-spacing: -1px;
  color: var(--green);
}

.rating {
  font: 550 12px/1.2 var(--nums);
  color: var(--muted);
  white-space: nowrap;
}

h1,h2,p {
  margin: 0;
}

h1 {
  border-left: 1px solid #bdcbc6;
  padding-left: 12px;
  font-size: clamp(16px,4.5vw,20px);
  letter-spacing: .03em;
}

.link {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.link:before {
  display: inline-block;
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: #879794;
}

.link[data-online=true]:before {
  background: #25876c;
}

.meter {
  color: #eff9f5;
  background: linear-gradient(115deg,#152d32,#16383a);
  border-radius: 17px;
  padding: clamp(16px,4.7vw,28px);
  box-shadow: 0 6px 18px #122e2d12;
}

.meter h2,.controls h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .04em;
}

.state {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid #95aaa6;
  border-radius: 50%;
}

.state[data-on=false] {
  background: #80928f;
  border-color: #b1c1bc;
}

.state[data-on=true] {
  background: #74e9b4;
  border-color: #b4ffda;
  box-shadow: 0 0 0 3px #74e9b423;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 21px 0 17px;
}

.metric {
  min-width: 0;
}

.metric+.metric {
  border-left: 1px solid #47605e;
  padding-left: clamp(12px,4.3vw,26px);
}

.label {
  font-size: 13px;
  color: #b5c9c6;
}

.readout {
  gap: 4px;
  align-items: baseline;
  white-space: nowrap;
}

output {
  font-variant-numeric: tabular-nums;
}

.readout output {
  font: 550 clamp(28px,8.6vw,50px)/1.23 var(--nums);
  letter-spacing: -.07em;
}

.unit {
  font: 500 14px/1 var(--nums);
  color: #a8d7c8;
}

.secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  border-top: 1px solid #45605e;
  padding-top: 13px;
  align-items: center;
}

.pair {
  gap: 6px;
  font-size: 12px;
  color: #b5c9c6;
}

.pair output {
  font: 600 15px/1.3 var(--nums);
  color: #f0f6f4;
}

.pair .unit {
  font-size: 11px;
}

.status-group {
  gap: 7px;
  font-size: 13px;
  color: #c7d9d4;
  white-space: nowrap;
}

.status-group strong {
  font: 700 13px/1 var(--nums);
  border: 1px solid #617874;
  border-radius: 4px;
  padding: 4px 5px;
}

.status-group[data-kind=cv] {
  color: #8ce5ba;
}

.status-group[data-kind=cc] {
  color: #ffda8e;
}

.status-group[data-kind=fault] {
  color: #ffae9e;
}

.rolebar {
  margin: 12px 0;
  padding: 9px 14px;
  background: #e6eeea;
  border: 1px solid #d3e0d9;
  border-radius: 12px;
}

.rolebar[data-role=view],.rolebar[data-role=free] {
  background: #edf0f2;
  border-color: #d8dfe1;
}

.rolebar strong {
  display: block;
  font-size: 14px;
}

.rolebar small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

button,input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
}

button:focus-visible,input:focus-visible {
  outline: 3px solid #40ae98;
  outline-offset: 2px;
}

.rolebar button {
  flex: none;
  background: transparent;
  color: var(--green);
  padding: 0 5px;
  font-size: 13px;
}

.controls {
  background: var(--card-background);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: clamp(15px,4.5vw,25px);
  box-shadow: 0 2px 6px #152c2706;
}

.controls h2 {
  margin-bottom: 15px;
}

.formrow {
  display: grid;
  grid-template-columns: minmax(0,1fr) 70px;
  gap: 7px 9px;
  margin-top: 13px;
  align-items: end;
}

.formrow label {
  grid-column: 1/-1;
  font-size: 13px;
  font-weight: 600;
}

.field {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  background: #f6f8f7;
  border: 1px solid #bdcec7;
  border-radius: 8px;
  padding-right: 12px;
}

.field:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 2px #19755f24;
}

.field input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 7px 12px;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  font: 600 20px/1.2 var(--nums);
  letter-spacing: -.035em;
}

.field input:focus {
  outline: none;
}

.field input:disabled {
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  opacity: 1;
}

.field .unit {
  color: var(--muted);
}

.apply {
  color: var(--green);
  background: #e6f0eb;
}

.switches {
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 16px;
}

.switches button {
  flex: 1;
  min-height: 46px;
}

#on {
  background: #146755;
  color: white;
}

#off {
  background: #fff;
  color: #85463b;
  border: 1px solid #d4bcb6;
}

button:disabled {
  opacity: .48;
  cursor: default;
}

#msg {
  font-size: 13px;
  color: var(--green);
}

#msg:not(:empty) {
  margin-top: 12px;
}

#msg[data-error=true] {
  color: #a43d2e;
}

@media(min-width:580px) {
  .forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .formrow {
    margin-top: 0;
  }

  .switches button {
    flex: none;
    min-width: 132px;
  }

}

@media(max-width:375px) {
  .meter {
    padding: 14px;
  }

  .secondary {
    gap: 7px 12px;
  }

  .pair {
    gap: 4px;
  }

  .readout output {
    font-size: 8.4vw;
  }

}

.memory {
  margin-top: 12px;
}

.memory summary {
  cursor: pointer;
  font-size: 17px;
  font-weight: 650;
  color: var(--ink);
}

.memory summary small {
  float: right;
  font: 500 13px/26px var(--nums);
  color: var(--muted);
}

.memcols {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1.25fr;
  align-items: center;
  text-align: right;
  padding: 0 12px;
  gap: 4px;
}

.memcols>:first-child {
  text-align: left;
}

.memhead {
  margin-top: 14px;
  background: #edf2ef;
  font-size: 12px;
  color: var(--muted);
  height: 30px;
  border-radius: 8px 8px 0 0;
}

.memlist {
  max-height: 224px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
}

.memrow {
  min-height: 44px;
  border-bottom: 1px solid #edf2ef;
  cursor: pointer;
  font: 500 14px/1.35 var(--nums);
}

.memrow:last-child {
  border: 0;
}

.memrow:has(input:checked) {
  box-shadow: inset 3px 0 var(--green);
  color: #104e43;
  background: #e4f1e9;
}

.memrow input {
  accent-color: var(--green);
  margin: 0 6px 0 0;
  vertical-align: middle;
}

.memrow .empty {
  grid-column: 2/4;
  font: 14px/1.4 Inter,sans-serif;
  color: var(--muted);
  text-align: center;
}

.memref {
  margin: 12px 0;
  font-size: 13px;
  color: var(--muted);
}

.memref strong {
  margin-left: 6px;
  color: var(--ink);
  font: 600 14px/1.4 var(--nums);
}

.memactions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.memactions button {
  background: #e6f0eb;
  color: var(--green);
}

.memactions button:last-child {
  background: #fff;
  border: 1px solid #d4bcb6;
  color: #85463b;
}

#memmsg,#memerror {
  font-size: 13px;
  margin-top: 8px;
}

#memmsg {
  color: var(--green);
}

#memmsg[data-error=true],#memerror {
  color: #a43d2e;
}

.config h3 {
  margin: 18px 0 3px;
  color: var(--green);
  font-size: 13px;
}

.setting {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(78px,110px) 52px;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid #e7ece9;
}

.setting label {
  font-size: 14px;
}

.setting input,.setting select,.netselect {
  font: inherit;
  color: var(--ink);
  background: #f7f9f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  width: 100%;
  padding: 6px;
}

.setting input {
  text-align: right;
  font-family: var(--nums);
  font-size: 16px;
}

.setting button,.netactions button {
  background: #e6f0eb;
  color: var(--green);
  font-size: 13px;
}

.setting [disabled] {
  opacity: .65;
}

.setting[hidden] {
  display: none;
}

.confignote {
  font-size: 13px;
  color: var(--muted);
  margin: 7px 0;
  min-height: 1em;
}

.netactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.netactions button {
  padding: 0 10px;
}
