:root {
  --bg: #f4f1ea;
  --surface: #faf8f3;
  --inset: #eae4d7;
  --tint: #dce8e0;
  --text: #1c2420;
  --muted: #4b564f;
  --subtle: #6b766f;
  --border: #d7cfc0;
  --border-strong: #c2b8a5;
  --forest: #163828;
  --forest-hover: #1f4d37;
  --copper: #b45309;
  --copper-bright: #d97706;
  --copper-soft: #f6e7d4;
  --low: #0f766e;
  --low-bg: #dff0ec;
  --low-border: #99cec4;
  --medium: #b45309;
  --medium-bg: #f7ead7;
  --medium-border: #e5be8a;
  --high: #9a3412;
  --high-bg: #f6e2db;
  --high-border: #dfa898;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.accent-rule { display: flex; height: 5px; width: 100%; }
.accent-forest { flex: 72; background: var(--forest); }
.accent-copper { flex: 28; background: var(--copper-bright); }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { border-radius: 8px; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
}
.badge-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--tint);
  color: var(--forest);
}
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--subtle); }

.header-links { display: flex; gap: 16px; flex-wrap: wrap; }
.nav-link {
  color: var(--forest);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.nav-link:hover { border-bottom-color: var(--forest); }

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.25fr);
  gap: 20px;
  padding-top: 22px;
  padding-bottom: 40px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.panel-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}
.mono-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--subtle);
}

.doc-textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.doc-textarea:focus { border-color: var(--forest); }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; }
.btn-primary { background: var(--forest); color: #f4f1ea; flex: 1; }
.btn-primary:hover:not(:disabled) { background: var(--forest-hover); }
.btn-demo { background: var(--copper-soft); color: #7c2d12; border-color: #e4c197; }
.btn-demo:hover:not(:disabled) { background: #efdabf; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--inset); }

.status-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.status-box.is-error { background: var(--high-bg); border-color: var(--high-border); }
.status-box.is-info { background: var(--tint); }
.status-box p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
  margin-top: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.engine-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.engine-box summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--forest);
}
.engine-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: var(--inset);
  border: 1px solid var(--border);
}
.seg-btn {
  padding: 7px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; }
.field input, .field select {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.help-text { font-size: 11.5px; color: var(--subtle); }

.kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--copper);
  background: var(--copper-soft);
  padding: 3px 8px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.empty-notice h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
}
.empty-notice p { color: var(--muted); }
.check-highlights { padding-left: 18px; color: var(--muted); }
.check-highlights li { margin-bottom: 6px; }
.check-highlights strong { color: var(--text); }

.risk-header { display: flex; align-items: center; gap: 14px; }
.gauge-wrap { position: relative; width: 82px; height: 82px; flex-shrink: 0; }
.gauge-svg { width: 82px; height: 82px; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--inset); stroke-width: 8; }
.gauge-progress {
  fill: none;
  stroke: var(--medium);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 219.9;
  stroke-dashoffset: 219.9;
  transition: stroke-dashoffset 0.5s ease;
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
}
.gauge-max { font-size: 10px; color: var(--subtle); }

.pill-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.risk-pill {
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.risk-pill.risk-low { color: var(--low); background: var(--low-bg); border-color: var(--low-border); }
.risk-pill.risk-medium { color: var(--medium); background: var(--medium-bg); border-color: var(--medium-border); }
.risk-pill.risk-high { color: var(--high); background: var(--high-bg); border-color: var(--high-border); }
.mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--inset);
  color: var(--muted);
}
.exec-summary { margin: 0; font-size: 13px; color: var(--muted); }

.export-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 14px;
  padding: 3px;
  background: var(--inset);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.tab-btn {
  padding: 7px 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: var(--surface); color: var(--text); }
.tab-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
}

.tab-pane { margin-top: 12px; }
.filter-bar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-chip {
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.filter-chip.active { background: var(--forest); color: #f4f1ea; border-color: var(--forest); }

.stack { display: flex; flex-direction: column; gap: 10px; }
.flag-card {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.flag-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.flag-head h3 { margin: 0; font-size: 13.5px; }
.flag-quote {
  margin: 0 0 6px;
  padding: 6px 9px;
  border-left: 3px solid var(--copper-bright);
  background: var(--surface);
  font-style: italic;
  font-size: 12.5px;
  color: var(--muted);
}
.flag-why { margin: 0; font-size: 12.5px; color: var(--muted); }

.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.progress-track { height: 6px; border-radius: 999px; background: var(--inset); overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; width: 0%; background: var(--forest); transition: width 0.2s ease; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.checklist li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.checklist li.checked label { text-decoration: line-through; color: var(--subtle); }

.questions-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.questions-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.q-num {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--tint);
  color: var(--forest);
  font-weight: 700;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.q-text { margin: 0; flex: 1; font-size: 13px; }
.copy-btn {
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--forest);
  color: #f4f1ea;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
}

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