:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --bg: #07101f;
  --bg-deep: #050b16;
  --surface: rgba(14, 25, 46, 0.86);
  --surface-strong: #101d35;
  --surface-soft: rgba(23, 39, 69, 0.66);
  --border: rgba(143, 166, 207, 0.2);
  --border-strong: rgba(143, 166, 207, 0.36);
  --text: #f5f7ff;
  --muted: #a8b5ce;
  --subtle: #7888a6;
  --accent: #7c6cff;
  --accent-bright: #9e94ff;
  --cyan: #48d9c5;
  --danger: #ff6687;
  --danger-bg: rgba(255, 102, 135, 0.12);
  --success: #52dfaa;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% -8%, rgba(124, 108, 255, 0.25), transparent 34rem),
    radial-gradient(circle at 92% 12%, rgba(72, 217, 197, 0.13), transparent 30rem),
    linear-gradient(155deg, var(--bg-deep), var(--bg) 55%, #091329);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
  content: "";
  pointer-events: none;
}

::selection {
  background: rgba(124, 108, 255, 0.4);
  color: #fff;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent-bright);
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.65rem 0.85rem;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg-deep);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(72, 217, 197, 0.4);
  outline-offset: 2px;
}

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

.shell {
  width: min(1180px, calc(100% - 2rem));
  min-height: 100vh;
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
}

.topbar {
  position: sticky;
  top: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 72px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(7, 16, 31, 0.82);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(20px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(158, 148, 255, 0.5);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(124, 108, 255, 0.34), rgba(72, 217, 197, 0.16));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(124, 108, 255, 0.16);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: -0.03em;
}

.brand-copy {
  display: grid;
  line-height: 1.2;
}

.brand-copy strong {
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.brand-copy small {
  margin-top: 0.22rem;
  color: var(--subtle);
  font-size: 0.72rem;
}

.topbar-actions,
.nav,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 0.6rem;
}

