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

:root {
  /* ── Brand palette ───────────────────────────────────────────────────────
     Charcoal #333 · Lemon Lime #F5FFA1 · White · Light gray #EBEBEB.
     Charcoal is the main interactive color; lemon lime is used very sparingly
     (just the strength-target badge) as a single accent pop. */
  --charcoal: #333333;
  --lime: #F5FFA1;

  --page: #FFFFFF;        /* page canvas (white) */
  --bg: #EBEBEB;          /* recessed gray: toggle tracks, disabled, slider rail */
  --bg-2: #F4F4F4;        /* soft surface */
  --bg-3: #FFFFFF;        /* card surface */
  --bg-4: #FFFFFF;        /* raised surface / hover */
  --border: #DCDCDC;
  --border-light: #E6E6E6;
  --text: #333333;        /* charcoal primary */
  --text-2: #5F5F5F;      /* secondary */
  --text-3: #8A8A8A;      /* tertiary */
  --accent: #333333;      /* charcoal: buttons, active fills, emphasis */
  --accent-hover: #1A1A1A;
  --accent-light: #333333;
  --accent-dim: #EBEBEB;  /* neutral tint: hover + light selected backgrounds */
  --success: #3F8F4F;
  --danger: #C44;
  --warning: #B25E09;
  --info: #333333;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.05);
  /* Soft elevation so white cards separate from the white page canvas */
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 10px 30px rgba(0,0,0,0.07);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

html { scroll-behavior: smooth; background: var(--page); }

body {
  font-family: var(--font-ui);
  background: var(--page);
  color: var(--text);
  /* No min-height:100vh — the body should be exactly as tall as its content so
     the auto-resizing embed iframe fits snugly (100vh would make the body fill
     the iframe and feed back into the height report, leaving excess space). The
     html background above keeps a short standalone page fully filled. */
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Icon slots emptied by emoji removal — collapse so they leave no gap. */
.brand-icon:empty, .bnav-icon:empty, .loading-icon:empty,
.sc-int-icon:empty, .sc-big-icon:empty, .sc-fit-icon:empty,
.sc-jar-icon:empty { display: none; }

/* ── Navbar ──────────────────────────────────────────────────────────────────── */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 58px;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-brand em {
  font-style: normal;
  color: var(--text-3);
  font-weight: 400;
  margin-left: 0.25em;
}
.brand-icon { font-size: 1.3rem; }

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.1rem;
  margin-left: auto;
  align-items: center;
}

.nav-link {
  color: var(--text-2);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
  display: block;
}
.nav-link:hover, .nav-link.active { color: var(--accent); background: var(--accent-dim); }
.admin-link { color: var(--text-3) !important; }
.admin-link:hover { color: var(--warning) !important; background: rgba(196,144,64,0.1) !important; }

.nav-dropdown { position: relative; }
.nav-dropdown-toggle { user-select: none; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  min-width: 140px;
  box-shadow: var(--shadow);
  list-style: none;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu .nav-link { width: 100%; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  margin-left: auto;
  padding: 0.3rem;
}

/* ── Main & Footer ────────────────────────────────────────────────────────── */
#app {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.8rem;
}
.footer-sep { margin: 0 0.5rem; }
.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.footer-link:hover { text-decoration: underline; }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 1rem;
  color: var(--text-3);
}
.loading-icon { font-size: 3rem; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:0.5; transform:scale(1); } 50% { opacity:1; transform:scale(1.1); } }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { color: var(--text); line-height: 1.1; font-family: var(--font-display); }
h1, h2 {
  font-weight: 700;
  letter-spacing: -0.022em;
}
h3, h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
h1 { font-size: 2.4rem; color: var(--text); }
h2 { font-size: 1.7rem; color: var(--text); }
h3 { font-size: 1.15rem; color: var(--text); }
h4 { font-size: 1rem; color: var(--text); }
p { color: var(--text-2); margin-bottom: 0.8rem; }
strong { color: var(--text); font-weight: 600; }
em { color: var(--accent-light); font-style: italic; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-3); font-size: 0.85rem; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }
.page-header h1 { margin-bottom: 0.4rem; }
.page-header p { font-size: 1rem; color: var(--text-2); }
.page-badge {
  display: inline-block;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-sm { padding: 1rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.3rem;
  min-height: 44px;
  border-radius: 980px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover:not(:disabled) { background: var(--accent-dim); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--border-light); color: var(--text); background: var(--bg-4); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; min-height: 36px; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 1rem; min-height: 50px; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
label {
  display: block;
  color: var(--text-2);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
label .label-hint {
  color: var(--text-3);
  font-weight: normal;
  font-size: 0.78rem;
  margin-left: 0.3rem;
}
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1rem; /* 16px minimum — prevents iOS zoom */
  padding: 0.65rem 0.85rem;
  min-height: 44px;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%238a7560'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.8rem center; padding-right: 2.2rem; }
input[type="range"] {
  padding: 0;
  background: none;
  border: none;
  min-height: 44px;
  accent-color: var(--accent);
  cursor: pointer;
  -webkit-appearance: none;
}
input[type="range"]:focus { box-shadow: none; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
.form-hint { font-size: 0.78rem; color: var(--text-3); margin-top: 0.25rem; }

/* ── Range slider with value ──────────────────────────────────────────────── */
.range-group { display: flex; align-items: center; gap: 0.8rem; }
.range-group input[type="range"] { flex: 1; }
.range-value {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  min-width: 60px;
  text-align: center;
  color: var(--accent-light);
  font-weight: 600;
}

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
}
.toggle-label { color: var(--text-2); font-size: 0.875rem; }
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.divider-label {
  text-align: center;
  color: var(--text-3);
  font-size: 0.8rem;
  position: relative;
  margin: 1.5rem 0;
}
.divider-label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background: var(--border);
}
.divider-label span {
  position: relative;
  background: var(--bg);
  padding: 0 0.8rem;
}

/* ── Result Panel ─────────────────────────────────────────────────────────── */
.result-panel {
  background: linear-gradient(135deg, var(--bg-3), var(--bg-4));
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.result-panel h3 { color: var(--accent-light); margin-bottom: 1rem; }

.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.result-item { text-align: center; }
.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.result-unit { font-size: 0.8rem; color: var(--accent); margin-left: 2px; }
.result-label { font-size: 0.78rem; color: var(--text-3); margin-top: 0.3rem; }

.strength-bar-wrap { margin: 1rem 0; }
.strength-bar {
  height: 8px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.strength-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--success), var(--accent), var(--danger));
  transition: width 0.5s ease;
}

/* ── Final Strength Target slider (Advanced) ──────────────────────────────── */
.strength-target { padding-top: 0.25rem; }
.st-value {
  text-align: center;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.st-caption {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-3);
  margin: 0.4rem 0 1.2rem;
}
.st-zones {
  display: grid;
  grid-template-columns: 2fr 3fr 2fr; /* Strong 12-13 · Standard 14-16 · Light 17-18 */
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}
.st-zone {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--border);
  transition: var(--transition);
}
.st-zone-on { color: var(--accent); border-bottom-color: var(--accent); }

