:root {
  --paper: #f4efe4;
  --paper-2: #fffdf7;
  --ink: #1c1915;
  --ink-soft: #4a453c;
  --rule: #d7ccb8;
  --terracotta: #9a3412;
  --terracotta-deep: #7c2d12;
  --forest: #3f6212;
  --forest-deep: #365314;
  --gold: #b45309;
  --danger: #9f1239;
  --ok: #3f6212;
  --shadow: 0 10px 30px rgba(48, 36, 20, 0.08);
  --radius: 18px;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --serif: "Fraunces", "Palatino Linotype", Georgia, serif;
  --mono: "Source Code Pro", ui-monospace, monospace;
  --space: 1.15rem;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@0.91.12/compiled/OpenDyslexic-Regular.woff2") format("woff2"),
       url("https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@0.91.12/compiled/OpenDyslexic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@0.91.12/compiled/OpenDyslexic-Bold.woff2") format("woff2"),
       url("https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@0.91.12/compiled/OpenDyslexic-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

html.easy {
  --sans: "OpenDyslexic", "Atkinson Hyperlegible", "Source Sans 3", sans-serif;
  --serif: "OpenDyslexic", "Atkinson Hyperlegible", sans-serif;
  --ink: #1a1a1a;
  font-size: 118%;
  letter-spacing: 0.04em;
  word-spacing: 0.16em;
}
html.easy body {
  line-height: 1.75;
}
html.easy p,
html.easy li,
html.easy label,
html.easy td,
html.easy th,
html.easy small {
  line-height: 1.75;
  max-width: 40rem;
}
html.easy h1, html.easy h2, html.easy h3 {
  letter-spacing: 0.02em;
  line-height: 1.35;
}
html.easy em, html.easy i {
  font-style: normal;
  font-weight: 700;
}
html.easy .card, html.easy .hero {
  background: #fffdf7;
}

html.contrast {
  --paper: #fff8ea;
  --ink: #111;
  --ink-soft: #222;
  --rule: #111;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 10% -10%, #f8e7d4 0%, transparent 50%),
    linear-gradient(180deg, var(--paper), #ece4d4);
  color: var(--ink);
  line-height: 1.5;
  overscroll-behavior-y: contain;
  padding-bottom: env(safe-area-inset-bottom);
}

img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--terracotta-deep); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  background: rgba(244, 239, 228, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}
.brand img { width: 36px; height: 36px; }
.brand-title { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.78rem; color: var(--ink-soft); }
.header-meta { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
}
.pill.on {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

.legal-banner {
  background: #2b2118;
  color: #f6efe4;
  padding: 0.55rem 1.25rem;
  font-size: 0.88rem;
}
.install-banner {
  padding: 0.55rem 1.25rem;
  font-size: 0.92rem;
  background: #fff7ed;
  color: #7c2d12;
  border-bottom: 1px solid #fdba74;
}
.install-banner .btn-row { margin-top: 0.4rem; }
.legal-banner a { color: #f3c9a8; }
.legal-banner strong { color: #fff; }

.identity-banner,
.share-banner {
  padding: 0.55rem 1.25rem;
  font-size: 0.92rem;
}
.identity-banner {
  background: #fff4e5;
  color: #7c2d12;
  border-bottom: 1px solid #fdba74;
}
.identity-banner a { color: #9a3412; font-weight: 700; }
.share-banner {
  background: #fff1f2;
  color: #9f1239;
  border-bottom: 1px solid #fda4af;
}
.share-banner a { color: #9f1239; font-weight: 700; }

.demo-banner {
  background: #ecfccb;
  color: #3f6212;
  border-bottom: 1px solid #bef264;
  padding: 0.55rem 1.25rem;
  font-size: 0.92rem;
}
.test-banner {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
  padding: 0.55rem 1.25rem;
  font-size: 0.92rem;
}
.demo-banner button {
  margin-left: 0.5rem;
  border: 1px solid #3f6212;
  background: #fff;
  color: #3f6212;
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 6.5rem);
}
@media (min-width: 961px) {
  .layout.has-nav {
    grid-template-columns: 13rem minmax(0, 1fr);
  }
}
nav.side {
  padding: 1rem 0.8rem;
  border-right: 1px solid var(--rule);
}
nav.side[hidden] { display: none !important; }
nav.side a, nav.side button.linkish {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}
nav.side a.active, nav.side a:hover, nav.side button.linkish:hover {
  background: var(--paper-2);
}
main {
  padding: 1.4rem 1.5rem 4rem;
  max-width: 1100px;
  min-width: 0;
  width: 100%;
}
main h1 {
  font-family: var(--serif);
  font-size: clamp(1.45rem, 4.5vw, 2.35rem);
  line-height: 1.2;
  margin: 0 0 0.6rem;
  overflow-wrap: break-word;
}

.hero {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 28px;
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.1;
  margin: 0 0 0.6rem;
  letter-spacing: -0.03em;
}
.lede { font-size: 1.1rem; max-width: 42rem; color: var(--ink-soft); }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }

.card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  min-width: 0;
  width: 100%;
}
.card h2, .card h3 { font-family: var(--serif); margin-top: 0; }
.muted { color: var(--ink-soft); }
.tiny { font-size: 0.82rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--terracotta);
  background: var(--terracotta);
  color: #fffaf4;
  padding: 0.55rem 1.05rem;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.btn.secondary {
  background: transparent;
  color: var(--terracotta-deep);
}
.btn.ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink);
}
.btn.ok { background: var(--forest); border-color: var(--forest); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

label.field { display: block; margin: 0.7rem 0; min-width: 0; }
label.field span { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  font-size: 16px;
}
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  max-width: none;
  padding: 0;
  accent-color: var(--forest);
}
textarea { min-height: 6rem; resize: vertical; }
textarea.tall { min-height: 7.5rem; }

.readiness-list { list-style: none; padding: 0; margin: 0.6rem 0 1rem; }
.readiness-list li {
  margin: 0.45rem 0;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
}
.readiness-list li.status-ok { background: #ecfccb; }
.readiness-list li.status-bad { background: #ffe4e6; }
.readiness-list li.status-warn { background: #fef3c7; color: var(--gold); font-weight: 700; }
.status-chip {
  display: inline-block;
  min-width: 5.2rem;
  margin-right: 0.45rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  background: #fff;
}
.status-ok .status-chip { color: var(--ok); border: 1px solid var(--ok); }
.status-bad .status-chip { color: var(--danger); border: 1px solid var(--danger); }
.status-warn .status-chip { color: var(--gold); border: 1px solid var(--gold); }
.req-hint {
  display: block;
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}
.report-preview {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #fff;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
  background: #fff;
}
.chip.on { background: #3f6212; color: #fff; border-color: #3f6212; }
.chip.warn { background: #fff7ed; border-color: #fdba74; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }

.kla-block { margin-bottom: 1.2rem; }
.course-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.55rem 0.7rem;
  align-items: start;
  padding: 0.55rem 0.15rem;
  border-bottom: 1px dashed var(--rule);
}
.course-pick input { margin-top: 0.2rem; }
.course-pick span { min-width: 0; }
.course-pick strong { display: block; }
.course-pick small { display: block; color: var(--ink-soft); overflow-wrap: anywhere; }

.status-ok { color: var(--ok); font-weight: 700; }
.status-bad { color: var(--danger); font-weight: 700; }
.callout {
  border-left: 4px solid var(--terracotta);
  padding: 0.7rem 0.9rem;
  background: #fff7ed;
  border-radius: 0 12px 12px 0;
}

.coach {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}
.coach strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 0.1rem 0 0.35rem;
}
.coach p { margin: 0.35rem 0 0.7rem; }
.guide-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0.8rem;
}
.guide-list li {
  display: grid;
  grid-template-columns: 1.2rem minmax(0, 1fr);
  gap: 0.45rem;
  margin: 0.4rem 0;
  align-items: start;
}
.guide-list .done { color: var(--ok); }
.guide-list .done a, .guide-list .done { text-decoration: none; }
.guide-mark { font-weight: 700; }
.tip-wrap {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.2rem;
}
.tip-btn {
  width: 1.55rem;
  height: 1.55rem;
  min-height: 0;
  min-width: 1.55rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--terracotta);
  background: #fff;
  color: var(--terracotta-deep);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.tip-btn:hover, .tip-wrap.open .tip-btn {
  background: var(--terracotta);
  color: #fffaf4;
}
.tip-pop {
  position: absolute;
  z-index: 40;
  left: 0;
  top: calc(100% + 0.4rem);
  width: min(19rem, calc(100vw - 2.5rem));
  background: #2b2118;
  color: #fff7ed;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.45;
  box-shadow: var(--shadow);
}
.tip-pop::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0.55rem;
  border: 6px solid transparent;
  border-top-width: 0;
  border-bottom-color: #2b2118;
}
.tip-pop[hidden] { display: none !important; }

.hidden { display: none !important; }
.toast {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  background: #2b2118;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  max-width: 22rem;
  z-index: 50;
}

.progress-row { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; margin: 0.35rem 0; }
.bar { height: 10px; background: #eadfcb; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--forest); }
.coverage-row { display: grid; grid-template-columns: minmax(0, 10rem) minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; margin: 0.45rem 0; }

.sample-card { display: grid; grid-template-columns: 88px 1fr; gap: 0.8rem; }
.thumb {
  width: 88px; height: 88px; object-fit: cover; border-radius: 12px; background: #eadfcb;
}

.role-card { cursor: pointer; min-height: 8rem; }
.role-card:hover { border-color: var(--terracotta); }

footer.app-foot {
  padding: 1rem 1.25rem 2rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  nav.side {
    display: flex;
    gap: 0.3rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem;
    background: var(--paper);
  }
  nav.side a, nav.side button.linkish {
    white-space: nowrap;
    width: auto;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
  }
  main { padding: 1rem; padding-bottom: 5.5rem; }
  .progress-row, .coverage-row, .sample-card { grid-template-columns: 1fr; }
  .hide-narrow { display: none !important; }
  .brand-sub { display: none; }
  .legal-banner { font-size: 0.78rem; padding: 0.45rem 0.9rem; }
  .header-meta { justify-content: flex-end; }
  .toast { left: 1rem; max-width: none; }
  .chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.8rem;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0.8rem;
}
.capture-actions .btn { flex: 1 1 10rem; }
.capture-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.5rem;
  margin: 0.6rem 0 1rem;
}
.capture-preview figure {
  margin: 0;
  background: #eadfcb;
  border-radius: 12px;
  overflow: hidden;
  min-height: 88px;
}
.capture-preview img, .capture-preview video {
  width: 100%;
  height: 88px;
  object-fit: cover;
  display: block;
}
.capture-preview figcaption {
  font-size: 0.72rem;
  padding: 0.25rem 0.4rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.capture-fab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: 52px;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: var(--terracotta);
  color: #fffaf4;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(122, 40, 16, 0.28);
  cursor: pointer;
  touch-action: manipulation;
}
.capture-fab[hidden] { display: none !important; }
body.has-fab main { padding-bottom: 5.5rem; }

@media print {
  .app-header, nav.side, .legal-banner, .install-banner, .capture-fab, .coach, .tip-wrap, .no-print { display: none !important; }
  .layout { display: block; }
  body { background: white; }
  .card, .hero { box-shadow: none; }
}
