:root {
  --bg: #05080f;
  --bg2: #070d18;
  --cyan: #36d3ff;
  --cyan-soft: rgba(54, 211, 255, .14);
  --teal: #2af5d0;
  --line: rgba(54, 211, 255, .18);
  --glass: rgba(12, 22, 38, .55);
  --glass-strong: rgba(10, 19, 33, .82);
  --text: #dbeaff;
  --muted: #7d92ad;
  --danger: #ff5c6c;
  --up: #2af5a0;
  --down: #ff6b7a;
  --radius: 16px;
  --glow: 0 0 24px rgba(54, 211, 255, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 80% -10%, #0c1c30 0%, transparent 60%),
              radial-gradient(900px 600px at 0% 100%, #0a1626 0%, transparent 55%),
              var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grade futurista de fundo */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(rgba(54,211,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54,211,255,.05) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 80%);
}

.hidden { display: none !important; }
.sub { color: var(--muted); font-size: .8rem; }
.muted { color: var(--muted); font-size: .85rem; }
.section-title { font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

.card {
  position: relative; z-index: 1;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.03);
}

/* Botões */
button { font: inherit; cursor: pointer; border-radius: 11px; border: 1px solid var(--line); transition: .18s; }
button.compact { padding: 8px 13px; font-size: .85rem; }
.primary { background: linear-gradient(180deg, var(--cyan), #1aa6d8); color: #022; border: none; font-weight: 700; box-shadow: var(--glow); }
.primary:hover { filter: brightness(1.08); }
.secondary { background: rgba(54,211,255,.08); color: var(--text); }
.secondary:hover { background: rgba(54,211,255,.16); border-color: var(--cyan); }
.danger { background: rgba(255,92,108,.14); color: var(--danger); border-color: rgba(255,92,108,.4); font-weight: 700; }
.danger:hover { background: rgba(255,92,108,.24); }

/* Login */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(3,6,12,.85); backdrop-filter: blur(6px); }
.login-card { width: min(360px, 90vw); text-align: center; }
.login-card h1 { margin: 6px 0 2px; letter-spacing: .3em; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card input { width: 100%; padding: 12px 14px; margin-bottom: 12px; border-radius: 11px; border: 1px solid var(--line); background: #050b14; color: var(--text); }
.login-card .primary { width: 100%; padding: 12px; }
.omega-mark { font-size: 3.4rem; color: var(--cyan); text-shadow: var(--glow); animation: pulse 3s ease-in-out infinite; }
.error { color: var(--danger); font-size: .85rem; margin-top: 8px; min-height: 1em; }

/* Topbar */
.app { position: relative; z-index: 1; max-width: 1320px; margin: 0 auto; padding: 16px clamp(12px, 3vw, 28px) 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; margin-bottom: 18px; border-radius: var(--radius); background: var(--glass-strong); border: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 14px; }
.omega-logo { font-size: 2.2rem; line-height: 1; color: var(--cyan); text-shadow: var(--glow); animation: pulse 3.5s ease-in-out infinite; }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: .28em; }
.topbar-info { display: flex; align-items: center; gap: 18px; }
.clock { text-align: right; line-height: 1.1; }
.clock #clockTime { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.weather { font-size: .9rem; color: var(--text); display: flex; align-items: center; gap: 7px; white-space: nowrap; }

/* Layout principal + lateral */
.layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.col-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

/* Hero / microfone */
.hero { text-align: center; overflow: hidden; }
.hero-ring { position: absolute; top: -40%; left: 50%; width: 360px; height: 360px; transform: translateX(-50%); border-radius: 50%; border: 1px solid rgba(54,211,255,.2); box-shadow: 0 0 80px rgba(54,211,255,.12) inset; pointer-events: none; animation: spin 22s linear infinite; }
.mic { width: 96px; height: 96px; border-radius: 50%; font-size: 2.2rem; background: radial-gradient(circle at 50% 35%, #0e2438, #061320); border: 1px solid var(--cyan); color: var(--cyan); box-shadow: var(--glow); margin: 6px auto 12px; display: grid; place-items: center; }
.mic.speaking { animation: micPulse 1.1s ease-in-out infinite; }
.voice-state { font-weight: 600; }
.audio-level { height: 5px; border-radius: 4px; background: rgba(54,211,255,.12); overflow: hidden; margin: 12px auto; max-width: 320px; }
.audio-level span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--cyan)); transition: width .12s; }
.transcript { color: var(--text); margin-top: 8px; min-height: 1.2em; }
.live-narration { color: var(--muted); font-size: .85rem; margin-top: 6px; font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 14px; }
.chips span { font-size: .72rem; padding: 4px 10px; border-radius: 999px; background: var(--cyan-soft); border: 1px solid var(--line); color: var(--muted); }

/* Resposta */
.resolution-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(54,211,255,.08);
}
.resolution-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cyan);
}
.resolution-text {
  color: var(--text);
  font-size: .92rem;
}
.resolution-banner.mode-awaiting-confirmation {
  background: linear-gradient(90deg, rgba(255,170,40,.16), rgba(255,170,40,.05));
  border-color: rgba(255,170,40,.45);
}
.resolution-banner.mode-awaiting-user-screen {
  background: linear-gradient(90deg, rgba(255,120,80,.18), rgba(255,170,40,.06));
  border-color: rgba(255,170,40,.55);
}
.resolution-banner.mode-awaiting-user {
  background: linear-gradient(90deg, rgba(255,170,40,.14), rgba(54,211,255,.05));
  border-color: rgba(255,170,40,.4);
}
.resolution-banner.mode-auto-recovered {
  background: linear-gradient(90deg, rgba(42,245,160,.16), rgba(54,211,255,.06));
  border-color: rgba(42,245,160,.35);
}
.resolution-banner.mode-recoverable-failure {
  background: linear-gradient(90deg, rgba(255,92,108,.16), rgba(255,120,80,.06));
  border-color: rgba(255,92,108,.4);
}
.resolution-banner.mode-autonomous-continuation,
.resolution-banner.mode-completed {
  background: linear-gradient(90deg, rgba(54,211,255,.12), rgba(42,245,208,.05));
}
.response-card #response { font-size: 1.05rem; line-height: 1.5; }
.task-state { color: var(--muted); font-size: .82rem; margin-top: 8px; }

