:root {
  color-scheme: dark;
  --bg: #0b0e17;
  --surface: rgba(24, 30, 47, .78);
  --surface-solid: #171d2d;
  --surface-soft: #111624;
  --line: rgba(255, 255, 255, .09);
  --text: #f4f5f8;
  --muted: #a8afc1;
  --accent: #a7f3d0;
  --accent-strong: #55d9a3;
  --accent-ink: #07130f;
  --violet: #c4b5fd;
  --warning: #fbbf24;
  --danger: #fb7185;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -8%, rgba(85, 217, 163, .18), transparent 34rem),
    radial-gradient(circle at 95% 12%, rgba(196, 181, 253, .13), transparent 30rem),
    var(--bg);
}
button, textarea, input { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 3px solid rgba(167, 243, 208, .35);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 0 5vw;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(20px);
  background: rgba(11, 14, 23, .78);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.brand-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--accent-ink);
  font-weight: 850;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  box-shadow: 0 9px 28px rgba(85, 217, 163, .24);
}
.brand strong { display: block; font-size: 1rem; letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); margin-top: 1px; }
.desktop-nav { display: flex; gap: 8px; flex: 1; }
.nav-button, .mobile-nav-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}
.nav-button { padding: 11px 14px; border-radius: 12px; }
.nav-button:hover, .nav-button.is-active { color: var(--text); background: rgba(255,255,255,.06); }

main { width: min(1180px, 90vw); margin: 0 auto; padding: 58px 0 110px; }
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 44px; align-items: center; min-height: calc(100vh - 190px); }
.eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .75rem;
  font-weight: 750;
}
.eyebrow::before { content: ""; width: 27px; height: 1px; background: currentColor; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.8rem, 6.2vw, 5.6rem); line-height: .98; letter-spacing: -.065em; max-width: 820px; margin-bottom: 24px; }
.hero-copy > p { font-size: clamp(1.05rem, 1.6vw, 1.28rem); color: var(--muted); line-height: 1.65; max-width: 670px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.primary, .secondary, .ghost, .danger-button {
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover, .secondary:hover, .ghost:hover { transform: translateY(-1px); }
.primary.compact { padding: 11px 15px; margin-left: auto; }
.secondary { background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.danger-button { background: rgba(251,113,133,.12); color: #fecdd3; border: 1px solid rgba(251,113,133,.28); }

.value-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; color: var(--muted); font-size: .9rem; }
.value-row span { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: rgba(255,255,255,.025); }

.demo-card, .panel, .conversation-card, .result-card, .profile-card, .history-card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.demo-card { border-radius: 30px; padding: 24px; transform: rotate(1.2deg); }
.demo-card-inner { border-radius: 22px; padding: 28px; background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.015)); }
.demo-kicker { color: var(--muted); font-size: .8rem; display: flex; justify-content: space-between; }
.demo-prompt { font-size: 1.34rem; line-height: 1.45; margin: 30px 0; }
.voice-orb {
  width: 86px;
  height: 86px;
  margin: 0 auto 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 0 0 13px rgba(167,243,208,.07), 0 0 0 27px rgba(167,243,208,.035);
  font-size: 1.7rem;
}
.demo-transcript { color: var(--muted); line-height: 1.55; padding: 16px; border-radius: 16px; background: rgba(0,0,0,.2); }
.demo-signal { margin-top: 16px; padding: 16px; border-left: 2px solid var(--accent); background: rgba(167,243,208,.055); }
.demo-signal strong { display: block; margin-bottom: 6px; }
.demo-signal span { color: var(--muted); font-size: .92rem; }

.section-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.section-header h1 { font-size: clamp(2.15rem, 4vw, 3.4rem); margin-bottom: 8px; }
.section-header p { color: var(--muted); margin-bottom: 0; max-width: 680px; line-height: 1.55; }

.companion-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 24px; }
.conversation-card { border-radius: var(--radius); overflow: hidden; }
.conversation-head { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 5px rgba(85,217,163,.09); }
.conversation-body { padding: 28px; }
.prompt-title { font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1.15; letter-spacing: -.035em; margin-bottom: 12px; }
.prompt-help { color: var(--muted); line-height: 1.55; }
.context-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.chip { border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.03); border-radius: 999px; padding: 8px 11px; cursor: pointer; }
.chip.is-selected { background: rgba(167,243,208,.13); color: var(--accent); border-color: rgba(167,243,208,.28); }
.input-wrap { position: relative; }
textarea {
  width: 100%;
  min-height: 205px;
  resize: vertical;
  color: var(--text);
  background: rgba(3, 6, 14, .42);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  line-height: 1.55;
}
textarea::placeholder { color: #71798f; }
.input-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .82rem; margin-top: 9px; }
.composer-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
.voice-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 13px 16px;
  cursor: pointer;
}
.voice-button.is-recording { border-color: rgba(251,113,133,.55); background: rgba(251,113,133,.12); }
.voice-pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.voice-button.is-recording .voice-pulse { background: var(--danger); animation: pulse 1.15s infinite; }
@keyframes pulse { 50% { transform: scale(1.6); opacity: .45; } }

