:root {
  color-scheme: dark;
  --bg: #0a0b0c;
  --surface: #0e0e0e;
  --surface-soft: rgba(255, 255, 255, 0.04);
  --surface-line: rgba(255, 255, 255, 0.08);
  --text: #f3f4f6;
  --muted: #b7bbc3;
  --muted-strong: #8d939f;
  --primary: #88adff;
  --secondary: #75dfb7;
  --danger: #ff7d7d;
  --live-footer-space: 11.5rem;
  --live-footer-space-mobile: 12rem;
  --debug-panel-width: min(30rem, calc(100vw - 2rem));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "Inter", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.screen {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(136, 173, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #090909 0%, #0c0c0d 100%);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: #0e0e0e;
}

.screen-start .topbar,
.screen-live .topbar {
  display: none;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-family: "Manrope", sans-serif;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #f5f5f5;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  transition: background-color 160ms ease, transform 160ms ease, color 160ms ease;
}

.icon-button:hover {
  background: #20201f;
  transform: translateY(-1px);
}

.icon-button .material-symbols-outlined {
  font-size: 1.35rem;
}

.icon-button.accent {
  color: var(--primary);
}

.icon-button.neutral {
  color: #787d86;
}

.start-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 4rem;
}

.hero-card {
  position: relative;
  z-index: 1;
  width: min(100%, 42rem);
  text-align: center;
}

.hero-copy {
  display: grid;
  gap: 1rem;
}

.hero-copy h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(2.35rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.hero-copy h2 span {
  color: var(--primary);
  font-style: italic;
}

.hero-copy p {
  margin: 0 auto;
  max-width: 20rem;
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.start-cta-wrap {
  padding-top: 2.25rem;
  display: grid;
  place-items: center;
  gap: 1.1rem;
}

.start-link {
  position: relative;
  display: inline-grid;
  place-items: center;
}

.start-halo {
  position: absolute;
  inset: 0.5rem;
  border-radius: 999px;
  background: rgba(136, 173, 255, 0.18);
  filter: blur(42px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.start-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 12rem;
  height: 12rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #6f9fff 0%, #9ec0ff 100%);
  box-shadow: 0 25px 60px rgba(77, 127, 255, 0.35);
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.start-button .material-symbols-outlined {
  position: relative;
  z-index: 1;
  font-size: 4rem;
  color: white;
  font-variation-settings: "FILL" 1;
}

.start-ring {
  position: absolute;
  inset: 0;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-radius: inherit;
}

.start-link:hover .start-halo,
.start-link:focus-visible .start-halo {
  opacity: 1;
  transform: scale(1.06);
}

.start-link:hover .start-button,
.start-link:focus-visible .start-button {
  transform: scale(1.03);
  box-shadow: 0 32px 80px rgba(77, 127, 255, 0.42);
}

.start-caption {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  color: var(--muted-strong);
  letter-spacing: 0.22em;
  font-size: 0.65rem;
  font-weight: 700;
}

.start-meter {
  width: 2rem;
  height: 0.25rem;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.start-meter div {
  width: 33%;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.background-orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(16px);
}

.background-orb-main {
  top: 50%;
  left: 50%;
  width: min(100vw, 44rem);
  height: min(100vw, 44rem);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(136, 173, 255, 0.08), transparent 65%);
}

.background-orb-side {
  top: 24%;
  right: -8rem;
  width: 25rem;
  height: 25rem;
  background: radial-gradient(circle, rgba(117, 223, 183, 0.08), transparent 70%);
}

.live-topbar {
  position: fixed;
  inset: 0 0 auto;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.live-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

.conversation-shell {
  position: relative;
  z-index: 1;
  max-width: 64rem;
  margin: 0 auto;
  height: calc(100vh - var(--live-footer-space));
  overflow-y: auto;
  padding: 2.5rem 1.5rem 2.5rem;
  scrollbar-gutter: stable;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.conversation-shell::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.conversation-feed {
  max-width: 48rem;
  margin: 0 auto;
  display: grid;
  gap: 2.75rem;
  padding-bottom: calc(var(--live-footer-space) + 1rem);
}

.message {
  display: grid;
  gap: 0.85rem;
}

.message[data-pending="true"] .message-body {
  opacity: 0.58;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  opacity: 0.62;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: #a8acb4;
}

.message-body {
  margin: 0;
  font-size: clamp(0.65rem, 1.45vw, 0.9rem);
  line-height: 1.4;
  font-weight: 500;
  color: #f5f7fa;
}

.message-user .message-body {
  color: #cfd6e2;
}

.message-assistant .message-body {
  color: #ffffff;
}

.message-evaluation {
  margin-top: 0.5rem;
}

.message-evaluation .message-meta {
  color: #d6deeb;
}

.evaluation-body {
  display: grid;
  gap: 0.9rem;
}

.evaluation-waiting {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #eef3fb;
}

.evaluation-dots {
  display: inline-block;
  min-width: 1rem;
  animation: pulse 1.4s ease-in-out infinite;
}

.evaluation-section {
  display: grid;
  gap: 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.03);
}

.evaluation-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.evaluation-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f5f7fb;
}

.evaluation-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(136, 173, 255, 0.12);
  color: #dfe8ff;
  font-size: 0.72rem;
  font-weight: 700;
}

.evaluation-copy,
.evaluation-summary {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #d8dde8;
}

.evaluation-summary {
  color: #f3f6fb;
}

.live-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 15;
  background:
    linear-gradient(180deg, rgba(14, 14, 14, 0) 0%, rgba(14, 14, 14, 0.7) 18%, #0e0e0e 100%);
}

.footer-shell {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem 1.5rem 2.5rem;
}

.footer-statusline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto 1rem;
  max-width: 48rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted-strong);
}

#statusMessage {
  flex: 1 1 16rem;
  min-width: 0;
}

#serverHealth {
  display: inline-grid;
  flex: 0 1 22rem;
  justify-items: end;
  gap: 0.12rem;
  max-width: 22rem;
  text-align: right;
  text-transform: none;
  letter-spacing: 0.05em;
  line-height: 1.35;
}

