:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #24211d;
  --muted: #75706a;
  --border: #e4e0d8;
  --accent: #2f5c4b;
  --accent-ink: #ffffff;
  --green: #4c8c5c;
  --yellow: #c99a2e;
  --orange: #cd7f32;
  --red: #b8483d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }

.topbar { background: var(--accent); color: var(--accent-ink); padding: 18px 0; }
.brand-title { font-size: 24px; font-weight: 700; letter-spacing: 0.5px; margin-right: 12px; }
.brand-sub { font-size: 14px; opacity: 0.85; }

.input-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin: 24px auto;
}

.input-panel label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px;
  font-weight: 600;
}
.input-panel label:first-child { margin-top: 0; }

#text-input {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  resize: vertical;
  font-family: inherit;
}

#keywords-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.controls { display: flex; align-items: center; gap: 14px; margin-top: 16px; }

button#check-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 26px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button#check-btn:hover { opacity: 0.92; }
button#check-btn:disabled { opacity: 0.5; cursor: default; }

.hint { color: var(--muted); font-size: 13px; }

.error {
  margin-top: 12px;
  background: #fbeceb;
  border: 1px solid #eec8c4;
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.hidden { display: none !important; }

.results { margin-bottom: 60px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn .badge { margin-left: 6px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card p.desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.risk-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.risk-score {
  font-size: 44px;
  font-weight: 800;
  min-width: 90px;
}
.risk-level-label {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  color: white;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.lvl-green { background: var(--green); }
.lvl-yellow { background: var(--yellow); }
.lvl-orange { background: var(--orange); }
.lvl-red { background: var(--red); }

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 140px 1fr 40px;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 14px;
}
.bar-track { background: #efece4; border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th, table.data-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: #e5f1e6; color: var(--green); }
.pill-warn { background: #fbf1dc; color: var(--yellow); }
.pill-bad { background: #f7e4d6; color: var(--orange); }
.pill-crit { background: #fbe4e1; color: var(--red); }

mark.hl-1 { background: #fdf2c8; }
mark.hl-2 { background: #fbe3a8; }
mark.hl-3 { background: #f6c39a; }
mark { padding: 1px 2px; border-radius: 3px; cursor: help; }

.problem-sentence {
  background: #fbf7ee;
  border-left: 3px solid var(--orange);
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 14px;
  border-radius: 4px;
}

.chip {
  display: inline-block;
  background: #f0ede4;
  border-radius: 999px;
  padding: 3px 10px;
  margin: 3px 4px 3px 0;
  font-size: 13px;
}

.footnote {
  color: var(--muted);
  font-size: 12px;
  padding: 20px;
  border-top: 1px solid var(--border);
}

.density-bar-row { display: grid; grid-template-columns: 140px 1fr 70px 90px; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; }
.density-bar-track { background: #efece4; border-radius: 6px; height: 8px; overflow: hidden; }
.density-bar-fill { height: 100%; background: #6f9c7c; }

.spinner { display:inline-block; width:16px; height:16px; border:2px solid #fff; border-top-color: transparent; border-radius:50%; animation: spin 0.8s linear infinite; vertical-align: middle; margin-right: 8px;}
@keyframes spin { to { transform: rotate(360deg); } }
