/* ===== CSS Custom Properties ===== */
:root {
  --color-bg: #fafaf9;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f5f9;
  --color-primary: #0369a1;
  --color-primary-dark: #075985;
  --color-primary-light: #e0f2fe;
  --color-accent: #d97706;
  --color-accent-light: #fef3c7;
  --color-text: #1e293b;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-border: #cbd5e1;
  --color-border-light: #e2e8f0;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --max-width: 1120px;
  --header-height: 56px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

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-primary); text-decoration: none; }
a:hover, a:focus-visible { color: var(--color-primary-dark); text-decoration: underline; }

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

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

/* ===== Accessibility ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

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

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}
.logo:hover, .logo:focus-visible { color: var(--color-primary-dark); text-decoration: none; }
.logo-text { display: none; }

.main-nav {
  display: none;
  gap: 20px;
  align-items: center;
}
.main-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 4px 0;
}
.main-nav a:hover, .main-nav a:focus-visible {
  color: var(--color-primary);
  text-decoration: none;
}

.menu-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
}

.mobile-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  padding: 8px 20px 16px;
}
.mobile-nav[hidden] { display: none; }
.mobile-nav a {
  display: block;
  padding: 10px 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-light);
}
.mobile-nav a:last-child { border-bottom: none; }

/* ===== Intro ===== */
.intro {
  padding: 48px 0 32px;
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
}
.intro h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-text);
  margin-bottom: 16px;
}
.lead {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  max-width: 640px;
  line-height: 1.7;
}
.last-updated {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Section Styles ===== */
section { padding: 40px 0; }
section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.section-note {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ===== Presets ===== */
.presets-section { background: var(--color-surface-alt); }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.preset-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.preset-card:hover, .preset-card:focus-visible {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  outline: none;
}
.preset-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 4px;
}
.preset-dims {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Planner Layout ===== */
.planner-section { background: var(--color-bg); }
.planner-layout {
  display: grid;
  gap: 32px;
}

/* Form Panel */
.planner-form-panel h2 { margin-bottom: 20px; }
fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--color-surface);
}
legend {
  font-weight: 600;
  font-size: 1rem;
  padding: 0 8px;
}
.field-group {
  margin-bottom: 18px;
}
.field-group:last-child { margin-bottom: 0; }
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.hint {
  display: block;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
input[type="number"] {
  width: 100%;
  max-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 1rem;
}
input[type="number"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(3,105,161,0.15);
  outline: none;
}
.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Buttons */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--color-primary-dark);
  color: #fff;
  text-decoration: none;
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover, .btn-secondary:focus-visible {
  background: var(--color-surface-alt);
}
.btn-small {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* Saved Combos */
.saved-combos {
  margin-top: 24px;
  padding: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
}
.saved-combos h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.saved-list {
  margin-bottom: 12px;
}
.empty-state {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-style: italic;
}
.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 0.85rem;
}
.saved-item:last-child { border-bottom: none; }
.saved-item-name { font-weight: 600; }
.saved-item-dims { color: var(--color-text-muted); font-size: 0.8rem; margin-left: 8px; }
.saved-item-actions { display: flex; gap: 6px; }
.btn-load {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--color-text-secondary);
}
.btn-load:hover { background: var(--color-surface-alt); }
.btn-delete {
  background: none;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--color-error);
}
.btn-delete:hover { background: #fef2f2; }

/* Preview Panel */
.planner-preview-panel h2 { margin-bottom: 8px; }
.template-wrapper {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
  margin-bottom: 16px;
}
#template-svg { width: 100%; height: auto; }

.template-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-primary);
}

/* ===== Reference Section ===== */
.reference-section { background: var(--color-surface-alt); }
.reference-layout {
  display: grid;
  gap: 24px;
}
.ref-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.ref-block h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.ref-block p {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  line-height: 1.7;
}
.ref-block ul, .ref-block ol {
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
.ref-block li { margin-bottom: 8px; line-height: 1.6; }
.steps-list li::marker { color: var(--color-primary); font-weight: 700; }
.mistakes-list strong { color: var(--color-accent); }

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.compare-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--color-surface-alt);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
}
.compare-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-light);
}
.compare-table tr:last-child td { border-bottom: none; }

/* ===== Why Section ===== */
.why-section { background: var(--color-bg); }
.why-section p {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  max-width: 720px;
  margin-bottom: 12px;
  line-height: 1.7;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-light);
  padding: 24px 0;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.footer-nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-nav a {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.footer-nav a:hover { color: var(--color-primary); }
.footer-branding {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--color-text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .logo-text { display: inline; }
  .template-stats { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 768px) {
  .main-nav { display: flex; }
  .menu-toggle { display: none; }
  .mobile-nav { display: none !important; }
  .planner-layout {
    grid-template-columns: 340px 1fr;
    align-items: start;
  }
  .reference-layout {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (min-width: 960px) {
  .planner-layout { grid-template-columns: 380px 1fr; }
  .reference-layout { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Print Styles ===== */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .intro, .presets-section,
  .planner-form-panel, .saved-combos, .reference-section,
  .why-section, .form-actions, .template-stats,
  .skip-link, .toast { display: none !important; }
  .planner-section { padding: 0; }
  .planner-layout { display: block; }
  .planner-preview-panel h2 { display: none; }
  .section-note { display: none; }
  .template-wrapper { border: none; }
  #template-svg {
    width: 100%;
    max-width: none;
    height: auto;
  }
}



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