/* =========================================================
   HIDDEN PATTERN — UNIVERSO 3D: HUD de "cockpit"
   ========================================================= */
.hpu {
  position: fixed;
  inset: 0;
  z-index: 12000;
  overflow: hidden;
  background: #010205;
  color: var(--sb-text, #f2f5fa);
  font-family: var(--sb-font-family, Inter, system-ui, sans-serif);
  opacity: 0;
  transform: scale(1.03);
  transition: opacity .38s ease, transform .5s cubic-bezier(.2, .8, .2, 1);
  outline: none;
  user-select: none;
}
.hpu.is-open { opacity: 1; transform: none; }
.hpu.is-dissolving { opacity: 0; transform: scale(1.08); filter: blur(6px); transition: opacity .26s ease, transform .3s ease, filter .3s ease; }
.hpu[hidden] { display: none; }
.hpu-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.hpu-canvas:active { cursor: grabbing; }

/* ---------- Etiquetas ---------- */
.hpu-labels { position: absolute; inset: 0; pointer-events: none; }
.hpu-label {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 10px 5px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: #fff;
  font-family: inherit; text-align: center; white-space: nowrap;
  pointer-events: auto; cursor: pointer;
  transition: opacity .25s, background .2s, border-color .2s;
  will-change: transform, opacity;
}
.hpu-label strong { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-shadow: 0 0 10px rgba(0, 0, 0, .9), 0 0 2px #000; }
.hpu-label small { font-size: 10.5px; color: rgba(214, 222, 240, .62); text-shadow: 0 0 6px #000; }
.hpu-label.hpu-galaxy strong { font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.hpu-label.hpu-center strong { font-size: 18px; font-weight: 700; }
.hpu-label.hpu-note strong { font-size: 12px; font-weight: 500; }
.hpu-label.hpu-note small { display: none; }
.hpu-label.is-hover, .hpu-label.is-selected, .hpu-label:focus-visible {
  background: rgba(8, 12, 24, .55);
  border-color: color-mix(in srgb, var(--c, #8f72ff) 70%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--c, #8f72ff) 35%, transparent);
  outline: none;
}
.hpu-label.hpu-note.is-hover small, .hpu-label.hpu-note.is-selected small { display: block; }
.hpu-label.is-hidden { opacity: 0 !important; pointer-events: none; }

/* ---------- Mira / bloqueio de alvo ---------- */
.hpu-reticle { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; opacity: .35; }
.hpu-reticle::before, .hpu-reticle::after { content: ""; position: absolute; background: rgba(200, 210, 255, .8); }
.hpu-reticle::before { left: 50%; top: 0; width: 1px; height: 100%; }
.hpu-reticle::after { top: 50%; left: 0; height: 1px; width: 100%; }
.hpu-reticle span { position: absolute; inset: 7px; border-radius: 50%; border: 1px solid rgba(200, 210, 255, .6); background: #010205; }
.hpu.is-traveling .hpu-reticle { opacity: 0; }

.hpu-lock { position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .2s; }
.hpu-lock.is-on { opacity: 1; }
.hpu-lock i { position: absolute; width: 14px; height: 14px; border: 1.5px solid rgba(190, 175, 255, .85); }
.hpu-lock.is-selected i { border-color: #b8a6ff; filter: drop-shadow(0 0 4px #7c5cff); }
.hpu-lock i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.hpu-lock i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.hpu-lock i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.hpu-lock i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.hpu-lock b { position: absolute; left: 100%; top: -2px; margin-left: 8px; font: 600 10px ui-monospace, Consolas, monospace; letter-spacing: .1em; color: rgba(190, 175, 255, .9); white-space: nowrap; }

/* ---------- Topo ---------- */
.hpu-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: grid; grid-template-columns: 1fr minmax(260px, 460px) 1fr; align-items: center; gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(1, 2, 8, .78), rgba(1, 2, 8, 0));
  pointer-events: none;
}
.hpu-top > * { pointer-events: auto; }
.hpu-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; font-size: 13px; }
.hpu-crumbs button { border: 0; background: rgba(255, 255, 255, .05); color: rgba(220, 226, 255, .75); padding: 6px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
.hpu-crumbs button:hover { background: rgba(124, 92, 255, .2); color: #fff; }
.hpu-crumbs button[aria-current] { color: #fff; background: rgba(124, 92, 255, .25); box-shadow: inset 0 0 0 1px rgba(143, 114, 255, .45); cursor: default; }
.hpu-crumbs span { color: rgba(255, 255, 255, .3); }

.hpu-search { position: relative; }
.hpu-search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: rgba(210, 220, 255, .6); stroke-width: 2; }
.hpu-search input {
  width: 100%; height: 38px; padding: 0 14px 0 36px;
  border-radius: 999px; border: 1px solid rgba(160, 170, 220, .2);
  background: rgba(8, 12, 26, .62); color: #fff; font: 13.5px inherit; font-family: inherit;
  backdrop-filter: blur(10px); outline: none;
}
.hpu-search input:focus { border-color: rgba(143, 114, 255, .7); box-shadow: 0 0 0 3px rgba(124, 92, 255, .2); }
.hpu-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto;
  border-radius: 14px; background: rgba(8, 12, 26, .95); border: 1px solid rgba(160, 170, 220, .18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.hpu-results li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.hpu-results li div { display: flex; flex-direction: column; min-width: 0; }
.hpu-results li small { color: rgba(200, 210, 240, .55); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hpu-results li[aria-selected="true"], .hpu-results li:hover { background: rgba(124, 92, 255, .22); }

.hpu-actions { justify-self: end; display: flex; gap: 8px; }
.hpu-btn {
  height: 38px; min-width: 38px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 10px; border: 1px solid rgba(160, 170, 220, .2);
  background: rgba(8, 12, 26, .6); color: #e8ebff; font: 600 13px inherit; font-family: inherit;
  cursor: pointer; backdrop-filter: blur(10px);
}
.hpu-btn em { font-style: normal; }
.hpu-btn:hover { border-color: rgba(143, 114, 255, .6); background: rgba(124, 92, 255, .2); }
.hpu-primary { background: linear-gradient(135deg, #7c5cff, #5b6cff) !important; border-color: transparent !important; color: #fff !important; box-shadow: 0 6px 24px rgba(124, 92, 255, .35); }
.hpu-close:hover { background: rgba(251, 113, 133, .2); border-color: rgba(251, 113, 133, .6); }

/* ---------- Cartão de alvo ---------- */
.hpu-card {
  position: absolute; right: 18px; top: 76px;
  width: min(330px, calc(100vw - 36px));
  max-height: calc(100vh - 160px); overflow: auto;
  padding: 16px 16px 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(14, 18, 38, .88), rgba(6, 8, 18, .9));
  border: 1px solid color-mix(in srgb, var(--c, #8f72ff) 40%, rgba(160, 170, 220, .15));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(16px);
  animation: hpuIn .25s cubic-bezier(.2, .8, .2, 1);
  user-select: text;
}
.hpu-card header { position: relative; padding-right: 30px; }
.hpu-card header small { font: 600 10px ui-monospace, Consolas, monospace; letter-spacing: .16em; color: color-mix(in srgb, var(--c, #8f72ff) 70%, #fff); }
.hpu-card h3 { margin: 4px 0 10px; font-size: 20px; line-height: 1.2; word-break: break-word; }
.hpu-card-close { position: absolute; right: -4px; top: -4px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: rgba(255, 255, 255, .6); cursor: pointer; }
.hpu-card-close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.hpu-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 12px; }
.hpu-card dl div { padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); text-align: center; }
.hpu-card dt { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: rgba(200, 210, 240, .55); }
.hpu-card dd { margin: 2px 0 0; font: 700 18px ui-monospace, Consolas, monospace; }
.hpu-card h4 { margin: 4px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(200, 210, 240, .6); }
.hpu-card ul { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 2px; }
.hpu-card ul button { width: 100%; text-align: left; border: 0; background: transparent; color: #dfe4ff; padding: 6px 8px; border-radius: 8px; cursor: pointer; font: 13px inherit; font-family: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hpu-card ul button:hover { background: rgba(124, 92, 255, .18); }
.hpu-preview { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: rgba(225, 230, 250, .85); white-space: pre-line; }
.hpu-card footer { display: flex; flex-wrap: wrap; gap: 6px; }
.hpu-card footer button, .hpu-menu button, .hpu-empty button, .hpu-fallback button {
  height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid rgba(160, 170, 220, .2);
  background: rgba(255, 255, 255, .05); color: #eef0ff; font: 600 12.5px inherit; font-family: inherit; cursor: pointer;
}
.hpu-card footer button:hover, .hpu-menu button:hover { background: rgba(124, 92, 255, .2); }
.hpu-danger { color: #fda4af !important; }
.hpu-danger:hover { background: rgba(251, 113, 133, .16) !important; border-color: rgba(251, 113, 133, .5) !important; }
.hpu-muted { color: rgba(200, 210, 240, .55); font-size: 12.5px; }

/* ---------- Menus / prompts / definições ---------- */
.hpu-menu, .hpu-settings {
  position: absolute; z-index: 5;
  min-width: 220px; padding: 8px;
  border-radius: 14px; background: rgba(9, 12, 26, .97); border: 1px solid rgba(160, 170, 220, .2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6); backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 2px;
  animation: hpuIn .16s ease-out;
}
.hpu-menu header { padding: 4px 8px 8px; font-size: 12px; color: rgba(200, 210, 240, .7); border-bottom: 1px solid rgba(255, 255, 255, .06); margin-bottom: 4px; }
.hpu-menu > button { text-align: left; border: 0; background: transparent; }
.hpu-menu > button:focus-visible { outline: 2px solid #7c5cff; }
.hpu-colors > div { display: grid; grid-template-columns: repeat(5, 30px); gap: 8px; padding: 6px; }
.hpu-colors > div button { width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--sw); border: 2px solid rgba(255, 255, 255, .25); }
.hpu-prompt { width: min(380px, calc(100vw - 32px)); padding: 14px; gap: 10px; }
.hpu-prompt input { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(160, 170, 220, .3); background: #050813; color: #fff; font: 15px inherit; font-family: inherit; outline: none; }
.hpu-prompt input:focus { border-color: #7c5cff; box-shadow: 0 0 0 3px rgba(124, 92, 255, .25); }
.hpu-prompt > div { display: flex; justify-content: flex-end; gap: 8px; }
.hpu-err { margin: 0; font-size: 12px; color: #fb7185; }
.hpu-err:empty { display: none; }
.hpu-settings { right: 18px; top: 64px; width: 300px; padding: 14px; gap: 10px; }
.hpu-settings h3 { margin: 0; font-size: 14px; }
.hpu-settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: rgba(200, 210, 240, .75); }
.hpu-settings select { height: 34px; border-radius: 8px; background: #050813; color: #fff; border: 1px solid rgba(160, 170, 220, .25); padding: 0 8px; font-family: inherit; }
.hpu-settings .hpu-check { flex-direction: row; align-items: center; gap: 8px; }
.hpu-settings[hidden] { display: none; }

/* ---------- Rodapé / velocidade / estatísticas ---------- */
.hpu-help {
  position: absolute; left: 18px; bottom: 14px; right: 260px;
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  font-size: 11.5px; color: rgba(200, 210, 240, .55); pointer-events: none;
}
.hpu-help kbd { font: 600 10.5px ui-monospace, Consolas, monospace; padding: 2px 6px; margin-right: 4px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .05); color: rgba(230, 235, 255, .8); }
.hpu-speed { position: absolute; right: 18px; bottom: 14px; display: flex; align-items: center; gap: 10px; font: 600 11px ui-monospace, Consolas, monospace; color: rgba(190, 175, 255, .85); letter-spacing: .08em; pointer-events: none; }
.hpu-speed-bar { width: 120px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.hpu-speed-bar i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #4d9cff, #b8a6ff, #ff4d8d); }
.hpu-hud-stats { position: absolute; right: 18px; bottom: 40px; font: 11px ui-monospace, Consolas, monospace; color: #7dffb0; background: rgba(0, 0, 0, .45); padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.hpu-hud-stats[hidden] { display: none; }

/* ---------- Título de chegada ---------- */
.hpu-title-card { position: absolute; left: 50%; top: 9%; transform: translate(-50%, 10px); text-align: center; pointer-events: none; opacity: 0; }
.hpu-title-card small { display: block; font: 600 11px ui-monospace, Consolas, monospace; letter-spacing: .5em; color: rgba(190, 175, 255, .8); margin-bottom: 6px; }
.hpu-title-card strong { font-size: clamp(22px, 3vw, 36px); font-weight: 700; letter-spacing: .06em; text-shadow: 0 0 30px rgba(124, 92, 255, .6); }
.hpu-title-card.is-on { animation: hpuTitle 2.6s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes hpuTitle { 0% { opacity: 0; transform: translate(-50%, 14px); letter-spacing: .2em; } 18% { opacity: 1; transform: translate(-50%, 0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -6px); } }
.hpu.is-traveling .hpu-top, .hpu.is-traveling .hpu-card, .hpu.is-traveling .hpu-help, .hpu.is-traveling .hpu-speed { opacity: .15; transition: opacity .3s; }

.hpu-empty, .hpu-fallback { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; max-width: 520px; padding: 24px; }
.hpu-empty h2 { margin: 0 0 8px; font-size: 26px; }
.hpu-empty p { color: rgba(210, 220, 245, .7); margin: 0 0 18px; }
.hpu-empty[hidden], .hpu-fallback[hidden] { display: none; }
.hpu-fb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin: 16px 0; }
.hpu-fb-grid button { height: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hpu-fb-core { width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle, #fff 0 6%, var(--c) 30%, transparent 70%); }

.hpu-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@keyframes hpuIn { from { opacity: 0; transform: translateY(6px); } }

body.hpu-active .app { visibility: hidden; }

@media (max-width: 860px) {
  .hpu-top { grid-template-columns: 1fr auto; }
  .hpu-search { grid-column: 1 / -1; grid-row: 2; }
  .hpu-btn em { display: none; }
  .hpu-help { display: none; }
  .hpu-card { top: auto; bottom: 46px; right: 12px; left: 12px; width: auto; max-height: 42vh; }
}
@media (prefers-reduced-motion: reduce) {
  .hpu, .hpu-card, .hpu-menu { transition: opacity .2s; animation: none; transform: none; }
  .hpu-title-card.is-on { animation-duration: 1.6s; }
}

/* ---------- Integração na barra lateral / ecrã vazio ---------- */
.hp-section-with-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hp-section-actions { display: inline-flex; gap: 4px; }
.hp-add { height: 26px; padding: 0 6px; border-radius: 7px; border: 1px solid var(--sb-border, rgba(148,163,184,.14)); background: rgba(124, 92, 255, .08); color: var(--sb-text-secondary, #aebaca); font-size: 11px; cursor: pointer; }
.hp-add:hover { background: rgba(124, 92, 255, .25); color: #fff; }
.hp-explore { margin-top: 22px; height: 42px; padding: 0 18px; border-radius: 12px; border: 0; background: linear-gradient(135deg, #7c5cff, #4d9cff); color: #fff; font: 600 14px var(--sb-font-family, inherit); cursor: pointer; box-shadow: 0 10px 30px rgba(124, 92, 255, .35); }
.hp-explore:hover { filter: brightness(1.1); }
.hp-explore-hint { margin-top: 10px; font-size: 12.5px; color: var(--sb-text-muted, #8f9db1); }