.nav {
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid rgba(143, 166, 207, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.nav a {
  padding: 0.48rem 0.68rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease;
}

.nav a:hover {
  background: rgba(124, 108, 255, 0.13);
  color: #fff;
}

.nav a[aria-current="page"] {
  background: rgba(124, 108, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(158, 148, 255, 0.22);
  color: #fff;
}

.mode-badge,
.phase-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: fit-content;
  border: 1px solid rgba(82, 223, 170, 0.28);
  border-radius: 999px;
  background: rgba(82, 223, 170, 0.09);
  color: #a9f4d6;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1;
  text-transform: uppercase;
}

.mode-badge {
  padding: 0.46rem 0.62rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(82, 223, 170, 0.1), 0 0 16px rgba(82, 223, 170, 0.8);
}

.workspace {
  padding: 4.5rem 0 2rem;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding: 0 0.25rem;
}

.page-heading > div {
  max-width: 760px;
}

.page-heading h1 {
  margin-bottom: 0.55rem;
  font-size: clamp(2rem, 5vw, 3.35rem);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

.page-heading p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.08rem);
}

.eyebrow,
.panel-kicker {
  margin-bottom: 0.35rem;
  color: var(--cyan);
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.dashboard-wide {
  grid-column: 1 / -1;
}

.panel {
  position: relative;
  min-width: 0;
  margin-bottom: 1rem;
  padding: clamp(1.15rem, 3vw, 1.55rem);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(145deg, var(--surface), rgba(10, 19, 37, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.dashboard-grid .panel {
  margin-bottom: 0;
}

.panel::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
  content: "";
  pointer-events: none;
}

.panel-primary {
  border-color: rgba(124, 108, 255, 0.3);
  background:
    radial-gradient(circle at 95% 0%, rgba(124, 108, 255, 0.14), transparent 25rem),
    linear-gradient(145deg, var(--surface), rgba(10, 19, 37, 0.94));
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading h2,
.panel h2 {
  margin-bottom: 0.42rem;
  font-size: 1.12rem;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.panel-heading p:last-child,
.panel > p:last-child {
  margin-bottom: 0;
}

.panel-icon {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--accent-bright);
  font-size: 1.2rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.stack > button {
  justify-self: start;
}

label {
  display: grid;
  gap: 0.45rem;
  color: #dce4f5;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: rgba(5, 12, 26, 0.7);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input,
select {
  min-height: 44px;
  padding: 0.65rem 0.78rem;
}

textarea {
  min-height: 150px;
  padding: 0.75rem 0.82rem;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(158, 148, 255, 0.55);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-bright);
  background: rgba(8, 16, 34, 0.95);
  box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.12);
  outline: none;
}

button,
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.62rem 0.9rem;
  border: 1px solid rgba(158, 148, 255, 0.75);
  border-radius: 10px;
  background: linear-gradient(135deg, #6959f5, #806eff);
  box-shadow: 0 9px 26px rgba(105, 89, 245, 0.22), inset 0 1px rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, filter 150ms ease;
}

button:hover,
.button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(0);
}

button.secondary,
.button.secondary,
button.quiet {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: none;
  color: #dce4f5;
}

button.quiet {
  min-height: 44px;
  padding: 0.48rem 0.68rem;
  font-size: 0.74rem;
}

button.danger {
  border-color: rgba(255, 102, 135, 0.55);
  background: var(--danger-bg);
  box-shadow: none;
  color: #ffb0c2;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.25);
  opacity: 0.48;
  transform: none;
}

.actions {
  gap: 0.65rem;
}

.muted {
  color: var(--muted);
}

.notice {
  margin-bottom: 1rem;
  padding: 0.78rem 0.9rem;
  border: 1px solid rgba(124, 108, 255, 0.28);
  border-left: 3px solid var(--accent-bright);
  border-radius: 10px;
  background: rgba(124, 108, 255, 0.08);
  color: #dce4ff;
}

.notice.error {
  border-color: rgba(255, 102, 135, 0.32);
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: #ffc0cd;
}

.voice-console {
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
  border: 1px solid rgba(72, 217, 197, 0.25);
  border-radius: 14px;
  background:
    radial-gradient(circle at 96% 8%, rgba(72, 217, 197, 0.12), transparent 16rem),
    rgba(4, 12, 25, 0.62);
}

.voice-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.voice-heading h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.voice-heading p:last-child {
  max-width: 720px;
  margin: 0;
  font-size: 0.8rem;
}

.voice-orb {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(143, 166, 207, 0.3);
  border-radius: 50%;
  background: rgba(143, 166, 207, 0.12);
  box-shadow: inset 0 0 0 7px rgba(5, 12, 26, 0.72);
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

[data-voice-state="connecting"] .voice-orb,
[data-voice-state="listening"] .voice-orb {
  border-color: rgba(72, 217, 197, 0.75);
  background: var(--cyan);
  box-shadow:
    inset 0 0 0 7px rgba(5, 12, 26, 0.72),
    0 0 0 6px rgba(72, 217, 197, 0.08),
    0 0 24px rgba(72, 217, 197, 0.46);
}

[data-voice-state="connecting"] .voice-orb {
  animation: voice-pulse 1.2s ease-in-out infinite;
}

[data-voice-state="muted"] .voice-orb {
  border-color: rgba(255, 193, 92, 0.65);
  background: #ffc15c;
  box-shadow: inset 0 0 0 7px rgba(5, 12, 26, 0.72), 0 0 20px rgba(255, 193, 92, 0.3);
}

[data-voice-state="error"] .voice-orb {
  border-color: rgba(255, 102, 135, 0.7);
  background: var(--danger);
  box-shadow: inset 0 0 0 7px rgba(5, 12, 26, 0.72), 0 0 20px rgba(255, 102, 135, 0.28);
}

.voice-level {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(143, 166, 207, 0.12);
}

.voice-level span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--accent-bright));
  box-shadow: 0 0 14px rgba(72, 217, 197, 0.42);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 70ms linear;
}

.voice-actions {
  margin-top: 0.1rem;
}

.voice-status,
.voice-transcript {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.voice-transcript:not(:empty) {
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(143, 166, 207, 0.16);
  border-radius: 9px;
  background: rgba(5, 12, 26, 0.68);
  color: #dce4f5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@keyframes voice-pulse {
  50% {
    box-shadow:
      inset 0 0 0 7px rgba(5, 12, 26, 0.72),
      0 0 0 10px rgba(72, 217, 197, 0.04),
      0 0 30px rgba(72, 217, 197, 0.58);
  }
}

.empty-state {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 1rem;
  border: 1px dashed rgba(143, 166, 207, 0.26);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--muted);
}

.empty-state strong {
  color: #dce4f5;
  font-size: 0.84rem;
}

.empty-state span {
  font-size: 0.78rem;
}

.phase-badge {
  padding: 0.52rem 0.7rem;
}

.phase-badge.compact {
  margin-left: 0.45rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.62rem;
}

.phase-idle,
.phase-ready {
  border-color: rgba(72, 217, 197, 0.28);
  background: rgba(72, 217, 197, 0.08);
  color: #98eee2;
}

.phase-running,
.phase-cancelling {
  border-color: rgba(158, 148, 255, 0.35);
  background: rgba(124, 108, 255, 0.12);
  color: #c4bdff;
}

.phase-paused {
  border-color: rgba(255, 193, 92, 0.35);
  background: rgba(255, 193, 92, 0.1);
  color: #ffd690;
}

.events {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.event,
.outcome {
  border: 1px solid rgba(143, 166, 207, 0.16);
  border-radius: 12px;
  background: rgba(4, 10, 23, 0.7);
}

.event {
  padding: 0.9rem;
}

.event strong {
  color: var(--cyan);
  font-size: 0.69rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.event pre,
.outcome {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.event pre {
  margin: 0.55rem 0 0;
}

.outcome {
  max-height: 520px;
  margin: 0;
  padding: 1rem;
  overflow: auto;
}

pre,
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
}

code {
  padding: 0.12rem 0.3rem;
  border: 1px solid rgba(143, 166, 207, 0.16);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: #b9f5ec;
  overflow-wrap: anywhere;
}

.auth-shell {
  display: grid;
  width: min(580px, calc(100% - 2rem));
  min-height: 100vh;
  margin: 0 auto;
  place-items: center;
  padding: 2rem 0;
}

.auth-panel {
  width: 100%;
  padding: clamp(1.4rem, 5vw, 2.2rem);
  border-color: rgba(124, 108, 255, 0.3);
  background:
    radial-gradient(circle at 100% 0%, rgba(72, 217, 197, 0.11), transparent 20rem),
    linear-gradient(145deg, rgba(16, 29, 53, 0.96), rgba(8, 16, 32, 0.97));
}

.auth-panel::before {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 0.4rem;
  place-items: center;
  border: 1px solid rgba(158, 148, 255, 0.45);
  border-radius: 15px;
  background: rgba(124, 108, 255, 0.15);
  color: #fff;
  content: "EA";
  font-size: 0.9rem;
  font-weight: 850;
}

.auth-panel h1 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.console-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 0.25rem 0;
  border-top: 1px solid rgba(143, 166, 207, 0.11);
  color: var(--subtle);
  font-size: 0.7rem;
}

[data-phx-session],
[data-phx-teleported-src] {
  display: contents;
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
  }

  .topbar-actions {
    max-width: 62%;
  }

  .workspace {
    padding-top: 2.5rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-wide {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 0.5rem;
  }

  .topbar {
    display: grid;
    gap: 0.85rem;
    border-radius: 14px;
  }

  .topbar-actions {
    display: grid;
    width: 100%;
    max-width: none;
    grid-template-columns: 1fr auto;
  }

  .mode-badge {
    justify-self: start;
  }

  .topbar-actions > form {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .nav a {
    flex: 1;
    text-align: center;
  }

  .page-heading {
    display: grid;
    gap: 1rem;
  }

  .page-heading h1 {
    font-size: 2.25rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 14px;
  }

  .console-footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  [data-voice-state="connecting"] .voice-orb {
    animation: none;
  }
}
