:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1d2320;
  --ink-2: #4a524e;
  --ink-3: #5a625e;
  --line: #e4e1d9;
  --brand: #1f4d3f;
  --brand-ink: #ffffff;
  --brand-soft: #e6efe9;
  --good: #1e6b46;
  --good-bg: #e3f2e9;
  --attention: #8a5300;
  --attention-bg: #fbf0dc;
  --bad: #9b2c2c;
  --bad-bg: #fbe7e5;
  --info: #234e7a;
  --info-bg: #e5eef8;
  --sample: #5b3f8c;
  --sample-bg: #efe9f8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.04), 0 4px 16px rgba(20, 30, 25, 0.04);
  font-family:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-height: 100vh;
}
h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(1.6rem, 2.5vw, 2.1rem);
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 0.98rem;
  margin-top: 1.25rem;
}
p {
  margin: 0 0 0.75rem;
}
a {
  color: var(--brand);
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #2f7a62;
  outline-offset: 2px;
}
.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  z-index: 10;
}
.skip-link:focus {
  left: 0.5rem;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--brand);
  color: var(--brand-ink);
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
button:hover,
.button:hover {
  background: #173b30;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
button.ghost:hover {
  background: var(--brand-soft);
  color: var(--ink);
}
button.inline {
  min-height: 32px;
  padding: 0.2rem 0.6rem;
}
.link {
  font-weight: 600;
}
.small {
  font-size: 0.86rem;
  color: var(--ink-3);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 0.25rem;
}
.lead {
  color: var(--ink-2);
  font-size: 1.04rem;
  max-width: 62ch;
}
.big {
  font-size: 1.08rem;
  color: var(--ink);
}

/* ---------- sign in ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow);
}
.login-card form {
  display: grid;
  gap: 0.5rem;
  margin: 1.25rem 0 0.75rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.brand small {
  font-weight: 500;
  color: var(--ink-3);
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
}
.access-state {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.93rem;
}
.access-state.ok {
  background: var(--good-bg);
  color: var(--good);
}
.access-state.warn {
  background: var(--attention-bg);
  color: var(--attention);
}
.recovery {
  margin-top: 0.75rem;
  font-size: 0.92rem;
  color: var(--ink-2);
}
.recovery summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
}

/* ---------- workspace frame ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  background: rgba(246, 245, 241, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
#primary-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  flex-wrap: wrap;
}
#primary-nav a {
  padding: 0.5rem 0.8rem;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 0.95rem;
}
#primary-nav a:hover {
  background: var(--brand-soft);
  color: var(--ink);
}
#primary-nav a.active {
  background: var(--brand);
  color: var(--brand-ink);
}
.account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-2);
  font-size: 0.93rem;
}
#menu-toggle {
  display: none;
}
main#main-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem) 3rem;
  outline: none;
}
.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 2.5rem;
  color: var(--ink-3);
  font-size: 0.86rem;
  border-top: 1px solid var(--line);
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}
.grid > .card {
  margin-bottom: 0;
}
.grid + .card {
  margin-top: 1.25rem;
}
.next {
  background: var(--brand);
  color: var(--brand-ink);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 1.25rem;
}
.next .eyebrow {
  color: #b9dccd;
}
.next h2 {
  font-size: 1.35rem;
}
.next p {
  color: #e3efe9;
  max-width: 70ch;
}
.next .small {
  color: #c6ddd3;
  margin-top: 0.6rem;
}
.next button,
.next .button {
  background: #ffffff;
  color: var(--brand);
}
.next button:hover,
.next .button:hover {
  background: #e6efe9;
}

/* ---------- tags ---------- */
.tag {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--info-bg);
  color: var(--info);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.5;
  align-self: center;
}
.tag.good {
  background: var(--good-bg);
  color: var(--good);
}
.tag.attention {
  background: var(--attention-bg);
  color: var(--attention);
}
.tag.muted {
  background: #eeece6;
  color: var(--ink-2);
}
.tag.sample {
  background: var(--sample-bg);
  color: var(--sample);
}

