@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Variable-latin.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Variable-latin-ext.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font: "Inter", -apple-system, system-ui, sans-serif;
  --bg: #050403;
  --text: rgba(255, 255, 255, 0.94);
  --text-2: rgba(255, 255, 255, 0.62);
  --text-3: rgba(255, 255, 255, 0.40);
  --amber: #ff9a1f;
  --gold: #ffc75a;
  /* tema (temas.js; o PC escolhe, o app acompanha): dourado é o original */
  --acento: 255 154 31; --claro: 255 199 90; --brilho: 255 140 50; --acento-2: 255 170 70;
  --acento-3: 255 178 77; --fundo-mic: 255 120 20; --brilho-mic: 255 140 30; --claro-2: #ffd9a8;
  --primario-a: #ffb24d; --primario-b: #ff8a14; --primario-texto: #1b0f02;
  /* alerta: confirmações e avisos importantes, numa cor que contrasta com o tema */
  --alerta: 255 92 92; --perigo-a: #ff7a45; --perigo-b: #e8501f; --perigo-texto: #fff;
  --cor-pensando: #fbbf24; --cor-falando: #ff9a3c;
  --glass: rgba(255, 255, 255, 0.065);
  --edge: rgba(255, 255, 255, 0.09);
  --state: #9aa0a6;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  /* áreas seguras: entalhe/Dynamic Island em cima, barra de gestos embaixo */
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); overscroll-behavior: none; }
body {
  font-family: var(--font); color: var(--text); -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01"; -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%; touch-action: manipulation;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  padding: var(--st) var(--sr) 0 var(--sl);
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }

:root[data-tema="azul"] {
  --bg: #020306;
  --amber: #2cc7f5;
  --gold: #a6f0ff;
  --acento: 44 199 245; --claro: 166 240 255; --brilho: 40 175 255; --acento-2: 70 200 250;
  --acento-3: 120 220 255; --fundo-mic: 20 120 255; --brilho-mic: 30 160 255; --claro-2: #d2f7ff;
  --primario-a: #7fe3ff; --primario-b: #1fa8f0; --primario-texto: #021018;
  --alerta: 255 167 38; --perigo-a: #ffbf4d; --perigo-b: #f08a00; --perigo-texto: #1b0f02;
  --cor-pensando: #3b9dff; --cor-falando: #5ee0ff;
}

/* fundo: o mesmo vidro escuro com brilho âmbar do painel do PC */
#bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 38% at 50% 36%, rgb(var(--brilho) / 0.10), transparent 70%),
    radial-gradient(120% 70% at 0% 0%, rgba(120, 130, 160, 0.10), transparent 60%),
    linear-gradient(170deg, #17161b 0%, #0b0a0d 55%, var(--bg) 100%);
}

/* ---------- topo ---------- */
#top { display: flex; align-items: center; gap: 10px; padding: 10px 18px 6px; min-height: 52px; }
.brand { font-weight: 650; letter-spacing: 0.02em; font-size: 17px; flex: 1; }
#pill {
  height: 30px; padding: 0 12px 0 10px; display: flex; align-items: center; gap: 8px;
  border-radius: 999px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge);
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--state); transition: background 0.4s ease; flex: none; }
.dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--state); opacity: 0; }
body.s-ouvindo .dot::after, body.s-pensando .dot::after, body.s-falando .dot::after { animation: pulse var(--pulse, 1.6s) var(--ease) infinite; }
body.s-ouvindo  { --state: #4ade80; --pulse: 1.4s; }
body.s-pensando { --state: var(--cor-pensando); --pulse: 0.9s; }
body.s-falando  { --state: var(--cor-falando); --pulse: 1.2s; }
body.s-dormindo { --state: #9aa0a6; }
body.s-desconectado { --state: #ef4444; }
@keyframes pulse { 0% { opacity: 0.55; transform: scale(0.6); } 100% { opacity: 0; transform: scale(1.9); } }
#gear { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; margin-right: -8px; }
#gear svg { width: 21px; height: 21px; fill: none; stroke: var(--text-2); stroke-width: 1.6; stroke-linejoin: round; }

/* ---------- PC offline ---------- */
#offline {
  margin: 4px 16px 0; padding: 10px 14px; border-radius: 14px; display: flex; align-items: center; gap: 10px;
  background: rgba(239, 68, 68, 0.14); box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35);
  color: #fecaca; font-size: 14px; font-weight: 550; --state: #ef4444;
}

/* ---------- esfera e conversa ---------- */
#main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; position: relative; }
#orb { width: min(86vw, 40dvh, 380px); aspect-ratio: 1; flex: none; margin-top: 2px; pointer-events: none; }
#hud { width: 100%; height: 100%; display: block; mix-blend-mode: screen; border-radius: 50%; }
body.typing #orb, body.confirming #orb { width: min(46vw, 22dvh); }
#orb { transition: width 0.45s var(--ease); }

#agent {
  margin: 2px 0 6px; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; color: var(--gold);
  background: rgb(var(--acento) / 0.10); box-shadow: inset 0 0 0 1px rgb(var(--acento) / 0.25);
  display: flex; align-items: center; gap: 8px; max-width: 88vw;
}
#agent-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spin { width: 11px; height: 11px; border-radius: 50%; border: 1.6px solid rgb(var(--claro) / 0.3); border-top-color: var(--gold); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

