:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #1a1d29;
  --muted: #6b7186;
  --accent: #6d5df6;
  --accent-2: #22c1dc;
  --shadow: 0 8px 30px rgba(20, 24, 60, 0.08);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #181b25;
  --border: #2a2e3d;
  --text: #eef0f7;
  --muted: #9aa0b5;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.section { margin-bottom: 40px; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 64px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none;
}
.logo-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 0deg, #f6435d, #f9a825, #38d47b, #22c1dc, #6d5df6, #f6435d);
}
.nav { display: flex; gap: 20px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500; }
.nav a:hover { color: var(--accent); }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 0.95rem;
}
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Hero */
.hero { padding: 64px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -0.02em; }
.gradient-text {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { max-width: 640px; margin: 16px auto 0; color: var(--muted); font-size: 1.05rem; }
.hero-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 20px; }
.hero-links a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.hero-links a:hover { text-decoration: underline; }

.seo-intro h2 { font-size: 1.55rem; margin-bottom: 14px; }
.seo-intro p { color: var(--muted); font-size: 0.96rem; }
.seo-intro p + p { margin-top: 14px; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}
.card-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 16px; }
.card-subtitle { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 10px; }
.card-header-row { display: flex; justify-content: space-between; align-items: center; }

/* Picker layout */
.picker-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }

.dropzone {
  position: relative; border: 2px dashed var(--border); border-radius: 12px;
  min-height: 320px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: crosshair; background: var(--bg);
  transition: border-color 0.2s ease;
}
.dropzone.dragover { border-color: var(--accent); }
.dropzone-hint { position: absolute; text-align: center; color: var(--muted); pointer-events: none; padding: 20px; }
.dropzone.has-image .dropzone-hint { display: none; }
#imageCanvas { max-width: 100%; height: auto; max-height: 520px; display: none; touch-action: none; }
.dropzone.has-image #imageCanvas { display: block; }

.loupe {
  position: fixed; display: none; pointer-events: none; z-index: 100;
  border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

.canvas-actions { display: flex; gap: 12px; margin-top: 16px; }

/* Buttons */
.btn {
  border: none; border-radius: 10px; padding: 10px 18px; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; transition: transform 0.1s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(90deg, var(--accent), #8a7bff); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

/* Result panel */
.swatch {
  height: 90px; border-radius: 12px; border: 1px solid var(--border);
  background: #6d5df6; margin-bottom: 16px; transition: background 0.15s ease;
}
.value-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.value-list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.value-label { width: 48px; font-size: 0.75rem; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; }
.value-list code {
  flex: 1; min-width: 0; font-size: 0.88rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 8px; padding: 6px 10px; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border);
  cursor: pointer; transition: transform 0.1s ease; position: relative;
}
.chip:hover { transform: scale(1.12); z-index: 2; }

/* Manual picker */
.manual-grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.manual-input input[type="color"] {
  width: 100%; height: 120px; border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; background: var(--surface); padding: 6px; margin-bottom: 12px;
}

.page-hero { padding: 56px 0 32px; text-align: center; }
.page-hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; }
.page-hero p { max-width: 640px; margin: 12px auto 0; color: var(--muted); }
.page-content { max-width: 900px; }
.error-page { min-height: calc(100vh - 145px); display: flex; align-items: center; padding: 56px 0; }
.error-page .container { width: 100%; }
.error-card { max-width: 620px; margin: 0 auto; text-align: center; padding: 52px 32px; }
.error-code { color: var(--accent); font-size: clamp(4rem, 14vw, 8rem); font-weight: 800; line-height: 0.95; letter-spacing: -0.06em; }
.error-card h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin-top: 18px; }
.error-message { max-width: 470px; margin: 12px auto 24px; color: var(--muted); }
.page-content h2 { font-size: 1.35rem; margin: 26px 0 10px; }
.page-content h2:first-of-type { margin-top: 0; }
.page-content p { color: var(--muted); }
.page-content p + p { margin-top: 14px; }
.page-content a { color: var(--accent); font-weight: 600; }
.contact-email { font-size: 1.15rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); padding: 28px 0; text-align: center;
  color: var(--muted); font-size: 0.88rem;
}

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 10px;
  font-size: 0.9rem; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Contrast checker */