.st-track { position: relative; height: 40px; }
.st-ticks {
  position: absolute;
  top: 50%; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  transform: translateY(-50%);
  pointer-events: none;
}
.st-ticks span { width: 1px; height: 13px; background: var(--border); border-radius: 1px; }
.st-track input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 40px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.st-track input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 40px; }
.st-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 40px; background: transparent; cursor: grab;
}
.st-track input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
.st-track input[type="range"]::-moz-range-track { background: transparent; height: 40px; }
.st-track input[type="range"]::-moz-range-thumb { width: 22px; height: 40px; background: transparent; border: none; }
.st-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--lime);
  color: var(--charcoal);
  border: 1px solid var(--charcoal);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.42rem 0.55rem;
  border-radius: 10px;
  min-width: 44px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(51,51,51,0.22);
  transition: left 0.12s ease;
}
.st-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.55rem;
  font-size: 0.7rem;
  color: var(--text-3);
}
.st-labels span { width: 30px; text-align: center; }
.st-labels span:first-child { text-align: left; }
.st-labels span:last-child { text-align: right; }
.strength-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.2rem;
}

/* ── Recipe Cards ─────────────────────────────────────────────────────────── */
.recipe-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.recipe-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }
.recipe-card.pinned { border-color: var(--accent); }
.recipe-card.pinned::before {
  content: '📌';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.9rem;
}
.recipe-card-title {
  font-family: var(--font);
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.recipe-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}
.tag {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem;
  color: var(--text-3);
}
.tag-accent { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.recipe-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-3);
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.recipe-card-stats span { white-space: nowrap; }
.recipe-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }

.upvote-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.8rem;
  color: var(--text-2);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-ui);
}
.upvote-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.upvote-btn.voted { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── Leaderboard ──────────────────────────────────────────────────────────── */
.leaderboard-list { display: flex; flex-direction: column; gap: 0.6rem; }
.lb-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  transition: var(--transition);
  cursor: pointer;
}
.lb-item:hover { border-color: var(--border-light); background: var(--bg-4); }
.lb-rank {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-3);
  min-width: 2.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.lb-rank.top-3 { color: var(--accent-light); font-size: 1.5rem; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-family: var(--font); color: var(--text); font-size: 0.95rem; truncate: ellipsis; }
.lb-author { font-size: 0.78rem; color: var(--text-3); }
.lb-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.lb-likes { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.lb-date { font-size: 0.72rem; color: var(--text-3); }

/* ── Home Page ────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}
.hero-icon { font-size: 4rem; margin-bottom: 1rem; display: block; }
.hero h1 { font-size: 3rem; margin-bottom: 0.5rem; }
.hero h1 em { color: var(--accent); }
.hero p { font-size: 1.1rem; max-width: 540px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.feature-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-top: 2rem; }
.feature-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.feature-card:hover { border-color: var(--accent); background: var(--bg-4); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.feature-card-icon { font-size: 2rem; margin-bottom: 0.7rem; display: block; }
.feature-card h3 { font-size: 0.95rem; color: var(--text); margin-bottom: 0.3rem; }
.feature-card p { font-size: 0.82rem; color: var(--text-3); margin: 0; }

/* ── Guide Page ───────────────────────────────────────────────────────────── */
.guide-steps { display: flex; flex-direction: column; gap: 1rem; }
.guide-step {
  display: flex;
  gap: 1.2rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.step-body h4 { color: var(--text); margin-bottom: 0.3rem; font-family: var(--font-ui); font-weight: 600; }
.step-body p { margin: 0; font-size: 0.875rem; }

.ratio-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.ratio-table th, .ratio-table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.ratio-table th { color: var(--text-3); font-weight: 500; }
.ratio-table td { color: var(--text-2); }
.ratio-table tr:last-child td { border-bottom: none; }
.ratio-table tr:hover td { background: var(--bg-4); }

/* ── Math Page ────────────────────────────────────────────────────────────── */
.math-formula {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: var(--accent-light);
  margin: 0.8rem 0;
}
.assumptions-grid { display: grid; gap: 0.6rem; }
.assumption-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.assumption-row:last-child { border-bottom: none; }
.assumption-key { color: var(--text-2); }
.assumption-val { color: var(--accent-light); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Admin Panel ──────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 0.3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.admin-tab {
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  margin-bottom: -1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-ui);
}
.admin-tab:hover { color: var(--text-2); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  color: var(--text-3);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.admin-table tr:hover td { background: var(--bg-4); }
.admin-table .inline-edit { background: var(--bg-2); border: 1px solid var(--border); border-radius: 4px; color: var(--text); padding: 0.25rem 0.5rem; font-size: 0.82rem; width: 100%; min-width: 80px; }

.login-box {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-box h2 { text-align: center; margin-bottom: 1.5rem; }
.lock-icon { text-align: center; font-size: 2.5rem; margin-bottom: 1rem; display: block; }

/* ── Toast Notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem 1.1rem;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-4); }

/* ── Tabs (in-page) ───────────────────────────────────────────────────────── */
.tab-buttons {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.tab-btn {
  flex: 1;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  min-width: 80px;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.tab-btn:hover:not(.active) { color: var(--text-2); background: var(--bg-4); }

/* ── Recipe Detail View ───────────────────────────────────────────────────── */
.recipe-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.recipe-stat-block {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.8rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}
.recipe-stat { text-align: center; }
.recipe-stat-val { font-size: 1.6rem; font-weight: 700; color: var(--accent-light); }
.recipe-stat-lbl { font-size: 0.75rem; color: var(--text-3); margin-top: 0.2rem; }

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-bar-wrap { position: relative; margin-bottom: 1.25rem; }
.search-bar-wrap input { padding-left: 2.2rem; }
.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 0.9rem;
  pointer-events: none;
}

/* ── Sort bar ─────────────────────────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.sort-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-3);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: var(--transition);
}
.sort-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.sort-btn:hover:not(.active) { border-color: var(--border-light); color: var(--text-2); }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.page-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-3);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:hover:not(.active):not(:disabled) { border-color: var(--border-light); color: var(--text); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Settings form rows ───────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label { margin: 0; flex: 1; }
.settings-row input[type="number"], .settings-row input[type="text"] { max-width: 140px; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.8rem; display: block; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-public { background: rgba(90,154,106,0.15); color: var(--success); border: 1px solid var(--success); }
.badge-private { background: var(--bg-4); color: var(--text-3); border: 1px solid var(--border); }
.badge-pinned { background: rgba(200,129,58,0.15); color: var(--accent); border: 1px solid var(--accent); }

/* ══════════════════════════════════════════════════════════════════════════════
   BOTTOM NAVIGATION (mobile-only)
   ══════════════════════════════════════════════════════════════════════════════ */
#bottom-nav {
  display: none;
}

/* ── More Sheet ──────────────────────────────────────────────────────────────── */
.more-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
}
.more-sheet-overlay.hidden { display: none; }
.more-sheet {
  width: 100%;
  background: var(--bg-2);
  border-top: 1px solid var(--border-light);
  border-radius: 20px 20px 0 0;
  padding: 0.75rem 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  animation: sheetUp 0.25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.more-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-light);
  margin: 0 auto 1rem;
}
.more-sheet-title {
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}
.more-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.more-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.9rem 0.5rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: var(--transition);
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.more-sheet-item:active { background: var(--bg-4); transform: scale(0.96); }
.more-sheet-item .more-icon { font-size: 1.4rem; }

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Navbar: logo-only strip on mobile ── */
  .nav-toggle { display: none; }
  .nav-links { display: none !important; }
  #navbar {
    height: 52px;
    padding: 0 1rem;
    justify-content: center;
  }
  .nav-brand { justify-content: center; }

  /* ── Bottom nav ── */
  #bottom-nav {
    display: grid;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    grid-template-columns: repeat(2, 1fr);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    align-items: stretch;
  }
  .bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-3);
    font-family: var(--font-ui);
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 0.4rem 0.25rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 0;
  }
  .bnav-item:active { opacity: 0.7; }
  .bnav-item.active { color: var(--accent); }
  .bnav-icon { font-size: 1.25rem; line-height: 1; }
  .bnav-label { font-size: 0.6rem; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* ── Content area: account for bottom nav ── */
  #app {
    padding: 1rem 1rem calc(72px + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
  }

  /* ── Toast: above bottom nav ── */
  #toast-container {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px) + 0.75rem);
    left: 1rem;
    right: 1rem;
    align-items: stretch;
  }
  .toast { max-width: 100%; text-align: center; }

  /* ── Modal: bottom sheet on mobile ── */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100%;
    padding: 1.5rem 1.25rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }
  .modal-close { top: 0.75rem; right: 0.75rem; }

  /* ── Typography ── */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  /* ── Hero ── */
  .hero { padding: 1.5rem 0.5rem 1rem; }
  .hero h1 { font-size: 2rem; }
  .hero-icon { font-size: 2.5rem; margin-bottom: 0.6rem; }
  .hero p { font-size: 0.95rem; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { text-align: center; justify-content: center; }

  /* ── Grids: single column on mobile ── */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }

  /* ── Feature cards: 2-column on mobile ── */
  .feature-cards { grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1.25rem; }
  .feature-card { padding: 1rem 0.75rem; }
  .feature-card-icon { font-size: 1.5rem; margin-bottom: 0.4rem; }
  .feature-card h3 { font-size: 0.82rem; }
  .feature-card p { font-size: 0.72rem; }

  /* ── Result grid: 2×2 ── */
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .result-value { font-size: 1.6rem; }

  /* ── Recipe cards: full-width with larger action area ── */
  .recipe-card { padding: 1rem; }
  .recipe-card-actions { margin-top: 0.75rem; }
  .upvote-btn { min-height: 40px; padding: 0.4rem 1rem; font-size: 0.875rem; }

  /* ── Buttons: stretch on mobile inside groups ── */
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; justify-content: center; }

  /* ── Tab buttons: larger targets ── */
  .tab-btn { min-height: 44px; font-size: 0.875rem; }
  .tab-buttons { gap: 0.25rem; }

  /* ── Sort bar ── */
  .sort-btn { min-height: 40px; padding: 0.4rem 1rem; }

  /* ── Range sliders: full-width row on mobile ── */
  .range-group { gap: 0.6rem; }
  .range-value { min-width: 54px; font-size: 0.875rem; }

  /* ── Leaderboard ── */
  .lb-item { padding: 0.85rem; gap: 0.75rem; }
  .lb-rank { min-width: 2rem; font-size: 1.1rem; }
  .lb-rank.top-3 { font-size: 1.3rem; }
  .lb-likes { font-size: 1rem; }

  /* ── Card padding tighter ── */
  .card { padding: 1.1rem; }

  /* ── Calculator: remove sticky on mobile ── */
  [style*="position:sticky"] { position: static !important; }

  /* ── Inline flex groups: always stack ── */
  .flex-wrap { flex-direction: column; }

  /* ── Result panel ── */
  .result-panel { padding: 1.1rem; }
  .result-value { font-size: 1.5rem; }

  /* ── Recipe stat block ── */
  .recipe-stat-block { padding: 0.9rem; }
  .recipe-stat-val { font-size: 1.3rem; }

  /* ── Leaderboard detail ── */
  .lb-stats { flex-direction: row; align-items: center; gap: 0.5rem; }

  /* ── Footer: hide on mobile (bottom nav replaces it) ── */
  footer { display: none; }

  /* ── Admin table: horizontal scroll ── */
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  .admin-table { min-width: 650px; }
  .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .admin-tab { white-space: nowrap; }

  /* ── Guide steps ── */
  .guide-step { flex-direction: column; gap: 0.75rem; }
  .step-num { width: 32px; height: 32px; font-size: 0.85rem; }

  /* ── Ratio table ── */
  .ratio-table th, .ratio-table td { padding: 0.5rem 0.6rem; font-size: 0.8rem; }

  /* ── Login box ── */
  .login-box { margin: 2rem auto; padding: 1.5rem; }

  /* ── Page badge ── */
  .page-header { margin-bottom: 1.25rem; }
}