#log {
  flex: 1; min-height: 0; width: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px 16px 10px; display: flex; flex-direction: column; gap: 8px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 calc(100% - 8px), transparent 100%);
  -webkit-user-select: text; user-select: text;
}
#log::-webkit-scrollbar { display: none; }
#log::before { content: ""; flex: 1; }          /* mensagens encostadas embaixo */
.msg { max-width: 84%; padding: 9px 13px; border-radius: 18px; font-size: 15.5px; line-height: 1.38; text-wrap: pretty; animation: rise 0.4s var(--ease); }
.msg.usuario { align-self: flex-end; background: rgb(var(--acento) / 0.16); box-shadow: inset 0 0 0 1px rgb(var(--acento) / 0.22); border-bottom-right-radius: 6px; }
.msg.jarvis { align-self: flex-start; background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge); border-bottom-left-radius: 6px; }
.msg.aviso { box-shadow: inset 0 0 0 1px rgb(var(--claro) / 0.35); }
.msg.erro { color: #fecaca; box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35); }
.msg .tag { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 2px; letter-spacing: 0.02em; }
.msg.pending { color: var(--text-3); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- confirmação ---------- */
#confirm {
  margin: 0 14px 8px; padding: 14px 16px 14px; border-radius: 20px;
  background: linear-gradient(165deg, rgb(var(--alerta) / 0.16), rgba(18, 16, 16, 0.97) 70%), #121012;
  box-shadow: inset 0 0 0 1.5px rgb(var(--alerta) / 0.70), 0 0 30px rgb(var(--alerta) / 0.18), 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: rise 0.35s var(--ease);
}
#confirm .label { font-size: 11.5px; color: rgb(var(--alerta)); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
#confirm p { font-size: 16px; line-height: 1.4; margin-bottom: 12px; }
#confirm .row { display: flex; gap: 10px; }
#confirm .btn { flex: 1; height: 50px; font-size: 17px; }

/* ---------- botões ---------- */
.btn {
  height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 600; font-size: 15.5px;
  background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge); color: var(--text);
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(180deg, var(--primario-a), var(--primario-b)); color: var(--primario-texto); box-shadow: none; }
.btn.danger { background: linear-gradient(180deg, var(--perigo-a), var(--perigo-b)); color: var(--perigo-texto); box-shadow: none; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; }

