/* SubStacker styles */
:root {
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --surface-alt: #F3F4F6;
  --text: #1F2937;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --primary: #6C3AED;
  --primary-hover: #5B21B6;
  --primary-light: #EDE9FE;
  --accent: #F59E0B;
  --accent-light: #FEF3C7;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-light: #FEE2E2;
  --success: #10B981;
  --success-light: #D1FAE5;
  --border: #E5E7EB;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --max-width: 1120px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

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

.nav-list {
  display: flex;
  list-style: none;
  gap: 24px;
}
.nav-link {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 4px 0;
}
.nav-link:hover { color: var(--primary); text-decoration: none; }

/* Hero */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  max-width: 600px;
  margin: 0 auto 16px;
}
.hero-sub {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 32px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9375rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); text-decoration: none; color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 0.875rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-light); text-decoration: none; }

/* Sections */
.section { padding: 48px 0; }
.section-alt { background: var(--surface-alt); }
.section-desc {
  color: var(--text-muted);
  margin-bottom: 24px;
  max-width: 600px;
}

/* Layout */
.layout-worksheet {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: start;
}

/* Presets */
.presets-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.presets-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Form */
.sub-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 120px 160px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-actions {
  display: flex;
  gap: 10px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
}
.sub-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.sub-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}
.sub-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sub-table tr:last-child td { border-bottom: none; }
.sub-table tr:hover { background: var(--surface-alt); }
.col-actions { text-align: right; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
}
.status-keep { background: var(--success-light); color: #065F46; }
.status-cancel { background: var(--danger-light); color: #991B1B; }
.status-review { background: var(--accent-light); color: #92400E; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 4px;
  font-family: var(--font);
}
.btn-icon:hover { background: var(--surface-alt); }
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover { background: var(--danger-light); }

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; }

/* Summary card */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.summary-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.summary-list { margin-bottom: 16px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}
.summary-row:last-child { border-bottom: none; }
.summary-row dt { color: var(--text-muted); }
.summary-row dd { font-weight: 700; }
.summary-row.highlight dd { color: var(--danger); }
.summary-row.highlight-save dd { color: var(--success); font-size: 1.125rem; }

.overlap-list { font-size: 0.875rem; }
.overlap-item {
  padding: 8px 12px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  color: #92400E;
}

.sticky { position: sticky; top: 80px; }

/* Overlap cards */
.overlap-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.overlap-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.overlap-card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.overlap-card p { color: var(--text-muted); font-size: 0.9375rem; }
.overlap-card .card-items {
  list-style: none;
  margin-top: 12px;
}
.overlap-card .card-items li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
}
.overlap-card .card-items li:last-child { border-bottom: none; }

/* Guide */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.guide-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.guide-card p { color: var(--text-muted); font-size: 0.9375rem; }

.guide-extra {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.guide-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.guide-note h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.guide-note p, .guide-note li { color: var(--text-muted); font-size: 0.9375rem; }
.guide-note ul { padding-left: 20px; }
.guide-note li { margin-bottom: 6px; }

.guide-examples { margin-bottom: 32px; }
.guide-examples h3 { font-size: 1.125rem; font-weight: 700; margin-bottom: 16px; }
.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.example-card {
  background: var(--primary-light);
  border: 1px solid #C4B5FD;
  border-radius: var(--radius);
  padding: 20px;
}
.example-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; color: var(--primary-hover); }
.example-card p { color: #4C1D95; font-size: 0.9375rem; }

/* FAQ */
.faq-block { margin-top: 32px; }
.faq-block h3 { font-size: 1.125rem; font-weight: 700; margin-bottom: 16px; }
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
details summary {
  padding: 14px 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9375rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
details[open] summary::after { content: '−'; }
details[open] summary { border-bottom: 1px solid var(--border); }
details p {
  padding: 14px 20px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-brand { font-weight: 700; font-size: 1rem; }
.footer-meta { font-size: 0.875rem; color: var(--text-muted); }
.footer-meta a { color: var(--text-muted); }
.footer-nav { display: flex; gap: 16px; }
.footer-nav a { font-size: 0.875rem; color: var(--text-muted); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 100;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 900px) {
  .layout-worksheet { grid-template-columns: 1fr; }
  .worksheet-side { order: -1; }
  .sticky { position: static; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 8px; }
  .nav-list { gap: 16px; }
  .hero { padding: 40px 0 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .presets-bar { flex-direction: column; align-items: flex-start; }
  .table-actions { justify-content: flex-start; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media print {
  .site-header, .site-footer, .hero-actions, .presets-bar, .sub-form, .table-actions, .btn, .worksheet-side { display: none !important; }
  .section { padding: 16px 0; }
  body { background: #fff; }
  .table-wrap { border: 1px solid #000; }
  .sub-table th, .sub-table td { border: 1px solid #000; padding: 8px; }
}



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