#serverHealth[data-mode="status"] {
  gap: 0;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.footer-meta-line {
  display: block;
}

.footer-meta-primary {
  font-size: 0.72rem;
  font-weight: 700;
  color: #f3f6fb;
}

.footer-meta-secondary {
  font-size: 0.6rem;
  color: var(--muted-strong);
}

.live-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.live-secondary-action {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #eef2f6;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.live-secondary-action .material-symbols-outlined {
  font-size: 1.3rem;
}

.live-secondary-action:hover,
.live-secondary-action:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
}

.live-secondary-action:disabled,
.mic-action:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
  transform: none;
}

.mic-action {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.mic-action-glow {
  position: absolute;
  inset: -1rem;
  border-radius: 999px;
  background: rgba(117, 223, 183, 0.16);
  filter: blur(24px);
  opacity: 0.75;
  transition: opacity 180ms ease, transform 180ms ease;
}

.mic-action-core {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #5acda1 0%, #91e7c5 100%);
  box-shadow: 0 18px 40px rgba(117, 223, 183, 0.28);
}

.mic-action-core .material-symbols-outlined {
  font-size: 1.9rem;
  color: #ffffff;
  font-variation-settings: "FILL" 1;
}

.mic-action:hover .mic-action-glow,
.mic-action:focus-visible .mic-action-glow {
  opacity: 1;
  transform: scale(1.05);
}

.background-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.9;
}

.debug-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  bottom: calc(var(--live-footer-space) + 1rem);
  z-index: 30;
  width: var(--debug-panel-width);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  background: rgba(10, 11, 12, 0.94);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.debug-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.debug-title,
.debug-subtitle {
  margin: 0;
}

.debug-title {
  font-family: "Manrope", sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #f6f7fb;
}

.debug-subtitle {
  margin-top: 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-strong);
}

.debug-clear {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  color: #eef2f6;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-feed {
  height: calc(100% - 4.2rem);
  overflow-y: auto;
  padding: 0.8rem;
  display: grid;
  gap: 0.65rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.45;
  color: #dce3ea;
}

.debug-entry {
  border-radius: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
}

.debug-entry[data-kind="out"] {
  border-color: rgba(136, 173, 255, 0.2);
}

.debug-entry[data-kind="in"] {
  border-color: rgba(117, 223, 183, 0.2);
}

.debug-entry[data-kind="warn"] {
  border-color: rgba(255, 200, 92, 0.28);
}

.debug-entry[data-kind="error"] {
  border-color: rgba(255, 125, 125, 0.28);
}