/* ---------- content blocks ---------- */
.facts {
  display: grid;
  gap: 0.6rem;
  margin: 0.75rem 0;
}
.facts.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.facts div {
  min-width: 0;
}
.facts dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-3);
}
.facts dd {
  margin: 0;
}
.plain {
  padding-left: 1.15rem;
  margin: 0.25rem 0 0.75rem;
}
.plain li {
  margin-bottom: 0.25rem;
}
.empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: left;
  color: var(--ink-2);
  background: #fbfaf7;
}
.empty-title {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
aside.info,
div.info {
  background: var(--info-bg);
  color: var(--info);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}
.sample-notice {
  background: var(--sample-bg);
  color: var(--sample);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.problem {
  background: var(--bad-bg);
  color: #5e1c1c;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.problem-title {
  font-weight: 700;
  color: var(--bad);
}
.problem p {
  margin-bottom: 0.35rem;
}
.notice {
  margin-bottom: 1rem;
}
.notice.good {
  background: var(--good-bg);
  color: var(--good);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 500;
}
.notice.bad {
  padding: 0;
}
.loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-3);
  padding: 2rem 0;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}
.todo,
.blockers,
.progress,
.questions,
.sources,
.history {
  list-style: none;
  padding: 0;
  margin: 0;
}
.todo li a {
  display: grid;
  gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.todo li a span {
  color: var(--ink-2);
  font-size: 0.92rem;
}
.todo li a:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.blockers li,
.progress li,
.sources li,
.history li {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}
.blockers li:last-child,
.progress li:last-child,
.sources li:last-child,
.history li:last-child {
  border-bottom: 0;
}
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}
.progress .facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  font-size: 0.92rem;
}
.evidence {
  border: 1px solid var(--line);
  border-left: 4px solid var(--good);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.evidence.counter {
  border-left-color: #c58a2a;
}
.evidence-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.evidence blockquote {
  margin: 0.6rem 0;
  font-size: 1.02rem;
}
.evidence .facts {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  font-size: 0.88rem;
}
.pattern,
.experiment {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.row-button {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  margin-bottom: 0.5rem;
  font-weight: 400;
}
.row-button span {
  color: var(--ink-2);
  font-size: 0.92rem;
}
.row-button:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.recommendation {
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.steps {
  padding-left: 1.2rem;
}

/* ---------- forms ---------- */
.form {
  display: grid;
  gap: 1rem;
}
.field {
  display: grid;
  gap: 0.3rem;
}
label,
legend {
  font-weight: 600;
}
.hint {
  font-size: 0.86rem;
  color: var(--ink-3);
  margin: 0;
}
input[type="text"],
input[type="password"],
textarea {
  font: inherit;
  width: 100%;
  border: 1px solid #cfcbc0;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  background: #fff;
  color: var(--ink);
}
textarea {
  min-height: 88px;
  resize: vertical;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.choice {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  cursor: pointer;
  font-weight: 400;
}
.choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.choice:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}
.choice span {
  display: grid;
}
.choice small {
  color: var(--ink-2);
}
.actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}
.advanced {
  margin-top: 2rem;
  color: var(--ink-3);
  font-size: 0.92rem;
}
.advanced summary {
  cursor: pointer;
}

/* ---------- dialog ---------- */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(680px, 94vw);
  max-height: 86vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
dialog::backdrop {
  background: rgba(20, 25, 22, 0.4);
}
dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
}
#dialog-content {
  padding: 1.25rem;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid,
  .facts.two,
  .progress .facts,
  .evidence .facts {
    grid-template-columns: 1fr;
  }
  .choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }
  .topbar {
    flex-wrap: wrap;
  }
  #primary-nav {
    display: none;
    flex-direction: column;
    order: 3;
    width: 100%;
  }
  #primary-nav.open {
    display: flex;
  }
  .account {
    order: 2;
  }
}
@media (max-width: 520px) {
  .choices {
    grid-template-columns: 1fr;
  }
  .account span {
    display: none;
  }
}

.choices.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.confirm {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  font-weight: 500;
}
.research {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.analysis {
  background: #fbfaf7;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 0.75rem 0;
}
.evidence.neutral {
  border-left-color: #b9b5aa;
}
.evidence-list summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  margin: 0.5rem 0;
}
.section-title {
  margin: 2rem 0 0.75rem;
  font-size: 1.05rem;
  color: var(--ink-2);
}
@media (max-width: 900px) {
  .choices.three {
    grid-template-columns: 1fr;
  }
}
