:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-alt: #f0f2ed;
  --border: #dcdfd7;
  --text: #1e2420;
  --text-muted: #5a635d;
  --accent: #2d6a4f;
  --accent-hover: #1b4d38;
  --accent-light: #b7e4c7;
  --warning: #c47f17;
  --error: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

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

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-icon { flex-shrink: 0; }

.site-nav {
  display: flex;
  gap: 20px;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.2s;
}

.site-nav a:hover { color: var(--accent); }

/* Hero */
.hero-section {
  padding: 48px 0 24px;
}

.hero-content h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 10px;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 600px;
}

/* Section titles */
.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
}

/* Calculator */
.calculator-section {
  padding: 32px 0;
}

.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.calc-inputs {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.input-group input,
.input-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.preset-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.btn-primary {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  padding: 10px 16px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0;
}

.btn-text:hover { color: var(--error); }

/* Results */
.calc-results {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 200px;
}

.result-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 0.95rem;
}

.result-main {
  text-align: center;
  margin-bottom: 20px;
}

.result-size {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.result-dpi-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.quality-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 10px;
}

.quality-excellent { background: #d8f3dc; color: #1b4d38; }
.quality-good { background: #fff3cd; color: #856404; }
.quality-fair { background: #fde2c8; color: #a04a0a; }
.quality-low { background: #f8d7da; color: #842029; }

.result-details {
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-details p { margin-bottom: 6px; }

.result-standards {
  margin-top: 16px;
}

.result-standards h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.standard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.standard-chip {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
}

.standard-chip.fit { border-color: var(--accent); background: #d8f3dc; color: #1b4d38; }
.standard-chip.crop { border-color: var(--warning); background: #fff3cd; color: #856404; }
.standard-chip.no-fit { border-color: var(--error); background: #f8d7da; color: #842029; }

/* Examples */
.examples-section { padding: 40px 0; }

.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.scenario-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent);
}

.scenario-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.scenario-result {
  font-weight: 600;
  color: var(--text) !important;
  font-size: 0.88rem !important;
}

/* Reference */
.reference-section { padding: 40px 0; }

.table-wrapper {
  overflow-x: auto;
  margin-bottom: 24px;
}

.reference-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}

.reference-table th {
  background: var(--surface-alt);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.reference-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.reference-table tr:last-child td { border-bottom: none; }

.reference-notes h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 20px 0 8px;
  color: var(--text);
}

.reference-notes ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.reference-notes li {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* History */
.history-section {
  padding: 32px 0 48px;
  border-top: 1px solid var(--border);
}

.history-list {
  margin-bottom: 12px;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.history-item .history-info { flex: 1; }

.history-item .history-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item .history-load {
  margin-left: 12px;
  padding: 4px 10px;
  background: var(--accent-light);
  color: var(--accent-hover);
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 999;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Print */
@media print {
  .site-header, .site-footer, .calc-actions, .preset-buttons, .history-section, .btn-text, #clear-history { display: none !important; }
  .calc-layout { grid-template-columns: 1fr; }
  body { background: #fff; }
}

/* Responsive */
@media (max-width: 768px) {
  .calc-layout { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }
  .hero-content h1 { font-size: 1.5rem; }
  .site-nav { gap: 14px; }
  .site-nav a { font-size: 0.85rem; }
}

@media (max-width: 480px) {
  .calc-actions { flex-direction: column; }
  .btn-primary, .btn-secondary { width: 100%; text-align: center; }
  .preset-buttons { gap: 6px; }
}


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