@font-face { font-family: "Outfit"; src: url("/fonts/outfit.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #05070c; --text: #fff; --dim: rgba(255,255,255,.66); --faint: rgba(255,255,255,.42);
  --glass: rgba(255,255,255,.10); --glass-2: rgba(255,255,255,.16); --glass-3: rgba(255,255,255,.26);
  --edge: rgba(255,255,255,.20); --sheen: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 45%);
  --on: #5be38c; --standby: #f5c35b; --off: #8c8f96; --danger: #ff8080;
  --blur: blur(26px) saturate(170%);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
html, body { margin: 0; min-height: 100%; color: var(--text);
  font: 300 16px/1.35 "Outfit", -apple-system, BlinkMacSystemFont, sans-serif; }
body { padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; flex: none; }

/* Wallpaper: two layers crossfade, a scrim keeps text readable like the launcher's wallpaper_dim. */
.wall { position: fixed; inset: -20px; z-index: -3; background: center / cover no-repeat; opacity: 0; transition: opacity 1.6s ease;
  filter: blur(2px) saturate(110%); transform: scale(1.04); }
.wall.show { opacity: 1; }
.scrim { position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(180deg, rgba(5,7,12,.30) 0%, rgba(5,7,12,.18) 35%, rgba(5,7,12,.70) 100%); }

.top { max-width: 980px; margin: 4px auto 22px; display: grid; grid-template-columns: 1fr auto; align-items: end; row-gap: 2px; }
.greet { grid-column: 1; font-size: 13px; letter-spacing: .32em; text-transform: uppercase; color: var(--dim); font-weight: 400; }
.clockrow { grid-column: 1; display: flex; align-items: baseline; gap: 16px; }
.clock { font-size: 64px; font-weight: 200; line-height: 1; letter-spacing: -.01em; text-shadow: 0 2px 24px rgba(0,0,0,.35); }
.date { font-size: 14px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); padding-left: 16px; border-left: 1px solid var(--edge); }
.add { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
@media (max-width: 560px) { .add { width: 46px; padding: 0; justify-content: center; font-size: 0; gap: 0; } .clock { font-size: 56px; } }

.glass-pill, .glass-round, .chip, .card, dialog, .rocker, .ring, .keypad button {
  background: var(--glass); background-image: var(--sheen); border: 1px solid var(--edge);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.glass-pill { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 11px 18px; min-height: 46px; font-weight: 400; }
[hidden] { display: none !important; }
.glass-round { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; }
button:active { transform: scale(.94); background-color: var(--glass-3); }
button { transition: transform .12s ease, background-color .2s ease; }

.tvs { max-width: 980px; margin: 0 auto; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.card { min-width: 0; border-radius: 30px; padding: 20px; display: grid; gap: 18px; background-color: rgba(18,20,26,.38);
  box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.name { margin: 0; font-size: 26px; font-weight: 300; }
.status { display: flex; align-items: center; gap: 7px; color: var(--dim); font-size: 14px; margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.card[data-power="on"] .dot { background: var(--on); box-shadow: 0 0 10px var(--on); }
.card[data-power="standby"] .dot { background: var(--standby); }
.card[data-power="on"] .power { color: var(--on); box-shadow: 0 0 24px rgba(91,227,140,.35), inset 0 0 0 1px rgba(91,227,140,.4); }
.card[data-power="offline"] .remote, .card[data-power="offline"] .keys, .card[data-power="standby"] .remote { opacity: .45; }

.now { padding: 2px 4px; }
.now-app { font-size: 38px; font-weight: 300; line-height: 1.05; text-shadow: 0 0 30px var(--glow, rgba(255,255,255,.25)); }
.now-sub { color: var(--dim); font-size: 16px; margin-top: 4px; min-height: 1.3em; }

.dock { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 12px; margin: 0 -4px;
  border-radius: 22px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); scrollbar-width: none; }
.dock::-webkit-scrollbar { display: none; }
.dock:empty { display: none; }
.tile { flex: none; width: 112px; aspect-ratio: 16 / 9; border-radius: 12px; scroll-snap-align: start; position: relative; overflow: hidden;
  display: grid; place-items: center; font-weight: 500; font-size: 15px; letter-spacing: .01em;
  box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.tile.current { outline: 2px solid #fff; outline-offset: 2px; }

.remote { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; justify-items: center; gap: 8px; }
.rocker { width: 58px; height: 168px; border-radius: 30px; display: grid; grid-template-rows: 1fr auto 1fr; place-items: center; }
.rocker button { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 30px; }
.rocker span { font-size: 11px; letter-spacing: .2em; color: var(--faint); font-weight: 500; }
.ring { width: 208px; height: 208px; border-radius: 50%; position: relative; background-color: rgba(255,255,255,.08); }
.arr { position: absolute; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; color: var(--dim); }
.arr.up { top: 4px; left: 72px; transform: rotate(-90deg); } .arr.down { bottom: 4px; left: 72px; transform: rotate(90deg); }
.arr.left { left: 4px; top: 72px; transform: rotate(180deg); } .arr.right { right: 4px; top: 72px; }
.arr.up:active { transform: rotate(-90deg) scale(.9); } .arr.down:active { transform: rotate(90deg) scale(.9); }
.arr.left:active { transform: rotate(180deg) scale(.9); }
.okbtn { position: absolute; inset: 58px; border-radius: 50%; background: var(--glass-2); background-image: var(--sheen);
  border: 1px solid var(--edge); font-weight: 500; font-size: 18px; letter-spacing: .06em; }

.keys { display: flex; justify-content: center; gap: 18px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding: 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 9px 15px; font-size: 15px; font-weight: 400; white-space: nowrap; min-height: 42px; }
.chip svg { width: 18px; height: 18px; }
.chip.active { background-color: rgba(255,255,255,.9); color: #0b0d12; }

.panel { padding: 4px 2px; }
.chan-display { text-align: center; font-size: 44px; font-weight: 200; letter-spacing: .14em; min-height: 54px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; }
.keypad button { height: 60px; border-radius: 20px; font-size: 24px; font-weight: 300; display: grid; place-items: center; }
.keypad .go { background-color: rgba(255,255,255,.85); color: #0b0d12; font-size: 18px; font-weight: 500; }
.textrow { display: flex; gap: 10px; margin-top: 10px; }
.tv-text { flex: 1; min-width: 0; padding: 13px 16px; border-radius: 999px; border: 1px solid var(--edge);
  background: rgba(0,0,0,.25); color: var(--text); font: inherit; font-size: 16px; outline: none; }
.tv-text:focus { border-color: rgba(255,255,255,.55); }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.apps .tile { width: auto; }
.hint, .meta { color: var(--dim); font-size: 14px; margin: 0; }
.meta { margin-top: 10px; }
.danger { color: var(--danger); }

.caption { text-align: center; color: var(--faint); font-size: 12px; margin-top: 26px; }
.empty, .conn { text-align: center; color: var(--dim); }
.conn { color: var(--standby); margin-bottom: 12px; }
.card.busy .okbtn { box-shadow: 0 0 0 2px rgba(255,255,255,.5); }

dialog { color: var(--text); border-radius: 28px; width: min(92vw, 440px); padding: 0; background-color: rgba(18,20,26,.75); }
dialog::backdrop { background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dlg { padding: 22px; display: grid; gap: 14px; } .dlg h2 { margin: 0; font-weight: 300; font-size: 24px; }
.dlg menu { margin: 0; padding: 0; display: flex; justify-content: flex-end; }
.dlg input { width: 100%; padding: 13px 16px; border-radius: 999px; border: 1px solid var(--edge); background: rgba(0,0,0,.25); color: var(--text); font: inherit; }
.cand { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  padding: 11px 18px; border-radius: 999px; background: rgba(18,20,26,.8); border: 1px solid var(--edge);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }

@media (max-width: 380px) { .ring { width: 184px; height: 184px; } .arr.up, .arr.down { left: 60px; } .arr.left, .arr.right { top: 60px; } .okbtn { inset: 52px; } }
/* Grid items default to min-width:auto, so the scrolling dock and chips would widen the card. */
.card > *, .top > * { min-width: 0; }
.top { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 560px) { .date { font-size: 12px; letter-spacing: .16em; } .clockrow { gap: 12px; } }
/* Proportional ring: fits between the two rockers on any phone width. */
.remote { grid-template-columns: 56px minmax(0, 1fr) 56px; }
.rocker { width: 56px; }
.ring { width: min(208px, 100%); height: auto; aspect-ratio: 1; }
.arr { width: 31%; height: 31%; }
.arr.up, .arr.down { left: 34.5%; } .arr.left, .arr.right { top: 34.5%; }
.arr.up { top: 2%; } .arr.down { bottom: 2%; } .arr.left { left: 2%; } .arr.right { right: 2%; }
.okbtn { inset: 28%; }
@media (max-width: 380px) { .arr.up, .arr.down { left: 34.5%; } .arr.left, .arr.right { top: 34.5%; } .okbtn { inset: 28%; } }
.now-sub.editable { cursor: pointer; text-decoration: underline dotted rgba(255,255,255,.35); text-underline-offset: 4px; }

/* ---------------------------------------------------------------- Casa (Home Hub) additions */
.defs { position: absolute; }
.topbtns { grid-column: 2; grid-row: 1 / span 2; align-self: center; display: flex; gap: 10px; align-items: center; }
.where { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.where svg { width: 16px; height: 16px; }
@media (max-width: 560px) { #logout span, .where { display: none; } #logout { width: 46px; padding: 0; justify-content: center; } }

.hubs { max-width: 980px; margin: 0 auto 18px; display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.hubs::-webkit-scrollbar { display: none; }
.hub { display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 7px; border-radius: 999px; white-space: nowrap;
  background: var(--glass); background-image: var(--sheen); border: 1px solid var(--edge); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.hub img { width: 30px; height: 30px; border-radius: 9px; }
.hub .dot { width: 8px; height: 8px; }
.hub[data-online="true"] .dot { background: var(--on); box-shadow: 0 0 10px var(--on); }
.hub[data-online="false"] .dot { background: var(--danger); }
.hub small { color: var(--faint); font-size: 13px; }
.hub a { color: var(--dim); display: inline-grid; place-items: center; width: 26px; height: 26px; margin-left: -2px; }
.hub a svg { width: 16px; height: 16px; }

#sections { max-width: 980px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 26px 18px; }
.section { min-width: 0; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 0 4px 12px; }
.section-head h3 { margin: 0; font-size: 13px; letter-spacing: .32em; text-transform: uppercase; color: var(--dim); font-weight: 400; }
.section-head .warn { color: var(--danger); font-size: 13px; }
.section.offline .card { opacity: .5; pointer-events: none; }

.card[data-power="off"] .dot { background: var(--standby); }
.card.busy .power { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.card.pending .status-text::after { content: " · invio…"; color: var(--faint); }
.summary { color: var(--dim); font-size: 14px; }

/* TV */
.tv-quick { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.pair { display: inline-flex; align-items: center; border-radius: 999px; background: var(--glass); background-image: var(--sheen);
  border: 1px solid var(--edge); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.pair button { width: 50px; height: 46px; display: grid; place-items: center; border-radius: 999px; }
.pair span { font-size: 11px; letter-spacing: .2em; color: var(--faint); font-weight: 500; padding: 0 2px; }
.card .remote.compact { grid-template-columns: minmax(0, 1fr); }
.card .remote.compact .ring { width: min(200px, 100%); }

/* Clima */
.ac-temp { display: flex; align-items: center; justify-content: center; gap: 22px; }
.ac-temp .val { font-size: 72px; font-weight: 200; line-height: 1; min-width: 2.4ch; text-align: center;
  text-shadow: 0 0 34px var(--glow, rgba(255,255,255,.25)); }
.ac-temp .val small { font-size: 30px; vertical-align: super; color: var(--dim); }
.card[data-mode="cool"] { --glow: rgba(110,190,255,.55); } .card[data-mode="heat"] { --glow: rgba(255,150,80,.55); }
.card[data-mode="dry"] { --glow: rgba(120,230,210,.5); }
.card[data-power="off"] .ac-temp .val { color: var(--dim); text-shadow: none; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; }
.mode { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: 18px; font-size: 13px;
  background: var(--glass); border: 1px solid var(--edge); }
.mode.active { background: rgba(255,255,255,.9); color: #0b0d12; }
.row-label { font-size: 11px; letter-spacing: .24em; color: var(--faint); text-transform: uppercase; margin: 0 4px -8px; }

/* Generic device (future hubs) */
.generic { display: flex; flex-wrap: wrap; gap: 8px; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; }
.login .card { gap: 14px; }
.login input { width: 100%; padding: 14px 18px; border-radius: 999px; border: 1px solid var(--edge); background: rgba(0,0,0,.28);
  color: var(--text); font: inherit; font-size: 17px; outline: none; }
.login input:focus { border-color: rgba(255,255,255,.55); }
.login .go { justify-content: center; background-color: rgba(255,255,255,.88); color: #0b0d12; font-weight: 500; }
.login .err { color: var(--danger); min-height: 1.3em; margin: 0; font-size: 14px; }
.login h1 { margin: 0; font-weight: 300; font-size: 34px; display: flex; align-items: center; gap: 12px; }
.login h1 img { width: 40px; height: 40px; border-radius: 11px; }
