:root {
  --hkm-launch-bg: #070912;
  --hkm-launch-panel: rgba(12, 15, 29, 0.9);
  --hkm-launch-line: rgba(139, 92, 246, 0.28);
  --hkm-launch-violet: #a78bfa;
  --hkm-launch-cyan: #67e8f9;
  --hkm-launch-green: #5eead4;
  --hkm-launch-muted: #8d96af;
  --hkm-launch-reveal-duration: 520ms;
}

html:not(.auth-verified):not(.auth-failed) body {
  visibility: hidden !important;
}

html.auth-verified:not(.app-ready) body {
  overflow: hidden;
}

html.auth-verified:not(.app-ready):not(.launch-revealing) .app-shell,
html.auth-verified:not(.app-ready):not(.launch-revealing) > body > #bgeffect,
html.auth-failed .app-shell,
html.auth-failed > body > #bgeffect,
html.auth-failed > body > #error,
html.auth-failed > body > #toast {
  visibility: hidden !important;
  pointer-events: none !important;
}

.hkm-auth-gate-error {
  position: fixed;
  z-index: 2147483647;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  color: #eef2ff;
  background:
    radial-gradient(circle at 20% 15%, rgba(124, 58, 237, 0.22), transparent 36%),
    #070912;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html.auth-failed .hkm-auth-gate-error {
  display: grid;
}

.hkm-auth-gate-error-card {
  width: min(460px, 100%);
  padding: 32px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 20px;
  background: rgba(15, 18, 34, 0.92);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

.hkm-auth-gate-error-card h1 {
  margin: 10px 0 8px;
  font-size: clamp(1.35rem, 4vw, 1.8rem);
}

.hkm-auth-gate-error-card p {
  margin: 0 0 24px;
  color: #aeb7ce;
}

.hkm-auth-gate-error-code {
  color: #fda4af;
  font: 700 0.72rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.15em;
}

.hkm-auth-gate-retry {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 18px;
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: 10px;
  color: #f5f3ff;
  background: rgba(124, 58, 237, 0.22);
  text-decoration: none;
}

.hkm-auth-gate-retry:focus-visible {
  outline: 3px solid var(--hkm-launch-cyan);
  outline-offset: 3px;
}

.hkm-launch-sequence {
  position: fixed;
  z-index: 2147483646;
  inset: 0;
  display: none;
  place-items: center;
  overflow: hidden;
  padding: clamp(18px, 4vw, 48px);
  color: #eef2ff;
  opacity: 0;
  visibility: hidden;
  background:
    radial-gradient(circle at 16% 12%, rgba(124, 58, 237, 0.28), transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(8, 145, 178, 0.17), transparent 31%),
    linear-gradient(145deg, #050711 0%, #090b18 52%, #050914 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: opacity 360ms ease, visibility 360ms ease;
}

html.auth-verified.launch-visible .hkm-launch-sequence {
  display: grid;
  opacity: 1;
  visibility: visible;
}

html.app-ready .hkm-launch-sequence {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Die Oberfläche wird bereits gerendert, bleibt während des Reveals aber
   vollständig inert. Erst der Controller setzt danach app-ready. */
html.auth-verified.launch-revealing:not(.app-ready) .app-shell,
html.auth-verified.launch-revealing:not(.app-ready) > body > #bgeffect {
  visibility: visible !important;
  pointer-events: none !important;
}

html.launch-revealing .app-shell {
  will-change: opacity, transform;
  animation: hkm-dashboard-reveal var(--hkm-launch-reveal-duration) cubic-bezier(0.22, 1, 0.36, 1) both;
}

html.launch-revealing > body > #bgeffect {
  will-change: opacity;
  animation: hkm-dashboard-background-reveal var(--hkm-launch-reveal-duration) ease-out both;
}

html.launch-revealing .pwa-bottom-nav {
  will-change: opacity;
  animation: hkm-dashboard-background-reveal var(--hkm-launch-reveal-duration) ease-out both;
}

html.launch-revealing .hkm-launch-sequence {
  visibility: visible;
  pointer-events: auto;
  animation: hkm-launch-overlay-exit var(--hkm-launch-reveal-duration) cubic-bezier(0.4, 0, 0.2, 1) both;
}

html.launch-revealing .hkm-launch-panel {
  will-change: transform;
  animation: hkm-launch-panel-exit var(--hkm-launch-reveal-duration) cubic-bezier(0.4, 0, 0.2, 1) both;
}

.hkm-launch-grid {
  position: absolute;
  inset: -20%;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(129, 140, 248, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(129, 140, 248, 0.13) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(600px) rotateX(58deg) translateY(18%);
  transform-origin: center bottom;
  animation: hkm-launch-grid-drift 14s linear infinite;
}

.hkm-launch-scan {
  position: absolute;
  inset: -30% 0 auto;
  height: 34%;
  opacity: 0.16;
  background: linear-gradient(to bottom, transparent, var(--hkm-launch-cyan), transparent);
  filter: blur(18px);
  animation: hkm-launch-scan 4.8s ease-in-out infinite;
}

.hkm-launch-panel {
  position: relative;
  width: min(760px, 100%);
  overflow: hidden;
  padding: clamp(24px, 5vw, 46px);
  border: 1px solid var(--hkm-launch-line);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 38%),
    var(--hkm-launch-panel);
  box-shadow:
    0 38px 120px rgba(0, 0, 0, 0.58),
    inset 0 1px rgba(255, 255, 255, 0.08),
    0 0 80px rgba(124, 58, 237, 0.09);
  backdrop-filter: blur(24px);
}

.hkm-launch-panel::before {
  position: absolute;
  content: "";
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(255, 255, 255, 0.025) 3px 4px);
}

