:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --paper: rgba(255, 252, 247, 0.84);
  --paper-strong: rgba(255, 252, 247, 0.94);
  --ink: #1d1b18;
  --muted: #6d6559;
  --line: rgba(29, 27, 24, 0.12);
  --accent: #006d5b;
  --accent-strong: #004f42;
  --accent-soft: rgba(0, 109, 91, 0.12);
  --warm: #c96a2b;
  --danger: #b12d1a;
  --success-bg: #d7f5e8;
  --success-ink: #0f5f45;
  --warning-bg: #fae5c9;
  --warning-ink: #8a4b1d;
  --danger-bg: #f8d7d1;
  --danger-ink: #8f2416;
  --focus-ring: rgba(0, 109, 91, 0.22);
  --shadow: 0 24px 80px rgba(56, 43, 24, 0.13);
  --shadow-hover: 0 28px 90px rgba(56, 43, 24, 0.18);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(201, 106, 43, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(0, 109, 91, 0.18), transparent 32%),
    linear-gradient(180deg, #faf6ee 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
}

.page-shell {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}

.ambient {
  position: absolute;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.4;
  pointer-events: none;
}

.ambient-left {
  background: rgba(201, 106, 43, 0.28);
  top: -8rem;
  left: -10rem;
}

.ambient-right {
  background: rgba(0, 109, 91, 0.28);
  top: 8rem;
  right: -12rem;
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 2rem;
}

.hero {
  max-width: 48rem;
  margin-bottom: 2rem;
  animation: rise-in 420ms ease-out;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1,
.results-head h2,
.panel-head h2 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.04em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 5rem);
  line-height: 0.94;
  max-width: 12ch;
}

.lede {
  margin: 1.1rem 0 0;
  max-width: 44rem;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.7;
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.cli-callout {
  margin-top: 1.3rem;
  max-width: 52rem;
  display: grid;
  gap: 0.35rem;
}

.agent-handoff {
  margin-top: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.52);
}

.agent-handoff-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.agent-handoff-head h2 {
  margin: 0.2rem 0 0;
  font-size: 1.1rem;
}

.agent-handoff .eyebrow {
  margin-bottom: 0;
}

.agent-handoff-disclosure {
  margin-top: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 247, 0.54);
  overflow: hidden;
}

.agent-handoff-disclosure summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 1rem;
  font: 600 0.95rem/1.3 "IBM Plex Sans", sans-serif;
  color: var(--ink);
}

.agent-handoff-disclosure summary::-webkit-details-marker {
  display: none;
}

.agent-handoff-disclosure summary::after {
  content: "+";
  float: right;
  font-size: 1.1rem;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.agent-handoff-disclosure[open] summary {
  border-bottom: 1px solid var(--line);
}

.agent-handoff-disclosure[open] summary::after {
  content: "−";
}

.agent-handoff-body {
  padding: 0.9rem 1rem 1rem;
}

.agent-handoff-text {
  width: 100%;
  min-height: 17rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(248, 244, 237, 0.94);
  padding: 1rem;
  color: var(--ink);
  font: 0.92rem/1.55 "IBM Plex Sans", sans-serif;
  white-space: pre-wrap;
}

.hero-points span,
.hero-stats span,
.urgency {
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  background: rgba(255, 252, 247, 0.68);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  font-size: 0.92rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel,
.results-shell,
.result-card {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel,
.results-shell {
  border-radius: var(--radius-xl);
  padding: 1.3rem;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h2,
.results-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.panel-head p,
.results-meta,
.submit-hint,
.results-empty,
.status-stats dt,
.meta-label,
.meta-copy {
  color: var(--muted);
}

.match-form textarea {
  width: 100%;
  min-height: 18rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.6);
  padding: 1rem 1.05rem;
  font: inherit;
  line-height: 1.6;
  color: var(--ink);
  outline: none;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.match-form textarea:focus {
  border-color: rgba(0, 109, 91, 0.42);
  box-shadow: 0 0 0 4px rgba(0, 109, 91, 0.08);
}

.match-form textarea.is-invalid,
.alert-form input.is-invalid {
  border-color: rgba(177, 45, 26, 0.35);
  box-shadow: 0 0 0 4px rgba(177, 45, 26, 0.08);
}

.quick-fill-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.52);
}

.secondary-button {
  padding: 0.7rem 1rem;
  background: rgba(255, 252, 247, 0.88);
  color: var(--ink);
  border: 1px solid rgba(29, 27, 24, 0.12);
  box-shadow: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(0, 109, 91, 0.32);
}

.form-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 1rem;
  margin-top: 1rem;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.4rem;
  background: linear-gradient(135deg, var(--accent) 0%, #008e74 100%);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  box-shadow: 0 14px 28px rgba(0, 109, 91, 0.22);
}

.quick-fill-row .submit-hint,
.form-row .submit-hint {
  flex: 1;
  min-width: 0;
}

#quick-fill-openai {
  min-width: 7.5rem;
}

#match-button {
  min-width: 9rem;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

button.is-loading {
  opacity: 1;
}

button.is-loading::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: white;
  animation: spin 820ms linear infinite;
}

