/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:         #f8f9fa;
  --surface:    #ffffff;
  --border:     #dee2e6;
  --text:       #212529;
  --text-muted: #6c757d;
  --primary:    #0066cc;
  --primary-h:  #004fa3;
  --pass:       #198754;
  --fail:       #dc3545;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg:         #121212;
  --surface:    #1e1e1e;
  --border:     #333333;
  --text:       #e0e0e0;
  --text-muted: #888888;
  --primary:    #4da6ff;
  --primary-h:  #80c1ff;
  --shadow:     0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.5);
}

/* ── Reset / base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  transition: background var(--transition), color var(--transition);
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.header-title h1 { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.1rem; }

.header-controls { display: flex; gap: 0.5rem; }
.ctrl-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition), border-color var(--transition);
}
.ctrl-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}
.section {}
.section h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}
.section-desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }

/* ── Drop zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 1.5rem;
  user-select: none;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(0, 102, 204, 0.04);
}
.drop-zone.has-image {
  border-color: var(--pass);
  border-style: solid;
}
.drop-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.drop-label { color: var(--text-muted); font-size: 0.9rem; }

/* ── CVD grid ─────────────────────────────────────────────────────────────── */
.cvd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.cvd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  transition: box-shadow var(--transition);
}
.cvd-card:hover { box-shadow: var(--shadow-md); }
.cvd-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--border);
  min-height: 120px;
}
.cvd-card-info {
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.cvd-name { font-weight: 600; font-size: 0.95rem; }
.cvd-desc { font-size: 0.78rem; color: var(--text-muted); }
.download-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.45rem;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.cvd-card:hover .download-btn { opacity: 1; pointer-events: auto; }

/* ── Contrast panel ───────────────────────────────────────────────────────── */
.contrast-panel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  align-items: start;
}
@media (max-width: 700px) {
  .contrast-panel { grid-template-columns: 1fr; }
}

.color-inputs { display: flex; flex-direction: column; gap: 1rem; }
.color-field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text-muted); }
.color-row { display: flex; align-items: center; gap: 0.5rem; }
input[type="color"] {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
  background: none;
}
.hex-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  font-family: monospace;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.hex-input:focus { outline: none; border-color: var(--primary); }

.contrast-result { display: flex; flex-direction: column; gap: 1rem; }
.ratio-display { text-align: center; }
.ratio-label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.ratio-value { font-size: 2rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

.wcag-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.wcag-table th, .wcag-table td {
  padding: 0.4rem 0.5rem;
  text-align: center;
  border: 1px solid var(--border);
}
.wcag-table thead th { background: var(--bg); font-weight: 600; }
.wcag-table tbody td:first-child { font-weight: 700; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.pass { background: #d1fae5; color: var(--pass); }
.badge.fail { background: #fee2e2; color: var(--fail); }
[data-theme="dark"] .badge.pass { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge.fail { background: #7f1d1d; color: #fca5a5; }

.contrast-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  min-height: 120px;
}
.contrast-preview {
  width: 100%;
  height: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1rem;
  text-align: center;
  transition: color var(--transition), background var(--transition);
}

.wcag-note {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Suggestions ──────────────────────────────────────────────────────────── */
.suggest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}
.suggest-pair {
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.suggest-pair:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}
.suggest-label { font-size: 1.4rem; font-weight: 700; }
.suggest-ratio { font-size: 0.72rem; font-weight: 600; opacity: 0.85; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
