:root {
  --bg: #f4f1ea;
  --bg-card: #fffcf7;
  --ink: #122033;
  --muted: #5c6b7c;
  --line: #d9d2c5;
  --navy: #0f1c2e;
  --navy-2: #173047;
  --teal: #0f766e;
  --teal-soft: #d9f2ee;
  --green: #1b7a4a;
  --green-soft: #d9f3e4;
  --amber: #b45309;
  --amber-soft: #fde7c7;
  --red: #b42318;
  --red-soft: #fde8e6;
  --rose: #9f1239;
  --info-bg: #f8ecec;
  --shadow: 0 1px 2px rgba(15, 28, 46, 0.06), 0 8px 24px rgba(15, 28, 46, 0.06);
  --radius: 14px;
  --tap: 44px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-pad-top: calc(14px + env(safe-area-inset-top));
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100dvh;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  z-index: 20;
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.site-header {
  background: var(--navy);
  color: #f6f3ee;
  padding: var(--header-pad-top) 16px 18px;
}
.header-inner { max-width: 720px; margin: 0 auto; }
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9d4e2;
}
.site-header h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 700;
}
.attribution {
  margin: 0 0 16px;
  font-size: 0.92rem;
  color: #d7e0ea;
}
.attribution a { color: #9ee0d6; }
.overall-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.9rem;
}
.overall-count { font-variant-numeric: tabular-nums; font-weight: 650; }
.bar {
  margin-top: 8px;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: #2dd4bf;
  border-radius: 99px;
  transition: width 0.25s ease;
}

.toolbar {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.niche-filter {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.chip {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  border-radius: 999px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
}
.chip[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.toolbar-actions { display: flex; gap: 8px; }
.btn {
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  flex: 1;
}
.btn-danger { color: var(--red); border-color: #f0c7c2; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px calc(32px + env(safe-area-inset-bottom));
}
.status-msg, .banner-error {
  background: var(--amber-soft);
  color: #7a3b04;
  padding: 14px 16px;
  border-radius: var(--radius);
}
.banner-error { background: var(--red-soft); color: var(--red); }
.error-box {
  background: var(--red-soft);
  color: #7a1610;
  padding: 16px;
  border-radius: var(--radius);
}
.error-box button { margin-top: 10px; }

.module {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.module.is-info {
  border-color: #e8c4c4;
  background: linear-gradient(180deg, #fff8f8 0%, var(--bg-card) 48px);
}
.module-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 14px 16px;
  min-height: var(--tap);
  cursor: pointer;
}
.module-toggle:focus-visible,
.chip:focus-visible,
.btn:focus-visible,
.seg button:focus-visible,

.check input:focus-visible,
a:focus-visible {
  outline: 3px solid #2dd4bf;
  outline-offset: 2px;
}
.module-kicker {
  grid-column: 1;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.module.is-info .module-kicker { color: var(--rose); }
.module-title {
  grid-column: 1;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}
.module-chevron {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  color: var(--muted);
  font-size: 1.1rem;
}
.module-progress {
  grid-column: 1;
  font-size: 0.82rem;
  color: var(--muted);
}
.module-progress .mini-bar {
  display: block;
  height: 6px;
  margin-top: 6px;
  background: #eee7db;
  border-radius: 99px;
  overflow: hidden;
}
.module-progress .mini-bar > span {
  display: block;
  height: 100%;
  background: var(--teal);
}
.module-body { padding: 0 16px 16px; }
.module-summary {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}
.policy-links {
  list-style: none;
  margin: 0 0 16px;
  padding: 12px;
  background: #fff;
  border: 1px solid #f0d4d4;
  border-radius: 10px;
}
.policy-links li { margin: 0 0 8px; font-size: 0.9rem; }
.policy-links li:last-child { margin: 0; }
.policy-links a { color: var(--teal); word-break: break-word; }

.task {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}
.task:last-child { margin-bottom: 0; }
.task-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.3;
}
.task-summary { margin: 8px 0 0; color: var(--muted); font-size: 0.95rem; }

.risk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  width: fit-content;
}
.risk-low { background: #e8f0ff; color: #1e40af; }
.risk-medium { background: var(--amber-soft); color: var(--amber); }
.risk-high { background: var(--red-soft); color: var(--red); }
.risk-notes { margin: 8px 0 0; font-size: 0.88rem; color: #7a3b04; }

.seg {
  display: flex;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
}
.seg button {
  flex: 1;
  min-height: var(--tap);
  border: 0;
  border-right: 1px solid var(--line);
  background: #f7f4ee;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"].todo { background: #e8edf3; color: var(--ink); }
.seg button[aria-pressed="true"].doing { background: var(--teal-soft); color: var(--teal); }
.seg button[aria-pressed="true"].done { background: var(--green-soft); color: var(--green); }

.task.todo { } 
.task.doing { border-color: #9cd4cd; }
.task.done { border-color: #a8d9bc; background: #f7fbf8; }

h4 {
  margin: 16px 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.steps { margin: 0; padding-left: 1.15rem; }
.steps li { margin: 0 0 10px; }
.steps li:last-child { margin: 0; }
.inference {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber);
}
.sources {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.sources a {
  font-size: 0.8rem;
  color: var(--teal);
  text-decoration: none;
  word-break: break-word;
}
.sources a:hover, .sources a:focus { text-decoration: underline; }
.src-ts { color: var(--muted); font-weight: 600; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { margin: 0; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 0;
}
.check input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--teal);
}
.check span { flex: 1; }

.niche-notes {
  background: #f3f7f6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
}
.niche-notes p { margin: 0 0 8px; }
.niche-notes p:last-child { margin: 0; }
.niche-notes strong { color: var(--navy); }

@media (min-width: 640px) {
  .site-header h1 { font-size: 1.6rem; }
  .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .toolbar-actions { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .bar > span, .module-progress .mini-bar > span { transition: none; }
}