.side-stack { display: grid; align-content: start; gap: 16px; }
.panel { border-radius: 19px; padding: 20px; box-shadow: none; }
.panel h3 { margin-bottom: 10px; font-size: 1rem; }
.panel p, .panel li { color: var(--muted); line-height: 1.55; font-size: .92rem; }
.panel ul { padding-left: 19px; margin-bottom: 0; }
.privacy-note { display: flex; gap: 12px; align-items: flex-start; }
.privacy-icon { flex: 0 0 auto; width: 33px; height: 33px; border-radius: 11px; display: grid; place-items: center; background: rgba(196,181,253,.12); color: var(--violet); }

.loading-card { min-height: 420px; display: grid; place-items: center; text-align: center; }
.loader { width: 62px; height: 62px; border-radius: 50%; border: 3px solid rgba(255,255,255,.07); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 22px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-steps { color: var(--muted); min-height: 26px; }

.result-grid { display: grid; gap: 20px; }
.result-card { border-radius: var(--radius); padding: 25px; box-shadow: none; }
.result-card.featured { background: linear-gradient(145deg, rgba(167,243,208,.13), rgba(24,30,47,.76)); border-color: rgba(167,243,208,.22); }
.result-label { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: .71rem; font-weight: 800; margin-bottom: 10px; }
.result-card h2 { font-size: clamp(1.45rem, 2.8vw, 2rem); letter-spacing: -.025em; }
.result-card p { color: #d4d8e2; line-height: 1.65; }
.advice-steps { display: grid; gap: 12px; counter-reset: advice; }
.advice-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.advice-step::before { counter-increment: advice; content: counter(advice); width: 31px; height: 31px; border-radius: 10px; display: grid; place-items: center; background: rgba(167,243,208,.11); color: var(--accent); font-weight: 750; }
.interpretation-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.interpretation-item { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(0,0,0,.12); }
.interpretation-item small { color: var(--muted); display: block; margin-bottom: 6px; }
.interpretation-item strong { line-height: 1.35; }
.signal-list { display: grid; gap: 12px; }
.signal-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.signal-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 7px; }
.signal-title span:last-child { color: var(--muted); font-size: .82rem; }
.meter { height: 8px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-strong), var(--violet)); }
.validation-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.feedback-box { margin-top: 16px; display: grid; gap: 10px; }
.feedback-box[hidden] { display: none; }
.feedback-box textarea { min-height: 105px; }

