/* JigSketch — Workshop Jig & Template Planner */
:root {
  --c-warm-50: #fdf8f0;
  --c-warm-100: #f5e6cc;
  --c-warm-200: #e8cfa0;
  --c-warm-300: #d4a96a;
  --c-warm-400: #c08a40;
  --c-warm-500: #a06b2a;
  --c-warm-600: #8B5E3C;
  --c-warm-700: #6b4528;
  --c-warm-800: #4a2f1a;
  --c-warm-900: #2e1c0f;
  --c-orange: #e8720c;
  --c-orange-light: #fff3e6;
  --c-green: #3a7d44;
  --c-red: #c0392b;
  --c-text: #2e1c0f;
  --c-text-muted: #6b5a4a;
  --c-bg: var(--c-warm-50);
  --c-surface: #ffffff;
  --c-border: var(--c-warm-200);
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 2px 8px rgba(46,28,15,0.08);
  --shadow-lg: 0 8px 32px rgba(46,28,15,0.12);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --max-w: 1200px;
  --header-h: 60px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body { font-family: var(--font); color: var(--c-text); background: var(--c-bg); line-height: 1.6; }
a { color: var(--c-warm-600); text-decoration: none; }
a:hover, a:focus-visible { color: var(--c-warm-800); text-decoration: underline; }
img, svg { display: block; max-width: 100%; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--c-warm-800);
  border-bottom: 2px solid var(--c-warm-600);
  height: var(--header-h);
}
.header-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--c-warm-100); font-weight: 700; font-size: 1.15rem; }
.logo:hover, .logo:focus-visible { color: #fff; text-decoration: none; }
.logo-text { letter-spacing: 0.02em; }
.main-nav { display: flex; gap: 20px; }
.main-nav a { color: var(--c-warm-200); font-size: 0.9rem; font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; }
.main-nav a:hover, .main-nav a:focus-visible { color: #fff; border-bottom-color: var(--c-orange); text-decoration: none; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--c-warm-800) 0%, var(--c-warm-600) 60%, var(--c-warm-500) 100%);
  color: #fff; padding: 60px 20px; text-align: center;
}
.hero-inner { max-width: 640px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.25; margin-bottom: 12px; }
.hero-sub { font-size: 1.05rem; opacity: 0.85; margin-bottom: 28px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); border: 2px solid transparent;
  font-family: var(--font); font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none; line-height: 1.3;
}
.btn:hover, .btn:focus-visible { text-decoration: none; }
.btn-primary { background: var(--c-orange); color: #fff; border-color: var(--c-orange); }
.btn-primary:hover, .btn-primary:focus-visible { background: #c9600a; border-color: #c9600a; }
.btn-secondary { background: var(--c-warm-600); color: #fff; border-color: var(--c-warm-600); }
.btn-secondary:hover, .btn-secondary:focus-visible { background: var(--c-warm-700); border-color: var(--c-warm-700); }
.btn-ghost { background: transparent; color: var(--c-warm-600); border-color: var(--c-border); }
.btn-ghost:hover, .btn-ghost:focus-visible { background: var(--c-warm-100); border-color: var(--c-warm-400); }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* Sections */
section { padding: 48px 20px; }
.section-heading { font-size: 1.5rem; margin-bottom: 6px; color: var(--c-warm-800); }
.section-sub { color: var(--c-text-muted); margin-bottom: 24px; font-size: 0.95rem; }

/* Planner */
.planner-section { max-width: var(--max-w); margin: 0 auto; }
.planner-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }

.planner-form {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow);
}
.planner-form fieldset { border: none; margin-bottom: 24px; }
.planner-form legend { font-weight: 700; font-size: 0.95rem; color: var(--c-warm-700); margin-bottom: 10px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--c-warm-700); }
.field input, .field select, .field textarea {
  padding: 8px 12px; border: 1.5px solid var(--c-border); border-radius: var(--radius);
  font-family: var(--font); font-size: 0.9rem; color: var(--c-text); background: var(--c-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--c-warm-500); box-shadow: 0 0 0 3px rgba(139,94,60,0.15);
}
.field textarea { resize: vertical; }
.hint { font-size: 0.75rem; color: var(--c-text-muted); }

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--c-border);
  background: var(--c-bg); font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s;
}
.preset-chip:hover { border-color: var(--c-warm-400); background: var(--c-warm-100); }
.preset-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.preset-chip:has(input:checked) {
  background: var(--c-warm-600); color: #fff; border-color: var(--c-warm-600);
}

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 8px; border-top: 1px solid var(--c-border); }

