:root {
  color-scheme: light;
  --ink: #15221d;
  --muted: #69736e;
  --paper: #f5f2ea;
  --card: rgba(255, 255, 255, 0.78);
  --line: rgba(21, 34, 29, 0.11);
  --green: #1f5c46;
  --green-dark: #173f33;
  --amber: #f3ad45;
  --shadow: 0 18px 60px rgba(45, 51, 45, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(80px);
  opacity: .4;
  pointer-events: none;
}
.ambient-one { width: 420px; height: 420px; top: -180px; right: 4vw; background: #f6d49b; }
.ambient-two { width: 340px; height: 340px; bottom: -180px; left: -80px; background: #bcd6c8; }

.shell { width: min(1160px, calc(100% - 44px)); margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 760; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: white; background: var(--green); box-shadow: 0 9px 22px rgba(31, 92, 70, .22); }
.brand-mark svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.connection { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 650; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b7afa3; box-shadow: 0 0 0 5px rgba(183, 175, 163, .12); }
.connection.online .status-dot { background: #3e9f73; box-shadow: 0 0 0 5px rgba(62, 159, 115, .12); }
.connection.warning .status-dot { background: var(--amber); box-shadow: 0 0 0 5px rgba(243, 173, 69, .15); }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 32px; padding: 72px 0 44px; }
.eyebrow { margin: 0 0 16px; color: var(--green); font-size: 11px; line-height: 1; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; max-width: 780px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(44px, 7vw, 76px); line-height: .98; letter-spacing: -.045em; }
.intro { max-width: 590px; margin: 24px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.master-actions { display: flex; gap: 10px; flex-shrink: 0; padding-bottom: 4px; }
.button { min-height: 48px; padding: 0 19px; border: 1px solid transparent; border-radius: 14px; cursor: pointer; font-size: 14px; font-weight: 720; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 10px 25px rgba(31, 92, 70, .2); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); box-shadow: 0 13px 28px rgba(31, 92, 70, .25); }
.button-secondary { background: rgba(255,255,255,.55); border-color: var(--line); }
.button-icon { margin-right: 7px; color: #ffd990; }

.summary { display: flex; align-items: center; gap: 36px; min-height: 75px; margin-bottom: 24px; padding: 0 22px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.38); }
.summary > div { display: flex; align-items: baseline; gap: 7px; }
.summary-value { font-family: Georgia, serif; font-size: 25px; }
.summary-label { color: var(--muted); font-size: 13px; }
.refresh { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; padding: 9px 0; border: 0; color: var(--green); background: transparent; cursor: pointer; font-size: 13px; font-weight: 720; }
.refresh svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.refresh.loading svg { animation: spin .8s linear infinite; }

.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.device-card { position: relative; overflow: hidden; padding: 26px; border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: var(--shadow); backdrop-filter: blur(10px); transition: border-color .2s, transform .2s; }
.device-card::after { content: ""; position: absolute; top: -80px; right: -70px; width: 180px; height: 180px; border-radius: 50%; background: var(--glow, rgba(243, 173, 69, .1)); filter: blur(9px); pointer-events: none; }
.device-card.is-on { border-color: rgba(243, 173, 69, .32); }
.device-card.offline { opacity: .76; }
.card-head { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 28px; }
.room { display: flex; gap: 14px; align-items: center; }
.lamp-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 15px; color: #8c8170; background: #eee9df; transition: .2s; }
.is-on .lamp-icon { color: #8a5c14; background: #fff0cf; box-shadow: 0 8px 22px rgba(243, 173, 69, .18); }
.lamp-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.room h2 { margin: 0 0 5px; font-size: 18px; letter-spacing: -.02em; }
.room p { margin: 0; color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 50px; height: 29px; flex: 0 0 auto; border: 0; border-radius: 999px; background: #d7d2c9; cursor: pointer; transition: .2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 21px; height: 21px; border-radius: 50%; background: white; box-shadow: 0 2px 7px rgba(0,0,0,.16); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(21px); }
.switch:disabled { cursor: not-allowed; opacity: .6; }

.control { margin-top: 23px; }
.control-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 11px; }
.control-label { color: var(--muted); font-size: 12px; font-weight: 680; }
.control-value { font-family: Georgia, serif; font-size: 16px; }
input[type="range"] { width: 100%; height: 5px; margin: 5px 0; border-radius: 9px; appearance: none; background: linear-gradient(90deg, var(--green) var(--fill, 50%), #dedbd3 var(--fill, 50%)); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { width: 19px; height: 19px; border: 3px solid white; border-radius: 50%; appearance: none; background: var(--green); box-shadow: 0 2px 7px rgba(0,0,0,.25); }
.temperature { background: linear-gradient(90deg, #f0a447 0%, #fff0cf 48%, #c7ddff 100%) !important; }
.presets { display: flex; gap: 7px; margin-top: 13px; }
.preset { flex: 1; padding: 9px 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(249,248,244,.8); color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 690; }
.preset:hover { border-color: rgba(31, 92, 70, .35); color: var(--green); }
.color-row { display: flex; align-items: center; gap: 13px; }
.color-input { width: 45px; height: 39px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.color-spectrum { flex: 1; height: 9px; border-radius: 999px; background: linear-gradient(90deg, #f66, #ffdf66, #74d680, #66caed, #7871ed, #df70dd, #f66); }
.offline-note { margin: 20px 0 0; padding: 12px 14px; border-radius: 12px; color: #8a591f; background: #fff4de; font-size: 12px; line-height: 1.5; }

.setup { display: grid; grid-template-columns: auto 1fr; gap: 25px; align-items: start; padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.65); box-shadow: var(--shadow); }
.setup-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 17px; color: var(--green); background: #e3eee8; font-size: 28px; }
.setup h2 { margin: 0 0 12px; font-family: Georgia, serif; font-size: 30px; font-weight: 500; letter-spacing: -.025em; }
.setup p:not(.eyebrow) { max-width: 750px; margin: 0 0 20px; color: var(--muted); line-height: 1.65; }
pre { max-width: 100%; overflow-x: auto; margin: 0; padding: 17px 19px; border-radius: 14px; color: #d7e8df; background: #1b2924; font-size: 12px; line-height: 1.65; }

.loading-card { grid-column: 1 / -1; display: grid; gap: 12px; padding: 30px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.5); }
.loading-card span { display: block; width: 100%; height: 16px; border-radius: 10px; background: linear-gradient(90deg, #e7e3db 20%, #f3f0e9 40%, #e7e3db 60%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.loading-card span:first-child { width: 35%; height: 24px; }
.loading-card span:last-child { width: 72%; }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 44px 0 30px; color: #8a918d; font-size: 11px; }
.footer-mark { display: inline-flex; align-items: center; gap: 7px; }
.footer-mark i { display: block; width: 5px; height: 5px; border-radius: 50%; background: #3e9f73; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(390px, calc(100% - 44px)); padding: 14px 17px; border-radius: 13px; color: white; background: #1c2924; box-shadow: 0 13px 34px rgba(0,0,0,.18); font-size: 13px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #743f35; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 780px) {
  .shell { width: min(100% - 28px, 660px); }
  .topbar { min-height: 76px; }
  .hero { display: block; padding: 48px 0 34px; }
  .master-actions { margin-top: 28px; }
  .device-grid { grid-template-columns: 1fr; }
  .summary { gap: 18px; padding: 0 16px; }
  .summary-label { display: none; }
  .setup { grid-template-columns: 1fr; padding: 26px; }
}

@media (max-width: 460px) {
  h1 { font-size: 43px; }
  .intro { font-size: 15px; }
  .master-actions .button { flex: 1; }
  .device-card { padding: 21px; }
  footer { display: block; line-height: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

