/* ===== CSS Variables ===== */
:root {
  --c-bg: #FDF8F4;
  --c-surface: #FFFFFF;
  --c-surface-alt: #F5EDE4;
  --c-primary: #C75B39;
  --c-primary-dark: #A8472B;
  --c-primary-light: #F0D5C8;
  --c-text: #2C1810;
  --c-text-muted: #6B5A52;
  --c-border: #D9C8BC;
  --c-success: #4A7C59;
  --c-warning: #C4842D;
  --c-warning-bg: #FFF8EC;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(44,24,16,0.08), 0 4px 12px rgba(44,24,16,0.06);
  --shadow-lg: 0 4px 16px rgba(44,24,16,0.1), 0 8px 32px rgba(44,24,16,0.06);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 1100px;
  --container-pad: 1.5rem;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--c-text); background: var(--c-bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--c-primary-dark); }
button, input, select { font: inherit; color: inherit; }
ul, ol { padding-left: 1.25rem; }

/* ===== Utilities ===== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -100%; left: 1rem; background: var(--c-primary); color: #fff; padding: 0.5rem 1rem; border-radius: 0 0 var(--radius) var(--radius); z-index: 100; font-weight: 600; }
.skip-link:focus { top: 0; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--container-pad); }

/* ===== Header ===== */
.site-header { background: var(--c-surface); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.2rem; color: var(--c-text); }
.logo:hover { text-decoration: none; }
.logo-accent { color: var(--c-primary); }
.nav { display: flex; gap: 1.25rem; }
.nav a { font-size: 0.9rem; font-weight: 500; color: var(--c-text-muted); padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--c-primary); border-bottom-color: var(--c-primary); text-decoration: none; }

/* ===== Hero ===== */
.hero { padding: 3rem 0 2rem; 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 0.75rem; }
.hero-sub { font-size: 1.05rem; color: var(--c-text-muted); max-width: 520px; margin: 0 auto; }

/* ===== Calculator Section ===== */
.calculator { padding: 1rem 0 3rem; }
.calc-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 860px) {
  .calc-grid { grid-template-columns: 1fr 300px; }
}
.calc-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); }

/* Scale controls */
.scale-control { margin-bottom: 1.5rem; }
.scale-label { display: block; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-text-muted); margin-bottom: 0.5rem; }
.preset-group { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.preset-btn { padding: 0.4rem 0.85rem; border: 1.5px solid var(--c-border); border-radius: 20px; background: var(--c-surface); font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.preset-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.preset-btn.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.custom-scale { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.custom-scale input[type="number"] { width: 80px; padding: 0.4rem 0.6rem; border: 1.5px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); font-size: 0.95rem; }
.custom-scale input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-light); }
.hint { font-size: 0.8rem; color: var(--c-text-muted); }

/* Ingredients table */
.ingredients-area { margin-bottom: 1.5rem; }
.ingredients-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
.ingredients-header h2 { font-size: 1.1rem; font-weight: 700; }
.ingredient-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.ingredient-table thead th { text-align: left; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--c-text-muted); padding: 0.4rem 0.5rem; border-bottom: 1.5px solid var(--c-border); }
.ingredient-table tbody td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.ingredient-table input[type="text"],
.ingredient-table input[type="number"] { width: 100%; padding: 0.4rem 0.5rem; border: 1.5px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); font-size: 0.92rem; }
.ingredient-table input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-light); }
.ingredient-table select { padding: 0.4rem 0.5rem; border: 1.5px solid var(--c-border); border-radius: var(--radius); background: var(--c-bg); font-size: 0.92rem; width: 100%; }
.result-col { min-width: 160px; }
.result-cell { font-weight: 600; color: var(--c-primary-dark); font-size: 0.92rem; }
.result-cell.empty { color: var(--c-text-muted); font-weight: 400; font-style: italic; font-size: 0.85rem; }
.action-col { width: 36px; text-align: center; }
.btn-remove { background: none; border: none; font-size: 1.2rem; color: var(--c-text-muted); cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 4px; line-height: 1; }
.btn-remove:hover { background: #FEE2E2; color: #DC2626; }

/* Buttons */
.calc-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.btn { padding: 0.55rem 1.25rem; border-radius: var(--radius); font-size: 0.92rem; font-weight: 600; cursor: pointer; transition: all 0.15s; border: 1.5px solid transparent; }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }
.btn-outline { background: var(--c-surface); color: var(--c-primary); border-color: var(--c-primary); }
.btn-outline:hover { background: var(--c-primary-light); }
.btn-outline:disabled { color: var(--c-text-muted); border-color: var(--c-border); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--c-text-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--c-text); background: var(--c-surface-alt); }

