:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-soft: #fffdf8;
  --text: #1f1e1b;
  --muted: rgba(31, 30, 27, 0.62);
  --quiet: rgba(31, 30, 27, 0.42);
  --accent: #d97757;
  --accent-soft: rgba(217, 119, 87, 0.12);
  --accent-strong: #c45f3f;
  --peach: #1f1e1b;
  --input: #fffdf8;
  --focus: #1f1e1b;
  --line: rgba(31, 30, 27, 0.14);
  --line-soft: rgba(31, 30, 27, 0.08);
  --radius: 4px;
  --font-display: "Newsreader", Georgia, serif;
  --font-body: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.4, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Landing theme: no vignette / grain */
body::before,
body::after {
  display: none;
  content: none;
}

/* Slow drifting ambient color */
.ambient {
  display: none;
}

@keyframes ambient-drift {
  from {
    transform: translate3d(-2.5%, -2%, 0) scale(1);
  }

  to {
    transform: translate3d(2.5%, 2%, 0) scale(1.06);
  }
}

/* Light that trails the cursor */
.cursor-glow,
.cursor-glow.is-awake {
  display: none;
}

/* Progress rail across the top */
.progress-rail {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  height: 2px;
  background: rgba(31, 30, 27, 0.08);
  transition: opacity 900ms ease;
}

.progress-rail.is-complete {
  opacity: 0;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  box-shadow: none;
  transition: width 1100ms var(--ease-out);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  padding: 30px clamp(18px, 4vw, 56px) 56px;
}

/* Entrance choreography for the static intro */
.enter {
  animation: enter-rise 950ms var(--ease-out) both;
}

.enter-1 { animation-delay: 60ms; }
.enter-2 { animation-delay: 320ms; }
.enter-3 { animation-delay: 640ms; }
.enter-4 { animation-delay: 940ms; }

@keyframes enter-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: none;
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.company-context {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
}

.company-context.has-kicker {
  flex-direction: column;
  gap: 12px;
}

.context-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--quiet);
}

.context-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-logo img {
  width: 100%;
  height: 100%;
  padding: 7px;
  box-sizing: border-box;
  object-fit: contain;
  border-radius: inherit;
}

.company-logo .logo-letter {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.company-logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: none;
}

.company-logo svg {
  width: 25px;
  height: 25px;
}

.company-context p {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.42rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.company-context span {
  color: var(--muted);
  font-size: 0.96rem;
}

.conversation {
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 26px;
  width: min(650px, 100%);
  padding-block: 48px;
}

.message-line,
.upload-zone,
.file-line,
.working-block,
.facts,
.action-row,
.cover-area,
.save-area,
.sent-banner {
  opacity: 0;
  transform: translateY(16px);
}

.message-line.is-visible,
.upload-zone.is-visible,
.file-line.is-visible,
.working-block.is-visible,
.facts.is-visible,
.action-row.is-visible,
.cover-area.is-visible,
.save-area.is-visible,
.sent-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 780ms ease,
    transform 780ms var(--ease-out);
}

.message-line {
  display: block;
}

p {
  overflow-wrap: anywhere;
}

/* The assistant speaks in a serif voice */
.message-title,
.stream-text {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.06rem, 2.2vw, 1.22rem);
  font-weight: 500;
  letter-spacing: 0.002em;
  line-height: 1.55;
}

/* Streamed words fade in individually */
.w {
  display: inline-block;
  opacity: 0;
  transform: translateY(5px);
  filter: none;
  animation: word-in 380ms var(--ease-out) forwards;
}

@keyframes word-in {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Live caret while streaming */
.stream-text.is-streaming::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.02em;
  margin-left: 4px;
  vertical-align: -0.16em;
  border-radius: 2px;
  background: var(--accent);
  animation: caret-blink 950ms steps(2, jump-none) infinite;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

.message-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  animation: note-in 550ms ease both;
}

@keyframes note-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Upload zone ---------- */

.upload-zone {
  justify-self: center;
  width: min(340px, 100%);
  margin-block: 2px 12px;
}

.upload-target {
  position: relative;
  display: grid;
  place-items: center;
  gap: 13px;
  min-height: 190px;
  padding: 28px 20px;
  border: 1px dashed rgba(31, 30, 27, 0.28);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 240ms ease,
    background 240ms ease,
    transform 240ms var(--ease-spring);
}