.hkm-launch-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
}

.hkm-launch-emblem {
  position: relative;
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
}

.hkm-launch-emblem img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 0 15px rgba(167, 139, 250, 0.42));
}

.hkm-launch-orbit {
  position: absolute;
  border: 1px solid rgba(167, 139, 250, 0.42);
  border-radius: 50%;
}

.hkm-launch-orbit::after {
  position: absolute;
  content: "";
  width: 6px;
  height: 6px;
  top: -3px;
  left: 50%;
  border-radius: 50%;
  background: var(--hkm-launch-cyan);
  box-shadow: 0 0 12px var(--hkm-launch-cyan);
}

.hkm-launch-orbit-outer {
  inset: 0;
  animation: hkm-launch-spin 7s linear infinite;
}

.hkm-launch-orbit-inner {
  inset: 11px;
  border-style: dashed;
  animation: hkm-launch-spin 5s linear infinite reverse;
}

.hkm-launch-kicker,
.hkm-launch-signal,
.hkm-launch-node {
  font: 700 0.68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hkm-launch-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--hkm-launch-violet);
}

.hkm-launch-heading h1 {
  margin: 0;
  font-size: clamp(1.65rem, 5vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.hkm-launch-heading p {
  margin: 8px 0 0;
  color: var(--hkm-launch-muted);
  font-size: 0.94rem;
}

.hkm-launch-signal {
  align-self: start;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--hkm-launch-green);
}

.hkm-launch-signal > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  animation: hkm-launch-pulse 1.6s ease-in-out infinite;
}

.hkm-launch-terminal {
  position: relative;
  margin-top: 30px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  background: rgba(2, 5, 15, 0.78);
  box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.38);
  font: 500 0.83rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hkm-launch-terminal-bar {
  display: flex;
  height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
  color: #69738b;
  background: rgba(255, 255, 255, 0.025);
}

.hkm-launch-terminal-bar span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #566078;
}

.hkm-launch-terminal-bar span:first-child { background: #fb7185; }
.hkm-launch-terminal-bar span:nth-child(2) { background: #fbbf24; }
.hkm-launch-terminal-bar span:nth-child(3) { background: #34d399; }

.hkm-launch-terminal-bar strong {
  margin-left: auto;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.hkm-launch-steps {
  display: grid;
  gap: 8px;
  min-height: 166px;
  margin: 0;
  padding: 17px 19px;
  list-style: none;
}

.hkm-launch-steps li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 9px;
  align-items: baseline;
  color: #6f7991;
  transition: color 180ms ease, transform 180ms ease;
}

.hkm-launch-steps li[data-state="active"] {
  color: #e9d5ff;
  transform: translateX(3px);
}

.hkm-launch-steps li[data-state="complete"] { color: #b7c2d8; }
.hkm-launch-steps li[data-state="warning"] { color: #fcd34d; }
.hkm-launch-steps li[data-state="error"] { color: #fda4af; }

.hkm-launch-step-state::before { content: "○"; }
.hkm-launch-steps li[data-state="active"] .hkm-launch-step-state::before { content: "▸"; color: var(--hkm-launch-cyan); }
.hkm-launch-steps li[data-state="complete"] .hkm-launch-step-state::before { content: "✓"; color: var(--hkm-launch-green); }
.hkm-launch-steps li[data-state="warning"] .hkm-launch-step-state::before { content: "!"; }
.hkm-launch-steps li[data-state="error"] .hkm-launch-step-state::before { content: "×"; }

.hkm-launch-cursor {
  position: absolute;
  right: 16px;
  bottom: 13px;
  color: var(--hkm-launch-cyan);
  animation: hkm-launch-cursor 850ms steps(1, end) infinite;
}

.hkm-launch-progress-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 14px;
  align-items: center;
  margin-top: 24px;
}

.hkm-launch-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.13);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.42);
}

.hkm-launch-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, var(--hkm-launch-violet) 58%, var(--hkm-launch-cyan));
  box-shadow: 0 0 18px rgba(103, 232, 249, 0.48);
  transition: width 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.hkm-launch-progress-row output {
  color: #c4b5fd;
  font: 700 0.75rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: right;
}

.hkm-launch-footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  color: var(--hkm-launch-muted);
  font-size: 0.78rem;
}

