:root {
  color-scheme: dark;
  --page: #050810;
  --surface: #0b1019;
  --ink: #f5f5f5;
  --muted: #b7becb;
  --border: #343c49;
  --border-strong: #687283;
  --accent: #ff6a00;
  --accent-dark: #d95300;
  --purple: #8a4fe3;
  --blue: #3478e5;
  --teal: #58c8b9;
  --danger: #ff4b4b;
  --focus: #ff6a00;
  --radius: 2px;
  font-family: "Segoe UI Variable Text", Aptos, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background-color: var(--page);
  color: var(--ink);
  overflow-x: hidden;
}

.ambient-audio-wave {
  width: min(980px, 78vw);
  height: 260px;
  position: fixed;
  top: 86px;
  right: -120px;
  z-index: 0;
  opacity: 0.72;
  pointer-events: none;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 24px rgba(255, 106, 0, 0.62)) drop-shadow(0 0 38px rgba(138, 79, 227, 0.42)) drop-shadow(0 0 52px rgba(52, 120, 229, 0.24));
  animation: ambient-drift 12s ease-in-out infinite alternate;
}

.ambient-audio-wave::before,
.ambient-audio-wave::after {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: repeat-x;
  background-size: 520px 180px;
  background-position: 0 54%;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 78%, transparent);
}

.ambient-audio-wave::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 180'%3E%3Cpath d='M0 90 C32 18 64 18 96 90 S160 162 192 90 S256 18 288 90 S352 162 384 90 S448 18 520 90' fill='none' stroke='%23ff8a1c' stroke-width='4.4' stroke-linecap='round'/%3E%3Cpath d='M0 90 C26 58 52 58 78 90 S130 122 156 90 S208 58 234 90 S286 122 312 90 S364 58 390 90 S468 122 520 90' fill='none' stroke='%23a066ff' stroke-width='3' stroke-linecap='round' opacity='.82'/%3E%3C/svg%3E");
  animation: wave-slide 7s linear infinite;
}

.ambient-audio-wave::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 180'%3E%3Cpath d='M0 102 C44 44 66 44 110 102 S198 160 242 102 S330 44 374 102 S462 160 520 102' fill='none' stroke='%23469aff' stroke-width='3.4' stroke-linecap='round' opacity='.7'/%3E%3C/svg%3E");
  transform: translateY(18px);
  animation: wave-slide 10s linear infinite reverse;
}

.ambient-audio-wave i { display: none; }

@keyframes ambient-drift {
  from { transform: translate3d(0, -8px, 0) rotate(-1deg); }
  to { transform: translate3d(-46px, 10px, 0) rotate(1deg); }
}

@keyframes wave-slide {
  from { background-position-x: 0; }
  to { background-position-x: -520px; }
}
button,
input,
select,
textarea { font: inherit; }

a { color: inherit; }

button,
.button,
.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 400;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover,
.button-link:hover { border-color: var(--border-strong); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.primary,
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button.primary:hover,
.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.text-button {
  min-height: auto;
  padding: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.icon-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
}

.icon-button > span {
  display: block;
  font-family: "Segoe UI Symbol", "Segoe UI", sans-serif;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

.topbar {
  min-height: 76px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 7px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid var(--border);
  background: rgba(5, 8, 16, 0.97);
  backdrop-filter: blur(12px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  width: clamp(158px, 18vw, 196px);
  height: auto;
  display: block;
}

.header-meta {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.engine-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: var(--accent);
}

.engine-state.ready .status-dot { background: var(--teal); }
.engine-state.not-ready .status-dot { background: var(--danger); }

.page-shell {
  width: min(1040px, calc(100% - 32px));
  position: relative;
  z-index: 1;
  margin: 0 auto;
  padding: 28px 0 64px;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2,
h3 {
  font-family: "Segoe UI Variable Display", "Aptos Display", "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.panel {
  padding: 24px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 20, 0.95);
}

.error-panel {
  width: min(720px, 100%);
  margin: 60px auto;
}

.error-panel pre {
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(380px, calc(100% - 40px));
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #111720;
  color: #ffffff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.is-hidden { display: none !important; }

@media (max-width: 780px) {
  .page-shell {
    width: min(100% - 20px, 1040px);
    padding-top: 18px;
  }
}

@media (max-width: 520px) {
  .topbar { min-height: 62px; padding: 6px 12px; }
  .brand-logo { width: 146px; }
  .header-meta { font-size: 0.72rem; }

  .ambient-audio-wave {
    width: 96vw;
    height: 140px;
    top: 96px;
    right: -18vw;
    gap: 4px;
    opacity: 0.09;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .ambient-audio-wave,
  .ambient-audio-wave i {
    animation: none;
  }
}

