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

:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface2: #f1ede7;
  --border: #ddd5ca;
  --text: #1b1714;
  --muted: #7f766d;
  --accent: #c84b2f;
  --green: #1d7f4a;
  --yellow: #a87512;
  --red: #bd3e29;
  --info: #315f8f;
  --font-head: 'Cabinet Grotesk', sans-serif;
  --font-body: 'Instrument Sans', sans-serif;
}

body {
  background:
    linear-gradient(rgba(246, 243, 239, 0.66), rgba(246, 243, 239, 0.78)),
    url("backg.jpg") center top / cover fixed no-repeat,
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
}

header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 3rem;
  border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 10px; }
a.logo { color: var(--text); text-decoration: none; }
.logo-mark {
  width: 36px;
  height: 36px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 900;
}
.logo-name { font-family: var(--font-head); font-size: 1.2rem; font-weight: 500; }
.logo-name strong { font-weight: 900; }
.header-right { display: flex; align-items: center; gap: 14px; }
.tagline { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.4px; }
.help-link {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  line-height: 1.2;
}
.help-link:hover { color: var(--accent); }

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.65);
}
.lang-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.lang-btn.active { color: var(--accent); }
.lang-sep { color: var(--border); font-size: 0.7rem; }

main {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 2rem 5rem;
}

.hero { padding: 4rem 0 2.5rem; }
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 1rem;
  letter-spacing: 0.4px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}
.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
  margin-bottom: 1.2rem;
}
.hero h1 .highlight { color: var(--accent); }
.hero p {
  color: var(--muted);
  font-size: 1rem;
  max-width: 540px;
  font-style: italic;
}

.form-card,
.analysis-card,
.email-section,
.confidence-panel,
.risk-badge-panel,
.red-flag-panel,
.insight-card,
.ex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.form-card {
  padding: 2rem;
  box-shadow: 0 4px 36px rgba(0,0,0,0.055);
}

.input-guide {
  background: #f7fafc;
  border: 1px solid #d9e4ee;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.guide-title {
  color: var(--info);
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.guide-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.guide-grid span {
  background: var(--surface);
  border: 1px solid #d9e4ee;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.32rem 0.6rem;
}

.input-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.6rem;
}

.disclaimer-note {
  color: #8a6500;
  background: #fff8e8;
  border: 1px solid #ead28a;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
}

