:root {
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --accent-hover: #6d28d9;
  --accent-soft: #f5f3ff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #faf5ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --radius: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- Navigation ---------- */
.nav {
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.nav-brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.nav-brand::before {
  content: "🧼";
  margin-right: 0.4rem;
}

.nav-links {
  display: flex;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container-narrow {
  max-width: 820px;
}

h1 {
  font-size: 2.25rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.025em;
  font-weight: 800;
}

.intro {
  color: var(--text-light);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  max-width: 720px;
}

h2 {
  font-size: 1.35rem;
  margin: 2rem 0 1rem;
  letter-spacing: -0.01em;
  font-weight: 700;
}

h3 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
  font-weight: 700;
}

/* ---------- Cards ---------- */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* ---------- Form controls ---------- */
label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

textarea {
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: var(--shadow);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
button,
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.05s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

button:hover,
.btn:hover { background: var(--accent-hover); }
button:active,
.btn:active { transform: translateY(1px); }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

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

/* ---------- Segmented toggle ---------- */
.toggle-group {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.toggle-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-group label {
  margin: 0;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-light);
  transition: all 0.15s;
  font-size: 0.88rem;
}

.toggle-group input[type="radio"]:checked + label {
  background: white;
  color: var(--accent);
  box-shadow: var(--shadow);
}

.toggle-group input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Form grid ---------- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group { margin-bottom: 1rem; }

.helper {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* ---------- Oil grid ---------- */
.oil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}

.oil-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-soft);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}

.oil-input:focus-within,
.oil-input.has-value {
  border-color: var(--accent);
  background: white;
}

.oil-input label {
  flex: 1;
  margin: 0;
  font-weight: 500;
  font-size: 0.85rem;
}

.oil-input input {
  width: 80px;
  text-align: right;
}

/* ---------- Results ---------- */
.results {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.results h2 { margin-top: 0; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.result-item {
  background: white;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  border: 1px solid #e9d5ff;
}

.result-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  margin-top: 0.15rem;
  letter-spacing: -0.02em;
}

.result-unit {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 500;
  margin-left: 0.25rem;
}

.recipe-summary {
  background: white;
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-top: 1rem;
  border: 1px solid #e9d5ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  line-height: 1.7;
  color: var(--text);
}

.copy-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  background: white;
  color: var(--accent);
  border: 1px solid #ddd6fe;
  border-radius: 6px;
  margin-top: 0.5rem;
}

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

/* ---------- Slider with label ---------- */
.slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.slider-value {
  font-weight: 700;
  color: var(--accent);
  min-width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- AdSense slots ---------- */
.adslot {
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: #9ca3af;
  margin: 1.5rem 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

/* ---------- Notes ---------- */
.warning {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: #92400e;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.info {
  background: #ede9fe;
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: #5b21b6;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.danger {
  background: #fee2e2;
  border-left: 3px solid #dc2626;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: #991b1b;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */
.footer {
  background: #f9fafb;
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
  margin-top: 4rem;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.6rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-light);
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  border-radius: 0;
}

.tab:hover { color: var(--accent); background: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Container list (multi) ---------- */
.repeat-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.5rem;
}

.remove-btn {
  background: transparent;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
}

.remove-btn:hover { background: #fef2f2; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .nav-container { padding: 0.75rem 1rem; }
  .container { padding: 1.5rem 1rem; }
  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.2rem; }
  .intro { font-size: 0.98rem; }
  .form-row,
  .form-row-3 { grid-template-columns: 1fr; gap: 0.75rem; }
  .nav-links { font-size: 0.82rem; gap: 0; }
  .nav-links a { padding: 0.35rem 0.55rem; }
  .nav-brand { font-size: 1.05rem; }
  .result-value { font-size: 1.25rem; }
  .repeat-row { grid-template-columns: 1fr 1fr; }
  .repeat-row .remove-btn { grid-column: 1 / -1; }
}