.hkm-launch-node { color: #667089; }

html.launch-warning .hkm-launch-progress > span {
  background: linear-gradient(90deg, #7c3aed, #f59e0b);
}

html.launch-complete .hkm-launch-panel {
  border-color: rgba(94, 234, 212, 0.5);
  box-shadow: 0 38px 120px rgba(0, 0, 0, 0.58), 0 0 90px rgba(94, 234, 212, 0.14);
}

.hkm-launch-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.hkm-launch-sequence[data-mode="compact"] .hkm-launch-panel {
  width: min(520px, 100%);
  padding: 24px 26px;
  border-radius: 20px;
}

.hkm-launch-sequence[data-mode="compact"] .hkm-launch-emblem {
  width: 60px;
  height: 60px;
}

.hkm-launch-sequence[data-mode="compact"] .hkm-launch-emblem img {
  width: 38px;
  height: 38px;
}

.hkm-launch-sequence[data-mode="compact"] .hkm-launch-heading h1 { font-size: 1.45rem; }
.hkm-launch-sequence[data-mode="compact"] .hkm-launch-heading p,
.hkm-launch-sequence[data-mode="compact"] .hkm-launch-signal,
.hkm-launch-sequence[data-mode="compact"] .hkm-launch-terminal,
.hkm-launch-sequence[data-mode="compact"] .hkm-launch-node { display: none; }
.hkm-launch-sequence[data-mode="compact"] .hkm-launch-progress-row { margin-top: 20px; }

@keyframes hkm-launch-spin { to { transform: rotate(360deg); } }
@keyframes hkm-launch-pulse { 50% { opacity: 0.42; transform: scale(0.72); } }
@keyframes hkm-launch-cursor { 50% { opacity: 0; } }
@keyframes hkm-launch-grid-drift { to { transform: perspective(600px) rotateX(58deg) translateY(calc(18% + 44px)); } }
@keyframes hkm-launch-scan {
  0%, 100% { transform: translateY(-30vh); }
  50% { transform: translateY(135vh); }
}
@keyframes hkm-dashboard-reveal {
  0%, 12% { opacity: 0; transform: translateY(10px) scale(0.995); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes hkm-dashboard-background-reveal { 0%, 12% { opacity: 0; } }
@keyframes hkm-launch-overlay-exit {
  0%, 12% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes hkm-launch-panel-exit {
  0%, 12% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(0.985); }
}

@media (max-width: 620px) {
  .hkm-launch-panel { padding: 24px 20px; border-radius: 20px; }
  .hkm-launch-header { grid-template-columns: auto 1fr; gap: 15px; }
  .hkm-launch-signal { display: none; }
  .hkm-launch-emblem { width: 62px; height: 62px; }
  .hkm-launch-emblem img { width: 40px; height: 40px; }
  .hkm-launch-heading p { font-size: 0.82rem; }
  .hkm-launch-terminal { margin-top: 22px; font-size: 0.72rem; }
  .hkm-launch-steps { min-height: 154px; padding: 15px; }
  .hkm-launch-footer { font-size: 0.7rem; }
  .hkm-launch-node { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hkm-launch-sequence,
  .hkm-launch-progress > span,
  .hkm-launch-steps li {
    transition-duration: 1ms !important;
  }

  .hkm-launch-grid,
  .hkm-launch-scan,
  .hkm-launch-orbit,
  .hkm-launch-signal > span,
  .hkm-launch-cursor,
  html.launch-revealing .app-shell,
  html.launch-revealing > body > #bgeffect,
  html.launch-revealing .pwa-bottom-nav,
  html.launch-revealing .hkm-launch-sequence,
  html.launch-revealing .hkm-launch-panel {
    animation: none !important;
  }

  .hkm-launch-scan { display: none; }
}

@media (forced-colors: active) {
  .hkm-launch-sequence,
  .hkm-auth-gate-error { forced-color-adjust: auto; }
  .hkm-launch-panel { border: 2px solid CanvasText; }
}
