:root {
  --fundo: #0a0a0a;
  --cartao: #161616;
  --borda: rgba(255, 255, 255, 0.09);
  --texto: #f2f2ee;
  --fraco: #6f6f6a;
  --lima: #d6f25c;
  --ambar: #f5b03e;
  --alerta: #f0523d;
  --raio: 28px;
  --sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--fundo); color-scheme: dark; }

body {
  margin: 0 auto;
  max-width: 1180px;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
           max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* comportamento de app: sem seleção de texto nem "puxar para recarregar" */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior-y: contain;
  padding-bottom: calc(max(28px, env(safe-area-inset-bottom)) + 84px); /* espaço da barra inferior */
}
input, textarea { -webkit-user-select: text; user-select: text; }

/* ---- vistas (Câmeras / Capturas / Ajustes) ---- */
.vista { display: none; animation: entrar 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
body[data-vista="cameras"] #vistaCameras,
body[data-vista="capturas"] #vistaCapturas,
body[data-vista="clima"] #vistaClima,
body[data-vista="casa"] #vistaCasa,
body[data-vista="ajustes"] #vistaAjustes { display: block; }
body:not([data-vista="cameras"]) #btnEditar { display: none; }
/* fora da grade o vídeo fica pausado: o contador "ao vivo" não se aplica */
body:not([data-vista="cameras"]) #topoEstado { display: none; }
@keyframes entrar { from { opacity: 0; transform: translateY(10px); } }

.cabecalho { padding: clamp(26px, 5vw, 52px) 4px clamp(18px, 3vw, 30px); }
.cabecalho h1 { margin: 0 0 12px; font-size: clamp(44px, 10vw, 84px); font-weight: 300; line-height: 0.95; letter-spacing: -0.045em; }
.cabecalho p { margin: 0; }

/* ---- barra inferior ---- */
.dock {
  position: fixed; z-index: 15; left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.72);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.dock button {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border: 0; border-radius: 999px;
  background: none; color: var(--fraco); font-size: 14px;
  transition: color 0.25s, background 0.25s, transform 0.2s;
}
.dock button:active { transform: scale(0.94); }
.dock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dock span { display: none; }
.dock button.ativo { color: var(--fundo); background: var(--lima); }
.dock button.ativo span { display: inline; font-weight: 500; }

/* ---- clima (ar-condicionados) ---- */
.cabecalho-clima { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.climas { display: grid; grid-template-columns: 1fr; gap: 16px; }
.clima {
  --tom: 214, 242, 92; /* cor do modo: lima por padrão */
  position: relative; overflow: hidden; isolation: isolate;
  padding: 22px; border-radius: var(--raio);
  background: var(--cartao); border: 1px solid var(--borda);
  transition: border-color 0.5s, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.clima.modo-COOL, .clima.modo-AIR_DRY { --tom: 120, 205, 235; }
.clima.modo-HEAT { --tom: 245, 176, 62; }
.clima::before { /* brilho do aparelho ligado, na cor do modo */
  content: ""; position: absolute; z-index: -1; width: 150%; aspect-ratio: 1; right: -60%; top: -75%;
  background: radial-gradient(circle, rgba(var(--tom), 0.26), transparent 62%);
  opacity: 0; transform: scale(0.7); transition: opacity 0.8s, transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.clima.ligado { border-color: rgba(var(--tom), 0.3); }
.clima.ligado::before { opacity: 1; transform: scale(1); animation: brisa 9s ease-in-out infinite alternate; }
@keyframes brisa { to { transform: scale(1.12) translate(-4%, 5%); } }

.clima header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.clima h2 { margin: 6px 0 6px; font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
.clima header p { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--fraco); }
.clima .num { color: var(--fraco); }
.clima.ligado header .ponto { background: rgb(var(--tom)); box-shadow: 0 0 0 0 rgba(var(--tom), 0.6); animation: pulso 2.4s infinite; }
.clima.ligado header p { color: var(--texto); }

.energia { width: 54px; height: 54px; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s; }
.clima.ligado .energia { background: rgb(var(--tom)); color: var(--fundo); border-color: transparent; box-shadow: 0 8px 30px rgba(var(--tom), 0.35); }
.energia.girando svg { animation: girar-leve 1s linear infinite; }
@keyframes girar-leve { to { transform: rotate(360deg); } }

/* ilustração do split */
.ar-figura { display: block; width: min(100%, 330px); margin: 14px auto -6px; overflow: visible; opacity: 0.5; filter: saturate(0.6); transition: opacity 0.6s, filter 0.6s, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.clima.ligado .ar-figura { opacity: 1; filter: drop-shadow(0 16px 26px rgba(var(--tom), 0.22)); }
.ar-aleta { transform-box: fill-box; transform-origin: 50% 0%; transition: transform 0.9s cubic-bezier(0.34, 1.3, 0.64, 1), fill 0.5s; }
.clima.ligado .ar-aleta { transform: translateY(9px) scaleY(0.55); fill: #b4b4ad; }
.clima.ligado.oscilando .ar-aleta { animation: aleta 3.2s ease-in-out infinite alternate; }
@keyframes aleta { from { transform: translateY(5px) scaleY(0.8); } to { transform: translateY(11px) scaleY(0.4); } }
.ar-led { fill: #8a8a84; transition: fill 0.5s; }
.clima.ligado .ar-led { fill: rgb(var(--tom)); animation: respirar 3.4s ease-in-out infinite; }
.ar-fluxo path { stroke: rgb(var(--tom)); stroke-dasharray: 5 9; opacity: 0; transition: opacity 0.6s; }
.clima.ligado .ar-fluxo path { animation: soprar 1.3s linear infinite; }
.clima.ligado .ar-fluxo path:nth-child(3) { opacity: 0.9; }
.clima.ligado.vento-MID .ar-fluxo path:nth-child(2), .clima.ligado.vento-MID .ar-fluxo path:nth-child(4),
.clima.ligado.vento-HIGH .ar-fluxo path, .clima.ligado.vento-AUTO .ar-fluxo path:nth-child(2), .clima.ligado.vento-AUTO .ar-fluxo path:nth-child(4) { opacity: 0.75; }
.clima.ligado.vento-LOW .ar-fluxo path { animation-duration: 2.2s; }
.clima.ligado.vento-HIGH .ar-fluxo path { animation-duration: 0.75s; }
@keyframes soprar { to { stroke-dashoffset: -28; } }

/* programar horário */
.agenda-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.agenda-form > span { color: var(--fraco); }
.alterna { display: flex; padding: 3px; border-radius: 999px; border: 1px solid var(--borda); background: rgba(0, 0, 0, 0.3); }
.alterna button { padding: 8px 14px; border: 0; border-radius: 999px; background: none; color: #a9a9a3; font-size: 14px; transition: background 0.25s, color 0.25s; }
.alterna button.ativa { background: var(--texto); color: var(--fundo); font-weight: 500; }
.agenda-form input[type="time"] {
  height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35); color: var(--texto); font: 500 16px var(--mono); color-scheme: dark; outline: none;
}
.agenda-form input[type="time"]:focus { border-color: rgb(var(--tom)); }
.pilula.ok { background: var(--lima); color: var(--fundo); border-color: transparent; font-weight: 500; }
.marcado { display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 999px; border: 1px solid rgba(var(--tom), 0.35); background: rgba(var(--tom), 0.08); color: #a9a9a3; }
.marcado b { color: var(--texto); font-weight: 500; }
.marcado button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: var(--texto); font-size: 16px; line-height: 1; }

.termo { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 4px; }
.alvo { display: flex; align-items: flex-start; font-weight: 300; line-height: 0.9; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; color: var(--fraco); transition: color 0.4s; }
.alvo b { font-size: clamp(84px, 24vw, 116px); font-weight: 300; }
.alvo sup { font-size: 30px; margin-top: 12px; letter-spacing: -0.02em; }
.alvo span { font-size: 40px; margin-top: 8px; color: rgb(var(--tom)); opacity: 0.5; }
.clima.ligado .alvo { color: var(--texto); }
.clima.ligado .alvo span { opacity: 1; }
.alvo.mudou b { animation: pular 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pular { 40% { transform: scale(1.08); } }
.termo .redondo { width: 56px; height: 56px; font-size: 26px; font-weight: 300; color: var(--texto); }
.termo .redondo:disabled, .energia:disabled { opacity: 0.35; }
/* desligado: cartão enxuto, só ligar ou ligar já numa cena */
.clima:not(.ligado) .so-ligado { display: none; }
.clima:not(.ligado) .cenas { margin-top: 16px; }
.mais { display: none; }
.clima.aberto .mais { display: block; animation: entrar 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.mais-botao {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin: 2px 0 0; padding: 12px; border: 0; border-top: 1px dashed var(--borda); background: none; color: var(--fraco);
}
.mais-botao i { font-style: normal; font-size: 15px; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); transform: rotate(90deg); }
.clima.aberto .mais-botao i { transform: rotate(-90deg); }
.rodape-clima { margin: 4px 0 0; padding: 10px 0 2px; border-top: 1px dashed var(--borda); color: #4a4a46; font-size: 10px; }

.regua { position: relative; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); margin: 8px 2px 10px; }
.regua i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--pos, 0%); border-radius: 4px; background: rgb(var(--tom)); opacity: 0.35; transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s; }
.regua b { position: absolute; top: 50%; left: var(--amb, 0%); width: 2px; height: 12px; margin-top: -6px; background: var(--ambar); border-radius: 2px; }
.clima.ligado .regua i { opacity: 1; }
.ambiente { display: flex; justify-content: space-between; margin: 0 2px 18px; color: var(--fraco); }
.ambiente em { font-style: normal; color: var(--ambar); }

.grupo { display: flex; flex-direction: column; gap: 9px; padding: 13px 0; border-top: 1px dashed var(--borda); }
.grupo > span { color: var(--fraco); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.pilulas { display: flex; flex-wrap: wrap; gap: 6px; }
.pilula {
  padding: 10px 16px; border-radius: 999px; font-size: 15px;
  border: 1px solid var(--borda); background: rgba(255, 255, 255, 0.03); color: #a9a9a3;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s, color 0.25s, border-color 0.25s;
}
.pilula:active { transform: scale(0.94); }
.pilula.ativa { background: rgb(var(--tom)); color: var(--fundo); border-color: transparent; font-weight: 500; }
.pilula.cena { border-style: dashed; }
.clima footer { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--borda); color: #4a4a46; font-size: 10px; }
.clima.fora { opacity: 0.55; }

/* ---- casa (TVs e outros aparelhos) ---- */
.tv { --tom: 214, 242, 92; }
.tv-figura { display: block; width: min(100%, 300px); margin: 16px auto 4px; overflow: visible; opacity: 0.55; transition: opacity 0.6s, filter 0.6s; }
.tv.ligado .tv-figura { opacity: 1; filter: drop-shadow(0 18px 30px rgba(var(--tom), 0.2)); }
.tv-tela { fill: #101010; transition: fill 0.6s; }
.tv-luz { opacity: 0; transition: opacity 0.8s; }
.tv.ligado .tv-luz { opacity: 1; animation: tela-viva 7s ease-in-out infinite alternate; }
@keyframes tela-viva { from { transform: translateX(-14px); } to { transform: translateX(14px); } }
.tv-led { fill: #55554f; transition: fill 0.5s; }
.tv.espera .tv-led { fill: var(--alerta); }
.tv.ligado .tv-led { fill: rgb(var(--tom)); }
.tv:not(.ligado) .so-ligado { display: none; }
.tv .aviso-tv { margin: 14px 0 0; padding-top: 14px; border-top: 1px dashed var(--borda); color: var(--fraco); line-height: 1.6; }
.volume { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 14px; }
.volume .redondo { width: 64px; height: 64px; font-size: 28px; font-weight: 300; color: var(--texto); }
.volume .redondo.meio { width: 54px; height: 54px; }
.volume > span { color: var(--fraco); }
.controle { display: grid; grid-template-columns: repeat(3, 60px); gap: 8px; justify-content: center; margin: 6px 0 14px; }
.controle .redondo { width: 60px; height: 60px; color: var(--texto); }
.controle .redondo.central { background: rgb(var(--tom)); color: var(--fundo); border-color: transparent; font: 500 13px var(--mono); }
.controle i { display: block; }

/* ---- capturas ---- */
.eventos-portao { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 8px; }
.evento { position: relative; padding: 0; border: 1px solid var(--borda); border-radius: 18px; overflow: hidden; background: var(--cartao); aspect-ratio: 4 / 3; text-align: left; }
.evento img { display: block; width: 100%; height: 100%; object-fit: cover; }
.evento .selo { position: absolute; left: 8px; top: 8px; padding: 4px 9px; border-radius: 999px; font-size: 10px; letter-spacing: 0.06em; background: rgba(0, 0, 0, 0.6); color: var(--texto); }
.evento.aberto .selo { background: var(--alerta); color: var(--fundo); font-weight: 500; }
.evento.fechado .selo { background: var(--lima); color: var(--fundo); font-weight: 500; }
.evento .tocar { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; }
.evento .tocar svg { width: 13px; height: 13px; fill: var(--texto); }
.evento .rodape { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); font-size: 11px; color: var(--texto); }
.evento .rodape small { color: var(--ambar); margin-left: 6px; }
.foto-aberta video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.evento-midias { position: absolute; left: 50%; bottom: max(96px, calc(env(safe-area-inset-bottom) + 90px)); transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: 92vw; }
.evento-midias .pilula { --tom: 214, 242, 92; background: rgba(10, 10, 10, 0.7); color: var(--texto); }
.evento-midias .pilula.ativa { background: var(--lima); color: var(--fundo); }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.foto { position: relative; padding: 0; border: 1px solid var(--borda); border-radius: 18px; overflow: hidden; background: var(--cartao); aspect-ratio: 4 / 3; }
.foto img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.foto span { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; text-align: left; font-size: 10px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); }
.vazio { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: var(--fraco); border: 1px dashed var(--borda); border-radius: var(--raio); line-height: 1.7; }

.foto-aberta { position: fixed; inset: 0; z-index: 20; background: #000; animation: surgir 0.25s ease-out; }
.foto-aberta[hidden] { display: none; }
.foto-aberta > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
a.redondo { color: inherit; }

/* ---- ajustes ---- */
.lista { display: flex; flex-direction: column; border: 1px solid var(--borda); border-radius: var(--raio); background: var(--cartao); overflow: hidden; max-width: 640px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border: 0; border-bottom: 1px solid var(--borda); background: none; text-align: left; width: 100%; }
.item:last-child { border-bottom: 0; }
.item span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item b { font-weight: 400; font-size: 16px; }
.item small { color: var(--fraco); font-size: 13px; overflow-wrap: anywhere; }
.item i { font-style: normal; font-size: 22px; color: var(--fraco); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.item em { font-style: normal; color: var(--lima); }
button.item:active { background: rgba(255, 255, 255, 0.04); }

.secao { margin: 30px 4px 12px; font-size: 13px; font-weight: 400; color: var(--fraco); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.item.ensinar, .item.eventos { flex-direction: column; align-items: stretch; }
.item.ensinar div { display: flex; gap: 8px; flex-wrap: wrap; }
.item.ensinar .chip { padding: 11px 16px; }
.item.eventos ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; color: #a9a9a3; line-height: 1.4; }
.item.eventos li b { color: var(--texto); font-weight: 400; margin-right: 8px; }
.chip.ligado { color: var(--fundo); background: var(--lima); border-color: var(--lima); }
#portaoPonto.aberto { color: var(--ambar); }
#portaoPonto.fechado { color: var(--lima); }

.senha-form { display: flex; flex-wrap: wrap; gap: 8px; }
.senha-form input {
  flex: 1 1 160px; min-width: 0; padding: 11px 14px;
  font: 400 16px var(--sans); color: var(--texto);
  background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 12px; outline: none;
}
.senha-form input:focus { border-color: var(--lima); }
.item[hidden] { display: none; }

/* ============================ LOGIN ============================ */
.login {
  --digitado: 0;
  position: fixed; inset: 0; z-index: 40; overflow: hidden;
  display: grid; place-items: center; padding: 24px;
  background: var(--fundo);
  transition: opacity 0.6s ease, transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.login[hidden] { display: none; }
.login.saindo { opacity: 0; transform: scale(1.08); pointer-events: none; }
body.no-login .dock, body.no-login .topo { visibility: hidden; }

/* fundo vivo: dois focos de luz derivando devagar atrás de uma grade fina */
.login-fundo { position: absolute; inset: 0; pointer-events: none; }
.login-fundo i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(80px); opacity: 0.22; will-change: transform;
}
.login-fundo i:nth-child(1) { left: -25vmax; top: -30vmax; background: radial-gradient(circle, #d6f25c, transparent 62%); animation: deriva1 19s ease-in-out infinite alternate; }
.login-fundo i:nth-child(2) { right: -30vmax; bottom: -32vmax; background: radial-gradient(circle, #3f8f7a, transparent 62%); opacity: 0.3; animation: deriva2 23s ease-in-out infinite alternate; }
.login-fundo b {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 0, transparent 68%); mask-image: radial-gradient(circle at 50% 42%, #000 0, transparent 68%);
  animation: grade 26s linear infinite;
}
@keyframes deriva1 { to { transform: translate(18vmax, 14vmax) scale(1.15); } }
@keyframes deriva2 { to { transform: translate(-16vmax, -12vmax) scale(1.2); } }
@keyframes grade { to { background-position: 44px 44px, 44px 44px; } }

.login-caixa {
  position: relative; width: min(100%, 360px);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-caixa > * { animation: subir 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.login-caixa > :nth-child(2) { animation-delay: 0.18s; }
.login-caixa > :nth-child(3) { animation-delay: 0.26s; }
.login-caixa > :nth-child(4) { animation-delay: 0.36s; }
.login-caixa > :nth-child(5) { animation-delay: 0.4s; }
.login-caixa > :nth-child(6) { animation-delay: 0.46s; }
.login-caixa > :nth-child(7) { animation-delay: 0.56s; }
@keyframes subir { from { opacity: 0; transform: translateY(18px); } }

/* logo: as barras do X "desenham" ao abrir; a lente respira e reage à digitação */
.login-logo { width: 104px; height: 104px; overflow: visible; margin-bottom: 18px; filter: drop-shadow(0 0 34px rgba(214, 242, 92, 0.22)); }
.login-logo .barras { transform-origin: 256px 256px; transition: transform 0.9s cubic-bezier(0.34, 1.4, 0.64, 1); }
.login-logo .barras path { stroke-dasharray: 295; stroke-dashoffset: 295; animation: tracar 0.9s cubic-bezier(0.6, 0, 0.2, 1) forwards; }
.login-logo .b2 { animation-delay: 0.16s; }
@keyframes tracar { to { stroke-dashoffset: 0; } }
.login-logo .anel, .login-logo .pupila { transform-box: fill-box; transform-origin: center; }
.login-logo .pupila { transform: scale(calc(1 + var(--digitado) * 0.07)); transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), fill 0.3s; animation: respirar 3.4s ease-in-out infinite; }
.login-logo .anel { animation: abrir-lente 1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s backwards; }
@keyframes respirar { 50% { opacity: 0.72; } }
@keyframes abrir-lente { from { transform: scale(0); } }
.login:focus-within .login-logo .barras { transform: rotate(90deg); }
.login.enviando .login-logo .barras { animation: girar 0.9s linear infinite; }
.login.certo .login-logo { transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); transform: scale(1.25); }
.login.certo .login-logo .pupila { transform: scale(2.4); }
.login.erro .login-logo .pupila { fill: var(--alerta); }
.login.erro .login-caixa { animation: negar 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes girar { to { transform: rotate(450deg); } }
@keyframes negar { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

.login h1 { margin: 0; font-size: 46px; font-weight: 300; letter-spacing: -0.045em; line-height: 1; }
.login-sub { display: flex; align-items: center; gap: 8px; margin: 12px 0 34px; color: var(--fraco); text-transform: uppercase; letter-spacing: 0.14em; font-size: 10px; }
.login-sub i { width: 6px; height: 6px; border-radius: 50%; background: var(--lima); box-shadow: 0 0 0 0 rgba(214,242,92,0.6); animation: pulso 2.4s infinite; }

.login-campo {
  display: flex; align-items: center; width: 100%; padding: 4px 6px 4px 22px;
  border-radius: 999px; background: rgba(22, 22, 22, 0.6);
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}
.login-campo:focus-within { border-color: rgba(214, 242, 92, 0.65); box-shadow: 0 0 0 5px rgba(214, 242, 92, 0.09), 0 18px 50px rgba(0, 0, 0, 0.45); background: rgba(26, 26, 26, 0.8); }
.login-campo input {
  flex: 1; min-width: 0; height: 52px; border: 0; outline: 0; background: none;
  color: var(--texto); font: 400 17px var(--sans); letter-spacing: 0.02em;
}
.login-campo input::placeholder { color: var(--fraco); letter-spacing: 0; }
.login-campo input[type="password"]:not(:placeholder-shown) { letter-spacing: 0.3em; }
#loginOlho { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--fraco); transition: color 0.2s, background 0.2s; }
#loginOlho svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#loginOlho.ativo { color: var(--lima); }

.login-erro { min-height: 18px; margin: 12px 0 6px; color: var(--alerta); }

.login-entrar {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 56px; border: 0; border-radius: 999px;
  background: var(--lima); color: var(--fundo); font: 500 17px var(--sans); letter-spacing: -0.01em;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s, opacity 0.2s;
  box-shadow: 0 10px 34px rgba(214, 242, 92, 0.18);
}
.login-entrar::before { /* brilho que atravessa o botão */
  content: ""; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  animation: brilho 3.6s ease-in-out 1.4s infinite;
}
@keyframes brilho { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.login-entrar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.login-entrar:active { transform: scale(0.97); }
.login-entrar:disabled { opacity: 0.6; }
.login-rodape { margin-top: 22px; color: #4a4a46; font-size: 10px; }

@media (hover: hover) {
  .login-entrar:hover { transform: translateY(-2px); box-shadow: 0 16px 44px rgba(214, 242, 92, 0.3); }
  .login-entrar:hover svg { transform: translateX(5px); }
  #loginOlho:hover { color: var(--texto); background: rgba(255, 255, 255, 0.06); }
  .login-logo:hover .barras { transform: rotate(90deg); }
}

/* ---- PC desligado ---- */
.fora {
  position: fixed; inset: 0; z-index: 14;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 30px; text-align: center; background: var(--fundo);
  animation: surgir 0.3s ease-out;
}
.fora[hidden] { display: none; }
.fora .logo { width: 84px; height: 84px; margin-bottom: 8px; }
.fora h2 { margin: 0; font-size: 26px; font-weight: 400; letter-spacing: -0.02em; }
.fora p { margin: 0; max-width: 340px; color: #a9a9a3; line-height: 1.5; }
.fora .chip { margin-top: 10px; padding: 12px 20px; }
.fora #foraEndereco { margin-top: 0; background: none; color: var(--fraco); }
.fora .diagnostico { max-width: 360px; padding: 14px 18px; border-radius: 20px; border: 1px solid var(--borda); background: var(--cartao); color: var(--texto); font-size: 15px; }
.fora .diagnostico b { display: block; margin-bottom: 4px; font-weight: 500; }
.fora .diagnostico.pc b { color: var(--alerta); }
.fora .diagnostico.celular b { color: var(--lima); }
body.sem-servidor .dock { display: none; }

button { font: inherit; color: inherit; cursor: pointer; }

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }
.fraco { color: var(--fraco); }
.fraco b { color: var(--texto); font-weight: 400; }

/* ---- topo ---- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  margin: 0 -10px; padding: 10px 10px 10px 12px;
  background: rgba(10, 10, 10, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--borda); border-radius: 999px;
}
.marca { display: flex; align-items: center; gap: 9px; color: var(--texto); text-decoration: none; }
.logo { display: block; width: 36px; height: 36px; overflow: visible; }
.logo .barras { transform-origin: 256px 256px; transition: transform 0.9s cubic-bezier(0.34, 1.4, 0.64, 1); }
.logo .pupila, .logo .anel { transform-box: fill-box; transform-origin: center; transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.marca span { font-size: 21px; font-weight: 500; letter-spacing: -0.035em; transition: letter-spacing 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.topo-estado {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  padding: 7px 12px; border-radius: 999px;
  color: var(--fraco); background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.topo-estado.ok { color: var(--texto); }
.topo-estado.ok .ponto { background: var(--lima); box-shadow: 0 0 0 0 rgba(214,242,92,0.6); animation: pulso 2.4s infinite; }
.topo-estado.parcial .ponto { background: var(--ambar); }
.topo-estado.fora .ponto { background: var(--alerta); }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--borda); border-radius: 999px;
  background: var(--cartao);
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}
.chip:active { transform: scale(0.96); }
body.editando .chip { color: var(--fundo); background: var(--lima); border-color: var(--lima); }

/* ---- painel do topo: hora em destaque + atalhos das câmeras ---- */
.painel {
  display: flex; flex-direction: column; gap: 22px;
  padding: clamp(26px, 5vw, 52px) 4px clamp(22px, 4vw, 38px);
}
.hora {
  display: flex; align-items: baseline; gap: 0.12em;
  font-size: clamp(64px, 15vw, 132px); font-weight: 300; line-height: 0.9; letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}
#horaS { font-size: 0.34em; color: var(--fraco); letter-spacing: -0.02em; }
.resumo { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; color: var(--fraco); }
.resumo #dataHoje { color: var(--texto); text-transform: capitalize; }

.atalhos { display: flex; flex-wrap: wrap; gap: 8px; }
.atalho {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 12px;
  border: 1px solid var(--borda); border-radius: 999px;
  background: var(--cartao); color: var(--texto);
  font-size: 15px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.25s, background 0.25s;
}
.atalho .num { color: var(--fraco); }
.atalho:active { transform: scale(0.96); }
.atalho.ao-vivo .ponto { background: var(--lima); }
.atalho.conectando .ponto { background: var(--ambar); }
.atalho.erro .ponto { background: var(--alerta); }

/* ---- grade ---- */
.grade { display: grid; grid-template-columns: 1fr; gap: 14px; }

.cam { display: flex; flex-direction: column; gap: 10px; min-width: 0; cursor: pointer; }
.tela {
  position: relative; overflow: hidden;
  aspect-ratio: var(--ar, 16/9);
  border-radius: var(--raio);
  background: var(--cartao);
  border: 1px solid var(--borda);
  isolation: isolate;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s;
}
.cam:active .tela { transform: scale(0.985); }
.tela video, .tela img.quadro {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #0e0e0e;
  opacity: 0; transition: opacity 0.6s;
}
.cam.ao-vivo video, .cam.ao-vivo img.quadro:not([hidden]) { opacity: 1; }

.vidro {
  background: rgba(22, 22, 22, 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
}

/* rótulo fica embaixo da imagem, sem cobrir nada */
.rotulo { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding: 0 8px 6px; }
.rotulo .num { color: var(--fraco); }
.rotulo h2 { margin: 0; font-size: 18px; font-weight: 400; letter-spacing: -0.015em; }
.rotulo p { margin: 0 0 0 auto; color: var(--fraco); display: flex; align-items: center; gap: 8px; }

.ponto { width: 6px; height: 6px; border-radius: 50%; background: var(--fraco); flex: none; }
.cam.ao-vivo .ponto { background: var(--lima); box-shadow: 0 0 0 0 rgba(214,242,92,0.6); animation: pulso 2.4s infinite; }
.cam.erro .ponto { background: var(--alerta); }
.cam.conectando .ponto { background: var(--ambar); }
@keyframes pulso { 70% { box-shadow: 0 0 0 7px rgba(214,242,92,0); } 100% { box-shadow: 0 0 0 0 rgba(214,242,92,0); } }

.cam .centro {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center; text-align: center; padding: 20px;
  color: var(--fraco); line-height: 1.7;
}
.cam.ao-vivo .centro { display: none; }

/* ---- edição ---- */
.edicao { display: none; gap: 8px; flex: 1 1 100%; min-width: 0; }
.edicao input {
  flex: 1; min-width: 0; width: 0; padding: 9px 12px;
  font: 400 16px var(--sans); color: var(--texto);
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.18); border-radius: 12px; outline: none;
}
.edicao input:focus { border-color: var(--lima); }
.edicao button {
  width: 40px; min-height: 40px; flex: none; border-radius: 12px;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.18);
}
body.editando .edicao { display: flex; }
body.editando .rotulo h2, body.editando .rotulo p { display: none; }
body.editando .rotulo .num { display: none; }
body.editando .cam { cursor: default; }
body.editando .tela { border-color: rgba(214,242,92,0.35); }

/* ---- rodapé ---- */
.rodape { display: flex; justify-content: space-between; margin-top: 26px; padding-top: 16px; border-top: 1px dashed var(--borda); }

/* ---- visor (câmera aberta) ---- */
.visor { position: fixed; inset: 0; z-index: 20; background: #000; animation: surgir 0.25s ease-out; }
.visor[hidden] { display: none; }
@keyframes surgir { from { opacity: 0; transform: scale(1.02); } }
.visor video, .visor img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#visorVideo { opacity: 0; transition: opacity 0.4s; }
.visor.hd #visorVideo { opacity: 1; }

.ptz {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
  width: 148px; height: 148px; border-radius: 50%;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.ptz[hidden] { display: none; }
.ptz button[hidden] { display: none; }
.ptz button { border: 0; background: none; display: grid; place-items: center; border-radius: 50%; color: rgba(255,255,255,0.75); transition: color 0.15s, background 0.15s; }
.ptz button.ativo { color: var(--fundo); background: var(--lima); }
.ptz svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ptz [data-dir="cima"] { grid-area: 1 / 2; }
.ptz [data-dir="esquerda"] { grid-area: 2 / 1; }
.ptz [data-dir="direita"] { grid-area: 2 / 3; }
.ptz [data-dir="baixo"] { grid-area: 3 / 2; }
.ptz i { grid-area: 2 / 2; margin: 9px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); }

.visor-topo {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.visor-rotulo { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; min-width: 0; }
.visor-rotulo strong { font-weight: 400; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visor-rotulo .fraco { color: rgba(255,255,255,0.55); white-space: nowrap; }
.visor-acoes {
  position: absolute; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 12px;
}
.visor-estado { position: absolute; inset: 0; display: grid; place-items: center; color: var(--fraco); pointer-events: none; }
.visor.ao-vivo .visor-estado { display: none; }

.redondo {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid rgba(255,255,255,0.16);
  background: rgba(22,22,22,0.6);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  transition: transform 0.15s, background 0.2s;
}
.redondo:active { transform: scale(0.92); background: rgba(60,60,60,0.7); }
.redondo svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.redondo.mudo .ondas { display: none; }
.redondo.ativo { color: var(--fundo); background: var(--lima); border-color: var(--lima); }

.aviso {
  position: fixed; z-index: 30; left: 50%; bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
  transform: translateX(-50%); padding: 11px 18px; white-space: nowrap;
  animation: surgir 0.2s ease-out;
}
.aviso[hidden] { display: none; }

/* ---- movimento ao passar o mouse (só onde existe mouse) ---- */
@media (hover: hover) {
  /* logo: o X gira um quarto de volta e a lente "foca" */
  .marca:hover .barras { transform: rotate(90deg); }
  .marca:hover .pupila { transform: scale(1.45); }
  .marca:hover .anel { transform: scale(1.06); }
  .marca:hover span { letter-spacing: 0; }

  /* câmera: a imagem aproxima de leve e surgem os cantos de enquadramento */
  .tela video, .tela img.quadro { transition: opacity 0.6s, transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .tela::after {
    content: ""; position: absolute; inset: 16px; z-index: 2; pointer-events: none;
    --c: var(--lima); --t: 2px; --l: 22px;
    background:
      linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t),
      linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l),
      linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t),
      linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l),
      linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t),
      linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l),
      linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t),
      linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l);
    background-repeat: no-repeat;
    opacity: 0; transform: scale(1.06);
    transition: opacity 0.35s, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  body:not(.editando) .cam:hover .tela { border-color: rgba(214, 242, 92, 0.4); }
  body:not(.editando) .cam:hover .tela video,
  body:not(.editando) .cam:hover .tela img.quadro { transform: scale(1.045); }
  body:not(.editando) .cam:hover .tela::after { opacity: 1; transform: scale(1); }
  .cam .rotulo h2 { transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
  body:not(.editando) .cam:hover .rotulo h2 { transform: translateX(4px); }

  .dock button:not(.ativo):hover { color: var(--texto); background: rgba(255, 255, 255, 0.07); }
  .clima:hover { transform: translateY(-3px); border-color: rgba(var(--tom), 0.4); }
  .pilula:not(.ativa):hover { color: var(--texto); border-color: rgba(var(--tom), 0.5); transform: translateY(-1px); }
  .energia:hover { transform: scale(1.08) rotate(-8deg); }
  .foto:hover img { transform: scale(1.06); }
  button.item:hover { background: rgba(255, 255, 255, 0.03); }
  button.item:hover i { transform: translateX(5px); color: var(--lima); }
  .atalho:hover { transform: translateY(-3px); border-color: rgba(214, 242, 92, 0.45); background: #1c1c1c; }
  .chip:hover { border-color: rgba(255, 255, 255, 0.3); }
}

/* ---- telas largas: grade em blocos ---- */
@media (min-width: 860px) {
  body { padding-left: 32px; padding-right: 32px; }
  .grade { grid-template-columns: 1fr 1fr; gap: 18px; }
  .climas { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
  .dock span { display: inline; }
  .dock button { padding: 11px 18px; }
  .fotos { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .topo .logo { width: 48px; height: 48px; }
  .marca { gap: 12px; }
  .marca span { font-size: 27px; }
  .topo { padding: 12px 14px 12px 16px; }
  .painel { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .atalhos { justify-content: flex-end; max-width: 52%; }
  .cam.alta { grid-row: span 2; }
  .cam.alta .tela { aspect-ratio: auto; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
#fotoApagar[hidden], #fotoVideo[hidden], #fotoImg[hidden] { display: none; }