.contrast-grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.contrast-inputs { display: flex; flex-direction: column; gap: 14px; }
.colour-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.colour-field input[type="color"] {
  width: 100%; height: 48px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); padding: 4px; cursor: pointer;
}
.contrast-preview {
  border: 1px solid var(--border); border-radius: 12px; padding: 28px 24px;
  font-size: 1.15rem; font-weight: 600; margin-bottom: 16px;
  transition: background 0.15s ease, color 0.15s ease;
}
.contrast-results { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.ratio { font-size: 2rem; font-weight: 800; }
.badge-list { list-style: none; display: flex; gap: 8px; }
.badge {
  padding: 6px 14px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  border: 1px solid var(--border); color: var(--muted);
}
.badge.pass { background: #16a34a; border-color: #16a34a; color: #fff; }
.badge.fail { background: #dc2626; border-color: #dc2626; color: #fff; }

/* Gradient generator */
.gradient-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.gradient-controls { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gradient-preview { height: 160px; max-width: 100%; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 16px; }
.code-row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.code-row code {
  flex: 1; min-width: 0; font-size: 0.85rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; overflow-x: auto; white-space: nowrap;
}
.code-row .copy-btn { flex: 0 0 auto; }
input[type="range"] { width: 100%; max-width: 100%; accent-color: var(--accent); }

/* Prevent any tool panel column from stretching past its card */
.picker-grid > *, .manual-grid > *, .contrast-grid > *, .gradient-grid > * { min-width: 0; }
.colour-field { max-width: 100%; }

/* Section headings */
.section-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 8px; }
.section-lead { color: var(--muted); margin-bottom: 24px; max-width: 640px; }

/* Feature highlights */
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.feature .feature-icon { font-size: 1.6rem; }
.feature h3 { font-size: 1rem; margin: 10px 0 6px; }
.feature p { color: var(--muted); font-size: 0.9rem; }

/* How-to steps */
.steps { counter-reset: step; list-style: none; display: grid; gap: 14px; margin-top: 8px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps li::before {
  counter-increment: step; content: counter(step);
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}

/* FAQ */
.faq details {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 10px; background: var(--surface);
}
.faq summary { font-weight: 600; cursor: pointer; }
.faq details[open] summary { color: var(--accent); }
.faq details p { margin-top: 10px; color: var(--muted); font-size: 0.95rem; }

/* Footer */
.footer-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 28px; text-align: left; padding-bottom: 24px; }
.footer-blurb { margin-top: 12px; max-width: 320px; }
.footer-grid h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; color: var(--text); }
.footer-grid ul { list-style: none; }
.footer-grid a { color: var(--muted); text-decoration: none; font-size: 0.9rem; line-height: 1.9; }
.footer-grid a:hover { color: var(--accent); }
.footer-note { border-top: 1px solid var(--border); padding-top: 18px; }

/* Responsive */
@media (max-width: 860px) {
  .picker-grid, .manual-grid, .contrast-grid, .gradient-grid, .footer-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 44px 0 28px; }
  .header-inner { gap: 14px; }
  .nav {
    gap: 14px; min-width: 0; overflow-x: auto; white-space: nowrap;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { font-size: 0.85rem; }
}

@media (max-width: 640px) {
  .container { padding: 0 14px; }
  .card { padding: 18px 16px; }
  .section { margin-bottom: 28px; }
  .section-title { font-size: 1.3rem; }
  .hero-sub { font-size: 0.98rem; }
  .logo { font-size: 1rem; }
  .theme-toggle { padding: 5px 8px; }
  .dropzone { min-height: 230px; }
  .canvas-actions { flex-wrap: wrap; }
  .canvas-actions .btn { flex: 1 1 140px; }
  .swatch { height: 70px; }
  .value-label { width: 42px; font-size: 0.7rem; }
  .value-list code { font-size: 0.8rem; padding: 6px 8px; }
  .copy-btn { padding: 6px 8px; font-size: 0.72rem; }
  .chip { width: 40px; height: 40px; }
  .ratio { font-size: 1.6rem; }
  .contrast-preview { padding: 20px 16px; font-size: 1rem; }
  .features-grid { grid-template-columns: 1fr; }
}
