:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #172126;
  background: #f5f7f8;
  letter-spacing: 0;
  --green: #16845b;
  --green-dark: #0d6243;
  --line: #dce3e5;
  --muted: #66747a;
  --red: #c9473b;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f5f7f8;
}

button, input { font: inherit; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1120px) / 2));
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand, .connection { display: flex; align-items: center; }
.brand { gap: 11px; font-weight: 700; }
.connection { gap: 8px; color: var(--muted); font-size: 14px; }

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: #172126;
  border-radius: 7px;
}

.brand-mark span {
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  position: relative;
}

.brand-mark span::before {
  content: "";
  position: absolute;
  width: 2px;
  height: 7px;
  left: 3px;
  top: -6px;
  background: #ffffff;
  border: 2px solid #172126;
}

.brand-mark.large { width: 42px; height: 42px; border-radius: 8px; }

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a8b1b5;
}

.connection.online .status-dot { background: #21a36d; box-shadow: 0 0 0 4px #dff3e9; }
.connection.error .status-dot { background: var(--red); box-shadow: 0 0 0 4px #f9e4e2; }

main { padding: 56px 24px 72px; }
.workspace { width: min(100%, 1120px); margin: 0 auto; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

h1 { margin: 0; font-size: 32px; line-height: 1.2; }
.topic-block { text-align: right; }
.topic-block span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.topic-block strong { font-family: Consolas, monospace; font-size: 15px; }

.device-layout {
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  align-items: center;
  gap: 64px;
  padding: 50px 5%;
}

.device-visual { min-height: 300px; display: grid; place-items: center; position: relative; }

.board {
  width: min(390px, 80%);
  aspect-ratio: 1.7;
  position: relative;
  background: #147957;
  border: 8px solid #e8ecec;
  box-shadow: 0 18px 40px rgba(23, 33, 38, .16), inset 0 0 0 2px rgba(255,255,255,.18);
  transform: perspective(900px) rotateX(7deg) rotateZ(-3deg);
}

.board::before, .board::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid #b9c4c5;
  border-radius: 50%;
  top: 15px;
}
.board::before { left: 15px; }
.board::after { right: 15px; }
.board-label { position: absolute; top: 18px; left: 52px; color: rgba(255,255,255,.72); font: 700 13px Consolas, monospace; }

.chip {
  width: 34%;
  aspect-ratio: 1;
  position: absolute;
  left: 33%;
  top: 24%;
  background: #20282b;
  border: 5px solid #303b3f;
  box-shadow: 0 7px 12px rgba(0,0,0,.24);
}

.pin-row { position: absolute; left: 12%; right: 12%; height: 5px; background: repeating-linear-gradient(90deg, #c6d0d0 0 6px, transparent 6px 16px); }
.pin-row-top { top: 14%; }
.pin-row-bottom { bottom: 14%; }

.led-lamp {
  width: 22px;
  height: 22px;
  position: absolute;
  right: 16%;
  bottom: 24%;
  border: 4px solid #b8c4c2;
  border-radius: 50%;
  background: #58645f;
  transition: background .2s, box-shadow .2s;
}

.led-lamp.on { background: #f6d54b; box-shadow: 0 0 10px #ffd94c, 0 0 28px rgba(255,217,76,.8); }
.led-label { position: absolute; right: 13%; bottom: 14%; color: rgba(255,255,255,.75); font: 10px Consolas, monospace; }

.signal-lines { position: absolute; width: 110px; right: 2%; top: 17%; display: grid; gap: 7px; }
.signal-lines i { height: 2px; background: #aeb9bc; transform-origin: right; }
.signal-lines i:nth-child(1) { transform: scaleX(.55); }
.signal-lines i:nth-child(2) { transform: scaleX(.78); }

.control-panel {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.control-label { margin: 0 0 7px; color: var(--muted); font-size: 14px; }
.control-state { margin: 0; font-size: 27px; font-weight: 700; }

.switch { width: 76px; height: 42px; flex: 0 0 auto; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 100%; height: 100%; display: block; padding: 4px; background: #c5ced1; border-radius: 21px; transition: background .2s; }
.switch-thumb { width: 34px; height: 34px; display: block; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.22); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(34px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(22,132,91,.28); outline-offset: 3px; }
.switch input:disabled + .switch-track { opacity: .55; cursor: wait; }

.activity {
  min-height: 76px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.activity-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #e8eeef; color: #506067; font: 700 15px Georgia, serif; }
.activity.success .activity-icon { background: #dff3e9; color: var(--green-dark); }
.activity.error .activity-icon { background: #f9e4e2; color: var(--red); }
.activity.loading .activity-icon { color: transparent; border: 2px solid #d6dfe1; border-top-color: var(--green); background: transparent; animation: spin .8s linear infinite; }
.activity strong { display: block; font-size: 14px; }
.activity p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.activity time { color: var(--muted); font-size: 12px; }

.login-layer { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(245,247,248,.96); }
.login-layer[hidden] { display: none; }
.login-dialog { width: min(100%, 380px); padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 20px 60px rgba(23,33,38,.12); }
.login-dialog h2 { margin: 24px 0 8px; font-size: 24px; }
.login-dialog > p { margin: 0 0 24px; color: var(--muted); }
.login-dialog label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.login-dialog input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #b9c5c8; border-radius: 5px; outline: none; }
.login-dialog input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,132,91,.14); }
.login-dialog button { width: 100%; height: 44px; margin-top: 16px; color: #fff; background: #172126; border: 0; border-radius: 5px; font-weight: 700; cursor: pointer; }
.form-error { min-height: 18px; margin: 7px 0 0 !important; color: var(--red) !important; font-size: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { height: 60px; padding: 0 18px; }
  .brand { font-size: 14px; }
  .connection { font-size: 12px; }
  main { padding: 32px 18px 48px; }
  h1 { font-size: 27px; }
  .device-layout { min-height: 0; grid-template-columns: 1fr; gap: 20px; padding: 34px 0 28px; }
  .device-visual { min-height: 250px; }
  .board { width: min(350px, 88%); }
  .signal-lines { right: 0; }
  .control-panel { min-height: 120px; padding: 24px 4px; }
  .control-state { font-size: 23px; }
  .activity { grid-template-columns: 34px 1fr; }
  .activity time { grid-column: 2; }
}

@media (max-width: 420px) {
  .brand span:last-child { display: none; }
  .section-heading { align-items: start; }
  .topic-block { max-width: 120px; }
  .device-visual { min-height: 215px; }
  .activity { padding: 14px; }
}

