:root {
  /* Episyche marketing site palette */
  --bg: #050a14;
  --bg-elevated: #0a121f;
  --surface: #0c1624;
  --surface2: #111d2e;
  --text: #ffffff;
  --muted: #9aa3b2;
  --accent: #ff7d45;
  --accent-dim: #e85d2a;
  --accent-glow: rgba(255, 125, 69, 0.22);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-x: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  line-height: 1.45;
  padding: calc(0.75rem + var(--safe-top)) var(--safe-x) calc(1rem + var(--safe-bottom));
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 100% 80% at 50% -30%, rgba(255, 125, 69, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 60%, rgba(120, 80, 200, 0.06) 0%, transparent 45%),
    radial-gradient(ellipse 60% 40% at 0% 80%, rgba(255, 125, 69, 0.04) 0%, transparent 40%);
}

.customer-app {
  max-width: 52rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

.customer-header {
  padding: 0 0.25rem;
}

.customer-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
}

@media (min-width: 540px) {
  .customer-brand {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: left;
    gap: 1rem;
  }

  .customer-brand-text {
    text-align: left;
  }
}

.customer-logo {
  width: clamp(48px, 11vw, 64px);
  height: auto;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 4px 20px var(--accent-glow));
}

.customer-brand-text {
  min-width: 0;
}

.customer-title {
  margin: 0;
  font-family: "Montserrat", "DM Sans", system-ui, sans-serif;
  font-size: clamp(1.15rem, 3.8vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.25;
}

.customer-title-tag {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
}

@media (min-width: 540px) {
  .customer-title-tag {
    display: inline;
    margin-top: 0;
    margin-left: 0.35rem;
  }
}

.customer-sub {
  margin: 0.4rem 0 0;
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  color: var(--muted);
  max-width: 36rem;
}

.customer-controls {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: clamp(12px, 3vw, 16px);
  padding: clamp(0.85rem, 3vw, 1.15rem);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem 0.85rem;
}

@media (min-width: 480px) {
  .control-grid {
    grid-template-columns: 1fr 1fr;
  }
  .field-span-2 {
    grid-column: span 2;
  }
}

@media (min-width: 720px) {
  .control-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .field-span-2 {
    grid-column: span 2;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field-input {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.field-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: rgba(255, 125, 69, 0.45);
}

.field-input option {
  background: var(--surface2);
  color: var(--text);
}

.customer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.btn-primary,
.btn-secondary {
  min-height: 48px;
  padding: 0.6rem 1.25rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  flex: 1 1 auto;
}

@media (min-width: 400px) {
  .btn-primary,
  .btn-secondary {
    flex: 0 1 auto;
  }
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #ffffff;
  box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text);
}

.status-line {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.customer-stage {
  position: relative;
  min-height: clamp(240px, 52vw, 380px);
  border-radius: clamp(12px, 3vw, 20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}

/* Taller stage + contain scaling so avatar video is not cropped (letterboxing OK). */
.customer-stage.customer-stage--avatar {
  min-height: min(70vh, 580px);
}

.stage-wave,
.stage-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.stage-avatar.hidden,
.hidden {
  display: none !important;
}

/* Full-width wave area (no circular frame) */
.wave-visual {
  width: 100%;
  max-width: min(100%, 40rem);
  flex: 1 1 auto;
  min-height: clamp(200px, 44vw, 300px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.35rem;
  background: radial-gradient(
    ellipse 90% 80% at 50% 45%,
    var(--accent-glow),
    transparent 70%
  );
}

.customer-siriwave {
  width: 100%;
  max-width: min(100%, 36rem);
  height: clamp(200px, 42vw, 300px);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.customer-siriwave canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}

.wave-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.customer-remote-media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  min-height: 0;
}

.customer-remote-media video {
  max-width: 100%;
  max-height: min(62vh, 480px);
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center center;
  border-radius: 12px;
}

.customer-stage--avatar .customer-remote-media video {
  max-height: min(68vh, 520px);
}

.customer-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.chat-scroll {
  max-height: min(44vh, 540px);
  min-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.45rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chat-row {
  display: flex;
  width: 100%;
}

.chat-row--user {
  justify-content: flex-end;
}

.chat-row--assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: min(88%, 34rem);
  padding: 0.5rem 0.72rem;
  border-radius: 10px;
  font-size: clamp(0.9rem, 2.8vw, 1.02rem);
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.bubble--user {
  background: linear-gradient(165deg, #ff7d45 0%, #c44a22 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(255, 125, 69, 0.2);
}

.bubble--assistant {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-bottom-left-radius: 4px;
}

.bubble--interim {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: clamp(0.82rem, 2.4vw, 0.92rem);
  font-style: italic;
  color: var(--muted);
  background: rgba(17, 29, 46, 0.95);
  border: 1px dashed rgba(255, 125, 69, 0.35);
  max-width: min(92%, 36rem);
}

.chat-interim-wrap {
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-strong);
}

.chat-interim-wrap.hidden {
  display: none !important;
}

.chat-interim-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.customer-footer {
  text-align: center;
  padding: 0.5rem 0 0.25rem;
}

.footer-link {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.footer-link:hover {
  color: var(--accent);
}

.mono {
  font-family: ui-monospace, monospace;
}
