:root {
  --ink: #1e2936;
  --ink-muted: #5c6b7a;
  --paper: #eef1f4;
  --paper-raised: #f8fafb;
  --brand: #3a5f73;
  --brand-strong: #2d4b5c;
  --brand-soft: rgba(58, 95, 115, 0.1);
  --line: rgba(30, 41, 54, 0.1);
  --line-soft: rgba(30, 41, 54, 0.06);
  --shadow: 0 12px 28px rgba(30, 41, 54, 0.07);
  --radius: 14px;
  --font-display: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(800px 420px at 90% -10%, rgba(58, 95, 115, 0.07) 0%, transparent 55%),
    linear-gradient(180deg, #e8ecf0 0%, var(--paper) 40%, #e9edf1 100%);
  background-attachment: fixed;
}

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.1rem 0 2.5rem;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.15rem 1.25rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
}
.mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: #f4f7f9;
}
.wordmark-text {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.wordmark-name { font-size: 1.12rem; font-weight: 600; }
.wordmark-sub {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-muted);
}
.topbar-tag {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.75rem;
  align-items: center;
  overflow: hidden;
  border-radius: 20px;
  padding: 2.35rem 2.1rem;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.9rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(58, 95, 115, 0.05);
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero h1 {
  margin: 0 0 0.85rem;
  max-width: 18ch;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.6vw, 2.7rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.lede {
  margin: 0 0 1.4rem;
  max-width: 38rem;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink-muted);
}

.cta-row { display: flex; gap: 0.65rem; flex-wrap: wrap; }
.fine {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: rgba(30, 41, 54, 0.48);
}

/* ---------- hero visual: stacked passes ---------- */

.hero-visual {
  position: relative;
  min-height: 280px;
}
.pass-stack {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.pass-card {
  position: absolute;
  width: min(268px, 84%);
  padding: 0.95rem 1.1rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 20px rgba(30, 41, 54, 0.06);
}
.pass-card.back {
  transform: translate(-34px, -78px) rotate(-5deg);
  opacity: 0.5;
}
.pass-card.mid {
  transform: translate(18px, -30px) rotate(2.5deg);
  opacity: 0.75;
}
.pass-card.front {
  transform: translate(-4px, 48px);
  border-color: rgba(58, 95, 115, 0.28);
  animation: lift 7s ease-in-out infinite;
}
.pass-label {
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
}
.pass-card.front .pass-label { color: var(--brand); }
.pass-figure {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.pass-figure span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-muted);
}
.pass-facts {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0 0;
  list-style: none;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.pass-facts li {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--brand-soft);
  font-size: 0.72rem;
  color: var(--brand-strong);
}
.sweep { display: none; }

@keyframes lift {
  0%, 100% { transform: translate(-4px, 48px); }
  50% { transform: translate(-4px, 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .pass-card.front, .bubble { animation: none; }
  .bubble.typing span { animation: none; opacity: 0.55; }
}

/* ---------- buttons ---------- */

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.78rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: var(--brand);
  color: #f4f7f9;
}
.btn.primary:hover { background: var(--brand-strong); }
.btn.primary:disabled { opacity: 0.6; cursor: progress; transform: none; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { border-color: rgba(30, 41, 54, 0.28); }

/* ---------- steps ---------- */

.steps { margin-top: 1rem; }
.steps ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.steps li {
  padding: 1rem 1.1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(248, 250, 251, 0.8);
}
.step-num {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--brand);
}
.steps h3 {
  margin: 0.45rem 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
}
.steps p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* ---------- workspace ---------- */

.workspace {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 0.85rem;
}

.chat-panel, .result-panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  height: min(68vh, 640px);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.result-panel {
  overflow-y: auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.1rem 0.7rem;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.step-pill {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(58, 95, 115, 0.35) transparent;
}

.bubble {
  max-width: 86%;
  padding: 0.78rem 0.95rem;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: rise 220ms ease;
}
.bubble.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.bubble.user {
  align-self: flex-end;
  background: var(--brand);
  color: #f4f7f9;
  border-bottom-right-radius: 4px;
}

.bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.7rem 0.9rem;
  min-height: 2.4rem;
  width: fit-content;
}
.bubble.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.35;
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-4px); opacity: 0.85; }
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1.1rem 1.05rem;
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.78rem 0.9rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
.composer input:focus {
  outline: 2px solid rgba(58, 95, 115, 0.28);
  outline-offset: 1px;
}

/* ---------- result panel ---------- */

.result-empty {
  margin: 1.1rem;
  padding: 1.15rem;
  border-radius: 12px;
  border: 1px dashed rgba(30, 41, 54, 0.2);
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

.result-loading {
  margin: 1.1rem;
  padding: 1.4rem 1.2rem 1.3rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

/* display:flex above would otherwise keep this visible despite the hidden attribute */
.result-empty[hidden],
.result-loading[hidden],
.result-body[hidden],
.json-block[hidden] {
  display: none !important;
}

.loading-orb {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.loading-orb span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.35;
  animation: bounce 1.1s ease-in-out infinite;
}
.loading-orb span:nth-child(2) { animation-delay: 0.15s; }
.loading-orb span:nth-child(3) { animation-delay: 0.3s; }

.loading-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.loading-sub {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

.loading-bars {
  width: 100%;
  display: grid;
  gap: 0.45rem;
}
.loading-bar {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(58, 95, 115, 0.08) 0%,
    rgba(58, 95, 115, 0.18) 45%,
    rgba(58, 95, 115, 0.08) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.loading-bar.short { width: 62%; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-5px); opacity: 0.9; }
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-orb span, .loading-bar { animation: none; opacity: 0.55; }
}

.result-body {
  padding: 1.1rem 1.1rem 0.5rem;
  display: grid;
  gap: 0.65rem;
}
.summary-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.05rem;
}
.summary-card h3 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}
.revision-label {
  display: inline-block;
  margin: 0 0 0.65rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.summary-body {
  margin: 0 0 0.8rem;
  white-space: pre-wrap;
  line-height: 1.55;
}
.summary-label {
  margin: 0.85rem 0 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
}
.summary-list {
  margin: 0 0 0.45rem;
  padding-left: 1.1rem;
  line-height: 1.5;
}
.summary-disclaimer {
  margin: 0.85rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--ink-muted);
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.55rem;
}
.metric .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 0.2rem;
}
.metric .value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}
.metric.quote {
  border-color: rgba(58, 95, 115, 0.22);
  background: rgba(58, 95, 115, 0.04);
}
.metric.quote .value { color: var(--brand-strong); font-size: 1.6rem; }

.json-block {
  margin: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 0.7rem;
}
.json-block summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brand-strong);
}
.json-block pre {
  margin: 0.65rem 0 0;
  padding: 0.75rem;
  max-height: 220px;
  overflow: auto;
  border-radius: 10px;
  background: #1e2936;
  color: #d5dde5;
  font-size: 0.76rem;
}

/* ---------- footer ---------- */

.site-foot {
  margin-top: 1.5rem;
  padding: 1rem 0.15rem 0;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.83rem;
  color: var(--ink-muted);
}
.site-foot p { margin: 0; }
.site-foot strong { color: var(--ink); font-weight: 600; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  .hero, .workspace { grid-template-columns: 1fr; }
  .hero { padding: 1.75rem 1.3rem; }
  .hero-visual { min-height: 230px; order: -1; }
  .steps ol { grid-template-columns: 1fr; }
  .topbar-tag { display: none; }
  .chat-panel, .result-panel { height: min(62vh, 560px); min-height: 380px; }
}