.submit-hint {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

.form-feedback {
  margin: 0.85rem 0 0;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 109, 91, 0.16);
  background: rgba(0, 109, 91, 0.1);
  color: var(--accent-strong);
  font-size: 0.92rem;
  line-height: 1.5;
}

.form-feedback.is-error {
  border-color: rgba(177, 45, 26, 0.18);
  background: rgba(177, 45, 26, 0.09);
  color: var(--danger-ink);
}

#billing-message.is-error {
  color: var(--danger-ink);
}

#resolution-banner {
  margin-bottom: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(0, 109, 91, 0.1);
  border: 1px solid rgba(0, 109, 91, 0.16);
  color: var(--accent-strong);
}

.status-meter {
  position: relative;
  height: 0.8rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(29, 27, 24, 0.08);
  margin-bottom: 1rem;
}

.status-bar {
  position: relative;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--warm), var(--accent));
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.status-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.36) 48%, transparent 100%);
  transform: translateX(-100%);
  animation: status-sheen 2.4s ease-in-out infinite;
}

.status-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 0;
}

.status-stats div {
  padding: 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--line);
}

.status-stats dt {
  margin-bottom: 0.2rem;
  font-size: 0.86rem;
}

.status-stats dd {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
}

.results-shell {
  animation: rise-in 520ms ease-out;
}

.results-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.results-meta {
  margin: 0;
  text-align: right;
  font-size: 0.94rem;
}

.results-region {
  display: grid;
  gap: 1rem;
}

.results-empty {
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.3rem;
  background: rgba(255, 255, 255, 0.56);
  border: 1px dashed var(--line);
  line-height: 1.65;
}

.results-region[aria-busy="true"] .results-empty {
  border-style: solid;
}

.results-empty--intro {
  color: var(--muted);
}

.results-empty--loading,
.results-empty--zero,
.results-empty--error {
  display: grid;
  gap: 0.45rem;
}

.results-empty-title {
  margin: 0;
  color: var(--ink);
  font: 700 1.05rem/1.25 "Space Grotesk", sans-serif;
}

.results-empty-copy {
  margin: 0;
}

.results-empty-list {
  margin: 0.25rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.results-empty-list li + li {
  margin-top: 0.3rem;
}

.results-empty--loading .results-empty-title::before {
  content: "";
  display: inline-block;
  width: 0.95rem;
  height: 0.95rem;
  margin-right: 0.6rem;
  vertical-align: -0.1rem;
  border-radius: 50%;
  border: 2px solid rgba(0, 109, 91, 0.2);
  border-top-color: var(--accent);
  animation: spin 820ms linear infinite;
}

.results-empty--zero {
  border-color: rgba(201, 106, 43, 0.22);
  background: rgba(255, 248, 239, 0.8);
}

.results-empty--error {
  border-color: rgba(177, 45, 26, 0.18);
  background: rgba(255, 245, 243, 0.82);
}

.results-list {
  display: grid;
  gap: 1rem;
}

.billing-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0, 109, 91, 0.12);
  background: rgba(255, 255, 255, 0.58);
}

.billing-panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.billing-panel-head h3 {
  margin: 0;
  font: 700 1.1rem/1.2 "Space Grotesk", sans-serif;
}

.billing-actions {
  display: grid;
  gap: 0.85rem;
}

.billing-actions input {
  min-height: 2.8rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  font: inherit;
}

.billing-action-row,
.account-dashboard-grid {
  display: grid;
  gap: 0.75rem;
}

.billing-action-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.billing-status {
  margin: 0 0 0.85rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(201, 106, 43, 0.2);
  background: rgba(255, 248, 239, 0.84);
  color: var(--warning-ink);
}

.result-card {
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  animation: rise-in 320ms ease-out;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.result-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(0, 109, 91, 0.16);
}

.result-card--preview {
  border-color: rgba(0, 109, 91, 0.16);
}

.result-card--paywall {
  border: 1px solid rgba(0, 109, 91, 0.2);
  background: linear-gradient(135deg, rgba(255, 252, 247, 0.96), rgba(241, 249, 246, 0.9));
}