/* Upvote button needs minimum tap target */
.upvote-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

@media (max-width: 400px) {
  .feature-cards { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  .hero h1 { font-size: 1.6rem; }
}

/* ── Wizard ────────────────────────────────────────────────────────────────── */
.wiz-wrap { max-width: 720px; margin: 0 auto; }

.wiz-header { text-align: center; margin-bottom: 2rem; }
.wiz-header h1 { font-size: 2rem; margin-bottom: 0.35rem; }
.wiz-header p { color: var(--text-2); }

.wiz-progress-wrap { margin-bottom: 1.75rem; }
.wiz-progress-track {
  height: 6px;
  background: var(--bg-4);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.wiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  transition: width 0.4s ease;
}
.wiz-step-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-3);
}
.wiz-step-label strong { color: var(--text-2); }

.wiz-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.wiz-question {
  font-size: 1.45rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.wiz-hint {
  color: var(--text-3);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Option cards grid — responsive by count */
.wiz-options {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.wiz-options-2 { grid-template-columns: repeat(2, 1fr); }
.wiz-options-3 { grid-template-columns: repeat(3, 1fr); }
.wiz-options-4 { grid-template-columns: repeat(2, 1fr); }

.wiz-option {
  position: relative;
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
  text-align: center;
  user-select: none;
}
.wiz-option:hover {
  border-color: var(--border-light);
  background: var(--bg-3);
  transform: translateY(-2px);
}
.wiz-option-selected {
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
}
.wiz-opt-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}
.wiz-opt-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.wiz-opt-sub {
  font-size: 0.75rem;
  color: var(--text-3);
  line-height: 1.4;
}
.wiz-option-selected .wiz-opt-sub { color: var(--accent); }

/* Checkbox checkmark badge */
.wiz-check {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: transparent;
  transition: var(--transition);
}
.wiz-option-selected .wiz-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Custom size input */
.wiz-custom-size {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.wiz-custom-size label { color: var(--text-2); font-size: 0.85rem; margin-bottom: 0.4rem; }

/* Dot navigation */
.wiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.wiz-nav-center {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.wiz-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: var(--transition);
  flex-shrink: 0;
}
.wiz-dot-active { background: var(--accent); transform: scale(1.3); }
.wiz-dot-done { background: var(--accent-dim); border: 1px solid var(--accent); }

/* Results page */
.wiz-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
}
.wiz-summary-label { font-size: 0.8rem; color: var(--text-3); white-space: nowrap; }
.wiz-pref-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; flex: 1; }

.wiz-results { display: flex; flex-direction: column; gap: 1.25rem; }

.wiz-rec-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}
.wiz-rec-card:hover { border-color: var(--border-light); }

