:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #edf2ef;
  --ink: #17201d;
  --muted: #62716b;
  --line: #d7dfda;
  --teal: #008c83;
  --teal-dark: #00645f;
  --blue: #275fa8;
  --orange: #d26a1e;
  --green: #2f8a4c;
  --danger: #b22d35;
  --shadow: 0 14px 35px rgba(27, 45, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 246, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.brand img {
  width: 92px;
  height: auto;
  display: block;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.status-pill {
  min-width: 62px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.status-pill.live {
  background: rgba(0, 140, 131, 0.12);
  color: var(--teal-dark);
}

.status-pill.demo {
  background: rgba(210, 106, 30, 0.12);
  color: #9a4b12;
}

.language-toggle {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(0, 100, 95, 0.24);
  border-radius: 999px;
  background: var(--surface);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.language-toggle:hover {
  border-color: rgba(0, 140, 131, 0.52);
  background: rgba(0, 140, 131, 0.08);
}

.workspace {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 2.6vw, 34px);
}

.control-band {
  display: grid;
  grid-template-columns: minmax(250px, 0.48fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.title-block,
.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.title-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 184px;
  padding: 22px 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 35rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.hero-notice {
  max-width: 35rem;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  font-weight: 700;
  line-height: 1.45;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.hero-facts span {
  padding: 5px 8px;
  border: 1px solid rgba(0, 100, 95, 0.18);
  border-radius: 999px;
  background: rgba(0, 140, 131, 0.08);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(104px, 1fr));
  grid-auto-rows: minmax(72px, auto);
  align-content: start;
  gap: 10px;
}

.control-button,
.icon-button,
.select-control,
.toolkit-card,
.recording-card,
.control-note-card {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.control-button,
.icon-button {
  padding: 11px 12px;
  text-align: left;
}

.control-button strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  line-height: 1.1;
}

.button-kicker,
.select-control span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.control-button:hover,
.icon-button:hover,
.select-control:focus-within {
  border-color: rgba(0, 140, 131, 0.52);
}

.control-button.active {
  border-color: rgba(210, 106, 30, 0.45);
  background: #fff4eb;
}

.control-button.connected {
  border-color: rgba(0, 140, 131, 0.45);
  background: #eaf7f4;
}

.control-button.accent {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.control-button.accent .button-kicker {
  color: rgba(255, 255, 255, 0.78);
}

.control-button.accent.running {
  background: var(--danger);
  border-color: var(--danger);
}

.recording-card {
  grid-column: span 6;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  background: #fbfcfb;
}

.recording-copy {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 12px;
  min-width: 0;
}

.recording-copy strong {
  display: block;
  font-size: 17px;
  line-height: 1.15;
}

.recording-copy p {
  grid-column: 1 / -1;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.recording-controls {
  display: grid;
  grid-template-columns: 0.72fr 1fr 1.1fr 0.9fr 0.9fr;
  gap: 8px;
  align-items: stretch;
}

.duration-control,
.record-primary,
.record-tool-button {
  min-height: 54px;
  border: 1px solid rgba(215, 223, 218, 0.94);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.duration-control {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 9px 10px;
}

.duration-control > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.duration-input {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.duration-input input {
  width: 48px;
  min-height: 30px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
}

.duration-input span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.record-primary,
.record-tool-button {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 9px 10px;
  text-align: left;
}

.record-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.record-primary .button-kicker {
  color: rgba(255, 255, 255, 0.78);
}

.record-primary strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.1;
}

.record-primary.running {
  background: var(--danger);
  border-color: var(--danger);
}

.record-tool-button:hover,
.record-primary:hover,
.duration-control:focus-within {
  border-color: rgba(0, 140, 131, 0.52);
}

.record-tool-button strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.15;
}

.record-tool-button small {
  display: none;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
}

.toolkit-card {
  grid-column: span 3;
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
}

.toolkit-placeholder {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolkit-placeholder .form-ckeck,
.toolkit-placeholder .form-check,
.toolkit-placeholder .form-switch,
.toolkit-placeholder .d-flex {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid rgba(215, 223, 218, 0.82);
  border-radius: 6px;
  background: #fbfcfb;
}

.toolkit-placeholder .toolkit-connect-control {
  border-color: rgba(0, 100, 95, 0.24);
  background: #ffffff;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.toolkit-placeholder .toolkit-connect-control:hover,
.toolkit-placeholder .toolkit-connect-control:focus-within {
  border-color: rgba(0, 140, 131, 0.58);
  background: rgba(0, 140, 131, 0.06);
}

.toolkit-placeholder .toolkit-connect-control.is-connected {
  border-color: rgba(0, 140, 131, 0.52);
  background: #eaf7f4;
}

.toolkit-placeholder .form-check-input {
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  margin: 0;
  appearance: none;
  border: 1px solid #b7c5bf;
  border-radius: 999px;
  background: #dce4e0;
  box-shadow: inset 0 0 0 2px #fff;
}

.toolkit-placeholder .form-check-input::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(23, 32, 29, 0.24);
  transition: transform 0.16s ease;
}

.toolkit-placeholder .form-check-input:checked {
  border-color: var(--teal);
  background: var(--teal);
}

.toolkit-placeholder .form-check-input:checked::before {
  transform: translateX(18px);
}

.toolkit-placeholder .form-check-label {
  color: var(--ink);
  overflow: hidden;
  min-width: 0;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.toolkit-device-name,
.toolkit-action-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolkit-device-name {
  font-size: 13px;
  line-height: 1.05;
}

.toolkit-action-label {
  margin-top: 5px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.toolkit-message {
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px solid rgba(178, 45, 53, 0.28);
  border-radius: 6px;
  background: rgba(178, 45, 53, 0.08);
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.toolkit-placeholder span[id^="ui"] {
  display: none;
}

.toolkit-placeholder span[id^="icon_led"],
.toolkit-placeholder span[id^="icon_settings"] {
  display: none;
}

.toolkit-placeholder .modal {
  display: none;
}

.control-note-card {
  grid-column: span 6;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: #fbfcfb;
}

.control-note-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.exam-guide {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.guide-card {
  min-height: 160px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.guide-card-wide {
  min-height: 180px;
}

.guide-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.62;
}

.guide-steps {
  display: grid;
  gap: 7px;
  margin: 13px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.guide-steps li::marker {
  color: var(--teal-dark);
  font-weight: 900;
}

.select-control {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
}

.select-control select,
.select-control input {
  width: 100%;
  min-height: 30px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.select-control.compact {
  max-width: none;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 900;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric {
  min-height: 118px;
  padding: 15px 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 2.7vw, 32px);
  line-height: 1;
  letter-spacing: 0;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 16px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 80px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.readout {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: nowrap;
}

.panel-definition {
  max-width: 34rem;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

canvas {
  display: block;
  width: 100%;
  background: #fbfcfb;
}

.cop-panel canvas,
.pressure-panel canvas {
  aspect-ratio: 1.25 / 0.92;
}

.pressure-explainer {
  display: grid;
  gap: 8px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.pressure-explainer p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.pressure-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend-dot,
.cop-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
}

.legend-dot.low {
  background: hsl(210, 85%, 28%);
}

.legend-dot.high {
  background: hsl(0, 85%, 56%);
}

.legend-line {
  width: 32px;
  height: 2px;
  background: linear-gradient(90deg, hsl(210, 85%, 28%), hsl(0, 85%, 56%));
}

.cop-swatch {
  border: 2px solid #ffffff;
  background: #45e6e6;
  box-shadow: 0 0 0 1px rgba(23, 32, 29, 0.28);
}

.panel:not(.cop-panel):not(.pressure-panel) canvas {
  aspect-ratio: 2.35 / 0.58;
}

@media (max-width: 1080px) {
  .control-band,
  .exam-guide,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolkit-card {
    grid-column: span 2;
  }

  .recording-card {
    grid-column: span 3;
    grid-template-columns: 1fr;
  }

  .recording-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-note-card {
    grid-column: span 3;
  }

  .metrics-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    width: 100%;
    justify-content: space-between;
  }

  .brand img {
    width: 84px;
  }

  .topbar-status {
    width: 100%;
    flex-wrap: wrap;
  }

  .control-grid,
  .exam-guide,
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-card-wide {
    grid-column: span 2;
  }

  .toolkit-card {
    grid-column: span 2;
  }

  .recording-card {
    grid-column: span 2;
  }

  .recording-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .record-primary {
    grid-column: auto;
  }

  .control-note-card {
    grid-column: span 2;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .select-control.compact {
    max-width: none;
  }

  .panel-head {
    flex-direction: column;
  }
}

@media (max-width: 460px) {
  .control-grid,
  .exam-guide,
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .guide-card-wide {
    grid-column: span 1;
  }

  .toolkit-card {
    grid-column: span 1;
  }

  .recording-card {
    grid-column: span 1;
  }

  .recording-controls,
  .record-primary {
    grid-template-columns: 1fr;
    grid-column: span 1;
  }

  .control-note-card {
    grid-column: span 1;
  }

  .workspace {
    padding-inline: 12px;
  }
}