.result-card--locked {
  position: relative;
  border: 1px dashed rgba(29, 27, 24, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 244, 237, 0.86)),
    repeating-linear-gradient(
      -45deg,
      rgba(29, 27, 24, 0.02),
      rgba(29, 27, 24, 0.02) 10px,
      rgba(29, 27, 24, 0.045) 10px,
      rgba(29, 27, 24, 0.045) 20px
    );
}

.result-card--locked:hover {
  transform: none;
}

.grant-detail {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.detail-grid,
.comparison-table {
  display: grid;
  gap: 0.85rem;
}

.detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.comparison-table {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.comparison-card {
  position: relative;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.comparison-remove-button {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(29, 27, 24, 0.12);
  background: rgba(255, 252, 247, 0.92);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.comparison-remove-button:hover {
  color: var(--ink);
  border-color: rgba(0, 109, 91, 0.2);
}

.alert-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.alert-form input {
  flex: 1 1 18rem;
  min-height: 2.8rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  font: inherit;
}

.result-head {
  display: flex;
  gap: 1.25rem;
  justify-content: space-between;
  align-items: start;
}

.result-head-main {
  flex: 1;
  min-width: 0;
}

.result-head h3 {
  margin: 0;
  font-size: clamp(1.28rem, 2vw, 1.55rem);
  line-height: 1.1;
}

.result-head-side {
  display: grid;
  justify-items: end;
  gap: 0.7rem;
}

.score-wrap {
  display: grid;
  gap: 0.28rem;
  justify-items: end;
}

.score-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-links a {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.5rem;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.score-chip--high {
  background: var(--success-bg);
  color: var(--success-ink);
}

.score-chip--medium {
  background: var(--warning-bg);
  color: var(--warning-ink);
}

.score-chip--low {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.meta-row,
.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.95rem;
}

.meta-pill,
.keyword-pill {
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.9rem;
}

.meta-pill--preview,
.lock-badge {
  background: rgba(0, 109, 91, 0.12);
  color: var(--accent-strong);
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 109, 91, 0.15);
  font-size: 0.86rem;
  font-weight: 600;
}

.keyword-pill {
  background: rgba(0, 109, 91, 0.08);
}

.urgency.is-soon {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: rgba(177, 45, 26, 0.22);
}

.result-copy {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.1rem;
}

.translation-note {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 109, 91, 0.14);
  background: rgba(0, 109, 91, 0.06);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.copy-block {
  border-left: 3px solid rgba(0, 109, 91, 0.18);
  padding-left: 0.9rem;
}

.copy-block strong {
  display: block;
  margin-bottom: 0.25rem;
}

.dashboard-widget {
  display: grid;
  gap: 0.4rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.dashboard-widget strong {
  font: 700 1.45rem/1 "Space Grotesk", sans-serif;
}

.result-actions {
  align-items: center;
}

.result-actions .secondary-button,
.result-actions .export-button,
.result-actions a {
  min-height: 2.8rem;
}

.export-button {
  background: linear-gradient(135deg, #1d1b18 0%, #3a342d 100%);
  color: white;
  border: 1px solid rgba(29, 27, 24, 0.08);
  box-shadow: 0 16px 28px rgba(29, 27, 24, 0.16);
}

.export-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(29, 27, 24, 0.22);
}

.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;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 0 0 2.75rem;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  text-align: center;
}

.site-footer a {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

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

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

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

@keyframes status-sheen {
  0%,
  20% {
    transform: translateX(-100%);
  }

  80%,
  100% {
    transform: translateX(160%);
  }
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .quick-fill-row,
  .agent-handoff-head,
  .results-head,
  .result-head,
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .results-meta {
    text-align: left;
  }

  .match-form textarea {
    min-height: 14rem;
  }

  .result-head-side,
  .score-wrap {
    justify-items: start;
  }
}

@media (max-width: 640px) {
  .layout {
    width: min(100vw - 1rem, 100%);
    padding: 1.25rem 0 2rem;
  }

  .panel,
  .results-shell {
    padding: 1rem;
    border-radius: 22px;
  }

  .hero h1 {
    max-width: 11ch;
  }

  .quick-fill-row,
  .form-row {
    gap: 0.75rem;
  }

  #quick-fill-openai,
  #match-button,
  #guest-checkout-button,
  #subscription-checkout-button,
  #credit-unlock-button,
  #refresh-access-button,
  #dashboard-load-button,
  .result-actions .secondary-button,
  .result-actions .export-button {
    width: 100%;
  }

  .result-actions a {
    width: 100%;
    justify-content: center;
  }

  .result-card {
    padding: 1.1rem;
  }

  .meta-row,
  .keyword-row {
    gap: 0.55rem;
  }
}
