:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 10px 30px rgba(15,23,42,0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.92);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-icon { color: var(--primary); }
.site-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.site-nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  text-decoration: none;
}
.site-nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }

/* Intro */
.intro { padding: 48px 0 32px; }
.intro h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 0 24px;
}
.intro-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
}
.stat-num {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 4px; font-size: 1.35rem; }
.card-sub { color: var(--text-muted); margin: 0 0 20px; font-size: 0.95rem; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.full-width { grid-column: 1 / -1; }
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field textarea { resize: vertical; }

.severity-field { grid-column: 1 / -1; }
.severity-control {
  display: flex;
  align-items: center;
  gap: 12px;
}
.severity-control input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  padding: 0;
  border: none;
}
.severity-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.severity-control input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.severity-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 28px;
  text-align: center;
}
.severity-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-subtle);
  padding: 0 2px;
}

.form-actions {
  flex-direction: row !important;
  gap: 10px;
  padding-top: 4px;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); }

/* Calibration */
.calibration-grid {
  display: grid;
  gap: 10px;
}
.cal-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}
.cal-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 24px;
  text-align: center;
  line-height: 1.4;
}

/* Chart */
.chart-wrap { margin-bottom: 16px; }
.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  font-size: 0.9rem;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
  position: relative;
}
.chart-bar {
  width: 100%;
  max-width: 28px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
  position: relative;
}
.chart-bar:hover { background: var(--primary-hover); }
.chart-bar-label {
  font-size: 0.6rem;
  color: var(--text-subtle);
  margin-top: 4px;
  white-space: nowrap;
}
.chart-bar-value {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
}
.chart-legend { margin-top: 8px; }
.legend-item { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* Insights */
.insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.insight {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--text);
}
.insight strong { color: var(--primary); }

/* Table */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 { margin: 0; }
.section-head .card-sub { margin: 0; }
.entry-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
}
tr:hover td { background: #fafbfc; }
.empty-row td { text-align: center; color: var(--text-subtle); padding: 24px; }
.severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-alt);
}
.severity-badge.s1 { background: #dcfce7; color: #166534; }
.severity-badge.s2 { background: #fef9c3; color: #854d0e; }
.severity-badge.s3 { background: #fed7aa; color: #9a3412; }
.severity-badge.s4 { background: #fecaca; color: #991b1b; }
.severity-badge.s5 { background: #fca5a5; color: #7f1d1d; }
.btn-delete {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.btn-delete:hover { background: var(--danger-light); }

/* Summary */
.summary-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-output {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  font-family: var(--mono);
  max-height: 500px;
  overflow-y: auto;
}
.summary-placeholder { color: var(--text-subtle); font-family: var(--font); margin: 0; }

/* Guide */
.guide { padding: 32px 0; }
.guide h2 { font-size: 1.5rem; margin: 0 0 20px; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.guide-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.guide-block h3 { margin: 0 0 8px; font-size: 1.05rem; }
.guide-block p, .guide-block ul { margin: 0; font-size: 0.92rem; color: var(--text-muted); }
.guide-block ul { padding-left: 18px; }
.guide-block li { margin-bottom: 4px; }

.guide-faq { margin-top: 24px; }
.guide-faq h3 { font-size: 1.15rem; margin: 0 0 12px; }
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  padding: 14px 16px;
}
details summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "+";
  display: inline-block;
  margin-right: 10px;
  color: var(--primary);
  font-weight: 700;
  width: 14px;
}
details[open] summary::before { content: "−"; }
details p { margin: 10px 0 0; font-size: 0.92rem; color: var(--text-muted); padding-left: 24px; }

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer-nav { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.footer-meta { color: var(--text-subtle); font-size: 0.8rem; }

/* Responsive */
@media (max-width: 640px) {
  .intro h1 { font-size: 1.75rem; }
  .lead { font-size: 1rem; }
  .card { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .intro-stats { gap: 12px; }
  .stat { flex: 1; min-width: 0; padding: 12px 14px; }
  .stat-num { font-size: 1.4rem; }
  .chart { height: 140px; }
  .chart-bar-label { font-size: 0.55rem; }
  .site-nav { gap: 0; }
  .site-nav a { font-size: 0.8rem; padding: 6px 8px; }
}

@media (max-width: 400px) {
  .header-inner { height: auto; flex-direction: column; padding: 10px 0; gap: 8px; }
  .site-header { position: static; }
}

/* Print */
@media print {
  .site-header, .site-footer, .form-actions, .entry-actions, .summary-actions, .btn { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