/* Linha de comando */
.command-row { display: flex; gap: 10px; }
.command-row input { flex: 1; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-strong); color: var(--text); }
.command-row input:focus { outline: none; border-color: var(--cyan); box-shadow: var(--glow); }

/* Painel lateral: mercado */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 10px var(--up); animation: pulse 1.6s ease-in-out infinite; }
.market-list { display: flex; flex-direction: column; gap: 2px; }
.market-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid rgba(54,211,255,.07); }
.market-row:last-child { border-bottom: none; }
.market-row .asset { font-weight: 600; text-transform: capitalize; }
.market-row .price { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.market-row .pct { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .85rem; padding: 2px 8px; border-radius: 999px; }
.pct.up { color: var(--up); background: rgba(42,245,160,.12); }
.pct.down { color: var(--down); background: rgba(255,107,122,.12); }

/* Painel lateral: notícias */
.news-panel { max-height: 46vh; overflow: hidden; }
.news-list { display: flex; flex-direction: column; gap: 0; max-height: 40vh; overflow-y: auto; }
.news-item { padding: 9px 2px; border-bottom: 1px solid rgba(54,211,255,.07); font-size: .86rem; line-height: 1.35; color: var(--text); text-decoration: none; display: block; }
.news-item:hover { color: var(--cyan); }
.news-list::-webkit-scrollbar { width: 5px; }
.news-list::-webkit-scrollbar-thumb { background: rgba(54,211,255,.25); border-radius: 3px; }

/* Tela do PC */
.screen-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.screen-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.screen-wrap { border-radius: 14px; overflow: hidden; position: relative; background: #02060c; min-height: 180px; border: 1px solid var(--line); }
.screen-wrap img { width: 100%; height: auto; display: block; cursor: zoom-in; }
.screen-status { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.72); padding: 5px 9px; border-radius: 8px; font-size: .72rem; color: var(--cyan); }
.screen-wrap:fullscreen { background: #000; display: grid; place-items: center; }
.screen-wrap:fullscreen img { max-width: 100vw; max-height: 100vh; width: auto; object-fit: contain; }

/* Diagnóstico */
.diagnostics summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.diagnostics pre { white-space: pre-wrap; word-break: break-word; font-size: .75rem; color: var(--muted); margin: 10px 0 0; }

/* ===== Modo "OMEGA precisa de você": tela do PC em FOCO/tela cheia ===== */
.needs-action-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 11px 14px; border-radius: 12px; background: linear-gradient(90deg, rgba(255,170,40,.2), rgba(255,170,40,.05)); border: 1px solid rgba(255,170,40,.55); color: #ffd9a0; font-weight: 600; }
.needs-action-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.screen-section.needs-action { outline: 2px solid rgba(255,170,40,.7); animation: needsPulse 1.8s ease-in-out infinite; }
@keyframes needsPulse { 0%,100% { box-shadow: 0 0 0 4px rgba(255,170,40,.10); } 50% { box-shadow: 0 0 0 8px rgba(255,170,40,.22); } }
/* Foco TOTAL: a tela do PC vira overlay de tela cheia mostrando o que acontece */
body.action-focus .screen-section {
  position: fixed; inset: 0; z-index: 60; margin: 0; border-radius: 0;
  display: flex; flex-direction: column; background: rgba(3,6,12,.96); padding: 14px clamp(12px,4vw,40px);
}
body.action-focus .screen-section .screen-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
body.action-focus .screen-section .screen-wrap img { max-height: calc(100vh - 140px); width: auto; max-width: 100%; }
body.action-focus .screen-section .needs-action-banner { font-size: 1.05rem; }
/* Variante AO VIVO (OMEGA agindo no PC): azul calmo, sem tom de alerta */
.screen-section.live-focus .needs-action-banner { background: linear-gradient(90deg, rgba(54,211,255,.18), rgba(54,211,255,.04)); border-color: rgba(54,211,255,.5); color: #a9e7ff; }
/* Zoom por pinça: o navegador não pode roubar o gesto em cima da imagem */
#screenWrap { overflow: hidden; }
#screenImage { touch-action: none; transform-origin: center center; will-change: transform; }
/* Celular: overlay ocupa a tela toda de verdade (dvh conta a barra do navegador) */
@media (max-width: 900px) {
  body.action-focus .screen-section { height: 100dvh; padding: 10px 8px; }
  body.action-focus .screen-section .screen-wrap img { max-height: calc(100dvh - 120px); width: 100%; object-fit: contain; }
  body.action-focus .screen-section .needs-action-banner { font-size: .92rem; padding: 8px 10px; }
}

/* Animações */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }
@keyframes micPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(54,211,255,.5); } 50% { box-shadow: 0 0 0 16px rgba(54,211,255,0); } }

