/* BuildBox - Furniture Assembly Hardware Sorter */
:root {
  --color-bg: #faf9f7;
  --color-surface: #ffffff;
  --color-surface-alt: #f3f1ed;
  --color-border: #dedad4;
  --color-border-strong: #c2bbb2;
  --color-text: #2c2a27;
  --color-text-muted: #6b6660;
  --color-text-light: #948f88;
  --color-accent: #c4652a;
  --color-accent-hover: #a85320;
  --color-accent-light: #fdf0e8;
  --color-accent-bg: #fff8f2;
  --color-danger: #b53d2b;
  --color-danger-light: #fdf2f0;
  --color-warn: #b8860b;
  --color-warn-light: #fff8e1;
  --color-success: #3a7d32;
  --color-success-light: #f0f7ee;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.10);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --transition: .2s ease;
  --max-width: 1120px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--color-accent-hover); }

img, svg { display: block; max-width: 100%; }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.skip-link {
  position: absolute; top: -100%;
  left: 1rem; z-index: 9999;
  background: var(--color-accent); color: #fff;
  padding: .5rem 1rem; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 0; }

/* Header */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}
.logo {
  display: flex; align-items: center; gap: .5rem;
  color: var(--color-text); text-decoration: none; font-weight: 700;
  font-size: 1.15rem;
}
.logo:hover { color: var(--color-accent); }
.logo-icon { flex-shrink: 0; }

.main-nav {
  display: flex; gap: .25rem; align-items: center;
}
.main-nav a {
  color: var(--color-text-muted); text-decoration: none;
  padding: .4rem .75rem; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.main-nav a:hover {
  background: var(--color-surface-alt); color: var(--color-text);
}

/* Hero */
.hero {
  padding: 3.5rem 0 3rem;
  background: linear-gradient(180deg, var(--color-accent-bg) 0%, var(--color-bg) 100%);
}
.hero-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800; line-height: 1.2;
  max-width: 24ch;
}
.hero-sub {
  margin-top: 1rem;
  font-size: 1.05rem;
  color: var(--color-text-muted);
  max-width: 52ch;
}
.hero-meta {
  display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap;
}
.badge {
  display: inline-block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Workspace */
.workspace { padding: 2.5rem 0 3rem; }
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

.section-title {
  font-size: 1.15rem; font-weight: 700;
  margin-bottom: 1.25rem;
}

/* Fields */
.field { margin-bottom: 1rem; }
.field-label {
  display: block;
  font-size: .85rem; font-weight: 600;
  margin-bottom: .3rem;
}
.field-label .hint {
  font-weight: 400; color: var(--color-text-light);
}
.field-select, .field-input, .field-textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font-sans);
  font-size: .9rem;
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.field-select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b6660' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}
.field-textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.5;
}
.field-select:focus, .field-input:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(196,101,42,.15);
}

/* Buttons */
.btn-row {
  display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; align-items: center;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: .875rem; font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(196,101,42,.35);
}
.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}
.btn-ghost {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.btn-ghost:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-text-light);
}
.btn-sm { padding: .4rem .85rem; font-size: .8rem; }

.save-status {
  margin-top: .5rem;
  font-size: .8rem;
  color: var(--color-text-muted);
  min-height: 1.2em;
}

/* Details */
.ws-details {
  margin-top: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ws-details-summary {
  padding: .6rem .85rem;
  font-size: .85rem; font-weight: 600;
  cursor: pointer;
  background: var(--color-surface-alt);
  user-select: none;
}
.ws-details-summary:hover { background: var(--color-border); }
.ws-details-body {
  padding: .75rem .85rem;
  font-size: .85rem; color: var(--color-text-muted);
}
.ws-details-body p { margin-bottom: .5rem; }
.ws-details-body dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; }
.ws-details-body dt { font-weight: 700; color: var(--color-text); }
.ws-details-body dd { margin: 0; }

/* Output area */
.output-area {
  min-height: 300px;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem 1.5rem;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--color-text-light);
}
.empty-icon { margin-bottom: .75rem; color: var(--color-border-strong); }
.empty-text { font-size: .9rem; max-width: 30ch; }

.result-actions {
  display: flex; gap: .5rem; margin-top: 1rem;
}

/* Result cards */
.result-header {
  margin-bottom: 1rem;
}
.result-header h3 {
  font-size: 1.1rem; font-weight: 700;
}
.result-header .result-sub {
  font-size: .82rem; color: var(--color-text-muted); margin-top: .15rem;
}