/* ---------- barra de baixo: falar e digitar ---------- */
#dock { padding: 6px 16px calc(10px + var(--sb)); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#mic {
  position: relative; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, rgb(var(--acento-3) / 0.30), rgb(var(--fundo-mic) / 0.12) 60%, rgb(var(--fundo-mic) / 0.06));
  box-shadow: inset 0 0 0 1.5px rgb(var(--acento-2) / 0.55), 0 0 30px rgb(var(--brilho-mic) / 0.18);
  transition: transform 0.2s var(--ease), box-shadow 0.3s ease, background 0.3s ease;
}
#mic:active { transform: scale(0.95); }
#mic svg { width: 32px; height: 32px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; grid-area: 1 / 1; transition: opacity 0.2s ease, transform 0.3s var(--ease); }
#mic .i-send { opacity: 0; transform: scale(0.6); }
#mic .ring { position: absolute; inset: -6px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.0); pointer-events: none; transition: box-shadow 0.08s linear; }
body.s-ouvindo #mic { background: radial-gradient(circle at 50% 35%, rgba(74, 222, 128, 0.32), rgba(34, 197, 94, 0.12) 60%, rgba(34, 197, 94, 0.05)); box-shadow: inset 0 0 0 1.5px rgba(74, 222, 128, 0.7), 0 0 34px rgba(74, 222, 128, 0.25); }
body.s-ouvindo #mic svg { stroke: #bbf7d0; }
body.s-ouvindo #mic .i-mic { opacity: 0; transform: scale(0.6); }
body.s-ouvindo #mic .i-send { opacity: 1; transform: none; }
body.s-pensando #mic, body.s-desconectado #mic { opacity: 0.55; }
body.s-falando #mic svg { stroke: var(--claro-2); }
#hint { font-size: 12.5px; color: var(--text-3); min-height: 16px; }
#type { width: 100%; display: flex; gap: 8px; align-items: center; }
#text {
  flex: 1; height: 44px; padding: 0 16px; border-radius: 22px; border: 0; outline: none; font-size: 16px;
  background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge);
}
#text::placeholder { color: var(--text-3); }
#text:focus { box-shadow: inset 0 0 0 1px rgb(var(--acento-2) / 0.55); }
#send { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge); }
#send svg { width: 20px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.typing #mic, body.typing #hint { display: none; }

/* ---------- folhas: pareamento e ajustes ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: calc(var(--st) + 12px) calc(var(--sr) + 12px) calc(var(--sb) + 12px) calc(var(--sl) + 12px);
  overflow-y: auto;
}
#pair { align-items: center; background: rgba(5, 4, 3, 0.86); }
.card {
  width: 100%; max-width: 460px; padding: 22px 20px 18px; border-radius: 26px; display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(165deg, rgba(34, 34, 42, 0.97), rgba(13, 13, 17, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: rise 0.4s var(--ease);
}
.card h1 { font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.card h2 { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 8px; }
.card .sub { font-size: 14px; line-height: 1.45; color: var(--text-2); -webkit-user-select: text; user-select: text; }
.card .warn { font-size: 14px; line-height: 1.45; color: var(--gold); background: rgb(var(--acento) / 0.1); padding: 10px 12px; border-radius: 12px; }
.card .err { font-size: 14px; color: #fca5a5; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.card input, .card textarea {
  height: 46px; padding: 0 14px; border-radius: 13px; border: 0; outline: none; font-size: 16px;
  background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px var(--edge);
}
.card textarea { height: auto; padding: 10px 12px; font-size: 13px; font-family: ui-monospace, Menlo, monospace; resize: none; word-break: break-all; }
#pair-code { font-size: 26px; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.card input:focus { box-shadow: inset 0 0 0 1px rgb(var(--acento-2) / 0.6); }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-2); }
.kv span:last-child { color: var(--text); text-align: right; word-break: break-all; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: var(--gold); word-break: break-all; }
.ver { font-size: 11.5px; color: var(--text-3); text-align: center; }
#shortcut-box { display: flex; flex-direction: column; gap: 8px; }

/* tela de bloqueio do Face ID (por cima de tudo; a esfera continua viva atrás) */
#lock { align-items: center; background: rgba(2, 2, 4, 0.72); z-index: 20; }
#lock .card { align-items: center; text-align: center; }
#lock .face { width: 64px; height: 64px; margin: 4px 0 2px; }
#lock .face svg { width: 100%; height: 100%; fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#lock .btn { width: 100%; }
.card select {
  height: 46px; padding: 0 12px; border-radius: 13px; border: 0; outline: none; font: inherit; font-size: 16px; color: var(--text);
  background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px var(--edge); -webkit-appearance: none; appearance: none;
}
.card .row2 { display: flex; gap: 10px; align-items: center; }
.card .row2 > * { flex: 1; }
