/* QuickSketch — minimal editorial UI */

:root {
  --bg: #F5F5F0;
  --surface: #FFFFFF;
  --text: #1A1A1A;
  --text-muted: #6B6B66;
  --text-subtle: #9A9A94;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --border: #E8E8E3;
  --border-strong: #D4D4CE;
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.04);
  --shadow-md: 0 4px 24px rgba(26, 26, 26, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --nav-height: 64px;
  --transition: 0.18s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  background: rgba(245, 245, 240, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav__brand {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav__link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.nav__link:hover {
  color: var(--text);
}

.nav__divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.nav__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: background var(--transition);
}

.nav__status.is-online .status-dot {
  background: #22C55E;
}

.nav__status.is-offline .status-dot {
  background: #EF4444;
}

/* ── Hero ── */

.hero {
  max-width: 720px;
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.25rem, 4vw, 3rem) clamp(2rem, 4vw, 3rem);
}

.hero__eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.hero__title {
  margin: 0 0 1.25rem;
  font-family: var(--font-serif);
  font-size: clamp(2.75rem, 6vw, 4.25rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--text);
}

.hero__subtitle {
  margin: 0;
  max-width: 520px;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.hero--performance {
  max-width: 900px;
  padding-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.35rem;
}

.hero-meta__item {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ── Workspace ── */

.workspace {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
  padding: 0 clamp(1.25rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem);
  max-width: 1400px;
  margin: 0 auto;
}

.workspace__main {
  display: flex;
  gap: 1rem;
  min-width: 0;
}

.performance-page {
  max-width: 1240px;
  margin: 0 auto;
  padding-bottom: clamp(3rem, 6vw, 5rem);
}

.report-section {
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  margin-bottom: clamp(2.5rem, 4vw, 3.5rem);
}

.section-header {
  margin-bottom: 1.35rem;
  max-width: 720px;
}

.section-header__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.section-header__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-card,
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.summary-card {
  padding: 1.1rem 1.15rem;
  min-height: 122px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.summary-card--placeholder {
  background: rgba(255, 255, 255, 0.7);
}

.summary-card__label {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.summary-card__value {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-weight: 500;
  line-height: 1.1;
  color: var(--text);
  text-wrap: balance;
}

.report-note {
  margin: 1rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.report-note--error {
  color: #B91C1C;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.artifact-card {
  padding: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.artifact-card__header {
  margin-bottom: 1rem;
}

.artifact-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.artifact-card__meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.chart-card {
  padding: 1.15rem;
  min-width: 0;
}

.chart-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.chart-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chart-card__meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-legend__swatch--train {
  background: var(--accent);
}

.chart-legend__swatch--val {
  background: #111827;
}

.chart-shell {
  min-height: 280px;
}

.chart-shell__empty {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-subtle);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.matrix-figure {
  margin: 0;
}

.matrix-image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.matrix-caption {
  margin-top: 0.875rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.metrics-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  background: var(--surface);
}

.metrics-table th,
.metrics-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.875rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.metrics-table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  background: rgba(245, 245, 240, 0.65);
}

.metrics-table tbody th {
  font-weight: 600;
  color: var(--text);
}

.metrics-table tbody tr:hover {
  background: rgba(245, 245, 240, 0.55);
}

.metrics-table tbody tr:last-child th,
.metrics-table tbody tr:last-child td {
  border-bottom: none;
}

.metrics-table__empty {
  text-align: center;
  color: var(--text-subtle);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.insight-card {
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 180px;
}

.insight-card--placeholder {
  background: rgba(255, 255, 255, 0.7);
}

.insight-card__eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.insight-card__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.insight-card__body {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.performance-body .nav__links {
  gap: 1rem;
}

.chart-plot {
  fill: var(--bg);
  stroke: none;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-line,
.chart-axis-tick {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--text-subtle);
  font-size: 11px;
  font-family: var(--font-sans);
}

.chart-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line--train,
.chart-point--train {
  stroke: var(--accent);
  fill: var(--accent);
}

.chart-line--val,
.chart-point--val {
  stroke: #111827;
  fill: #111827;
}

.nav__link.is-active {
  color: var(--text);
}

/* ── Tool rail ── */

.tool-rail {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 52px;
  height: 52px;
  padding: 0.4rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.tool-btn svg {
  width: 20px;
  height: 20px;
}

.tool-btn__label {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tool-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.tool-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-btn--primary {
  color: var(--accent);
}

.tool-btn--primary:hover {
  background: var(--accent-soft);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-rail__divider {
  height: 1px;
  margin: 0.25rem 0.5rem;
  background: var(--border);
}

/* ── Canvas area ── */

.canvas-area {
  flex: 1;
  min-width: 0;
}

.canvas-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: min(72vh, 640px);
}

#sketch-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='3' fill='none' stroke='%23FFFFFF' stroke-width='3'/%3E%3Ccircle cx='12' cy='12' r='3' fill='none' stroke='%231A1A1A' stroke-width='1.5'/%3E%3Cpath d='M12 1.5v7M12 16.5v6M1.5 12h7M16.5 12h6' stroke='%23FFFFFF' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M12 1.5v7M12 16.5v6M1.5 12h7M16.5 12h6' stroke='%231A1A1A' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, crosshair;
}

.canvas-card.is-eraser #sketch-canvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ccircle cx='14' cy='14' r='8' fill='none' stroke='%23FFFFFF' stroke-width='3'/%3E%3Ccircle cx='14' cy='14' r='8' fill='none' stroke='%231A1A1A' stroke-width='1.5'/%3E%3Cpath d='M14 4v4M14 20v4M4 14h4M20 14h4' stroke='%23FFFFFF' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M14 4v4M14 20v4M4 14h4M20 14h4' stroke='%231A1A1A' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 14 14, cell;
}

.canvas-hint {
  margin: 0.875rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  text-align: center;
}

/* ── Results panel ── */

.results-panel {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.results-panel__header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.results-panel__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.results-panel__meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.results-panel__body {
  flex: 1;
  padding: 1.25rem 1.5rem;
}

.results-panel__footer {
  padding: 0.75rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
}

.results-empty,
.results-loading,
.results-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 200px;
  text-align: center;
}

.results-empty p,
.results-loading p,
.results-error p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 220px;
  line-height: 1.55;
}

.results-error p {
  color: #B91C1C;
}

.is-hidden {
  display: none !important;
}

/* Spinner */

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Result cards */

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-card {
  padding: 1rem 1.125rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}

.result-card:first-child {
  border-color: var(--border-strong);
  background: var(--surface);
}

.result-card__rank {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.result-card:first-child .result-card__rank {
  color: var(--accent);
}

.result-card__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
}

.result-card__name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.2;
  text-transform: capitalize;
}

.result-card__confidence {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.result-card__bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.result-card__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.result-card:not(:first-child) .result-card__bar-fill {
  background: var(--text-subtle);
}

/* Categories */

.categories-details {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.categories-details summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition);
  user-select: none;
}

.categories-details summary:hover {
  color: var(--text);
}

.categories-details[open] summary {
  margin-bottom: 0.75rem;
  color: var(--text);
}

.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-chip {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  text-transform: capitalize;
}

/* Buttons */

.btn-text {
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text:hover {
  color: var(--accent-hover);
}

/* ── Footer ── */

.site-footer {
  padding: 1.5rem clamp(1.25rem, 4vw, 3rem);
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

/* ── Responsive ── */

@media (max-width: 1024px) {
  .performance-page {
    padding-bottom: 3rem;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .results-panel {
    min-height: auto;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .performance-body .nav {
    height: auto;
    min-height: var(--nav-height);
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .performance-body .nav__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 0.45rem;
  }

  .performance-body .nav__link {
    display: inline-flex;
  }

  .workspace__main {
    flex-direction: column;
  }

  .chart-card__header {
    flex-direction: column;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .hero-meta {
    gap: 0.5rem;
  }

  .hero-meta__item {
    width: 100%;
    justify-content: center;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: auto;
  }

  .insight-grid {
    grid-template-columns: 1fr;
  }

  .insight-card {
    min-height: auto;
  }

  .metrics-table {
    min-width: 560px;
  }

  .tool-rail {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }

  .tool-rail__divider {
    display: none;
  }

  .tool-btn {
    width: 48px;
    height: 48px;
  }

  body:not(.performance-body) .nav__link {
    display: none;
  }

  body:not(.performance-body) .nav__divider {
    display: none;
  }

  .canvas-card {
    aspect-ratio: 1;
    max-height: none;
  }
}