/* Responsivo: lateral desce pra baixo no celular */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .col-side { position: static; flex-direction: column; }
  .news-panel, .news-list { max-height: none; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .topbar-info { gap: 12px; }
  .clock #clockTime { font-size: 1.2rem; }
  .screen-actions { justify-content: flex-start; }
  .brand-name { font-size: 1.05rem; }
}

/* FEEDBACK VISUAL: pesquisa (imagens + links) em tela cheia — o app nativo é a tela do OMEGA */
.visual-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(6, 10, 18, 0.97);
  backdrop-filter: blur(6px);
  display: none; flex-direction: column;
  padding: 18px 22px; overflow-y: auto;
}
.visual-overlay.show { display: flex; animation: voFade .2s ease; }
@keyframes voFade { from { opacity: 0; } to { opacity: 1; } }
.visual-overlay .vo-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; position: sticky; top: 0;
}
.visual-overlay .vo-q { font-size: 22px; font-weight: 700; color: #eaf6ff; }
.visual-overlay .vo-close {
  background: rgba(80,200,255,.15); color: #8fdfff; border: 1px solid rgba(80,200,255,.4);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font-size: 14px;
}
.visual-overlay .vo-close:hover { background: rgba(80,200,255,.3); }
.visual-overlay .vo-imgs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 22px;
}
.visual-overlay .vo-img { display: block; border-radius: 10px; overflow: hidden; aspect-ratio: 1/1; background: #0d1726; }
.visual-overlay .vo-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.visual-overlay .vo-img:hover img { transform: scale(1.05); }
.visual-overlay .vo-links { display: flex; flex-direction: column; gap: 10px; }
.visual-overlay .vo-card {
  display: block; text-decoration: none; padding: 12px 14px; border-radius: 12px;
  background: rgba(20,32,52,.7); border: 1px solid rgba(80,200,255,.15);
}
.visual-overlay .vo-card:hover { border-color: rgba(80,200,255,.5); background: rgba(28,44,70,.8); }
.visual-overlay .vo-title { color: #9fd9ff; font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.visual-overlay .vo-url { color: #6a8aa8; font-size: 12px; margin-bottom: 5px; word-break: break-all; }
.visual-overlay .vo-snippet { color: #c4d4e4; font-size: 13px; line-height: 1.4; }

/* ===== LAYOUT CLEAN (04/07): orb central + menu lateral + opções com timer ===== */
.clean-topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.menu-button { background: var(--glass); border: 1px solid var(--line); color: var(--text); font-size: 1.25rem; border-radius: 12px; padding: 8px 14px; cursor: pointer; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.weather.discrete { font-size: .78rem; color: var(--muted); }
.clock.discrete { display: flex; flex-direction: column; align-items: flex-end; font-size: .9rem; }
.clock.discrete .sub { font-size: .62rem; }

/* Orb central */
.orb-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100dvh - 120px); gap: 14px; padding: 0 16px; }
.omega-orb { position: relative; width: clamp(160px, 42vw, 240px); height: clamp(160px, 42vw, 240px); border-radius: 50%; border: 2px solid var(--line); background: radial-gradient(circle at 34% 30%, rgba(54,211,255,.22), rgba(10,19,33,.9)); color: var(--cyan); cursor: pointer; display: grid; place-items: center; box-shadow: var(--glow); transition: box-shadow .3s, border-color .3s; }
.orb-symbol { font-size: clamp(4rem, 16vw, 6.5rem); font-weight: 700; text-shadow: 0 0 24px rgba(54,211,255,.6); }
.orb-ring { position: absolute; inset: -10px; border-radius: 50%; border: 1px solid rgba(54,211,255,.25); pointer-events: none; }
.omega-orb.listening { border-color: var(--teal); box-shadow: 0 0 34px rgba(42,245,208,.5); animation: orbPulse 1.6s ease-in-out infinite; }
.omega-orb.working { border-color: var(--cyan); animation: orbPulse 1s ease-in-out infinite; }
.omega-orb.speaking { border-color: #ffd479; box-shadow: 0 0 30px rgba(255,212,121,.45); }
@keyframes orbPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.orb-state { font-size: .95rem; }
.orb-level { width: min(240px, 60vw); }
.orb-transcript, .orb-narration { max-width: min(520px, 88vw); text-align: center; min-height: 1.1em; }
.orb-response { max-width: min(560px, 90vw); text-align: center; color: var(--text); font-size: .95rem; white-space: pre-wrap; max-height: 30dvh; overflow-y: auto; }

/* Menu lateral */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(380px, 92vw); background: var(--glass-strong); backdrop-filter: blur(14px); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .28s ease; z-index: 80; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
body.drawer-open .drawer { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; }
.drawer-header { display: flex; align-items: center; gap: 10px; }
.drawer-mic { width: 100%; height: auto; border-radius: 12px; padding: 12px; font-size: 1rem; display: flex; align-items: center; justify-content: center; gap: 8px; }
.drawer-section summary { cursor: pointer; font-weight: 600; }
.drawer-select { flex: 1; background: var(--glass); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px; }
.drawer input[type=password], .drawer input[type=text] { background: var(--glass); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px; }

/* Tela do PC: invisível no dia a dia; só aparece no modo ação (fullscreen) ou manual */
.screen-section { display: none; }
body.action-focus .screen-section { display: flex; }
.screen-section.user-visible { display: block; position: fixed; inset: auto 10px 10px 10px; z-index: 60; max-height: 45dvh; overflow: hidden; }

/* Opções com tempo limite */
.options-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(3,6,12,.75); backdrop-filter: blur(6px); padding: 18px; }
.options-card { width: min(480px, 94vw); background: var(--glass-strong); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--glow); }
.options-title { font-weight: 700; margin-bottom: 12px; text-align: center; }
.options-list { display: flex; flex-direction: column; gap: 10px; }
.options-list button { text-align: left; background: var(--cyan-soft); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 13px 14px; font-size: .95rem; cursor: pointer; }
.options-list button:active { background: rgba(54,211,255,.3); }
.options-timer { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); margin-top: 14px; overflow: hidden; }
.options-timer span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--cyan)); transition: width .2s linear; }

