:root {
  font-family:
    Inter,
    Segoe UI,
    Arial,
    sans-serif;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
  color-scheme: light;
  --panel: #ffffff;
  --primary-text: #ffffff;
  --text: #17332f;
  --page: #f4f7f6;
  --button-text: #284b43;
  --nav-text: #62776f;
  --connection-bg: #e8f0ed;
  --connection-border: #d8e7e0;
  --selected-bg: #edf7f3;
  --selected-border: #6fb4a5;
  --badge-text: #5d7c70;
  --badge-bg: #f0f5f2;
  --drop-bg: #f8fbfa;
  --drop-border: #b6cec4;
  --icon-bg: #e8f3ee;
  --primary-hover: #066d64;
  --empty-icon: #b4ccc1;
  --empty-heading: #456659;
  --result-bg: #f5f9f7;
  --soft-bg: #f4f8f6;
  --label-text: #526d63;
  --input-bg: #fcfdfc;
  --input-text: #25463c;
  --thumb-bg: #edf3ef;
  --error-text: #a64231;
  --error-bg: #fff1eb;
  --accent: #087f74;
  --line: #dce7e3;
  --muted: #71827d;
}
.result-image {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--soft-bg);
  border-radius: 9px;
  margin-bottom: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
summary,
canvas {
  -webkit-tap-highlight-color: transparent;
}
button {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 11px 17px;
  border-radius: 9px;
  color: var(--button-text);
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 46px;
  line-height: 1.16;
  letter-spacing: -1.8px;
  margin-bottom: 16px;
  font-weight: 650;
}
h1 span {
  color: var(--accent);
}
h2 {
  font-size: 26px;
  letter-spacing: -0.7px;
  margin: 8px 0 0;
}
h3 {
  font-size: 17px;
  margin: 0;
}
small,
.subtle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
header {
  height: 82px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 max(5vw, 24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  font-size: 20px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand b {
  font-weight: 450;
  color: var(--accent);
}
.brandmark {
  display: inline-grid;
  place-items: center;
  background: #087f74;
  color: white;
  font-size: 22px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-weight: 700;
}
.brandmark:after {
  content: "";
  width: 5px;
  height: 5px;
  background: #a4dfcc;
  position: absolute;
  margin: 22px 0 0 25px;
  border-radius: 50%;
}
nav {
  display: flex;
  gap: 30px;
  font-size: 13px;
  color: var(--nav-text);
}
.quiet {
  border: 0;
  background: transparent;
  padding: 8px;
  font-size: 12px;
}
main {
  max-width: 1360px;
  margin: auto;
  padding: 48px 5vw 24px;
}
.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 25px;
  margin-bottom: 32px;
}
.heading p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 750;
  color: var(--accent);
  display: block;
  margin-bottom: 14px;
}
.connection {
  display: grid;
  grid-template-columns: 10px 1fr;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  background: var(--connection-bg);
  border: 1px solid var(--connection-border);
  border-radius: 12px;
  padding: 18px;
}
.connection small {
  grid-column: 2;
}
.dot {
  width: 7px;
  height: 7px;
  background: #78958c;
  border-radius: 50%;
}
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 43px;
  padding: 23px 0;
}
.summary > div {
  padding: 0 25px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.summary > div:last-child {
  border: 0;
}
.summary span {
  font-size: 9px;
  letter-spacing: 1.4px;
  color: var(--muted);
  font-weight: 700;
}
.summary strong {
  font-size: 19px;
  font-weight: 600;
}
.summary small {
  font-size: 11px;
}
.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 35px 0 20px;
  gap: 16px;
  scroll-margin-top: 20px;
}
.section-title .eyebrow {
  margin: 0;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.module {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
}
.module:has(input:checked) {
  background: var(--selected-bg);
  border-color: var(--selected-border);
  box-shadow: 0 0 0 1px #6fb4a522;
}
.module input {
  position: absolute;
  right: 12px;
  top: 12px;
  accent-color: var(--accent);
}
.module-icon {
  grid-row: span 2;
  align-self: center;
  font-size: 26px;
  color: var(--accent);
}
.module strong {
  font-size: 14px;
}
.module small {
  font-size: 11px;
}
.analysis-grid {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  gap: 20px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  min-width: 0;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.badge {
  font-size: 10px;
  color: var(--badge-text);
  background: var(--badge-bg);
  padding: 6px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  gap: 12px;
}
.tabs button {
  border: 0;
  border-radius: 0;
  padding: 0 4px 12px;
  color: var(--muted);
  font-size: 12px;
}
.tabs button.active {
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}
.dropzone {
  display: flex;
  min-height: 225px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--drop-bg);
  border: 1px dashed var(--drop-border);
  border-radius: 10px;
  gap: 12px;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}
.dropzone > span {
  font-size: 28px;
  color: var(--accent);
  background: var(--icon-bg);
  border-radius: 12px;
  padding: 7px 17px;
}
.dropzone strong {
  font-size: 14px;
}
.dropzone input {
  max-width: 235px;
  font-size: 11px;
  border: 0;
  padding: 0;
}
.primary {
  background: var(--accent);
  color: var(--primary-text);
  border-color: var(--accent);
}
.primary:hover {
  background: var(--primary-hover);
}
.wide {
  width: 100%;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footnote {
  display: block;
  margin-top: 12px;
  font-size: 10px;
}
.empty {
  text-align: center;
  color: var(--muted);
  display: flex;
  min-height: 310px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.empty > span {
  font-size: 50px;
  color: var(--empty-icon);
  margin-bottom: 18px;
}
.empty h3 {
  color: var(--empty-heading);
  margin-bottom: 12px;
}
.empty p {
  font-size: 13px;
  line-height: 1.8;
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.result-card {
  background: var(--result-bg);
  padding: 18px;
  border-radius: 10px;
  display: grid;
  gap: 8px;
}
.result-card strong {
  font-size: 24px;
  font-weight: 650;
}
.result-card > span {
  font-size: 11px;
  color: var(--muted);
}
.result-card small {
  font-size: 10px;
}
.quality {
  padding: 15px;
  border-left: 3px solid #81b8a3;
  background: var(--soft-bg);
  margin: 18px 0;
  font-size: 12px;
  line-height: 1.6;
}
.settings {
  margin-top: 20px;
}
summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}
summary span {
  float: right;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
details[open] summary {
  margin-bottom: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
label {
  font-size: 11px;
  color: var(--label-text);
  font-weight: 600;
}
input:not([type="checkbox"]),
select {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  padding: 11px;
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--input-text);
  margin-top: 7px;
  min-width: 0;
}
input:focus,
button:focus-visible,
select:focus {
  outline: 2px solid #80c8b6;
  outline-offset: 2px;
}
input[type="checkbox"] {
  accent-color: var(--accent);
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.actions button {
  font-size: 12px;
}
.actions select {
  width: auto;
  margin: 0;
  font-size: 12px;
}
.section-title .actions {
  margin: 0;
}
.mqtt-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
}
.toggles {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}
.toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.payload {
  background: #15352f;
  color: #eff9f4;
  border-color: #15352f;
}
.payload .badge {
  background: #284c42;
  color: #b1d1c2;
}
pre {
  background: #102c26;
  border: 1px solid #305047;
  border-radius: 8px;
  padding: 18px;
  color: #b2d9c4;
  font-size: 11px;
  line-height: 1.75;
  overflow: auto;
  height: 280px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.payload .footnote {
  color: #9bbcaf;
}
.history-row {
  display: grid;
  grid-template-columns: 65px 1fr auto auto;
  gap: 18px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.history-row:last-child {
  border: 0;
}
.history-row img {
  width: 65px;
  height: 48px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--thumb-bg);
}
.history-row strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}
.history-row button {
  font-size: 11px;
}
.history-list > .subtle {
  padding: 15px;
  text-align: center;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 35px;
  padding: 20px 0;
  color: var(--muted);
  font-size: 10px;
}
footer b {
  margin: 0 8px;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
.image-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 10px;
}
.image-tools small {
  font-size: 10px;
}
.error {
  color: var(--error-text);
  background: var(--error-bg);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
}
.login {
  max-width: 400px;
  padding: 36px;
  margin: 12vh auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 15px 70px #123a3010;
}
.login .brandmark {
  margin-bottom: 25px;
}
.login h1 {
  font-size: 32px;
}
.login p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.login label {
  display: block;
  margin-bottom: 18px;
}
.login button {
  width: 100%;
  display: flex;
  justify-content: space-between;
}
.login > small {
  display: block;
  margin-top: 24px;
  font-size: 10px;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: #163d32;
  color: white;
  padding: 15px 25px;
  border-radius: 10px;
  box-shadow: 0 5px 30px #0002;
  max-width: 90vw;
  font-size: 13px;
  z-index: 20;
}
[hidden] {
  display: none !important;
}
@media (max-width: 950px) {
  main {
    padding: 30px 24px;
  }
  .module {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .module-icon {
    grid-row: auto;
  }
  .module strong {
    font-size: 13px;
  }
  .summary > div {
    padding: 0 15px;
  }
  .summary strong {
    font-size: 16px;
  }
  .badge {
    white-space: normal;
  }
  .analysis-grid,
  .mqtt-grid {
    grid-template-columns: 1fr;
  }
  .empty {
    min-height: 200px;
  }
}
@media (max-width: 600px) {
  header {
    padding: 0 18px;
    height: 68px;
  }
  nav {
    display: none;
  }
  .brand {
    font-size: 17px;
  }
  main {
    padding: 28px 16px;
  }
  .heading {
    display: block;
  }
  h1 {
    font-size: 36px;
  }
  .connection {
    margin-top: 22px;
    display: inline-grid;
  }
  .summary {
    grid-template-columns: 1fr 1fr;
    gap: 22px 0;
    padding: 20px 0;
  }
  .summary > div:nth-child(2) {
    border: 0;
  }
  .summary small {
    font-size: 10px;
  }
  .module-grid {
    grid-template-columns: 1fr 1fr;
  }
  .module {
    grid-template-columns: 30px 1fr;
  }
  .module-icon {
    grid-row: span 2;
  }
  .panel {
    padding: 18px;
  }
  .section-title {
    align-items: start;
  }
  .section-title > .subtle {
    display: none;
  }
  h2 {
    font-size: 22px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .history-row {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }
  .history-row img {
    display: none;
  }
  .history-row > button:last-child {
    grid-column: 2;
  }
  .history-row small {
    font-size: 10px;
  }
  footer {
    display: block;
    line-height: 1.8;
  }
  footer span {
    display: block;
  }
  .login {
    margin: 8vh 16px;
  }
  summary span {
    display: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101b1a;
  --panel: #192826;
  --text: #e5f0ec;
  --accent: #65d9bf;
  --line: #354943;
  --muted: #a5bab2;
  --button-text: #deebe5;
  --nav-text: #b5cbc2;
  --connection-bg: #213a32;
  --connection-border: #36594b;
  --selected-bg: #233f35;
  --selected-border: #65bc9c;
  --badge-text: #b8d9c9;
  --badge-bg: #293e36;
  --drop-bg: #14221e;
  --drop-border: #4a6e5e;
  --icon-bg: #294638;
  --primary-text: #102c24;
  --primary-hover: #8ce6ce;
  --empty-icon: #699b84;
  --empty-heading: #c2dbcf;
  --result-bg: #20352c;
  --soft-bg: #22382f;
  --label-text: #bfd4c8;
  --input-bg: #13231c;
  --input-text: #e5f0ec;
  --thumb-bg: #293e36;
  --error-text: #ffbcaa;
  --error-bg: #452e28;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.theme-control {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.theme-control select {
  width: auto;
  margin: 0;
  padding: 8px 10px;
  font-size: 12px;
}
.login .login-theme {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}
@media (max-width: 600px) {
  header {
    gap: 8px;
    flex-wrap: wrap;
    height: auto;
    min-height: 68px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .header-actions {
    gap: 8px;
    margin-left: auto;
  }
}