.wiz-rec-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-left: 3px solid var(--accent);
  padding-left: 0.9rem;
  margin-bottom: 1.25rem;
}
.wiz-rec-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}
.wiz-rec-title {
  font-family: var(--font);
  font-size: 1.15rem;
  color: var(--text);
}
.wiz-rec-ratio {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-light);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Measurement display */
.wiz-measurements {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.wiz-measure {
  text-align: center;
  flex: 1;
  min-width: 100px;
}
.wiz-measure-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.wiz-measure-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.2rem;
  font-variant-numeric: tabular-nums;
}
.wiz-measure-lbl { font-size: 0.72rem; color: var(--text-3); line-height: 1.3; }
.wiz-measure-op {
  font-size: 1.5rem;
  color: var(--text-3);
  font-weight: 300;
  flex-shrink: 0;
}

/* Why box */
.wiz-why {
  background: var(--bg-4);
  border-left: 3px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.wiz-why strong { color: var(--text); }

/* Step-by-step collapsible */
.wiz-steps-detail {
  margin-bottom: 1rem;
}
.wiz-steps-detail summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-3);
  padding: 0.4rem 0;
  user-select: none;
  transition: var(--transition);
}
.wiz-steps-detail summary:hover { color: var(--text-2); }
.wiz-steps-detail[open] summary { color: var(--accent); margin-bottom: 0.75rem; }
.wiz-steps-list {
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-2);
}
.wiz-steps-list li { line-height: 1.5; }