.upload-target:hover {
  border-color: rgba(217, 119, 87, 0.5);
  background: rgba(217, 119, 87, 0.045);
}

.upload-target.is-dragging {
  border-color: var(--accent);
  background: rgba(217, 119, 87, 0.09);
  transform: scale(1.025);
}

.upload-target input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid rgba(217, 119, 87, 0.25);
  box-shadow: none;
  transition:
    transform 240ms var(--ease-spring),
    box-shadow 240ms ease;
}

/* No glow halo on cream theme */
.upload-orbit::before {
  display: none;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.92);
  }

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

.upload-orbit svg {
  position: relative;
  width: 42px;
  height: 42px;
  animation: icon-float 4.2s ease-in-out infinite;
}

@keyframes icon-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

.upload-target:hover .upload-orbit,
.upload-target.is-dragging .upload-orbit {
  transform: translateY(-3px);
  box-shadow: none;
  border-color: var(--accent);
}

.upload-text {
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 550;
}

.upload-hint {
  margin-top: -7px;
  color: var(--quiet);
  font-size: 0.84rem;
}

/* ---------- File + working log ---------- */

.file-line {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 550;
}

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

.replace-button {
  margin-left: 6px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--quiet);
  font-size: 0.84rem;
  font-weight: 600;
  transition: color 160ms ease;
}

.replace-button:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 4px;
}

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

.working-block summary {
  width: fit-content;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.working-block summary::-webkit-details-marker {
  display: none;
}

.working-block summary::after {
  content: "  expand";
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 500;
}

.working-block[open] summary::after {
  content: "";
}

.work-list {
  display: grid;
  gap: 9px;
  padding: 13px 0 0;
  margin: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.work-step {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  min-height: 24px;
  color: var(--quiet);
  transition: color 400ms ease;
}

.work-step.is-active {
  color: var(--text);
}

.work-step.is-done {
  color: var(--muted);
}

.work-mark {
  display: inline-block;
  color: var(--accent);
}

.work-step.is-done .work-mark {
  animation: mark-pop 320ms var(--ease-spring);
}

@keyframes mark-pop {
  0% {
    transform: scale(0.3);
  }

  70% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

.work-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(217, 119, 87, 0.3);
  border-top-color: var(--accent);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Extracted facts ---------- */

.facts {
  display: grid;
  gap: 18px;
}

.fact-section {
  display: grid;
  gap: 13px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.fact-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.fact-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: baseline;
}

.fact-kicker,
.fact-status {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.fact-kicker {
  color: var(--quiet);
}

.fact-status {
  color: #2f6b4f;
}

.fact-status.is-warn {
  color: var(--accent);
}

.fact-actions {
  display: flex;
  gap: 14px;
  align-items: baseline;
}

.confirm-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #2f6b4f;
  font-weight: 600;
  transition: color 160ms ease;
}

.confirm-button:hover {
  color: #1f4d38;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.chips-review-note {
  color: var(--accent);
}

.chips-actions {
  margin-top: 2px;
}

.fact-section-title {
  margin: 3px 0 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 620;
  line-height: 1.16;
}

.fact-section-summary {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.fact-section-body {
  display: grid;
  gap: 8px;
}

.fact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--text);
  background: var(--bg-soft);
}

.fact-row.needs-review {
  background: rgba(217, 119, 87, 0.08);
  box-shadow: inset 0 0 0 1px rgba(217, 119, 87, 0.22);
}

.fact-row.needs-review .fact-note {
  color: var(--accent);
}

.fact-value {
  min-width: 0;
}

.fact-value p {
  margin: 0;
  font-weight: 550;
}

.fact-note {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 400;
}

.skill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-chip {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 9px;
  color: var(--muted);
  background: var(--bg-soft);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
}

.skill-edit {
  justify-self: start;
}

.skill-input {
  min-height: 120px;
  resize: vertical;
}

.edit-button,
.ghost-button,
.pill-button,
.text-button,
.file-upload-button {
  border: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 600;
}

.edit-button {
  padding: 0;
  text-underline-offset: 4px;
  transition: color 160ms ease;
}

.edit-button:hover,
.ghost-button:hover,
.text-button:hover {
  color: var(--accent-strong);
}

.edit-button:hover {
  text-decoration: underline;
}

.fact-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--input);
  color: var(--text);
  box-shadow: none;
}