/* Preview */
.planner-preview { display: flex; flex-direction: column; gap: 20px; position: sticky; top: calc(var(--header-h) + 20px); }
.preview-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.preview-card h3 { font-size: 0.95rem; color: var(--c-warm-700); margin-bottom: 12px; }

.diagram-wrap { background: var(--c-warm-50); border-radius: var(--radius); padding: 12px; overflow: hidden; }
#jig-diagram { width: 100%; height: auto; }
.diagram-base { fill: var(--c-warm-200); stroke: var(--c-warm-500); stroke-width: 2; }
.diagram-fence { fill: var(--c-warm-600); }
.diagram-stop { fill: var(--c-orange); }
.diagram-slot { fill: none; stroke: var(--c-warm-700); stroke-width: 2; }
.diagram-label { font-size: 13px; fill: var(--c-warm-700); font-weight: 600; }
.diagram-dim { stroke: var(--c-warm-500); stroke-width: 1; }
.diagram-dim-label { font-size: 11px; fill: var(--c-text-muted); }

.cut-list { font-size: 0.88rem; }
.cut-list table { width: 100%; border-collapse: collapse; }
.cut-list th, .cut-list td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--c-border); }
.cut-list th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-text-muted); }
.cut-list td { font-variant-numeric: tabular-nums; }

.summary-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 0.88rem; }
.summary-list dt { font-weight: 600; color: var(--c-warm-700); }
.summary-list dd { color: var(--c-text); }

/* History */
.history-section { max-width: var(--max-w); margin: 0 auto; }
.saved-plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.saved-plan-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.saved-plan-card h4 { font-size: 1rem; color: var(--c-warm-800); }
.saved-plan-card p { font-size: 0.85rem; color: var(--c-text-muted); }
.saved-plan-card .card-actions { display: flex; gap: 8px; margin-top: auto; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--c-text-muted); }

/* Guide */
.guide-section { max-width: var(--max-w); margin: 0 auto; background: var(--c-warm-100); border-radius: var(--radius-lg); }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 24px; }
.guide-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
  padding: 24px; box-shadow: var(--shadow);
}
.guide-card h3 { font-size: 1rem; color: var(--c-warm-700); margin-bottom: 8px; }
.guide-card p, .guide-card li { font-size: 0.88rem; color: var(--c-text); }
.guide-card ul { padding-left: 18px; margin-top: 6px; }
.guide-card li { margin-bottom: 4px; }

/* Footer */
.site-footer { background: var(--c-warm-800); color: var(--c-warm-200); padding: 32px 20px; margin-top: 48px; }
.footer-inner { max-width: var(--max-w); margin: 0 auto; text-align: center; font-size: 0.85rem; display: flex; flex-direction: column; gap: 10px; }
.footer-inner nav { display: flex; justify-content: center; gap: 20px; }
.footer-inner a { color: var(--c-warm-300); }
.footer-inner a:hover, .footer-inner a:focus-visible { color: #fff; }
.small { font-size: 0.78rem; opacity: 0.7; }

.muted { color: var(--c-text-muted); }

/* Print */
@media print {
  .site-header, .site-footer, .planner-form, .form-actions, .hero, .history-section, .guide-section { display: none !important; }
  body { background: #fff; color: #000; }
  .planner-section { display: block; padding: 0; }
  .planner-layout { display: block; }
  .planner-preview { position: static; }
  .preview-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 16px; }
}

/* Responsive */
@media (max-width: 900px) {
  .planner-layout { grid-template-columns: 1fr; }
  .planner-preview { position: static; }
  .field-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .header-inner { padding: 0 12px; }
  .main-nav { gap: 12px; }
  .main-nav a { font-size: 0.82rem; }
  section { padding: 32px 12px; }
  .planner-form { padding: 18px; }
  .preset-chip { padding: 5px 10px; font-size: 0.78rem; }
  .form-actions { flex-direction: column; }
  .btn { width: 100%; }
  .guide-grid { grid-template-columns: 1fr; }
  .saved-plans-grid { grid-template-columns: 1fr; }
}

/* Focus visible */
:focus-visible { outline: 2px solid var(--c-orange); outline-offset: 2px; }



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