/* ==========================================================================
   Pro Color Extractor — Swiss Studio Design System
   Bespoke zero-dependency styles (Warm Paper Light / Obsidian Graphite Dark)
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #efefec;
  --surface-3: #e5e5e0;
  --border: #e2e2dc;
  --border-strong: #c8c8bf;
  --tx: #141518;
  --tx-2: #4c4f57;
  --tx-3: #717580;
  --cta-bg: #141518;
  --cta-tx: #ffffff;
  --cta-hover: #2a2c33;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: rgba(21, 128, 61, 0.12);
  --aa: #1d4ed8;
  --aa-bg: rgba(29, 78, 216, 0.12);
  --err: #dc2626;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
}

:root.dark {
  color-scheme: dark;
  --bg: #0d0e11;
  --surface: #15171c;
  --surface-2: #1c1f26;
  --surface-3: #252932;
  --border: #262a34;
  --border-strong: #393f4d;
  --tx: #f2f3f5;
  --tx-2: #a5aab6;
  --tx-3: #767c8a;
  --cta-bg: #f2f3f5;
  --cta-tx: #0d0e11;
  --cta-hover: #ffffff;
  --accent: #3b82f6;
  --ok: #4ade80;
  --ok-bg: rgba(34, 197, 94, 0.14);
  --aa: #60a5fa;
  --aa-bg: rgba(59, 130, 246, 0.15);
  --err: #f87171;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--sans);
  line-height: 1.55;
  background: var(--bg);
  color: var(--tx);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

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

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--cta-bg);
  color: var(--cta-tx);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
}

.skip-link:focus {
  top: 1rem;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-inline: 1rem;
}

@media (min-width: 768px) {
  .container {
    padding-inline: 2rem;
  }
}

/* Header */
.topbar {
  position: relative;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__swatches {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.brand__swatches span {
  border-radius: 2px;
}

.brand__name {
  font-size: 0.95rem;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  display: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tx-2);
  transition: color 0.15s, background-color 0.15s;
}

.nav-link:hover {
  color: var(--tx);
  background: var(--surface-2);
}

@media (min-width: 768px) {
  .nav-link {
    display: inline-flex;
    align-items: center;
  }
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--r-md);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn--primary {
  background: var(--cta-bg);
  color: var(--cta-tx);
}

.btn--primary:hover {
  background: var(--cta-hover);
}

.btn--secondary {
  background: var(--surface);
  color: var(--tx);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--xs {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.select-field {
  padding: 0.42rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tx);
  cursor: pointer;
}

.input-field {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  color: var(--tx);
}

.input-field::placeholder {
  color: var(--tx-3);
}

.input-field:focus {
  border-color: var(--accent);
  outline: none;
}

/* Workspace Hero (Tool-First Editorial Architecture) */
.hero-workspace {
  padding-block: 2rem 2.5rem;
}

@media (min-width: 960px) {
  .hero-workspace {
    padding-block: 2.75rem 3rem;
  }
}

.hero-head {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tx-3);
}

.hero-title {
  font-size: clamp(1.85rem, 4vw, 2.85rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  max-width: 22ch;
}

.hero-sub {
  font-size: 1rem;
  color: var(--tx-2);
  max-width: 62ch;
}

/* Studio Capture Grid */
.capture-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 960px) {
  .capture-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  }
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem;
}

.drop-zone {
  position: relative;
  min-height: 250px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
}

.drop-zone__prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.drop-zone__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tx-2);
}

.drop-zone__icon svg {
  width: 20px;
  height: 20px;
}

.drop-zone__title {
  font-size: 0.95rem;
  font-weight: 600;
}

.drop-zone__title span {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.drop-zone__hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--tx-3);
}

/* Interactive Eyedropper Canvas Container */
.preview-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  padding: 0.5rem;
}

#pickerCanvas {
  max-width: 100%;
  max-height: 320px;
  width: auto;
  height: auto;
  display: block;
  cursor: crosshair;
  border-radius: 6px;
}

.preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  font-size: 0.78rem;
}

.eyedropper-readout {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.eyedropper-chip {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.url-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.875rem;
}

.progress-wrap {
  margin-top: 0.75rem;
}

.progress-track {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--cta-bg);
  transition: width 0.25s ease;
}

/* Sample Gallery Panel */
.samples-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.25rem;
}

.samples-card__title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tx-2);
  margin-bottom: 0.35rem;
}

.samples-card__desc {
  font-size: 0.8125rem;
  color: var(--tx-3);
  margin-bottom: 0.9rem;
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.sample-btn {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.45rem;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border);
  text-align: left;
  transition: border-color 0.15s, transform 0.12s;
}