.fact-input:focus {
  border-color: var(--text);
  outline: none;
}

/* ---------- Buttons ---------- */

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.action-row.is-retired {
  opacity: 0.48;
  pointer-events: none;
}

.answer-row .fact-input {
  width: auto;
  flex: 1 1 240px;
  min-height: 42px;
  padding: 8px 14px;
}

.pill-button {
  min-height: 42px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: var(--text);
  box-shadow: none;
  color: var(--bg);
  transition:
    transform 200ms var(--ease-out),
    background 200ms ease,
    color 200ms ease;
}

.pill-button:hover {
  transform: translateY(-2px);
  background: #2c2a26;
  box-shadow: none;
  color: var(--bg);
}

.pill-button:active {
  transform: translateY(0) scale(0.98);
}

.pill-button.is-selected {
  background: var(--accent);
  box-shadow: none;
  color: #fffdf8;
}

.file-upload-button {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 20px;
  background: var(--bg-soft);
  box-shadow: none;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 200ms var(--ease-out),
    background 200ms ease,
    border-color 200ms ease;
}

.file-upload-button:hover {
  transform: translateY(-2px);
  background: var(--bg-soft);
  border-color: var(--text);
  color: var(--text);
}

.file-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.ghost-button {
  min-height: 42px;
  padding: 0 10px;
  color: var(--muted);
  transition: color 160ms ease;
}

/* ---------- Cover letter ---------- */

.cover-area {
  display: grid;
  gap: 14px;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.cover-editor {
  min-height: 180px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--bg-soft);
  color: var(--text);
  box-shadow: none;
  transition: border-color 220ms ease;
}

.cover-editor:focus {
  border-color: var(--text);
  outline: none;
}

.cover-editor::placeholder {
  color: var(--quiet);
}

.cover-file-status {
  min-height: 1.35em;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

/* ---------- Sent banner + save ---------- */

.sent-banner {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding-top: 6px;
}

.sent-check {
  width: 46px;
  height: 46px;
  color: var(--accent);
}

.sent-check circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-dasharray: 152;
  stroke-dashoffset: 152;
  animation: draw-stroke 700ms 150ms var(--ease-out) forwards;
}

.sent-check path {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: draw-stroke 450ms 750ms var(--ease-out) forwards;
}

@keyframes draw-stroke {
  to {
    stroke-dashoffset: 0;
  }
}

.sent-banner p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sent-banner span {
  color: var(--muted);
  font-size: 0.95rem;
}

.save-area {
  display: grid;
  gap: 14px;
}

.save-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  color: var(--muted);
  list-style: none;
}

.save-list li {
  animation: note-in 550ms ease both;
}

.save-list li:nth-child(1) { animation-delay: 120ms; }
.save-list li:nth-child(2) { animation-delay: 240ms; }
.save-list li:nth-child(3) { animation-delay: 360ms; }
.save-list li:nth-child(4) { animation-delay: 480ms; }

.save-list li::before {
  content: "✓ ";
  color: var(--accent);
}

.gsi-slot {
  position: relative;
  display: inline-flex;
  min-height: 46px;
  width: 280px;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
}

.gsi-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.011;
  cursor: pointer;
}

.gsi-overlay > div,
.gsi-overlay iframe {
  width: 100% !important;
  height: 100% !important;
}

.google-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--bg);
  background: var(--text);
  box-shadow: none;
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
}

/* ---------- Confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -5vh;
  left: var(--x);
  width: 8px;
  height: 13px;
  opacity: 0;
  animation: confetti-fall var(--d) var(--delay) cubic-bezier(0.22, 0.4, 0.62, 0.98) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(var(--s));
  }

  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--sway), 108vh, 0) rotate(var(--r)) scale(var(--s));
  }
}

.is-hidden {
  display: none !important;
}

@media (max-width: 700px) {
  .app {
    padding: 22px 18px 40px;
  }

  .conversation {
    align-self: start;
    padding-top: 54px;
  }

  .company-logo {
    width: 42px;
    height: 42px;
  }

  .company-context p {
    font-size: 1.22rem;
  }

  .fact-section-head,
  .fact-row {
    grid-template-columns: 1fr;
  }

  .edit-button {
    justify-self: start;
  }

  .cursor-glow {
    display: none;
  }
}

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

  .cursor-glow,
  .confetti {
    display: none;
  }
}
