:root {
  color-scheme: light;
  --ink: #132432;
  --ink-soft: #52636f;
  --paper: #f4efe7;
  --white: #fffdf9;
  --line: rgba(19, 36, 50, 0.13);
  --coral: #ec8f73;
  --gold: #f4c95d;
  --red: #c9534c;
  --shadow: 0 22px 60px rgba(20, 31, 41, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; }

button, input { font: inherit; }
button { -webkit-user-select: none; user-select: none; }

[hidden] { display: none !important; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 15% 12%, rgba(244, 201, 93, 0.28), transparent 28%),
    radial-gradient(circle at 86% 88%, rgba(236, 143, 115, 0.23), transparent 31%),
    var(--paper);
}

.login-card {
  width: min(100%, 390px);
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 32px;
  padding: 32px 26px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-logo { width: 72px; height: 72px; border-radius: 19px; box-shadow: 0 12px 28px rgba(19, 36, 50, 0.22); }
.eyebrow { margin: 25px 0 5px; color: var(--coral); letter-spacing: 0.18em; font-size: 0.71rem; font-weight: 800; }
.login-card h1 { margin: 0; font-size: clamp(2.1rem, 9vw, 2.75rem); letter-spacing: -0.045em; }
.login-copy { margin: 9px 0 28px; color: var(--ink-soft); line-height: 1.45; }

.login-card form { display: grid; gap: 16px; }
.login-card label { display: grid; gap: 7px; }
.login-card label span { padding-left: 3px; color: var(--ink-soft); font-size: 0.79rem; font-weight: 700; }
.login-card input {
  width: 100%;
  height: 53px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  color: var(--ink);
  padding: 0 16px;
  outline: none;
  font-size: 1rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.login-card input:focus { border-color: var(--coral); box-shadow: 0 0 0 4px rgba(236, 143, 115, 0.15); }
.form-error { min-height: 20px; margin: -4px 2px -5px; color: var(--red); font-size: 0.82rem; }
.primary-button {
  height: 54px;
  border: 0;
  border-radius: 17px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 25px rgba(19, 36, 50, 0.24);
}
.primary-button:disabled { opacity: 0.58; }

.app-view { min-height: 100dvh; background: #f7f4ee; }
.topbar {
  position: sticky;
  z-index: 12;
  top: 0;
  min-height: calc(56px + env(safe-area-inset-top));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  background: #1c1c1c;
  color: white;
  box-shadow: none;
}
.brand { min-height: 44px; display: flex; align-items: center; gap: 10px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand p { margin: 0; font-size: 0.92rem; font-weight: 650; letter-spacing: 0; }
.brand span { display: block; margin-top: 1px; color: #83c6a9; font-size: 0.68rem; }
.brand span.offline { color: #f1ab9e; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #e1e1e1; display: grid; place-items: center; }
.icon-button:active { background: rgba(255,255,255,.1); }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.console { padding: 0 max(0px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(0px, env(safe-area-inset-left)); }
.plan-shell {
  width: 100%;
  margin: 0 auto;
  background: transparent;
  border: 0;
  border-radius: 0 0 24px 24px;
  padding: 0;
  box-shadow: none;
  overflow: hidden;
}
.plan { position: relative; width: 100%; aspect-ratio: 851 / 654; }
.plan > img { display: block; width: 100%; height: 100%; border-radius: 0 0 24px 24px; }
.hotspots { position: absolute; inset: 0; }
.hotspot {
  position: absolute;
  z-index: 1;
  width: clamp(44px, 10vw, 64px);
  height: clamp(44px, 10vw, 64px);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: #44739e;
  transition: transform 0.14s ease, opacity 0.18s ease;
}
.hotspot-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(38px, 9vw, 58px);
  height: clamp(38px, 9vw, 58px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(37, 48, 59, .97);
  box-shadow: 0 3px 10px rgba(15, 23, 32, .34);
  transition: color .18s ease, transform .14s ease, box-shadow .18s ease;
}
.hotspot-core svg {
  width: clamp(17px, 4vw, 22px);
  height: clamp(17px, 4vw, 22px);
  fill: currentColor;
  color: inherit;
}
.hotspot-label {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 68%;
  transform: translateX(-50%);
  min-height: 18px;
  padding: 3px 7px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  background: rgba(15, 23, 32, .94);
  color: #fff;
  box-shadow: 0 2px 7px rgba(15,23,32,.28);
  font-size: clamp(.5rem, 1.55vw, .68rem);
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}
.hotspot:focus-visible { outline: 2px solid #03a9f4; outline-offset: 3px; }
.hotspot:active .hotspot-core { transform: translate(-50%, -50%) scale(.88); }
.hotspot:active, .hotspot:focus-visible { z-index: 4; }
.hotspot:disabled { cursor: default; }
.hotspot.is-on { color: #ffc107; }
.hotspot.is-on .hotspot-core { box-shadow: 0 0 0 2px rgba(255,193,7,.12), 0 3px 10px rgba(15,23,32,.34); }
.hotspot.is-loading { opacity: 0.58; }
.hotspot.is-unavailable { opacity: 0.38; filter: grayscale(1); }
.hotspot.is-stale { opacity: 0.48; filter: grayscale(1); }
.hotspot.is-stale .hotspot-core::after {
  content: "?";
  position: absolute;
  right: -5px;
  top: -7px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #384758;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.hotspot.is-pending { pointer-events: none; }
.hotspot.is-pending .hotspot-core { animation: pulse 0.75s infinite alternate; }
@keyframes pulse { to { transform: translate(-50%, -50%) scale(.9); opacity: .7; } }

.shortcuts {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom));
}
.shortcuts-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 0 2px 14px;
}
.shortcuts-heading p {
  margin: 0 0 4px;
  color: #7b8790;
  font-size: .64rem;
  font-weight: 850;
  letter-spacing: .15em;
}
.shortcuts-heading h2 {
  margin: 0;
  color: #243542;
  font-size: 1.25rem;
  letter-spacing: -.025em;
}
.shortcuts-heading > span {
  margin-bottom: 2px;
  padding: 5px 9px;
  border: 1px solid rgba(19,36,50,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: #73808a;
  font-size: .68rem;
  font-weight: 750;
}
.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.shortcut-card {
  position: relative;
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(19,36,50,.08);
  border-radius: 21px;
  padding: 14px 12px;
  background: rgba(255,253,249,.96);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 24px rgba(28,40,50,.08);
  transition: transform .14s ease, box-shadow .14s ease, opacity .18s ease;
}
.shortcut-card:active { transform: scale(.97); box-shadow: 0 4px 14px rgba(28,40,50,.08); }
.shortcut-card:focus-visible { outline: 3px solid rgba(68,115,158,.28); outline-offset: 2px; }
.shortcut-card:disabled { opacity: .48; }
.shortcut-card.is-pending { opacity: .7; pointer-events: none; }
.shortcut-card.is-pending .shortcut-icon { animation: shortcut-pulse .7s ease-in-out infinite alternate; }
.shortcut-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #edf1f3;
  color: #506675;
}
.shortcut-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shortcut-copy { min-width: 0; display: grid; gap: 4px; }
.shortcut-copy strong { font-size: .88rem; line-height: 1.1; letter-spacing: -.01em; }
.shortcut-copy small { color: #72808a; font-size: .68rem; line-height: 1.25; }
.shortcut-card--leave .shortcut-icon { background: #f8e8e4; color: #bd6558; }
.shortcut-card--bright .shortcut-icon { background: #fff2c9; color: #a77709; }
.shortcut-card--evening .shortcut-icon { background: #e7edf8; color: #586f9f; }
.shortcut-card--night .shortcut-icon { background: #e9e7f2; color: #6f668a; }
.shortcut-card--kitchen .shortcut-icon { background: #e7f2ec; color: #527b67; }
.shortcut-card--salon .shortcut-icon { background: #ece8e0; color: #756855; }
@keyframes shortcut-pulse { to { transform: scale(.88); opacity: .68; } }

.install-hint {
  position: fixed;
  z-index: 20;
  left: 14px;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  max-width: 440px;
  margin: auto;
  padding: 17px 46px 17px 18px;
  border-radius: 19px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}
.install-hint strong, .install-hint span { display: block; }
.install-hint span { margin-top: 4px; color: #d5dde1; font-size: 0.78rem; line-height: 1.38; }
.install-hint button { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; border: 0; background: transparent; color: white; font-size: 1.7rem; }

.sheet-backdrop { position: fixed; z-index: 29; inset: 0; background: rgba(10, 20, 28, 0.42); opacity: 0; transition: opacity 0.22s; }
.sheet-backdrop.open { opacity: 1; }
.bottom-sheet {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  max-height: calc(100dvh - 10px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: auto;
  padding: 9px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--white);
  box-shadow: 0 -20px 50px rgba(19, 36, 50, 0.25);
  transform: translateY(105%);
  transition: transform 0.22s ease-out;
}
.bottom-sheet.open { transform: translateY(0); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 18px; border-radius: 3px; background: #ced4d7; }
.sheet-title-row { display: flex; justify-content: space-between; align-items: center; }
.sheet-title-row p { margin: 0 0 3px; color: var(--coral); font-size: 0.68rem; font-weight: 850; letter-spacing: 0.14em; }
.sheet-title-row h2 { margin: 0; font-size: 1.65rem; }
.sheet-title-row > span { color: var(--ink); font-size: 2rem; font-weight: 300; }
.climate-sheet { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.climate-header { align-items: center; }
.climate-header-actions { display: flex; align-items: center; gap: 8px; }
.climate-header-actions > span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f2ec;
  color: #527b67;
  font-size: .72rem;
  font-weight: 800;
}
.sheet-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #eef0ed;
  color: #60707a;
  font-size: 1.5rem;
  line-height: 1;
}
.climate-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 15px 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, #e8f3f5, #f4f0e8);
}
.current-climate { display: grid; align-content: center; }
.current-climate span { color: #66808d; font-size: .62rem; font-weight: 850; letter-spacing: .13em; }
.current-climate strong { margin-top: 2px; color: var(--ink); font-size: 2.15rem; font-weight: 500; line-height: 1; }
.climate-power {
  min-width: 90px;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  gap: 7px;
  border: 1px solid #d8aaa5;
  border-radius: 16px;
  background: #f8e8e4;
  color: var(--red);
}
.climate-power span { font-size: 1.25rem; }
.climate-power b { font-size: .76rem; }
.climate-power.is-on { border-color: #93c5b0; background: #dceee5; color: #39745a; }
.climate-section { margin-top: 14px; }
.climate-section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.climate-section-title span { color: var(--ink); font-size: .78rem; font-weight: 850; }
.climate-section-title small { color: #829098; font-size: .65rem; font-weight: 700; }
.temperature-control {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7f4ee;
}
.temperature-control button {
  height: 48px;
  border: 0;
  border-radius: 13px;
  background: white;
  color: #357f96;
  font-size: 1.65rem;
  box-shadow: 0 3px 10px rgba(19,36,50,.08);
}
.temperature-control strong { color: var(--ink); font-size: 1.55rem; font-weight: 650; text-align: center; }
.climate-options { display: grid; gap: 7px; }
.mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fan-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.climate-options button {
  min-height: 49px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f4ee;
  color: #5a6871;
  font-size: .67rem;
  font-weight: 800;
}
.mode-grid button { display: grid; place-content: center; gap: 2px; }
.mode-grid button span { color: #438da3; font-size: 1.05rem; line-height: 1; }
.climate-options button.is-selected { border-color: #6aa7b8; background: #e2f0f3; color: #216c82; box-shadow: inset 0 0 0 1px rgba(62,139,160,.1); }
.climate-sheet button:focus-visible { outline: 3px solid rgba(68,115,158,.3); outline-offset: 2px; }
.climate-sheet button:disabled { opacity: .42; }
.climate-unavailable-note { margin: 3px 0 0; color: #72838c; font-size: .72rem; line-height: 1.4; }
.climate-sheet.is-pending .climate-section,
.climate-sheet.is-pending .climate-hero { opacity: .72; }

.tv-sheet { padding-bottom: calc(25px + env(safe-area-inset-bottom)); }
.tv-title-row { align-items: center; }
.tv-title-actions { display: flex; align-items: center; gap: 8px; }
.tv-title-actions > span {
  max-width: 130px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f2ec;
  color: #527b67;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}
.tv-power-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid #e5bbb5;
  border-radius: 50%;
  background: #f9e9e5;
  color: var(--red);
  font-size: 1.35rem;
}
.tv-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}
.tv-command,
.tv-playback-actions button,
.tv-volume-actions button {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f7f4ee;
  color: var(--ink);
  font-size: .7rem;
  font-weight: 800;
}
.tv-command span { font-size: 1.25rem; line-height: 1; }
.tv-dpad {
  width: 210px;
  height: 210px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  margin: 17px auto;
  border: 1px solid rgba(19,36,50,.1);
  border-radius: 50%;
  padding: 12px;
  background: #243542;
  box-shadow: 0 10px 25px rgba(19,36,50,.2);
}
.tv-dpad button {
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #f7f4ee;
  font-size: 1rem;
  font-weight: 800;
}
.tv-dpad button:active { background: rgba(255,255,255,.12); transform: scale(.92); }
.tv-dpad button:nth-child(1) { grid-area: 1 / 2; }
.tv-dpad button:nth-child(2) { grid-area: 2 / 1; }
.tv-dpad button:nth-child(3) { grid-area: 2 / 2; }
.tv-dpad button:nth-child(4) { grid-area: 2 / 3; }
.tv-dpad button:nth-child(5) { grid-area: 3 / 2; }
.tv-dpad .tv-dpad-select { background: rgba(255,255,255,.13); font-size: .76rem; }
.tv-playback-actions { display: grid; margin-bottom: 9px; }
.tv-playback-actions button { min-height: 58px; grid-template-columns: auto auto; justify-content: center; column-gap: 9px; font-size: .75rem; }
.tv-volume-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}
.tv-volume-actions button { min-height: 60px; padding: 7px 4px; }
.tv-playback-actions button span,
.tv-volume-actions button span { font-size: 1.05rem; line-height: 1; }
.tv-dpad button[data-tv-action],
.tv-volume-actions button[data-tv-action] { touch-action: none; user-select: none; -webkit-user-select: none; }
.tv-sheet button:focus-visible { outline: 3px solid rgba(68,115,158,.3); outline-offset: 2px; }
.tv-sheet button.is-pending { opacity: .55; }
.tv-sheet button:disabled { opacity: .45; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 36px);
  padding: 12px 17px;
  border-radius: 15px;
  background: var(--ink);
  color: white;
  font-size: 0.83rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  box-shadow: var(--shadow);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.danger { background: var(--red); }

@media (orientation: landscape) and (max-height: 620px) {
  .topbar { min-height: calc(50px + env(safe-area-inset-top)); padding-bottom: 3px; }
  .brand { min-height: 44px; }
  .brand img { width: 28px; height: 28px; }
  .plan-shell { width: 100%; }
}

@media (min-width: 760px) {
  .console { padding-left: 12px; padding-right: 12px; }
  .plan-shell { border-radius: 0 0 28px 28px; }
}

@media (max-width: 370px) {
  .shortcuts { padding-left: 10px; padding-right: 10px; }
  .shortcut-grid { gap: 8px; }
  .shortcut-card { min-height: 88px; gap: 9px; padding: 12px 9px; border-radius: 18px; }
  .shortcut-icon { width: 38px; height: 38px; border-radius: 12px; }
  .shortcut-copy strong { font-size: .79rem; }
  .shortcut-copy small { font-size: .62rem; }
  .tv-dpad { width: 180px; height: 180px; margin: 12px auto; }
  .tv-volume-actions { gap: 5px; }
  .tv-volume-actions button { font-size: .61rem; }
}