/* Info panel */
.info-panel { display: flex; flex-direction: column; gap: 1.25rem; }
.info-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); }
.info-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.5rem; }
.info-card p, .info-card li { font-size: 0.88rem; color: var(--c-text-muted); line-height: 1.55; }
.info-card ul { margin-top: 0.4rem; }
.info-card li { margin-bottom: 0.3rem; }
.warning-card { background: var(--c-warning-bg); border-color: #E8C98A; }
.ref-table { width: 100%; font-size: 0.85rem; border-collapse: collapse; margin-top: 0.5rem; }
.ref-table td { padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--c-border); }
.ref-table td:first-child { font-weight: 600; white-space: nowrap; }

/* ===== Guide Section ===== */
.guide { padding: 2rem 0 4rem; }
.guide h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 1.5rem; }
.guide-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 3rem; }
@media (min-width: 700px) {
  .guide-grid { grid-template-columns: repeat(3, 1fr); }
}
.guide-step { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 1.25rem; position: relative; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--c-primary); color: #fff; border-radius: 50%; font-weight: 700; font-size: 0.85rem; margin-bottom: 0.75rem; }
.guide-step h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.4rem; }
.guide-step p { font-size: 0.9rem; color: var(--c-text-muted); line-height: 1.55; }

.guide-details { margin-bottom: 2.5rem; }
.guide-details h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.75rem; }
.guide-details p { font-size: 0.92rem; color: var(--c-text-muted); line-height: 1.6; margin-bottom: 0.75rem; }

.faq-list { margin-top: 0.75rem; }
.faq-list dt { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.3rem; }
.faq-list dd { font-size: 0.9rem; color: var(--c-text-muted); line-height: 1.55; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--c-border); }
.faq-list dd:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.why-note { background: var(--c-primary-light); border-radius: var(--radius-lg); padding: 1.5rem; }
.why-note h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.5rem; }
.why-note p { font-size: 0.92rem; color: var(--c-text-muted); line-height: 1.6; }

/* ===== Page templates ===== */
.page-hero { padding: 2.5rem 0 1.5rem; text-align: center; }
.page-hero h1 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); font-weight: 800; margin-bottom: 0.5rem; }
.page-content { padding: 1rem 0 3rem; }

/* ===== Footer ===== */
.site-footer { background: var(--c-surface); border-top: 1px solid var(--c-border); padding: 1.5rem 0; margin-top: 2rem; }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; }
.footer-brand { font-weight: 700; font-size: 0.95rem; }
.footer-nav { display: flex; gap: 1rem; font-size: 0.85rem; }
.footer-meta { font-size: 0.8rem; color: var(--c-text-muted); }

/* ===== Print styles ===== */
@media print {
  .site-header, .site-footer, .scale-control, .ingredients-header .btn-ghost, .btn-remove, .calc-actions, .info-panel, .hero { display: none !important; }
  body { background: #fff; }
  .calc-panel { box-shadow: none; border: 1px solid #ccc; }
  .result-cell { color: #000; }
  .guide { page-break-before: always; }
}

/* ===== Responsive tweaks ===== */
@media (max-width: 600px) {
  .header-inner { flex-direction: column; gap: 0.5rem; padding: 0.75rem 0; }
  .hero { padding: 2rem 0 1.5rem; }
  .calc-panel { padding: 1rem; }
  .ingredient-table thead { display: none; }
  .ingredient-table tbody tr { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.6rem 0; border-bottom: 1px solid var(--c-border); }
  .ingredient-table tbody td { border: none; padding: 0.2rem 0.3rem; }
  .ingredient-table tbody td:first-child { flex: 1 1 100%; }
  .ingredient-table tbody td:nth-child(2) { flex: 0 0 70px; }
  .ingredient-table tbody td:nth-child(3) { flex: 0 0 80px; }
  .ingredient-table tbody td.result-cell { flex: 1 1 100%; }
  .ingredient-table tbody td.action-col { flex: 0 0 auto; }
  .preset-group { gap: 0.3rem; }
  .preset-btn { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
  .calc-actions { gap: 0.4rem; }
  .btn { padding: 0.5rem 0.9rem; font-size: 0.88rem; }
}



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