.form-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group.full { margin-bottom: 1.25rem; }
.label-row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-transform: uppercase;
}
.opt { font-weight: 500; text-transform: none; letter-spacing: 0; }
.char-count { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
input,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
input:focus,
textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(26,23,20,0.06);
}
input::placeholder,
textarea::placeholder { color: #aaa29a; }
textarea { resize: vertical; min-height: 210px; }

.submit-btn {
  width: 100%;
  padding: 1rem 2rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s, transform 0.2s;
}
.submit-btn:hover { background: var(--accent); transform: translateY(-1px); }
.submit-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.loading-state { text-align: center; padding: 5rem 2rem; }
.pulse-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-text { font-family: var(--font-head); font-size: 1.3rem; font-weight: 800; margin-bottom: 0.4rem; }
.load-sub { color: var(--muted); font-size: 0.9rem; }
.ellipsis::after { content: ''; animation: ell 1.5s steps(4, end) infinite; }
@keyframes ell {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

.error-state {
  background: #fff0ee;
  border: 1px solid #f7c9c1;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  color: var(--red);
  margin-top: 1rem;
}

.results-wrapper { animation: fadeUp 0.45s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.verdict-banner {
  border-radius: 8px;
  padding: 1.6rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.verdict-banner.accept { background: #e8f6ef; border: 1px solid #b8dfcb; }
.verdict-banner.negotiate { background: #fff8e5; border: 1px solid #ead28a; }
.verdict-banner.decline { background: #fff0ed; border: 1px solid #f2c2b9; }
.verdict-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.verdict-text {
  font-family: var(--font-head);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0;
}
.accept .verdict-text { color: var(--green); }
.negotiate .verdict-text { color: var(--yellow); }
.decline .verdict-text { color: var(--red); }
.mode-pill {
  display: inline-flex;
  margin-top: 0.65rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.mode-pill.ai { background: #e8f0f8; color: var(--info); }
.mode-pill.local { background: #fff8e5; color: var(--yellow); }
.risk-score-wrap { text-align: right; }
.risk-score-val {
  font-family: var(--font-head);
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}
.risk-score-desc { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.missing-alert {
  background: #fff8e8;
  border: 1px solid #ead28a;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
}
.missing-title { font-weight: 800; font-size: 0.9rem; margin-bottom: 6px; color: #815c00; }
.missing-list { font-size: 0.86rem; color: #6f5000; }

.info-bar {
  background: #eaf1f7;
  border: 1px solid #c8d7e5;
  color: var(--info);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.extract-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.ex-card { padding: 1rem 1.25rem; min-height: 128px; }
.ex-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}
.ex-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 4px;
}
.ex-val { font-size: 0.88rem; font-weight: 600; color: var(--text); line-height: 1.4; overflow-wrap: anywhere; }
.ex-val.missing { color: #aaa29a; font-style: italic; font-weight: 500; }

.analysis-card {
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.25rem;
}
.analysis-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
.analysis-card p { font-size: 0.92rem; line-height: 1.7; }

.confidence-panel {
  padding: 1.2rem 1.35rem;
  margin-bottom: 1.25rem;
}

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

.confidence-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.55rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.confidence-pill {
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  white-space: nowrap;
}

.confidence-pill.high { background: #e8f6ef; color: var(--green); }
.confidence-pill.medium { background: #fff8e5; color: var(--yellow); }
.confidence-pill.low { background: #fff0ed; color: var(--red); }

.risk-badge-panel,
.red-flag-panel {
  padding: 1.2rem 1.35rem;
  margin-bottom: 1.25rem;
}

.risk-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
}

.risk-badge.low {
  background: #e8f6ef;
  color: var(--green);
  border: 1px solid #b8dfcb;
}

.risk-badge.medium {
  background: #fff8e5;
  color: var(--yellow);
  border: 1px solid #ead28a;
}

.risk-badge.high {
  background: #fff0ed;
  color: var(--red);
  border: 1px solid #f2c2b9;
}

.red-flag-panel ul {
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.red-flag-panel li + li { margin-top: 0.45rem; }
.red-flag-panel .empty { color: var(--muted); }

.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.insight-card { padding: 1.2rem 1.35rem; }
.insight-card.wide { grid-column: 1 / -1; }
.insight-card h2 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}
.insight-card ul,
.insight-card ol {
  padding-left: 1.1rem;
  color: var(--text);
  font-size: 0.9rem;
}
.insight-card li + li { margin-top: 0.45rem; }
.insight-card .empty { color: var(--muted); }

.email-section {
  overflow: hidden;
  margin-bottom: 2rem;
}
.email-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.email-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.98rem;
}
.copy-btn {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-body);
  white-space: nowrap;
}
.copy-btn:hover { background: var(--accent); }
.copy-btn.copied { background: var(--green); }
.email-body {
  display: block;
  min-height: 260px;
  border: none;
  border-radius: 0;
  background: var(--surface);
  padding: 1.5rem;
  font-size: 0.92rem;
  line-height: 1.75;
  resize: vertical;
}
.email-body:focus { box-shadow: inset 0 0 0 3px rgba(26,23,20,0.06); border-color: transparent; }

.disclaimer-box {
  color: #8a6500;
  background: #fff8e8;
  border: 1px solid #ead28a;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
}
.back-btn:hover { border-color: var(--text); color: var(--text); }

footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.guide-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.guide-hero {
  padding: 1rem 0 2rem;
}

.guide-hero h1 {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
  margin-bottom: 1rem;
}

.guide-hero p {
  color: var(--muted);
  max-width: 680px;
}

.guide-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.guide-section h2 {
  font-family: var(--font-head);
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
}

.guide-section ul,
.guide-section ol {
  padding-left: 1.2rem;
  font-size: 0.94rem;
}

.guide-section li + li { margin-top: 0.5rem; }

.example-offer {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
  overflow-x: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.footer-disclaimer {
  margin: 0.5rem auto 0;
  max-width: 620px;
  font-size: 0.74rem;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .extract-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(rgba(246, 243, 239, 0.72), rgba(246, 243, 239, 0.84)),
      url("backg.jpg") center top / cover scroll no-repeat,
      var(--bg);
  }
  header {
    padding: 1rem 1.25rem;
    align-items: flex-start;
    gap: 1rem;
  }
  .header-right {
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
  }
  .tagline { display: none; }
  main { padding: 0 1rem 4rem; }
  .hero { padding: 3rem 0 2rem; }
  .form-card { padding: 1.25rem; }
  .form-top,
  .confidence-grid,
  .insight-grid { grid-template-columns: 1fr; }
  .insight-card.wide { grid-column: 1; }
  .verdict-text { font-size: 1.45rem; }
  .risk-score-wrap { text-align: left; }
  .email-header { align-items: flex-start; flex-direction: column; }
}
