:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1b1e23;
  --sub: #8b929c;
  --line: #edeef1;
  --accent: #f7a11a;
  --accent-deep: #d98600;
  --ok: #23b26d;
  --danger: #ef4b3f;
  --shadow: 0 6px 20px rgba(20, 25, 35, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.wrap { max-width: 480px; margin: 0 auto; padding: 16px; }

/* 顶栏 */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 4px; margin-bottom: 6px;
}
.nav h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: .3px; }
.nav .back { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; margin-left: -6px; }
.nav .back svg { width: 20px; height: 20px; }
.nav .action { font-size: 14px; color: var(--accent-deep); background: none; border: 0; padding: 8px 4px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card.tight { padding: 13px 16px; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 7px; }
.input {
  width: 100%; height: 48px; padding: 0 14px; font-size: 16px; color: var(--text);
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 12px; outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--accent); background: #fff; }
.input::placeholder { color: #b6bcc5; }
.code-row { display: flex; gap: 10px; }
.code-row .input { flex: 1; }
.btn-code {
  flex: 0 0 116px; height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--accent-deep); font-size: 14px; font-weight: 500;
}
.btn-code:disabled { color: #b6bcc5; }

.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 50px; border: 0; border-radius: 13px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: #fff; box-shadow: 0 8px 18px rgba(247, 161, 26, .28);
  transition: transform .12s, opacity .12s;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: #fff; color: var(--text); box-shadow: none; border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: #fff; color: var(--danger); box-shadow: none; border: 1px solid #f6d5d2; }
.btn:disabled { opacity: .55; box-shadow: none; }
.btn.sm { height: 38px; width: auto; padding: 0 16px; font-size: 14px; border-radius: 10px; }

/* 状态标记 */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { background: rgba(35, 178, 109, .1); color: var(--ok); }
.badge.off { background: #f1f2f4; color: #9aa1ab; }
.badge.lit { background: rgba(247, 161, 26, .13); color: var(--accent-deep); }

/* 设备卡片 */
.dev { display: flex; align-items: center; gap: 13px; }
.dev .ico {
  width: 46px; height: 46px; border-radius: 13px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: center;
  background: #f7f8fa; color: #b8bec7;
}
.dev .ico.lit { background: rgba(247, 161, 26, .12); color: var(--accent); }
.dev .meta { flex: 1; min-width: 0; }
.dev .name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .sub { font-size: 12px; color: var(--sub); margin-top: 3px; }
.dev-row { display: flex; gap: 8px; margin-top: 14px; }
.dev-row .btn { height: 40px; font-size: 14px; font-weight: 500; border-radius: 10px; }
.dev-row .btn.ghost { flex: 0 0 96px; }

/* 空状态 */
.empty { text-align: center; padding: 48px 10px 30px; color: var(--sub); }
.empty .ico { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 22px; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.empty p { margin: 0 0 6px; font-size: 14px; }

/* 控制页大灯 */
.hero { text-align: center; padding: 26px 16px 20px; }
.lamp-ball {
  width: 132px; height: 132px; margin: 0 auto 16px; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #f2f3f5, #e6e8ec);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, .06);
  display: flex; align-items: center; justify-content: center;
  transition: background .35s, box-shadow .35s;
}
.lamp-ball.lit {
  background: radial-gradient(circle at 50% 40%, #fff3d6, #ffbe4d 62%, #f6a01a);
  box-shadow: 0 0 46px rgba(247, 161, 26, .45), inset 0 0 20px rgba(255, 255, 255, .5);
}
.lamp-ball svg { width: 56px; height: 56px; }
.lamp-ball.lit svg { color: #8a5400; }
.lamp-ball svg { color: #b3b9c2; }
.hero .state { font-size: 22px; font-weight: 600; }
.hero .sub { font-size: 12px; color: var(--sub); margin-top: 6px; }
.power {
  margin: 6px auto 0; width: 100%; max-width: 300px;
}

/* 开关 */
.switch { position: relative; width: 46px; height: 27px; flex: 0 0 46px; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: #dfe2e7; border-radius: 999px; transition: background .2s; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.16);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(19px); }

/* 定时条目 */
.timer-item { display: flex; align-items: center; gap: 12px; }
.timer-item .time { flex: 1; }
.timer-item .t1 { font-size: 17px; font-weight: 600; }
.timer-item .t2 { font-size: 12px; color: var(--sub); margin-top: 4px; }
.timer-item.disabled { opacity: .55; }
.timer-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }

/* 弹窗 */
.mask {
  position: fixed; inset: 0; background: rgba(18, 22, 28, .45); display: flex; align-items: flex-end;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 480px; margin: 0 auto; background: #fff;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(24px); transition: transform .22s;
  max-height: 88vh; overflow: auto;
}
.mask.show .sheet { transform: translateY(0); }
.sheet h3 { font-size: 17px; margin: 0 0 16px; text-align: center; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row .field { flex: 1; }
.week { display: flex; gap: 7px; margin-top: 2px; }
.week .day {
  flex: 1; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  color: var(--sub); font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.week .day.on { background: rgba(247, 161, 26, .12); border-color: var(--accent); color: var(--accent-deep); font-weight: 600; }
.hint { font-size: 12px; color: var(--sub); margin-top: 8px; }
.sheet-btns { display: flex; gap: 10px; margin-top: 20px; }
.sheet-btns .btn { flex: 1; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(10px);
  background: rgba(24, 28, 34, .88); color: #fff; font-size: 14px; padding: 11px 18px;
  border-radius: 10px; max-width: 80vw; text-align: center; z-index: 200;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(255,255,255,.6); z-index: 150; }
.loading.show { display: flex; }
.spinner { width: 26px; height: 26px; border: 3px solid #eee; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { text-align: center; color: #b3b9c2; font-size: 12px; padding: 18px 0 8px; }
