:root {
  --blue-950: #071b3a;
  --blue-900: #0b2856;
  --blue-700: #0b4aa2;
  --blue-600: #1565d8;
  --blue-100: #dbeafe;
  --green-100: #dcfce7;
  --green-700: #15803d;
  --red-100: #fee2e2;
  --red-700: #b91c1c;
  --slate-900: #0f172a;
  --slate-600: #475569;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(7, 27, 58, .16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--slate-900);
  background:
    radial-gradient(circle at top left, rgba(21, 101, 216, .18), transparent 34rem),
    linear-gradient(180deg, #f8fbff 0%, #edf3fb 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px 28px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid rgba(148, 163, 184, .35);
  padding: 5px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 14px;
}

.lang-toggle {
  width: 48px;
  height: 38px;
  border: 1px solid rgba(11, 74, 162, .18);
  border-radius: 12px;
  color: var(--blue-700);
  background: var(--white);
  font-weight: 900;
}

.hero-panel,
.balance-panel,
.control-panel,
.manual-panel,
.log-panel {
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(148, 163, 184, .3);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 16px;
}

.balance-panel {
  padding: 16px;
}

.top-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.sensor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sensor-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 16px;
  background: var(--white);
}

.sensor-card span,
.sensor-card em {
  display: block;
  color: var(--slate-600);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.sensor-card strong {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin: 9px 0 7px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.sensor-card small {
  padding-top: 4px;
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 900;
}

.difference-card {
  margin-top: 10px;
  padding: 24px 16px 18px;
  border-radius: 18px;
  color: var(--white);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .12), transparent 45%),
    linear-gradient(135deg, var(--blue-950), var(--blue-700));
  text-align: center;
}

.difference-card[data-state="warn"] {
  background: linear-gradient(135deg, #713f12, #d97706);
}

.difference-card[data-state="ng"] {
  background: linear-gradient(135deg, #7f1d1d, #dc2626);
}

.difference-card[data-state="wait"] {
  background: linear-gradient(135deg, #374151, #6b7280);
}

.difference-card p {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 800;
}

.difference-card div:first-of-type {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 7px;
}

#differenceValue {
  font-size: 78px;
  line-height: .95;
  font-weight: 900;
  letter-spacing: 0;
}

.difference-card div:first-of-type span {
  padding-top: 12px;
  color: #bfdbfe;
  font-size: 18px;
  font-weight: 900;
}

#judgementValue {
  display: inline-flex;
  margin-top: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 13px;
  letter-spacing: .08em;
}

.diff-track {
  height: 10px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
}

.diff-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #fde047, #ef4444);
  transition: width .18s ease;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.connection-pill,
.device-name {
  min-width: 0;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.connection-pill {
  color: #1d4ed8;
  background: var(--blue-100);
}

.connection-pill.online {
  color: var(--green-700);
  background: var(--green-100);
}

.device-name {
  overflow: hidden;
  color: var(--slate-600);
  background: var(--slate-100);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.angle-card {
  min-height: 238px;
  padding: 26px 16px 18px;
  border-radius: 18px;
  color: var(--white);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .12), transparent 45%),
    linear-gradient(135deg, var(--blue-950), var(--blue-700));
  text-align: center;
}

.angle-card p {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
  font-weight: 700;
}

.angle-line {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  min-height: 98px;
}

#angleValue {
  font-size: 82px;
  line-height: .94;
  font-weight: 900;
  letter-spacing: 0;
}

.degree {
  padding-top: 11px;
  color: #bfdbfe;
  font-size: 19px;
  font-weight: 900;
}

.angle-track {
  height: 12px;
  margin-top: 26px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
}

.angle-fill {
  width: 50%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width .18s ease;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.metric-grid article {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 14px;
  background: var(--white);
}

.metric-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 700;
}

.metric-grid strong {
  font-size: 24px;
}

.control-panel,
.manual-panel,
.log-panel {
  padding: 14px;
  margin-top: 12px;
  box-shadow: 0 14px 35px rgba(7, 27, 58, .08);
}

.message {
  min-height: 42px;
  margin: 0 0 13px;
  color: var(--slate-600);
  font-size: 14px;
  line-height: 1.5;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  color: var(--slate-900);
  background: var(--slate-100);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  color: var(--white);
  background: linear-gradient(135deg, var(--blue-700), var(--blue-600));
  box-shadow: 0 14px 28px rgba(21, 101, 216, .24);
}

button.danger {
  color: var(--red-700);
  background: var(--red-100);
}

button.full {
  width: 100%;
  margin-top: 10px;
}

.option-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.option-row label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border-radius: 12px;
  color: var(--slate-600);
  background: var(--slate-100);
  font-size: 12px;
  font-weight: 900;
}

.manual-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.manual-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 12px;
  color: var(--blue-700);
  background: #eff6ff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

pre {
  min-height: 72px;
  max-height: 150px;
  margin: 0;
  overflow: auto;
  color: var(--slate-600);
  white-space: pre-wrap;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.manual-page {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.manual-card {
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, .3);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 18px 48px rgba(7, 27, 58, .1);
}

.manual-card h1 {
  margin-bottom: 8px;
}

.manual-card h2 {
  margin-top: 24px;
  font-size: 18px;
}

.manual-card p,
.manual-card li {
  color: var(--slate-600);
  line-height: 1.75;
}

.manual-card code {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--slate-100);
}

.back-link {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--blue-700);
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 360px) {
  .shell {
    padding-inline: 12px;
  }

  #angleValue {
    font-size: 70px;
  }

  .button-grid,
  .manual-links {
    grid-template-columns: 1fr;
  }
}