.wiz-rec-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

/* ── Wizard: mobile overrides (within the global mobile @media block above) ── */
@media (max-width: 768px) {
  .wiz-wrap { max-width: 100%; }
  .wiz-header { margin-bottom: 1.25rem; }
  .wiz-header h1 { font-size: 1.6rem; }
  .wiz-header p { font-size: 0.875rem; }

  .wiz-card { padding: 1.25rem 1rem; }
  .wiz-question { font-size: 1.15rem; }
  .wiz-hint { font-size: 0.82rem; margin-bottom: 1.1rem; }

  /* 2-option steps: 1 column on small phones, 2 col on larger */
  .wiz-options-2 { grid-template-columns: 1fr; gap: 0.6rem; }
  .wiz-options-3 { grid-template-columns: 1fr; gap: 0.6rem; }
  .wiz-options-4 { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

  .wiz-option { padding: 0.9rem 0.75rem; }
  .wiz-opt-icon { font-size: 1.6rem; margin-bottom: 0.35rem; }
  .wiz-opt-label { font-size: 0.875rem; }
  .wiz-opt-sub { font-size: 0.72rem; }

  .wiz-nav { margin-top: 1.25rem; gap: 0.75rem; }
  .wiz-nav .btn { flex: 1; }
  .wiz-nav-center { display: none; } /* hide dots on mobile to save space */

  /* Measurements: stack cleanly */
  .wiz-measurements { flex-direction: column; gap: 0.4rem; padding: 0.9rem; }
  .wiz-measure-op { display: none; }
  .wiz-measure { min-width: 0; display: flex; align-items: center; gap: 0.6rem; text-align: left; }
  .wiz-measure-icon { font-size: 1.2rem; flex-shrink: 0; margin-bottom: 0; }
  .wiz-measure-val { font-size: 1rem; }
  .wiz-measure-lbl { display: none; }

  .wiz-rec-card { padding: 1.1rem; }
  .wiz-rec-actions { flex-direction: column; }
  .wiz-rec-actions .btn { width: 100%; }

  .wiz-summary { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .wiz-summary .btn { align-self: flex-start; }

  .wiz-progress-wrap { margin-bottom: 1.1rem; }
}

@media (max-width: 400px) {
  .wiz-options-4 { grid-template-columns: 1fr; }
}

/* ── SIMPLE CALCULATOR (sc-*) ─────────────────────────────────────────────── */

.sc-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 820px;
  margin: 0 auto;
}

/* ── Section cards: left inputs and right recipe share one uniform style ── */
.sc-card {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.sc-card-header {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.sc-card-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}

.sc-inputs-card .sc-section-split { margin-bottom: 1.5rem; }
.sc-section {}

/* Two controls side by side (Grind Size · Units) */
.sc-section-split {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 1rem;
}
.sc-section-split > div { flex: 1 1 0; min-width: 0; }
.sc-section-split .sc-toggle { display: flex; width: 100%; }
.sc-section-split .sc-toggle-opt { flex: 1; padding-left: 0.4rem; padding-right: 0.4rem; }

/* Small "i" info icon with a hover/focus tooltip */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 0.45rem;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  cursor: help;
  position: relative;
  transition: var(--transition);
}
/* Smaller variant for inline use next to a small uppercase label */
.info-icon-sm {
  width: 14px;
  height: 14px;
  margin-left: 0.4rem;
  border-width: 1px;
  font-size: 0.58rem;
  transform: translateY(-1px);
}
.info-icon:hover, .info-icon:focus { border-color: var(--accent); color: var(--accent); outline: none; }
.info-tip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 230px;
  background: var(--text);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 20;
}
.info-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
}
.info-icon:hover .info-tip, .info-icon:focus .info-tip { opacity: 1; visibility: visible; }

