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

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-alt: #f5f1eb;
  --border: #e0d9d0;
  --border-strong: #c4b9ac;
  --text: #2c2825;
  --text-muted: #6b635c;
  --text-light: #9a9188;
  --accent: #c47a2b;
  --accent-hover: #a86820;
  --accent-light: #fdf3e6;
  --accent-bg: #fff8ee;
  --success: #3a8a5c;
  --success-bg: #eef7f1;
  --danger: #c0392b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.04);
  --max-width: 1160px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --surface: #23201d;
    --surface-alt: #2c2825;
    --border: #3d3833;
    --border-strong: #554f48;
    --text: #ede8e2;
    --text-muted: #a89f96;
    --text-light: #7d746b;
    --accent: #dfa04a;
    --accent-hover: #e8b46a;
    --accent-light: #2c2218;
    --accent-bg: #2a241c;
    --success: #5cb87a;
    --success-bg: #1e2e24;
    --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.3), 0 8px 32px rgba(0,0,0,0.2);
  }
}

html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.skip-link {
  position: absolute; top: -100%; left: 16px; background: var(--accent);
  color: #fff; padding: 8px 16px; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 100; font-weight: 600;
}
.skip-link:focus { top: 0; }

/* === Header === */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: 16px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); font-weight: 700; font-size: 0.95rem;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo-icon { color: var(--accent); flex-shrink: 0; }
.logo-icon.small { opacity: 0.8; }
.site-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 0.875rem; color: var(--text-muted); font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--surface-alt); color: var(--text); text-decoration: none;
}

@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; }
  .logo-text { font-size: 0.8rem; }
  .site-nav { width: 100%; overflow-x: auto; padding-bottom: 2px; }
}

/* === Hero === */
.hero {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg) 100%);
  padding: 60px 0 48px;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800; line-height: 1.2; max-width: 600px;
  margin-bottom: 16px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-sub {
  font-size: 1.05rem; color: var(--text-muted);
  max-width: 560px; margin-bottom: 12px;
}
.hero-meta {
  font-size: 0.82rem; color: var(--text-light);
  display: flex; align-items: center; gap: 6px;
}
.hero-meta::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  background: var(--success); border-radius: 50%;
}

/* === Section Headings === */
.section-heading {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 20px;
}
.section-intro {
  color: var(--text-muted); margin-bottom: 20px; max-width: 640px;
}

/* === Calculator Section === */
.calculator-section { padding: 48px 0; }
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
  .calc-sidebar { order: 2; }
}

/* === Presets === */
.preset-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; margin-bottom: 24px;
}
.preset-label {
  font-size: 0.8rem; color: var(--text-light); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; margin-right: 4px;
}
.preset-btn {
  padding: 5px 12px; font-size: 0.8rem;
  border: 1px solid var(--border-strong); border-radius: 20px;
  background: var(--surface); color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font);
}
.preset-btn:hover {
  background: var(--accent-light); border-color: var(--accent);
  color: var(--text);
}

/* === Fieldset === */
.calc-fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 24px; background: var(--surface);
}
.calc-fieldset legend {
  font-weight: 700; font-size: 0.95rem; padding: 0 8px;
}
.calc-fieldset.compact { padding: 16px; }
.field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 16px;
}
.field-row:last-child { margin-bottom: 0; }
@media (max-width: 500px) {
  .field-row { grid-template-columns: 1fr; }
}
.field label {
  display: block; font-size: 0.82rem; font-weight: 600;
  margin-bottom: 4px; color: var(--text);
}
.field input, .field select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-size: 0.95rem; font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 122, 43, 0.15);
}
.field-hint {
  display: block; font-size: 0.75rem; color: var(--text-light);
  margin-top: 3px;
}

/* === Results === */
.results-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.results-panel h3 {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-light); margin-bottom: 16px; font-weight: 600;
}
.cost-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.cost-card {
  text-align: center; padding: 16px 8px;
  background: var(--surface-alt); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.cost-period {
  display: block; font-size: 0.75rem; color: var(--text-light);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.cost-value {
  display: block; font-size: 1.6rem; font-weight: 800;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.standby-note {
  margin-top: 14px; padding: 10px 14px;
  background: var(--accent-bg); border-radius: var(--radius-sm);
  font-size: 0.82rem; color: var(--text-muted);
}
.standby-note span { font-weight: 700; color: var(--accent); }

@media (max-width: 500px) {
  .cost-grid { grid-template-columns: 1fr; }
}

/* === Action Bar === */
.action-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.btn {
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-alt); }
.btn-ghost {
  background: transparent; color: var(--text-light);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-alt); }
.btn-full { width: 100%; justify-content: center; }

/* === Sidebar === */
.calc-sidebar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); position: sticky; top: 72px;
  max-height: calc(100vh - 88px); overflow-y: auto;
}
.calc-sidebar h2 {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 4px;
}
.sidebar-desc {
  font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px;
}
.comparison-results {
  margin: 16px 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.comp-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}