.sample-btn:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.sample-btn canvas {
  width: 100%;
  height: 64px;
  border-radius: 6px;
  display: block;
}

.sample-btn span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tx-2);
}

/* Results Workspace */
.results-section {
  padding-bottom: 3rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
  border-top: 1px solid var(--border);
}

.toolbar__title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.toolbar__meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--tx-3);
  margin-top: 0.15rem;
}

.toolbar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.seg-tabs {
  display: inline-flex;
  padding: 0.2rem;
  gap: 0.15rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.seg-tabs--wrap {
  flex-wrap: wrap;
}

.format-tab,
.export-tab {
  padding: 0.35rem 0.65rem;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tx-2);
  transition: background-color 0.12s, color 0.12s;
}

.format-tab:hover,
.export-tab:hover {
  color: var(--tx);
}

.format-tab.active,
.export-tab[aria-pressed='true'] {
  background: var(--cta-bg);
  color: var(--cta-tx);
}

/* Proportional Dominance Bar */
.palette-bar {
  display: flex;
  height: 52px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.palette-bar__seg {
  position: relative;
  min-width: 6px;
  overflow: hidden;
  transition: flex-grow 0.25s ease, filter 0.15s;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0.35rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.palette-bar__seg:hover {
  flex-grow: 1.6 !important;
}

/* Color Cards Grid */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 0.9rem;
}

.color-swatch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-swatch:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.swatch-top {
  position: relative;
  height: 112px;
  padding: 0.65rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
}

.swatch-chip {
  padding: 0.16rem 0.45rem;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.swatch-body {
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.swatch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.swatch-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--tx-3);
  font-variant-numeric: tabular-nums;
}

.swatch-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.wcag-pill {
  padding: 0.14rem 0.42rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
}

.wcag-pill--aaa {
  background: var(--ok-bg);
  color: var(--ok);
}

.wcag-pill--aa {
  background: var(--aa-bg);
  color: var(--aa);
}

.wcag-pill--low {
  background: var(--surface-2);
  color: var(--tx-3);
}

/* Studio Lower Grid: Context Preview + Code Exporter */
.studio-lower {
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .studio-lower {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  }
}

.panel-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-box__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.85rem 1.15rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.panel-box__title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tx-2);
}

.panel-box__body {
  padding: 1.15rem;
  flex: 1;
}

.context-card {
  padding: 1.25rem;
  border-radius: var(--r-lg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.context-card__eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.context-card__h {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.context-card__p {
  font-size: 0.875rem;
  line-height: 1.5;
  opacity: 0.9;
}

.context-card__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.context-btn {
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.code-scroll {
  display: block;
  padding: 1rem 1.15rem;
  height: 280px;
  max-height: 280px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.6;
  white-space: pre;
  color: var(--tx);
}

.suite-links {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.suite-links__group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Authoritative Documentation / SEO Sections */
.docs-section {
  padding-block: 3rem;
  border-top: 1px solid var(--border);
}

.section-heading {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.section-lead {
  color: var(--tx-2);
  font-size: 0.95rem;
  max-width: 65ch;
  margin-bottom: 1.75rem;
}

.steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .steps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
}

.doc-card__num {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tx-3);
  margin-bottom: 0.5rem;
}

.doc-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.doc-card p {
  font-size: 0.875rem;
  color: var(--tx-2);
}

/* Format Reference Table */
.table-wrap {
  margin-top: 1.5rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

table.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.spec-table th,
.spec-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.spec-table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tx-3);
  background: var(--surface-2);
}

.spec-table tr:last-child td {
  border-bottom: none;
}

.spec-table code {
  font-family: var(--mono);
  font-size: 0.8rem;
}

/* FAQ */
.faq-list {
  display: grid;
  gap: 0.65rem;
  max-width: 860px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.faq-item summary {
  padding: 1rem 1.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--tx-3);
}

.faq-item[open] summary::after {
  content: '−';
}

.faq-item__body {
  padding: 0 1.15rem 1rem;
  font-size: 0.875rem;
  color: var(--tx-2);
}

/* Footer */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: 1.75rem;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--tx-3);
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer__links a:hover {
  color: var(--tx);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Toast */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.65rem 1rem;
  border-radius: var(--r-md);
  background: var(--cta-bg);
  color: var(--cta-tx);
  border: 1px solid var(--border-strong);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.toast--error {
  background: var(--err);
  color: #ffffff;
}