.profile-overview { display: grid; grid-template-columns: 1fr 1.7fr; gap: 22px; }
.profile-score { min-height: 245px; border-radius: var(--radius); padding: 28px; background: linear-gradient(145deg, rgba(167,243,208,.15), rgba(196,181,253,.08)); border: 1px solid rgba(167,243,208,.2); }
.score-number { font-size: 4.7rem; letter-spacing: -.08em; font-weight: 850; line-height: 1; margin: 18px 0 8px; }
.score-number span { font-size: 1.1rem; color: var(--muted); letter-spacing: normal; }
.profile-card { border-radius: var(--radius); padding: 25px; box-shadow: none; }
.profile-pattern { padding: 17px 0; border-top: 1px solid var(--line); }
.profile-pattern:first-of-type { border-top: 0; padding-top: 0; }
.pattern-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.pattern-head small { color: var(--muted); }
.pattern-contexts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.pattern-contexts span { font-size: .74rem; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.05); color: var(--muted); }
.empty-state { text-align: center; padding: 60px 20px; border: 1px dashed rgba(255,255,255,.16); border-radius: var(--radius); }
.empty-state p { color: var(--muted); }

.history-list { display: grid; gap: 13px; }
.history-card { border-radius: 18px; padding: 20px; box-shadow: none; cursor: pointer; }
.history-card:hover { border-color: rgba(167,243,208,.23); }
.history-meta { display: flex; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: .79rem; margin-bottom: 10px; }
.history-card h3 { margin-bottom: 8px; }
.history-card p { color: var(--muted); margin-bottom: 0; line-height: 1.5; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: .72rem; background: rgba(167,243,208,.11); color: var(--accent); }

.data-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.data-card { border: 1px solid var(--line); border-radius: 19px; padding: 22px; background: var(--surface-soft); }
.data-card p { color: var(--muted); line-height: 1.55; }
.data-card .actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }

.mobile-nav { display: none; }
.toast { position: fixed; left: 50%; bottom: 28px; translate: -50% 120px; opacity: 0; padding: 12px 17px; border-radius: 999px; background: #f3f4f6; color: #111827; font-weight: 700; z-index: 100; transition: .25s ease; box-shadow: var(--shadow); }
.toast.is-visible { translate: -50% 0; opacity: 1; }

@media (max-width: 900px) {
  .desktop-nav { display: none; }
  .topbar { padding: 0 4.5vw; }
  main { width: min(92vw, 760px); padding-top: 34px; }
  .hero { grid-template-columns: 1fr; min-height: auto; gap: 34px; }
  .demo-card { transform: none; }
  .companion-layout, .profile-overview { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 640px) {
  .topbar { height: 66px; }
  .primary.compact { display: none; }
  main { width: 91vw; padding: 28px 0 98px; }
  h1 { font-size: 3.05rem; }
  .hero-actions > * { width: 100%; }
  .demo-card { padding: 13px; border-radius: 23px; }
  .demo-card-inner { padding: 21px; }
  .conversation-body { padding: 21px; }
  .side-stack, .data-grid, .interpretation-grid { grid-template-columns: 1fr; }
  .composer-actions { align-items: stretch; }
  .composer-actions > * { width: 100%; justify-content: center; }
  .validation-actions > * { flex: 1 1 100%; }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: rgba(11,14,23,.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }
  .mobile-nav-button { display: grid; gap: 4px; place-items: center; padding: 6px 2px; font-size: .69rem; }
  .mobile-nav-button span { font-size: 1.12rem; }
  .mobile-nav-button.is-active { color: var(--accent); }
  .toast { bottom: 82px; max-width: 90vw; text-align: center; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-picker select {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  color: inherit;
  padding: 0 34px 0 12px;
  font: inherit;
  cursor: pointer;
}

.language-picker select option {
  color: #151a28;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .topbar-actions {
    gap: 6px;
  }

  .language-picker select {
    max-width: 94px;
    min-height: 36px;
    padding-left: 8px;
    font-size: .78rem;
  }

  #newSituationHeader {
    display: none;
  }
}