.debug-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.debug-entry-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f5f7fb;
}

.debug-entry-time {
  color: var(--muted-strong);
  font-size: 0.68rem;
}

.debug-entry-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.background-orb-live-main {
  top: 20%;
  right: -10rem;
  width: 34rem;
  height: 34rem;
  background: radial-gradient(circle, rgba(136, 173, 255, 0.14), transparent 65%);
}

.background-orb-live-side {
  bottom: 8%;
  right: 18%;
  width: 20rem;
  height: 20rem;
  background: radial-gradient(circle, rgba(117, 223, 183, 0.12), transparent 68%);
}

.status-error {
  background: rgba(255, 125, 125, 0.12);
  color: var(--danger);
}

.status-pending {
  background: rgba(136, 173, 255, 0.1);
  color: var(--primary);
}

.status-success {
  background: rgba(117, 223, 183, 0.08);
  color: var(--secondary);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.75;
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 1rem;
  }

  .conversation-shell {
    height: 100vh;
    padding: 0.9rem 0.75rem calc(var(--live-footer-space-mobile) + 0.55rem);
  }

  .conversation-feed {
    gap: 1.7rem;
    padding-bottom: 0;
  }

  .message-meta {
    gap: 0.55rem;
    font-size: 0.55rem;
    letter-spacing: 0.18em;
    flex-wrap: wrap;
  }

  .message-body {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  .evaluation-body {
    gap: 0.75rem;
  }

  .evaluation-section {
    gap: 0.35rem;
    padding: 0.8rem 0.85rem;
    border-radius: 0.9rem;
  }

  .evaluation-section-head {
    gap: 0.7rem;
  }

  .evaluation-section-title,
  .evaluation-score {
    font-size: 0.66rem;
  }

  .evaluation-copy,
  .evaluation-summary {
    font-size: 0.8rem;
    line-height: 1.5;
  }

  .footer-shell {
    padding: 0.35rem 0.75rem max(0.7rem, env(safe-area-inset-bottom));
  }

  .footer-statusline {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    gap: 0.22rem;
    margin-bottom: 0.4rem;
    font-size: 0.56rem;
    letter-spacing: 0.02em;
    text-transform: none;
  }

  #statusMessage {
    flex: none;
    max-width: 18rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.28;
    color: #dce4f0;
    text-transform: none;
  }

  #serverHealth {
    flex: none;
    max-width: none;
    gap: 0.08rem;
    justify-items: center;
    text-align: center;
    line-height: 1.2;
    text-transform: none;
    letter-spacing: 0;
  }

  .footer-meta-primary {
    font-size: 0.78rem;
    font-weight: 800;
  }

  .footer-meta-secondary {
    font-size: 0.55rem;
    color: #99a3b3;
  }

  .live-controls {
    gap: 0.7rem;
  }

  .live-secondary-action {
    width: 2.45rem;
    height: 2.45rem;
  }

  .live-secondary-action .material-symbols-outlined {
    font-size: 1.05rem;
  }

  .mic-action-core {
    width: 4.15rem;
    height: 4.15rem;
  }

  .mic-action-core .material-symbols-outlined {
    font-size: 1.55rem;
  }

  .mic-action-glow {
    inset: -0.55rem;
  }

  .debug-panel {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    bottom: calc(var(--live-footer-space-mobile) + 0.75rem);
    width: auto;
  }

  .start-button {
    width: 10.5rem;
    height: 10.5rem;
  }
}

@media (max-width: 420px) {
  .screen-live {
    --live-footer-space-mobile: 10.4rem;
  }

  .conversation-shell {
    padding-bottom: calc(var(--live-footer-space-mobile) + 0.4rem);
  }

  .footer-statusline {
    margin-bottom: 0.28rem;
  }

  #statusMessage {
    font-size: 0.64rem;
  }

  .footer-meta-primary {
    font-size: 0.72rem;
  }

  .footer-meta-secondary {
    font-size: 0.5rem;
  }

  #serverHealth[data-mode="cost"] .footer-meta-secondary {
    display: none;
  }

  .live-controls {
    gap: 0.55rem;
  }

  .live-secondary-action {
    width: 2.3rem;
    height: 2.3rem;
  }

  .mic-action-core {
    width: 3.95rem;
    height: 3.95rem;
  }
}
