:root {
  --ink: #1c1e21;
  --muted: #5b5e63;
  --line: #d8dadc;
  --paper: #ffffff;
  --wash: #f1f3f4;
  --accent: #0b6e5f;
  --accent-dark: #084f45;
  --danger: #a4262c;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, -apple-system, "Segoe UI", Verdana, sans-serif;
  line-height: 1.6;
  font-size: 1rem;
}

.wrap { max-width: 72rem; margin: 0 auto; padding: 0 1.5rem; }
.hero p, .step p, .substeps, .summary { max-width: 60rem; }

.topbar { background: var(--ink); color: #fff; }
.topbar-inner {
  display: flex; align-items: baseline; gap: 0.75rem; padding-top: 0.6rem; padding-bottom: 0.6rem;
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.tagline { color: #c9cccf; font-size: 0.9rem; }
.lang-toggle { margin-left: auto; color: #fff; }

a { color: var(--accent-dark); }
a:hover { color: var(--accent); }

h1 { font-size: 1.7rem; line-height: 1.25; margin: 1.5rem 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 0.5rem; }

.hero p { font-size: 1.05rem; color: var(--muted); max-width: 38rem; }

.steps { list-style: none; margin: 2rem 0; padding: 0; }
.step {
  display: grid; grid-template-columns: 2.5rem 1fr; gap: 1rem;
  padding: 1.25rem 0; border-top: 1px solid var(--line);
}
.step:last-child { border-bottom: 1px solid var(--line); }
.step-num {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem;
}
.step h2 { margin-top: 0.15rem; }
.substeps { margin: 0.5rem 0; padding-left: 1.25rem; }
.substeps li { margin: 0.25rem 0; }

.btn {
  display: inline-block; border: 1px solid transparent; border-radius: var(--radius);
  padding: 0.55rem 1.1rem; font-size: 1rem; font-weight: 600;
  text-decoration: none; cursor: pointer; line-height: 1.4;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-secondary { background: var(--wash); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--muted); color: var(--ink); }
.btn-demo { background: var(--ink); color: #fff; font-size: 1.1rem; padding: 0.8rem 1.6rem; }
.btn-demo:hover { background: #000; color: #fff; }
.btn-big { font-size: 1.1rem; padding: 0.8rem 1.6rem; }
.btn-small { font-size: 0.9rem; padding: 0.35rem 0.8rem; }
.btn[disabled] { opacity: 0.6; cursor: wait; }

label { display: block; font-weight: 600; margin-bottom: 0.2rem; }
.check label { display: inline; font-weight: 400; }
.check small { display: block; }
input[type="file"], input[type="password"] {
  font-size: 1rem; padding: 0.4rem; max-width: 100%;
}
input[type="password"], input[type="text"], input[type="month"] { border: 1px solid var(--line); border-radius: var(--radius); width: 16rem; max-width: 100%; font-size: 1rem; padding: 0.4rem; }
small { color: var(--muted); }

.loading { display: none; margin: 1rem 0; font-weight: 600; }
.loading.htmx-request { display: block; }
.spinner {
  display: inline-block; width: 1rem; height: 1rem; margin-right: 0.5rem;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; vertical-align: -0.15rem;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  border: 1px solid var(--danger); border-radius: var(--radius);
  background: #fdf0f0; color: var(--danger);
  padding: 0.75rem 1rem; margin: 1rem 0; font-weight: 600;
}

.kicker { color: var(--muted); font-weight: 600; margin-bottom: 0; }
.verdict h1 { margin-top: 0; }
.confidence { font-size: 1.05rem; }
.summary { font-size: 1.05rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline;
  padding: 0.6rem 0; border-top: 1px solid var(--line);
}
.timeline time { font-weight: 700; min-width: 6.5rem; }
.timeline .code { font-family: Consolas, monospace; font-weight: 700; }
.timeline .dump { color: var(--muted); }
.timeline .no-dump { color: var(--muted); font-style: italic; }

.findings, .healthy, .checklist { margin: 0; padding: 0; list-style: none; }
.findings li, .checklist li {
  padding: 0.6rem 0; border-top: 1px solid var(--line);
}
.healthy li { padding: 0.3rem 0; }

.badge {
  display: inline-block; font-size: 0.8rem; font-weight: 700;
  border-radius: 999px; padding: 0.1rem 0.6rem; margin-right: 0.5rem;
  vertical-align: 0.1rem;
}
.badge-fact, .badge-done { background: var(--ink); color: #fff; }
.badge-hypothesis, .badge-pending, .badge-unknown {
  border: 1px solid var(--muted); color: var(--ink);
}

.cta-row { margin: 2rem 0 0.5rem; }
.meta { color: var(--muted); font-size: 0.9rem; }

.tabs input[type="radio"] { position: absolute; opacity: 0; }
.tab-labels { display: flex; gap: 0; border-bottom: 2px solid var(--line); }
.tab-labels label {
  padding: 0.5rem 1.25rem; font-weight: 600; cursor: pointer;
  border: 2px solid transparent; border-bottom: none; margin-bottom: -2px;
}
#tab-en:checked ~ .tab-labels label[for="tab-en"],
#tab-es:checked ~ .tab-labels label[for="tab-es"] {
  border-color: var(--line); background: var(--paper);
}
.tab-panel { display: none; border: 2px solid var(--line); border-top: none; padding: 1rem; }
#tab-en:checked ~ #panel-en, #tab-es:checked ~ #panel-es { display: block; }
.tab-panel pre {
  white-space: pre-wrap; word-wrap: break-word; margin: 0;
  font-family: Consolas, monospace; font-size: 0.92rem;
}

.subject { font-weight: 600; }

.serial-box { margin: 1.25rem 0; }
.serial-box label { display: inline; font-weight: 600; margin-right: 0.5rem; }
.serial-box input { width: 14rem; }
.serial-box small { display: block; margin-top: 0.25rem; }

.footer {
  margin-top: 3rem; padding: 1rem 0 2rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem;
}

/* Collect: required/optional tags, localized file pickers */
.tag {
  display: inline-block; font-size: 0.75rem; font-weight: 700; border-radius: 999px;
  padding: 0.05rem 0.55rem; margin-left: 0.4rem; vertical-align: 0.1rem;
}
.tag-required { background: var(--danger); color: #fff; }
.tag-optional { border: 1px solid var(--muted); color: var(--muted); font-weight: 600; }
.field { margin: 1rem 0; }
.field-label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.file-pick { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-btn { display: inline-block; margin: 0; font-weight: 600; }
.file-input:focus-visible + .file-btn { outline: 3px solid var(--accent); outline-offset: 2px; }
.file-name { color: var(--muted); }
.file-name.has-file { color: var(--ink); font-weight: 600; }

/* Collect: OS badge and screenshot guide */
.os-badge {
  display: inline-block; margin: 1.25rem 0 0; padding: 0.2rem 0.75rem;
  border-radius: 999px; background: #e8f0fe; color: #174ea6; font-weight: 700; font-size: 0.9rem;
}
.os-note {
  border: 1px solid #c58a00; background: #fff6e0; border-radius: var(--radius);
  padding: 0.6rem 0.9rem; font-weight: 600;
}
.guide > li { margin: 0.6rem 0; }
.shot { margin: 0.5rem 0 0.75rem; }
.shot img {
  display: block; max-width: 100%; height: auto; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.shot figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.field-error { color: var(--danger); font-weight: 600; margin: 0.4rem 0 0; }
.field.invalid .file-btn { border-color: var(--danger); box-shadow: 0 0 0 2px #fde2e2; }
.keep-open {
  background: #fff6e0; border: 1px solid #c58a00; border-radius: var(--radius);
  padding: 0.6rem 0.9rem; color: #5c3b00; font-weight: 700;
}

/* AI explanations and next steps */
.ai-notes ul, .next-steps ol { margin: 0; padding: 0; }
.ai-notes ul { list-style: none; display: grid; gap: 0.6rem; }
.ai-note {
  display: grid; grid-template-columns: 2rem 1fr; gap: 0.75rem; align-items: start;
  border: 1px solid var(--line); border-left: 6px solid var(--status);
  border-radius: var(--radius); padding: 0.7rem 0.9rem; background: var(--paper);
}
.ai-note p { margin: 0.2rem 0 0; }
.next-steps { border: 2px solid var(--accent); border-radius: var(--radius); padding: 0.5rem 1.25rem 0.75rem; margin: 1rem 0 1.5rem; }
.next-steps h2 { margin-top: 0.5rem; }
.next-steps ol { padding-left: 1.4rem; }
.next-steps li { margin: 0.45rem 0; }
.next-steps .btn { margin-top: 0.35rem; }

.explain { border: 2px solid var(--accent); border-radius: var(--radius); padding: 0.25rem 1.25rem 1rem; margin: 1.5rem 0; background: #f4faf8; }
.explain h3 { font-size: 1.05rem; margin: 1rem 0 0.3rem; }
.btn-ai { font-size: 1.05rem; padding: 0.7rem 1.4rem; }
.ex-overview { font-size: 1.1rem; }
.ex-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.ex-action { color: var(--ink); }
.ex-steps { padding-left: 1.4rem; }
.ex-steps li { margin: 0.3rem 0; }
.ex-glossary { margin-top: 1rem; }
.ex-glossary summary { font-weight: 700; cursor: pointer; }
.ex-glossary dt { font-family: Consolas, monospace; font-weight: 700; margin-top: 0.6rem; }
.ex-glossary dd { margin: 0.1rem 0 0 0; }
.tech-note { background: var(--wash); border-radius: var(--radius); padding: 0.6rem 0.8rem; }

/* Two paths and the fix plan */
.two-paths { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1rem 0 0.25rem; }
.path {
  display: flex; flex-direction: column; gap: 0.2rem; text-decoration: none;
  border-radius: var(--radius); padding: 0.8rem 1rem; border: 2px solid var(--accent);
}
.path strong { font-size: 1.1rem; }
.path span { font-size: 0.92rem; }
.path-fix { background: #fff; color: var(--accent-dark); }
.path-fix:hover { background: #eaf5f2; color: var(--accent-dark); }
.path-case { background: var(--accent); color: #fff; }
.path-case:hover { background: var(--accent-dark); color: #fff; }
.path-case span { color: #e6f4f1; }
.fix { border: 2px solid #b45309; border-radius: var(--radius); padding: 0.25rem 1.25rem 1rem; margin: 1.5rem 0; background: #fffbf3; }
.fix-assess { border-radius: var(--radius); padding: 0.6rem 0.8rem; font-size: 1.05rem; }
.fix-likely { background: #dcfce7; color: #14532d; }
.fix-warranty { background: #fef3c7; color: #713f12; }
.fix-steps { padding-left: 1.4rem; display: grid; gap: 0.6rem; }
.fix-step { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem; }
.fix-step p { margin: 0.25rem 0; }
.fix-step.done { opacity: 0.7; }
.fix-step.done .fix-step-title { text-decoration: line-through; }
.fix-check { display: flex; gap: 0.5rem; align-items: center; font-weight: 700; font-size: 1.05rem; }
.fix-check input { width: 1.15rem; height: 1.15rem; }
.fix-meta { color: var(--muted); font-size: 0.9rem; }
.fix-ok { color: #14532d; }
.fix-acts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem !important; }
.fix-acts code { font-size: 0.85rem; }
.local-fix { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.lf-needs-local { font-size: 0.85rem; color: var(--muted); background: var(--wash); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 0.25rem 0.6rem; }
.lf-done { color: #14532d; font-weight: 700; font-size: 0.9rem; }
.lf-error { color: var(--danger); font-weight: 600; font-size: 0.9rem; }
.fix-stop { border-top: 1px solid var(--line); margin-top: 0.9rem; padding-top: 0.6rem; }
.fix-stop small { display: block; margin-top: 0.4rem; }
.tried { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.4rem 1rem 0.8rem; margin: 1rem 0; }
@media (max-width: 36rem) { .two-paths { grid-template-columns: 1fr; } }

/* Diagnosis: verdict card, health grid, chart */
.verdict-card {
  border: 2px solid var(--line); border-left-width: 8px; border-radius: var(--radius);
  padding: 1rem 1.25rem; margin: 0.5rem 0 1.5rem; background: var(--wash);
}
.verdict-card h1 { margin: 0.2rem 0 0.4rem; }
.verdict-card .cta-row { margin: 1rem 0 0.25rem; }
.eyebrow { margin: 0; font-weight: 700; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.03em; }
.key-fact { font-size: 1.15rem; font-weight: 700; margin: 0.25rem 0; }
.status-problem { --status: var(--danger); --status-bg: #fdf0f0; }
.status-attention { --status: #8a5a00; --status-bg: #fff6e0; }
.status-ok { --status: var(--accent); --status-bg: #eaf5f2; }
.status-no_data { --status: var(--muted); --status-bg: var(--wash); }
.verdict-card.status-problem, .verdict-card.status-attention { border-left-color: var(--status); }

.health-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem;
}
.health-card {
  display: grid; grid-template-columns: 2rem 1fr; column-gap: 0.6rem; align-items: center;
  border: 1px solid var(--line); border-top: 4px solid var(--status);
  border-radius: var(--radius); padding: 0.6rem 0.7rem; background: var(--status-bg);
}
.health-icon {
  grid-row: span 2; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--status); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.health-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.health-status { color: var(--status); font-weight: 700; font-size: 0.9rem; }
.health-detail { grid-column: 1 / -1; font-size: 0.9rem; }
.health-detail:not(:empty) { margin-top: 0.35rem; }
.health-detail small { display: block; }

.chart { margin: 0.5rem 0 1rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--danger); }
.chart-axis { stroke: var(--muted); stroke-width: 1; }
.chart-value { font-size: 13px; font-weight: 700; text-anchor: middle; fill: var(--ink); }
.chart-label { font-size: 11px; text-anchor: middle; fill: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.tech { margin: 1.5rem 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 1rem; }
.tech summary { font-weight: 700; cursor: pointer; }
.tech h3 { font-size: 1.05rem; margin: 1rem 0 0.25rem; }
.tech h4 { font-size: 0.95rem; margin: 0.75rem 0 0.25rem; color: var(--muted); }

.ld-steps { margin: 0.5rem 0; padding-left: 1.25rem; font-weight: 400; }
.ld-steps li { opacity: 0.45; }
.job-steps li { animation: none !important; }
.job-steps li.done { opacity: 1; color: var(--accent-dark); }
.job-steps li.active { opacity: 1; font-weight: 700; }
.loading.htmx-request .ld-steps li { animation: ld-step 1s forwards; }
.loading.htmx-request .ld-steps li:nth-child(1) { animation-delay: 0s; }
.loading.htmx-request .ld-steps li:nth-child(2) { animation-delay: 2s; }
.loading.htmx-request .ld-steps li:nth-child(3) { animation-delay: 4s; }
.loading.htmx-request .ld-steps li:nth-child(4) { animation-delay: 40s; }
@keyframes ld-step { to { opacity: 1; font-weight: 700; } }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 36rem) {
  h1 { font-size: 1.4rem; }
  .step { grid-template-columns: 2rem 1fr; gap: 0.75rem; }
  .step-num { width: 2rem; height: 2rem; font-size: 1rem; }
  .btn-big, .btn-demo { width: 100%; text-align: center; }
  .tagline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--line); }
  .ld-steps li { opacity: 1; }
  .loading.htmx-request .ld-steps li { animation: none; }
}
