:root {
  color-scheme: dark;
  --bg: #02070b;
  --panel: rgba(4, 17, 27, 0.82);
  --line: rgba(0, 213, 255, 0.32);
  --line-soft: rgba(0, 213, 255, 0.16);
  --cyan: #00d5ff;
  --cyan-bright: #9bf7ff;
  --green: #62ffad;
  --amber: #ffbd5a;
  --red: #ff5b6a;
  --text: #d9f9ff;
  --muted: rgba(217, 249, 255, 0.58);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

#boot-splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(0, 213, 255, 0.2), transparent 34%),
    radial-gradient(circle at 50% 46%, rgba(255, 189, 90, 0.08), transparent 18%),
    linear-gradient(180deg, #06121d, #02070b 70%);
  transition: opacity 420ms ease, transform 420ms ease, filter 420ms ease;
}

#boot-splash::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 4px),
    linear-gradient(110deg, transparent 0 44%, rgba(0, 213, 255, 0.14) 50%, transparent 56% 100%);
  mix-blend-mode: screen;
  opacity: 0.58;
  animation: boot-scan 1.35s linear infinite;
}

#boot-splash.hide {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.035);
  filter: blur(8px);
}

.boot-reactor,
.boot-orbit {
  position: absolute;
  width: min(58vmin, 340px);
  aspect-ratio: 1;
  border-radius: 50%;
}

.boot-reactor {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.68) 0 4%, rgba(155, 247, 255, 0.46) 5% 14%, rgba(0, 213, 255, 0.1) 15% 31%, transparent 34%),
    radial-gradient(circle, transparent 0 37%, rgba(0, 213, 255, 0.1) 38% 39%, transparent 40%);
  filter: drop-shadow(0 0 28px rgba(0, 213, 255, 0.42));
}

.boot-reactor::before,
.boot-reactor::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.boot-reactor::before {
  inset: 0;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 8deg, rgba(0, 213, 255, 0.78) 0deg 2deg, transparent 2deg 8deg),
    conic-gradient(from 36deg, transparent 0 18deg, rgba(155, 247, 255, 0.86) 18deg 38deg, transparent 38deg 90deg, rgba(255, 189, 90, 0.7) 90deg 108deg, transparent 108deg 180deg, rgba(155, 247, 255, 0.72) 180deg 214deg, transparent 214deg 360deg);
  mask: radial-gradient(circle, transparent 0 46%, #000 47% 59%, transparent 60% 100%);
  animation: boot-spin 5.4s linear infinite;
}

.boot-reactor::after {
  inset: 29%;
  border-radius: 0;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.96) 0 13%, rgba(191, 245, 255, 0.86) 14% 28%, rgba(0, 213, 255, 0.34) 31% 57%, transparent 62%),
    conic-gradient(from 18deg, rgba(155, 247, 255, 0.86), rgba(0, 213, 255, 0.12), rgba(255, 189, 90, 0.55), rgba(155, 247, 255, 0.86));
  clip-path: polygon(50% 6%, 88% 77%, 12% 77%);
  box-shadow: 0 0 60px rgba(0, 213, 255, 0.72);
  animation: boot-core 1.35s ease-in-out infinite alternate;
}

.boot-orbit {
  border: 1px solid rgba(0, 213, 255, 0.16);
  box-shadow: inset 0 0 34px rgba(0, 213, 255, 0.12), 0 0 64px rgba(0, 213, 255, 0.12);
}

.boot-orbit::before {
  content: "";
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(255, 189, 90, 0.24);
  border-radius: 50%;
}

body {
  /* 100vh on iOS Safari is the largest possible viewport, so the bottom of
     the page sits behind the home indicator/keyboard. 100dvh tracks the
     dynamic viewport correctly; vh stays as a fallback for older browsers. */
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 12%, rgba(0, 213, 255, 0.22), transparent 32rem),
    linear-gradient(180deg, #02070b, #02070b 44%, #04131e);
  color: var(--text);
  /* Prevent iOS rubber-band scrolling from peeking white at the edges, and
     stop the browser from auto-zooming on text input focus. */
  overscroll-behavior: contain;
  -webkit-text-size-adjust: 100%;
}

@keyframes boot-spin { to { transform: rotate(360deg); } }
@keyframes boot-spin-reverse { to { transform: rotate(-360deg); } }
@keyframes boot-core {
  from { transform: scale(0.92) rotate(-3deg); opacity: 0.76; }
  to { transform: scale(1.06) rotate(3deg); opacity: 1; }
}
@keyframes boot-scan {
  from { transform: translateX(-8%); }
  to { transform: translateX(8%); }
}

@media (prefers-reduced-motion: reduce) {
  .boot-reactor,
  .boot-reactor::before,
  .boot-reactor::after,
  #boot-splash::before {
    animation: none;
  }
}

button, input, textarea {
  font: inherit;
}

button {
  /* iOS Safari double-taps zoom unless we opt out via touch-action, and
     the default tap highlight flashes a translucent square that looks
     ugly against the dark theme. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  /* iOS auto-zooms when the focused input has font-size <16px. Bump just
     enough that we keep the compact look but don't trigger zoom. */
  font-size: 16px;
}

.shell {
  width: min(760px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow,
.panel-head,
.metrics span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  color: var(--cyan-bright);
  font-size: 34px;
  letter-spacing: 0.22em;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--amber);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.14em;
  background: rgba(0, 15, 24, 0.75);
}

.pill.online {
  color: var(--green);
}

.panel {
  position: relative;
  margin: 10px 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 213, 255, 0.11), transparent 42%),
    var(--panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.26), inset 0 0 24px rgba(0, 213, 255, 0.035);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(0, 213, 255, 0.08);
  pointer-events: none;
}

.panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head strong {
  color: var(--cyan);
  font-size: 10px;
}

label {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(0, 8, 13, 0.74);
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 213, 255, 0.14);
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 20, 32, 0.76);
  color: var(--cyan-bright);
  padding: 11px 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  width: 100%;
  background: rgba(0, 213, 255, 0.16);
}

button.danger {
  border-color: rgba(255, 91, 106, 0.58);
  color: #ffc4cb;
  background: rgba(94, 11, 22, 0.66);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line-soft);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.auth-actions button.primary {
  width: 100%;
}

.metrics {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metrics div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(0, 8, 13, 0.54);
}

.metrics strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 10px 0;
}

.result-panel pre {
  position: relative;
  z-index: 1;
  min-height: 150px;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.history {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(0, 8, 13, 0.48);
}

.history-item .meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.history-item strong {
  color: var(--text);
  font-size: 12px;
}

.status-completed { color: var(--green); }
.status-failed { color: var(--red); }
.status-sent,
.status-queued { color: var(--amber); }

@media (min-width: 720px) {
  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
