:root {
  --bg: #F4F3EE;
  --surface: #FFFFFF;
  --border: #E1DFD6;
  --text: #2C2C2A;
  --text-secondary: #6B6A63;
  --accent: #378ADD;
  --accent-dark: #185FA5;
  --danger: #C0392B;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }
header h1 { font-size: 22px; margin: 0 0 4px; }
header .sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 18px; }

.creditbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 20px; font-size: 14px;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px;
}
.panel h2 { font-size: 14px; margin: 16px 0 8px; }
.panel h2:first-child { margin-top: 0; }

textarea, input[type="range"], input[type="file"], input[type="email"], input[type="text"] { width: 100%; }
textarea, input[type="email"], input[type="text"] {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  font-family: inherit; resize: vertical;
}
.hint { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0; }

.btn {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer;
  font-weight: 500;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; margin-top: 14px; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { background: #B7C6D6; cursor: not-allowed; }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }

.preview { max-width: 100%; border-radius: 8px; margin-top: 8px; border: 1px solid var(--border); }

.result-wrap { min-height: 240px; display: flex; align-items: center; justify-content: center; }
.result-wrap img { max-width: 100%; border-radius: 8px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal-inner {
  background: var(--surface); border-radius: var(--radius); padding: 20px; width: 320px;
}
.pack {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.pack button { padding: 6px 12px; }

.error { color: var(--danger); }

.back-link { display:inline-block; font-size:13px; color: var(--accent); text-decoration:none; margin-bottom:8px; }
.back-link:hover { text-decoration:underline; }

.wrap-wide { max-width: 1180px; }

.mode-tabs { display:flex; gap:8px; margin-bottom:18px; }
.mode-tab {
  flex:1; padding:10px 14px; border-radius:8px; border:1px solid var(--border);
  background: var(--surface); color: var(--text-secondary); font-size:14px; font-weight:500;
  cursor:pointer;
}
.mode-tab.active { background: var(--accent); border-color: var(--accent); color:#fff; }

.planner-grid { display:grid; grid-template-columns: 340px 1fr; gap:18px; align-items:start; margin-bottom:18px; }
@media (max-width: 900px) { .planner-grid { grid-template-columns: 1fr; } }

.field { margin-bottom:14px; }
.field label { display:block; font-size:12px; color: var(--text-secondary); margin-bottom:4px; }
.field-row { display:flex; gap:10px; }
.field-row .field { flex:1; }
.field-value { font-weight:600; font-size:13px; margin-top:2px; }
.field input[type="number"], .field input[type="text"] {
  width:100%; border:1px solid var(--border); border-radius:8px; padding:7px 9px; font-size:13px; font-family:inherit;
}
.field-check { display:flex; align-items:center; gap:8px; font-size:13px; }
.field-check input { width:auto; }
.field-with-btn { display:flex; gap:8px; align-items:center; }
.field-with-btn input { flex:1; }
.btn-icon { padding:7px 10px; font-size:14px; }

.variant-row { display:flex; gap:8px; margin:14px 0; }
.variant-btn {
  flex:1; padding:9px 6px; font-size:12px; border-radius:8px; border:1px solid var(--border);
  background: var(--surface); color: var(--text-secondary); cursor:pointer;
}
.variant-btn.active { background: var(--accent-dark); border-color: var(--accent-dark); color:#fff; }

.section-label { font-size:13px; font-weight:600; margin: 18px 0 8px; }
.section-label:first-child { margin-top:0; }

.svg-wrap { width:100%; min-height:320px; display:flex; align-items:center; justify-content:center; background: var(--bg); border-radius:8px; overflow:hidden; }
.svg-wrap svg { width:100%; height:auto; max-height:520px; }

.canvas-actions { display:flex; gap:8px; margin-top:14px; flex-wrap:wrap; }
.canvas-actions .btn { flex:1; min-width:180px; margin-top:0; }
#exportedPreview { max-width:100%; border-radius:8px; margin-top:10px; border:1px solid var(--border); }

.warning { background:#FBEFE0; border:1px solid #E8C88F; color:#8A5A17; border-radius:8px; padding:8px 12px; font-size:12px; margin-bottom:10px; }

.legend { display:flex; flex-wrap:wrap; gap:10px 14px; margin-bottom:10px; font-size:11px; color: var(--text-secondary); }
.legend-item { display:flex; align-items:center; gap:5px; }
.legend-swatch { width:11px; height:11px; border-radius:3px; display:inline-block; flex-shrink:0; }

.results-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap:12px; }
.result-card { border:1px solid var(--border); border-radius:8px; padding:10px 12px; }
.result-card .label { font-size:11px; color: var(--text-secondary); margin-bottom:4px; }
.result-card .value { font-size:18px; font-weight:600; }
.result-card .value.ok::after { content: " ✓"; color:#2E8B57; font-size:14px; }
.result-card .value.bad::after { content: " ✗"; color: var(--danger); font-size:14px; }
.result-card .sub { font-size:11px; color: var(--text-secondary); margin-top:2px; }

.cost-total { font-size:26px; font-weight:700; margin-bottom:4px; }
.cost-lines { font-size:12px; color: var(--text-secondary); line-height:1.7; }