/* Controle remoto pela imagem da tela (06/07) */
.remote-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.remote-bar input { flex: 1; min-width: 140px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: inherit; }
.remote-bar .active { outline: 2px solid rgba(80,200,255,.8); }

/* ===== TELA CHEIA própria (07/07): overlay que funciona no APK (o WebView não
   tem requestFullscreen — o botão falhava mudo) e mantém a barra de controle
   visível. A rotação horizontal vem da ponte nativa (app) ou do
   orientation.lock (navegador). */
body.screen-full .screen-section {
  display: flex; position: fixed; inset: 0; z-index: 80; margin: 0; max-height: none;
  border-radius: 0; flex-direction: column; background: #000; padding: 6px; overflow: hidden;
}
body.screen-full .screen-section .screen-wrap {
  flex: 1; min-height: 0; display: grid; place-items: center;
  background: #000; border: 0; border-radius: 0;
}
body.screen-full .screen-section .screen-wrap img {
  width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain;
}
body.screen-full .needs-action-banner { display: none; }
.screen-exit { display: none; }
body.screen-full .screen-exit {
  display: block; position: fixed; top: 10px; right: 10px; z-index: 85;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(0,0,0,.55); color: #fff; font-size: 1.05rem; cursor: pointer;
}
/* feedback do toque no controle remoto: anel onde o clique foi enviado */
.tap-dot {
  position: fixed; z-index: 99; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; border: 2px solid rgba(80,200,255,.9); background: rgba(80,200,255,.25);
  pointer-events: none; animation: tapDot .45s ease-out forwards;
}
@keyframes tapDot { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