.sorting-mat {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .6rem;
  margin-bottom: 1.5rem;
}
.sort-cell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .6rem;
  text-align: center;
}
.sort-cell .sort-icon {
  font-size: 1.25rem; margin-bottom: .25rem;
}
.sort-cell .sort-label {
  font-size: .75rem; font-weight: 700; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.sort-cell .sort-parts {
  font-size: .78rem; margin-top: .3rem;
  line-height: 1.4;
}
.sort-cell .sort-count {
  display: inline-block;
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-weight: 700;
  font-size: .7rem;
  padding: .1rem .4rem;
  border-radius: 999px;
  margin-top: .3rem;
}

.result-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}
.result-panel-header {
  padding: .6rem .85rem;
  font-size: .85rem; font-weight: 700;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: .4rem;
}
.result-panel-body {
  padding: .7rem .85rem;
  font-size: .85rem;
}
.result-panel-body ul {
  list-style: disc;
  padding-left: 1.25rem;
}
.result-panel-body li { margin-bottom: .3rem; }

.panel-warn .result-panel-header {
  background: var(--color-warn-light);
  border-bottom-color: rgba(184,134,11,.2);
  color: var(--color-warn);
}
.panel-danger .result-panel-header {
  background: var(--color-danger-light);
  border-bottom-color: rgba(181,61,43,.2);
  color: var(--color-danger);
}
.panel-success .result-panel-header {
  background: var(--color-success-light);
  border-bottom-color: rgba(58,125,50,.2);
  color: var(--color-success);
}

.checklist {
  list-style: none;
  counter-reset: steps;
}
.checklist li {
  counter-increment: steps;
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .5rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: .85rem;
}
.checklist li:last-child { border-bottom: none; }
.checklist li::before {
  content: counter(steps);
  flex-shrink: 0;
  width: 1.5rem; height: 1.5rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  margin-top: .1rem;
}
.checklist li.step-warn::before {
  background: var(--color-warn);
}
.checklist li .step-note {
  font-size: .75rem;
  color: var(--color-text-light);
  margin-top: .1rem;
}
.checklist li .step-warn-label {
  display: inline-block;
  font-size: .65rem; font-weight: 700;
  background: var(--color-warn-light);
  color: var(--color-warn);
  padding: .05rem .35rem;
  border-radius: 3px;
  margin-left: .25rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* Printable mat */
.printable-mat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
}
.printable-mat h4 {
  font-size: .9rem; font-weight: 700; margin-bottom: .5rem;
}
.mat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
}
.mat-cell {
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: .5rem;
  text-align: center;
  min-height: 70px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.mat-cell .mat-label {
  font-size: .65rem; font-weight: 700;
  color: var(--color-text-light);
  text-transform: uppercase; letter-spacing: .04em;
}
.mat-cell mat-count {
  font-size: .7rem; color: var(--color-text-muted); margin-top: .1rem;
}

/* Guide section */
.guide-section {
  padding: 3rem 0 4rem;
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.guide-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow var(--transition);
}
.guide-card:hover { box-shadow: var(--shadow-md); }
.guide-card h3 {
  font-size: 1rem; font-weight: 700; margin-bottom: .4rem;
}
.guide-card p {
  font-size: .875rem; color: var(--color-text-muted);
}

.guide-content h3 {
  font-size: 1.05rem; font-weight: 700;
  margin-bottom: .6rem;
}
.guide-content p {
  font-size: .9rem; color: var(--color-text-muted);
  margin-bottom: .75rem;
  max-width: 68ch;
}
.mistake-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin-bottom: 1.5rem;
}
.mistake-list li {
  font-size: .9rem; color: var(--color-text-muted);
  margin-bottom: .5rem;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1.25rem 0;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
}
.footer-copy {
  font-size: .8rem; color: var(--color-text-muted);
}
.footer-nav {
  display: flex; gap: 1rem;
}
.footer-nav a {
  font-size: .8rem; color: var(--color-text-muted);
}
.footer-nav a:hover { color: var(--color-accent); }

/* Print */
@media print {
  .site-header, .site-footer, .hero, .guide-section,
  .ws-input-col, .result-actions, .btn-row, .save-status,
  .ws-details, .main-nav, .badge {
    display: none !important;
  }
  .workspace-grid { display: block; }
  .ws-output-col { width: 100%; }
  body { background: #fff; }
  .sort-cell { break-inside: avoid; }
  .result-panel { break-inside: avoid; }
}

/* Responsive */
@media (max-width: 768px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .hero { padding: 2rem 0 1.75rem; }
  .workspace { padding: 1.5rem 0 2rem; }
  .header-inner { height: 48px; }
  .main-nav a { font-size: .8rem; padding: .3rem .5rem; }
  .mat-grid { grid-template-columns: repeat(2, 1fr); }
  .sorting-mat { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

@media (max-width: 480px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
}



/* 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;
}
