/* Lemon House. Colours are CSS variables set from the sky (time of day + weather)
   by app.js, so every page follows the same sky. Phone first; on a wide screen the
   app sits in a centred column with the sky full-bleed behind it. */
:root {
  --bg: #FBEDE4; --card: #FFF8F3; --glass: rgba(255,248,243,0.94); --text: #2B3150; --muted: #565B7A;
  --label: #8A4F66; --line: #EEDDD4; --shadow: rgba(62,70,119,0.12); --primary: #2B3150; --on-primary: #FFF8F3;
  --alert-bg: #F6C2B4; --alert: #9C3E29; --accent: #F9D27A; --tile-off: #FFF8F3; --dot-off: #F4E3DA;
  --hero-text: #FFFFFF; --chip: rgba(255,255,255,0.28); --climate: #D9D1F0;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Nunito Sans', system-ui, sans-serif; font-size: 15px; transition: background .6s ease, color .6s ease; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.serif { font-family: Fraunces, Georgia, serif; }
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.boot { margin: auto; font-family: Fraunces, serif; font-size: 22px; opacity: .6; }

/* hero sky */
.hero { position: relative; height: calc(330px + var(--safe-top)); overflow: hidden; }
.hero.small { height: calc(220px + var(--safe-top)); }
.sky-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-top { position: relative; padding: calc(16px + var(--safe-top)) 18px 0; display: flex; justify-content: space-between; align-items: flex-start; color: var(--hero-text); gap: 12px; }
.hero-title { font-family: Fraunces, serif; font-size: 26px; line-height: 1.1; }
.hero-sub { font-size: 14px; font-weight: 700; margin-top: 4px; }
.chip-btn { height: 44px; min-width: 44px; padding: 0 14px; border-radius: 22px; border: 0; background: var(--chip); color: var(--hero-text); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.back { width: 44px; padding: 0; justify-content: center; }

/* cards */
.note { margin: -30px 14px 0; position: relative; padding: 18px; border-radius: 26px; background: var(--glass); box-shadow: 0 10px 30px var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.note .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--label); }
.note .say { font-family: Fraunces, serif; font-size: 20px; line-height: 1.3; }
.note .more { font-size: 14px; line-height: 1.5; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { min-height: 46px; padding: 0 20px; border-radius: 23px; border: 0; background: var(--primary); color: var(--on-primary); font-weight: 700; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.section { margin: 22px 14px 0; display: flex; flex-direction: column; gap: 10px; }
.section h2 { font-family: Fraunces, serif; font-weight: 600; font-size: 19px; margin: 0; display: flex; justify-content: space-between; align-items: baseline; }
.section h2 .btn { font-family: 'Nunito Sans', sans-serif; font-size: 14px; min-height: 44px; padding: 0 16px; }
.section h2 small { font-family: 'Nunito Sans', sans-serif; font-size: 13px; font-weight: 700; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 0; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; background: var(--card); color: var(--text); box-shadow: 0 2px 10px var(--shadow); }
.chip.alert { background: var(--alert-bg); color: #2B3150; }
.dotr { width: 8px; height: 8px; border-radius: 4px; background: var(--alert); flex: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.room { min-height: 104px; padding: 12px; border-radius: 20px; background: var(--card); box-shadow: 0 3px 12px var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.room .name { font-weight: 700; }
.room .st { font-size: 13px; color: var(--muted); }
.room .st .alert-t { color: var(--alert); font-weight: 700; }
.ico { width: 40px; height: 40px; border-radius: 20px; background: var(--dot-off); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; flex: none; }
.tile { min-height: 68px; padding: 10px 12px; border: 0; border-radius: 20px; display: flex; align-items: center; gap: 10px; text-align: left; background: var(--tile-off); color: var(--text); box-shadow: 0 3px 12px var(--shadow); transition: background .2s, box-shadow .2s; }
.tile.wide { grid-column: 1 / -1; }
.tile.on { background: var(--accent); color: #2B3150; box-shadow: 0 6px 20px rgba(249,210,122,.5); }
.tile .ico { margin: 0; width: 42px; height: 42px; border-radius: 21px; }
.tile.on .ico { background: #FFF6DA; box-shadow: 0 0 14px rgba(255,236,170,.9); }
.tile .t-name { font-weight: 700; display: block; }
.tile .t-st { font-size: 12px; font-weight: 600; opacity: .8; }
.tile.offline { opacity: .5; }

/* room page */
.list { background: var(--card); border-radius: 22px; box-shadow: 0 4px 16px var(--shadow); display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; font-weight: 700; }
.li .sub { font-size: 13px; color: var(--muted); font-weight: 400; }
.switch { width: 58px; height: 34px; border-radius: 17px; border: 0; padding: 3px; display: flex; align-items: center; background: var(--dot-off); justify-content: flex-start; flex: none; }
.switch[aria-pressed="true"] { background: var(--accent); justify-content: flex-end; }
.switch span { width: 28px; height: 28px; border-radius: 14px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.climate { padding: 16px; border-radius: 24px; background: var(--climate); color: var(--text); display: flex; flex-direction: column; gap: 14px; }
.climate .big { font-family: Fraunces, serif; font-size: 50px; line-height: 1; text-align: center; }
.climate .pm { width: 56px; height: 56px; border-radius: 28px; border: 0; background: var(--card); font-size: 26px; }
.spacer { height: 24px; }

/* dock */
.dock { margin-top: auto; position: sticky; bottom: 0; padding: 10px 14px calc(14px + var(--safe-bottom)); background: var(--bg); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; z-index: 5; }
.scenes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.scene { min-height: 44px; padding: 4px; border-radius: 22px; border: 1.5px solid var(--line); background: var(--card); font-size: 12px; font-weight: 700; line-height: 1.15; }
.ask { display: flex; gap: 8px; align-items: center; }
.ask input { flex: 1; min-width: 0; height: 48px; border-radius: 24px; border: 1.5px solid var(--line); background: var(--card); padding: 0 16px; font-size: 16px; }
.ask button { width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--primary); display: flex; align-items: center; justify-content: center; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: 20px; font-weight: 700; font-size: 14px; transition: all .25s ease; max-width: calc(100% - 40px); text-align: center; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.offline-bar { margin: 8px 14px 0; padding: 8px 12px; border-radius: 14px; background: var(--alert-bg); color: #2B3150; font-size: 13px; font-weight: 700; text-align: center; }

/* sign in */
.signin { margin: -30px 14px 0; position: relative; padding: 22px; border-radius: 26px; background: var(--glass); box-shadow: 0 10px 30px var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.signin input { height: 50px; border-radius: 25px; border: 1.5px solid var(--line); background: var(--card); padding: 0 18px; font-size: 16px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@keyframes lhDrift { from { transform: translateX(-10px) } to { transform: translateX(14px) } }
@keyframes lhSway { from { transform: rotate(-0.6deg) } to { transform: rotate(0.6deg) } }
@keyframes lhRain { from { transform: translateY(-12px) } to { transform: translateY(14px) } }
@keyframes lhFlash { 0%, 86%, 100% { opacity: 0 } 88%, 92% { opacity: 1 } }
@media (min-width: 520px) { body { background: var(--bg); } .app { box-shadow: 0 0 60px var(--shadow); } }

/* light control panel */
.li-name { background: none; border: 0; padding: 12px 0; text-align: left; font-weight: 700; color: inherit; min-height: 44px; }
.li-name .sub { font-weight: 400; color: var(--muted); }
.sheet-wrap { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.sheet-wrap.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 22, 40, .35); }
.sheet { max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; background: var(--card); color: var(--text);
  border-radius: 28px 28px 0 0; padding: 10px 20px calc(18px + var(--safe-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 18px;
  animation: sheetUp .22s ease-out; }
@keyframes sheetUp { from { transform: translate(-50%, 40px); opacity: .6 } to { transform: translate(-50%, 0); opacity: 1 } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-title { font-family: Fraunces, serif; font-size: 24px; }
.switch.big { width: 76px; height: 46px; border-radius: 23px; padding: 4px; }
.switch.big span { width: 38px; height: 38px; border-radius: 19px; }
.ctl { display: flex; flex-direction: column; gap: 10px; }
.ctl-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; color: var(--muted); }
.ctl-row strong { color: var(--text); font-size: 16px; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 52px; border-radius: 26px; outline: none; margin: 0; }
.slider.bri { background: linear-gradient(90deg, #3A3F5C, #FFE6A0); }
.slider.warm { background: linear-gradient(90deg, #FFB25E, #FFF6E8 55%, #CFE3FF); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 52px; height: 52px; border-radius: 26px; background: #fff; border: 3px solid rgba(0,0,0,.08); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.slider::-moz-range-thumb { width: 46px; height: 46px; border-radius: 23px; background: #fff; border: 3px solid rgba(0,0,0,.08); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.sw { aspect-ratio: 1; min-height: 48px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--line); }
.done { align-self: stretch; }

/* the brain's answer, above the scenes */
.answer { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; padding: 12px 44px 12px 14px; box-shadow: 0 4px 16px var(--shadow); }
.answer-q { font-size: 13px; color: var(--muted); }
.answer-say { font-family: Fraunces, serif; font-size: 17px; line-height: 1.35; margin-top: 2px; }
.answer-x { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border: 0; background: none; font-size: 22px; color: var(--muted); }
.dots::after { content: '…'; animation: dots 1.2s steps(3, end) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0 } to { width: 1.2em } }
.keybox { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; text-align: left; padding: 12px; border-radius: 14px; border: 1.5px dashed var(--line); background: var(--bg); min-height: 44px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.steps code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 6px; word-break: break-all; }