.comp-row:last-child { border-bottom: none; }
.comp-row span { color: var(--text-muted); }
.comp-row strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.comp-row.highlight {
  background: var(--success-bg);
}
.comp-row.highlight strong { color: var(--success); }
.payback-note {
  font-size: 0.8rem; color: var(--text-light);
  padding: 8px 12px; background: var(--surface-alt);
  border-radius: var(--radius-sm); margin-bottom: 16px;
  text-align: center;
}

/* === Saved List === */
.saved-list { margin-top: 24px; }
.saved-list h3 {
  font-size: 0.9rem; font-weight: 700; margin-bottom: 8px;
}
.empty-state {
  font-size: 0.82rem; color: var(--text-light); font-style: italic;
}
.saved-items { list-style: none; }
.saved-items li {
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.82rem; display: flex; justify-content: space-between;
  align-items: center; gap: 8px;
}
.saved-items li:last-child { border-bottom: none; }
.saved-item-name { font-weight: 600; }
.saved-item-cost { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.saved-item-remove {
  background: none; border: none; color: var(--text-light);
  cursor: pointer; font-size: 1rem; padding: 2px 6px;
  border-radius: var(--radius-sm); line-height: 1;
}
.saved-item-remove:hover { background: var(--surface-alt); color: var(--danger); }

/* === Guide Section === */
.guide-section {
  padding: 56px 0; background: var(--surface-alt);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.guide-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.guide-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.guide-card h3 {
  font-size: 0.95rem; font-weight: 700; margin-bottom: 8px;
}
.guide-card p {
  font-size: 0.875rem; color: var(--text-muted); line-height: 1.65;
}

/* === Reference Section === */
.reference-section { padding: 56px 0; }
.table-wrapper {
  overflow-x: auto; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.ref-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.875rem; min-width: 520px;
}
.ref-table th {
  text-align: left; padding: 11px 14px;
  background: var(--surface-alt); color: var(--text-muted);
  font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
}
.ref-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover td { background: var(--surface-alt); }
.ref-table td:last-child { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.table-footnote {
  font-size: 0.78rem; color: var(--text-light); margin-bottom: 32px;
}

/* === Mistakes Block === */
.mistakes-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 36px;
}
.mistakes-block h3 {
  font-size: 1rem; font-weight: 700; margin-bottom: 16px;
}
.mistakes-block ul {
  list-style: none; display: grid; gap: 14px;
}
.mistakes-block li {
  font-size: 0.875rem; color: var(--text-muted); line-height: 1.65;
  padding-left: 20px; position: relative;
}
.mistakes-block li::before {
  content: '→'; position: absolute; left: 0; color: var(--accent);
  font-weight: 700;
}
.mistakes-block strong { color: var(--text); }

/* === FAQ Block === */
.faq-block {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.faq-block h3 {
  padding: 20px 24px 0; font-size: 1rem; font-weight: 700;
}
.faq-block details {
  border-bottom: 1px solid var(--border);
}
.faq-block details:last-child { border-bottom: none; }
.faq-block summary {
  padding: 16px 24px; cursor: pointer; font-weight: 600;
  font-size: 0.9rem; color: var(--text);
  transition: background 0.15s;
}
.faq-block summary:hover { background: var(--surface-alt); }
.faq-block details[open] summary {
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
}
.faq-block details p {
  padding: 14px 24px; font-size: 0.875rem;
  color: var(--text-muted); line-height: 1.65;
}

/* === Footer === */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 32px 0; margin-top: auto;
}
.footer-inner {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 12px 24px; justify-content: space-between;
}
.footer-brand {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem; font-weight: 600; color: var(--text);
}
.footer-nav {
  display: flex; gap: 16px;
}
.footer-nav a {
  font-size: 0.82rem; color: var(--text-muted);
}
.footer-note {
  font-size: 0.75rem; color: var(--text-light); flex: 1 1 100%;
}
.footer-copy {
  font-size: 0.75rem; color: var(--text-light);
}

@media (max-width: 640px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* === Print === */
@media print {
  .site-header, .site-footer, .preset-bar, .action-bar,
  .calc-sidebar, .site-nav, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .results-panel { border: 2px solid #333; box-shadow: none; }
  .hero { padding: 20px 0; background: none; border: none; }
}

/* === Focus Visible === */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}


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