.sc-lbl {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.6rem;
}

/* Dilution selector (right column, above the recipe card) — 4 cards in a row */
.dil-select { margin-bottom: 1rem; }
.dil-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.dil-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.3rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.45rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.dil-btn-ratio {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
  line-height: 1;
}
.dil-btn-label {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-2);
}
.dil-btn-coffee {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.dil-btn:hover { border-color: var(--text-3); }
.dil-btn.on { background: var(--accent); border-color: var(--accent); }
.dil-btn.on .dil-btn-ratio,
.dil-btn.on .dil-btn-coffee { color: #fff; }
.dil-btn.on .dil-btn-label { color: rgba(255,255,255,0.85); }
.dil-btn.is-off { opacity: 0.45; cursor: not-allowed; background: var(--bg); }
.dil-btn.is-off:hover { border-color: var(--border); }
.dil-note {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-3);
}
.sc-dilute-hint {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: var(--text-2);
}

/* Segmented toggle (e.g. Grind Size: Coarse | Medium) */
.sc-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 980px;
  padding: 3px;
  gap: 2px;
}
.sc-toggle-opt {
  border: none;
  background: transparent;
  padding: 0.45rem 1.4rem;
  min-height: 38px;
  border-radius: 980px;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sc-toggle-opt:hover { color: var(--text); }
.sc-toggle-opt.on {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Pill buttons */
.sc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sc-pill {
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: 2rem;
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sc-pill:hover { border-color: var(--text-3); color: var(--text); }

.sc-pill-on, .sc-pill-on:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.sc-pill-on .sc-pill-hint { color: rgba(255,255,255,0.78); }

.sc-pill-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 0.4rem;
}

.sc-container-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 0.35rem;
}

.sc-custom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.sc-custom-row input[type="number"] {
  width: 90px;
  flex-shrink: 0;
}

.sc-custom-row select {
  width: 72px;
  flex-shrink: 0;
}

/* Intensity 2×2 grid */
.sc-int-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.sc-int-card {
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

.sc-int-card:hover { border-color: var(--accent); }

.sc-int-on {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.sc-int-icon { font-size: 1.5rem; line-height: 1; }

.sc-int-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.15rem;
}

.sc-int-ratio {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-light);
}

.sc-int-sub {
  font-size: 0.68rem;
  color: var(--text-3);
  line-height: 1.3;
}

/* Result panel */
.sc-result-wrap { display: flex; flex-direction: column; gap: 0.75rem; }

/* .sc-result-card inherits the unified card look from .sc-card */

.sc-result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sc-result-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
/* Output / Details sub-section headings inside the recipe card */
.sc-section-lbl { display: block; margin-bottom: 0.75rem; }

.sc-result-container {
  font-size: 0.8rem;
  color: var(--text-3);
  background: var(--bg-3);
  border-radius: 1rem;
  padding: 0.2rem 0.65rem;
}

/* Big measurements row */
.sc-big-measures {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.sc-big-measure {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  flex: 1;
  min-width: 110px;
  text-align: center;
}

.sc-big-icon { font-size: 1.25rem; }

.sc-big-val {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

.sc-unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
}

.sc-big-lbl {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.15rem;
}

.sc-big-alt {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}

.sc-big-plus {
  font-size: 1.5rem;
  color: var(--text-3);
  flex-shrink: 0;
  align-self: center;
}

/* Fit check bar */
.sc-fit {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  background: var(--bg-3);
}

.sc-fit-good { border-left: 3px solid #4caf50; }
.sc-fit-warn { border-left: 3px solid #ff9800; }
.sc-fit-bad  { border-left: 3px solid #f44336; }

.sc-fit-icon { font-size: 1.1rem; flex-shrink: 0; }

.sc-fit-text {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.4;
}

.sc-fit-track {
  width: 60px;
  height: 6px;
  background: var(--bg-4);
  border-radius: 3px;
  flex-shrink: 0;
  overflow: hidden;
}

.sc-fit-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Output rows */
.sc-out-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
}

.sc-out-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  padding: 0.2rem 0;
}

.sc-out-lbl { color: var(--text-3); }
.sc-out-val { font-weight: 600; color: var(--text); }

/* Dilution instructions */
.sc-dilution {
  background: var(--bg-3);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
}

.sc-d-step {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text-2);
}

.sc-d-num {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.sc-dilution-note {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 0.5rem;
  line-height: 1.4;
}

/* Steeping guidance grid */
.sc-steep-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.sc-steep-cell {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
}

.sc-steep-cell strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 0.2rem;
}

.sc-steep-time {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-light);
}

.sc-steep-note {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.2rem;
  line-height: 1.3;
}

/* Actions */
.sc-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.sc-actions .btn {
  flex: 1;
  min-width: 100px;
}

/* Desktop: side-by-side */
@media (min-width: 769px) {
  .sc-layout {
    flex-direction: row;
    align-items: stretch;
  }
  .sc-inputs-card { flex: 0 0 340px; }
  .sc-result-wrap { flex: 1; }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .sc-int-grid { grid-template-columns: 1fr 1fr; }
  .sc-big-measures { gap: 0.4rem; }
  .sc-big-measure { min-width: 90px; padding: 0.7rem 0.6rem; }
  .sc-big-val { font-size: 1.6rem; }
  .sc-steep-grid { grid-template-columns: 1fr 1fr; }
  .sc-actions { flex-direction: column; }
  .sc-actions .btn { width: 100%; }

  /* Grind Size / Units toggles: shrink text so both options fit their pill */
  .sc-section-split { gap: 1rem 0.75rem; }
  .sc-section-split .sc-toggle-opt {
    font-size: 0.78rem;
    padding: 0.42rem 0.25rem;
    min-height: 36px;
  }

  /* Recipe selector: 2 across (two rows) instead of one cramped line */
  .dil-btns { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
  .dil-btn { padding: 0.8rem 0.5rem; }
  .dil-btn-label { font-size: 0.78rem; }
}
