:root {
  color-scheme: dark;
  --bg: #101014;
  --card: #1a1a22;
  --text: #ececf0;
  --muted: #9a9aa8;
  --accent: #7c5cff;
  --green: #2fb56b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: env(safe-area-inset-top) 12px calc(env(safe-area-inset-bottom) + 12px);
  max-width: 520px;
  margin-inline: auto;
}

header { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; }
h1 { font-size: 20px; margin: 0; }
.version { font-size: 11px; color: var(--muted); font-weight: 400; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.badge {
  border: 0; border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; color: #fff; cursor: pointer;
}
.badge.cloud        { background: var(--green); }
.badge.toy_offline  { background: #c99a2e; }
.badge.disconnected { background: #b54040; }

.dial { text-align: center; margin-bottom: 10px; }
.dial-value { font-size: 56px; font-weight: 700; line-height: 1; }
.dial-value small { font-size: 20px; color: var(--muted); }
.dial-bar {
  height: 10px; border-radius: 5px; background: #2a2a34;
  margin: 12px 0 4px; overflow: hidden;
}
#dialFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transition: width .12s linear;
}

input[type="range"] { width: 100%; margin: 10px 0; accent-color: var(--accent); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }

button { font-size: 15px; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer; }
button.primary   { background: var(--accent); color: #fff; flex: 1; }
button.secondary { background: #2a2a34; color: var(--text); }
button:disabled  { opacity: .45; cursor: default; }

#panicBtn {
  display: block; width: 100%;
  background: #c22; color: #fff;
  font-size: 18px; font-weight: 700;
  padding: 16px; border-radius: 14px;
  margin: 0 0 12px;
}
#panicBtn:active { background: #e33; }

label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
input[type="url"], input[type="password"], select {
  width: 100%; margin-top: 4px;
  background: #23232d; color: var(--text);
  border: 1px solid #34343f; border-radius: 8px;
  padding: 10px; font-size: 14px;
}
select { width: auto; }

.note { font-size: 13px; color: var(--muted); margin-top: 6px; }
.code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 22px; letter-spacing: 3px;
  background: #23232d; border-radius: 8px;
  padding: 8px 12px; display: inline-block; margin: 8px 0;
}
#qrImg { max-width: 220px; width: 100%; border-radius: 8px; display: block; margin: 8px 0; }

#curveCanvas {
  width: 100%; height: 200px;
  background: #14141a;
  border-radius: 10px;
  display: block;
}
