:root {
  --bg: #1a1210;
  --panel: #251a16;
  --panel2: #30221c;
  --line: #3d2c24;
  --text: #f6ece4;
  --muted: #b39b8d;
  --accent: #f28c2e;
  --heat: #e8502e;
  --heat2: #ff6a3d;
  --green: #4caf7d;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(130% 90% at 50% 0%, #2a1c16 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 96px; }
header.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 18px; }
header.top img { width: 40px; height: 40px; border-radius: 10px; }
header.top h1 { font-size: 20px; margin: 0; font-weight: 700; }
header.top .sp { flex: 1; }
.iconbtn { background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  width: 38px; height: 38px; border-radius: 10px; font-size: 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.b-heating { background: rgba(232,80,46,.2); color: var(--heat2); }
.b-idle { background: rgba(76,175,125,.2); color: var(--green); }
.b-offline, .b-unknown { background: #3a2c25; color: var(--muted); }
.b-err { background: rgba(242,140,46,.18); color: var(--accent); }

.metrics { display: flex; gap: 22px; margin: 14px 0 4px; }
.metric b { display: block; font-size: 22px; }
.metric span { font-size: 12px; color: var(--muted); }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
button.btn { border: none; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
button.btn:active { transform: scale(.98); }
button.primary { background: linear-gradient(180deg, var(--heat2), var(--heat)); border: none; }
button.accent { background: linear-gradient(180deg, #ffb057, var(--accent)); border: none; color: #2a1708; }
button.full { grid-column: 1 / -1; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; }

input, select { width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 16px; }
label.fld { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }

input[type=range] { -webkit-appearance: none; height: 30px; background: transparent; padding: 0; border: none; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--heat)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px;
  border-radius: 50%; background: #fff; border: 3px solid var(--heat); }

.days { display: flex; gap: 6px; margin-top: 6px; }
.day { flex: 1; text-align: center; padding: 10px 0; border-radius: 10px; background: var(--panel2);
  border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.day.on { background: var(--accent); color: #2a1708; border-color: var(--accent); }

.sched { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sched:last-child { border-bottom: none; }
.sched .t { font-size: 20px; font-weight: 700; width: 64px; }
.switch { width: 46px; height: 28px; border-radius: 999px; background: #43322a; position: relative; border: none; flex: none; }
.switch.on { background: var(--green); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .15s; }
.switch.on::after { left: 21px; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(26,18,16,.95);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: none; color: var(--muted); padding: 12px; font-size: 12px; }
.tabbar button.active { color: var(--accent); }
.tabbar .ic { display: block; font-size: 20px; margin-bottom: 2px; }

.fab { position: fixed; right: 18px; bottom: 76px; width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(180deg, #ffb057, var(--accent)); color: #2a1708; border: none; font-size: 28px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); margin-bottom: env(safe-area-inset-bottom); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; z-index: 50; }
.modal .sheet { background: var(--bg); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; border: 1px solid var(--line); }
.sheet h3 { margin: 4px 0 14px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }

.hidden { display: none !important; }
.center { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #000; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; opacity: 0; transition: .2s; }
.toast.show { opacity: .95; }

/* login */
.login { max-width: 360px; margin: 10vh auto; text-align: center; padding: 20px; }
.login img { width: 96px; height: 96px; border-radius: 22px; margin-bottom: 16px; }
.login h1 { margin: 0 0 20px; }
.login button { margin-top: 14px; }
.or { color: var(--muted); font-size: 13px; margin: 16px 0; }
.err { color: var(--heat2); font-size: 14px; margin-top: 10px; min-height: 18px; }
