/* =====================================================================
   SLUSH·IT — clean, compact UI
   ===================================================================== */

:root {
  /* warm, slightly-tinted neutrals — more depth than pure white */
  --bg: #eef0f4;
  --bg-tint: #e7eaf0;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --border: #dfe2e8;
  --border-strong: #c8ccd4;
  --text: #14161c;
  --text-2: #444a55;
  --text-3: #6b7280;
  --text-mute: #9aa0aa;

  /* accent: a deeper indigo with personality, not generic blue */
  --accent: #4f46e5;
  --accent-hover: #3730a3;
  --accent-soft: #eef2ff;
  --accent-soft-2: #e0e7ff;

  /* metric tints — each section gets its own subtle hue */
  --tint-abv: #fff4e6;
  --tint-abv-edge: #fde2bf;
  --tint-abv-ink: #b4571a;

  --tint-brix: #e6f6f4;
  --tint-brix-edge: #b8e1da;
  --tint-brix-ink: #1f6f63;

  --tint-vol: #eef2ff;
  --tint-vol-edge: #c7d2fe;
  --tint-vol-ink: #3730a3;

  --tint-guide: #fff8e1;
  --tint-guide-edge: #fde6a0;
  --tint-guide-ink: #855a04;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --radius: 6px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px -4px rgba(15, 23, 42, 0.06);

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e13;
    --bg-tint: #0a0c10;
    --surface: #161a22;
    --surface-2: #1c2029;
    --border: #2a2f3a;
    --border-strong: #3a4150;
    --text: #f1f3f7;
    --text-2: #c8ccd4;
    --text-3: #98a0ac;
    --text-mute: #6a7180;

    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e1b4b66;
    --accent-soft-2: #312e8155;

    --tint-abv: #3a210e;
    --tint-abv-edge: #5e3614;
    --tint-abv-ink: #fbbf77;

    --tint-brix: #0d2c28;
    --tint-brix-edge: #1b4a43;
    --tint-brix-ink: #6ed3c1;

    --tint-vol: #1e1b4b;
    --tint-vol-edge: #312e81;
    --tint-vol-ink: #a5b4fc;

    --tint-guide: #2c2107;
    --tint-guide-edge: #4a3911;
    --tint-guide-ink: #f4cf6c;

    --ok: #4ade80;
    --ok-soft: #14532d66;
    --warn: #fbbf24;
    --warn-soft: #78350f66;
    --danger: #f87171;
    --danger-soft: #7f1d1d66;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 1px 2px rgba(0,0,0,0.4), 0 6px 16px -4px rgba(0,0,0,0.5);
  }
}

/* -- reset -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, var(--accent-soft) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-tint) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* -- decorative bg elements (hidden in clean mode) ---------------- */
.bg-grain, .bg-glow { display: none; }

/* -- layout containers -------------------------------------------- */
.topbar, .view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
}

/* -- topbar ------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1;
  margin: 0;
  color: var(--text);
  font-style: normal;
  font-variation-settings: normal;
  display: inline-flex;
  align-items: baseline;
}
.brand-text h1 .brand-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 4px;
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px var(--accent-soft);
  font-size: 0;
  color: transparent;
}
.brand-text p {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0;
  text-transform: none;
}

.view-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 0;
  box-shadow: var(--shadow-sm);
}
.view-switch button {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  transition: background .12s, color .12s, box-shadow .12s;
}
.view-switch button.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent);
}
.view-switch button:not(.active):hover { background: var(--surface-2); color: var(--text); }

/* -- panels ------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-head h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 0;
  font-style: normal;
  font-variation-settings: normal;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.panel-head h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
}
.panel-head p {
  margin: 2px 0 0;
  color: var(--text-3);
  font-size: 12px;
  flex-basis: 100%;
}

/* per-section accent stripe colors */
.targets .panel-head h2::before { background: var(--tint-vol-ink); }
.ingredients .panel-head h2::before { background: var(--text-2); }
.guide .panel-head h2::before { background: var(--tint-guide-ink); }
.adjustments .panel-head h2::before { background: var(--tint-brix-ink); }
.results .panel-head h2::before { background: var(--accent); }

/* -- views -------------------------------------------------------- */
.view { display: none; }
.view.active { display: block; }

/* -- recipe bar --------------------------------------------------- */
.recipe-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}
.recipe-bar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1 1 360px;
}
.recipe-bar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.field-inline {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 30px;
  min-width: 200px;
  flex: 1 1 200px;
}
.field-inline-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: none;
  letter-spacing: 0;
}
.field-inline input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  color: var(--text);
  font-style: normal;
  font-family: var(--font-ui);
}

#recipe-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 30px;
  padding: 0 28px 0 10px;
  color: var(--text);
  font-size: 13px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 49%, var(--text-3) 51%),
                    linear-gradient(-45deg, transparent 49%, var(--text-3) 51%);
  background-size: 5px 5px, 5px 5px;
  background-position: right 14px top 13px, right 10px top 13px;
  background-repeat: no-repeat;
}

/* -- buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-mini { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-add { margin-top: 8px; height: 28px; font-size: 12px; }
.btn-icon { width: 30px; padding: 0; }
.btn-icon svg { display: block; }

.bar-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  align-self: center;
}

/* -- cloud sync button ------------------------------------------- */
.btn-cloud {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  padding-left: 18px;
}
.btn-cloud .cloud-icon { display: block; flex: none; }
.btn-cloud .cloud-status {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
/* status dot */
.btn-cloud::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-mute);
}
.btn-cloud[data-state="synced"]::before { background: var(--ok); }
.btn-cloud[data-state="syncing"]::before {
  background: var(--accent);
  animation: cloud-pulse 1s ease-in-out infinite;
}
.btn-cloud[data-state="offline"]::before { background: var(--warn); }
.btn-cloud[data-state="error"]::before,
.btn-cloud[data-state="auth"]::before { background: var(--danger); }
.btn-cloud[data-state="synced"] .cloud-icon { color: var(--ok); }
.btn-cloud[data-state="error"] .cloud-status,
.btn-cloud[data-state="auth"] .cloud-status { color: var(--danger); }

@keyframes cloud-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* -- field -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 11px;
  color: var(--text-3);
  padding-left: 2px;
}
.field-input-wrap {
  display: flex; align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 32px;
  transition: border-color .12s, box-shadow .12s;
}
.field-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-input-wrap input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--text);
  width: 100%;
  min-width: 0;
}
.field-suffix {
  display: grid; place-items: center;
  padding: 0 10px;
  background: var(--surface-2);
  border-left: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.field-unit {
  background: var(--surface-2);
  border: 0;
  border-left: 1px solid var(--border);
  padding: 0 8px;
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--font-mono);
  appearance: none;
}

/* -- targets grid ------------------------------------------------- */
.targets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

/* -- ingredients table ------------------------------------------- */
.ingredients-table-wrap {
  display: block;
  overflow-x: auto;
  margin: 0 -4px;
}
.ingredients-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}
.ingredients-table th {
  text-align: left;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
.ingredients-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.ingredients-table tbody tr:hover { background: var(--surface-2); }
.ingredients-table td {
  padding: 2px 6px;
  vertical-align: middle;
}

.col-num {
  font-family: var(--font-mono);
  color: var(--text-mute);
  width: 28px;
  font-size: 12px;
  text-align: center;
}
.col-type { width: 100px; }
.col-name { min-width: 120px; }
.col-num-input { width: 72px; }
.col-derived {
  text-align: right;
  color: var(--text-2);
  white-space: nowrap;
  font-size: 12px;
  padding-right: 10px !important;
}
.col-remove { width: 28px; padding: 0 4px !important; text-align: center; }
.col-drag { width: 22px; padding: 0 2px !important; text-align: center; }

/* drag handle + drag states */
.drag-handle {
  width: 22px; height: 26px;
  display: inline-grid; place-items: center;
  color: var(--text-mute);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
  opacity: 0;
  transition: opacity .12s, color .12s, background .12s;
}
.drag-handle:hover { color: var(--text-2); background: var(--surface-2); }
.drag-handle:active { cursor: grabbing; }
.ingredients-table tbody tr:hover .drag-handle,
.ing-card .drag-handle { opacity: 1; }

[data-idx].dragging {
  opacity: 0.35;
  background: var(--accent-soft) !important;
}
[data-idx].drop-above {
  box-shadow: 0 -2px 0 0 var(--accent) inset;
}
[data-idx].drop-below {
  box-shadow: 0 2px 0 0 var(--accent) inset;
}
.ingredients-table tbody tr.drop-above td {
  border-top: 2px solid var(--accent);
}
.ingredients-table tbody tr.drop-below td {
  border-bottom: 2px solid var(--accent);
}
body.dragging-active, body.dragging-active * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

.ingredients-table input,
.ingredients-table select {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  color: var(--text);
  outline: 0;
  height: 26px;
  transition: border-color .1s, background .1s;
}
.ingredients-table input:hover,
.ingredients-table select:hover {
  border-color: var(--border);
}
.ingredients-table input[type="number"] {
  font-family: var(--font-mono);
  text-align: right;
}
.ingredients-table input:focus,
.ingredients-table select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.ingredients-table select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 51%),
                    linear-gradient(-45deg, transparent 50%, var(--text-3) 51%);
  background-size: 4px 4px, 4px 4px;
  background-position: right 8px top 50%, right 5px top 50%;
  background-repeat: no-repeat;
  padding-right: 18px;
}

.ingredients-table tfoot td {
  padding: 8px 8px 4px;
  font-size: 11px;
  color: var(--text-3);
}
.ingredients-table tfoot .totals-label { text-align: right; text-transform: none; letter-spacing: 0; }
.ingredients-table tfoot .mono { color: var(--text); text-align: right; padding-right: 10px; }

.row-remove {
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  border-radius: 4px;
  color: var(--text-mute);
  background: transparent;
  border: 0;
  opacity: 0;
  transition: color .1s, background .1s, opacity .1s;
}
.ingredients-table tbody tr:hover .row-remove,
.ing-card .row-remove { opacity: 1; }
.row-remove:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* -- ingredients cards (phone) ----------------------------------- */
.ingredients-cards { display: none; }
.ing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
}
.ing-card-head {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.ing-card-num {
  font-family: var(--font-mono);
  color: var(--text-mute);
  font-size: 12px;
  width: 18px; text-align: center;
}
.ing-card-name {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  color: var(--text);
  outline: 0;
  font-style: normal;
  font-family: var(--font-ui);
  font-weight: 500;
  min-width: 0;
  width: 100%;
}
.ing-card-name:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ing-card-type {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 22px 6px 8px;
  font-size: 12px;
  color: var(--text-2);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 51%),
                    linear-gradient(-45deg, transparent 50%, var(--text-3) 51%);
  background-size: 4px 4px, 4px 4px;
  background-position: right 8px top 50%, right 5px top 50%;
  background-repeat: no-repeat;
}
.ing-card-head .row-remove { width: 26px; height: 26px; }

.ing-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.ing-card-grid > label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  color: var(--text-3);
  min-width: 0;
}
.ing-card-grid input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-align: right;
  outline: 0;
  height: 30px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.ing-card-grid input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.ing-card-derived {
  grid-column: 1 / -1;
  display: flex;
  gap: 14px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.ing-card-derived span {
  display: flex; align-items: baseline; gap: 4px;
}
.ing-card-derived em {
  font-style: normal;
  font-size: 10px;
  color: var(--text-3);
}
.ing-card-derived b {
  font-weight: 500;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono);
}

/* -- guide -------------------------------------------------------- */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.guide-card {
  background: var(--tint-guide);
  border: 1px solid var(--tint-guide-edge);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.guide-label {
  font-size: 11px;
  color: var(--tint-guide-ink);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.guide-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.guide-unit { font-size: 12px; color: var(--tint-guide-ink); font-family: var(--font-mono); font-weight: 500; }
.guide-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.guide-card .btn { align-self: flex-start; margin-top: 2px; }
.guide-card-both {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent-soft-2) 100%);
  border-color: var(--accent-soft-2);
}
.guide-card-both .guide-label { color: var(--accent); }

/* -- results ------------------------------------------------------ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.result-card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
}
.result-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}
.result-card-abv {
  background: var(--tint-abv);
  border-color: var(--tint-abv-edge);
}
.result-card-abv::before { background: var(--tint-abv-ink); }
.result-card-abv .result-label { color: var(--tint-abv-ink); }
.result-card-abv .result-unit { color: var(--tint-abv-ink); }

.result-card-brix {
  background: var(--tint-brix);
  border-color: var(--tint-brix-edge);
}
.result-card-brix::before { background: var(--tint-brix-ink); }
.result-card-brix .result-label { color: var(--tint-brix-ink); }
.result-card-brix .result-unit { color: var(--tint-brix-ink); }

.result-card-vol {
  background: var(--tint-vol);
  border-color: var(--tint-vol-edge);
}
.result-card-vol::before { background: var(--tint-vol-ink); }
.result-card-vol .result-label { color: var(--tint-vol-ink); }
.result-card-vol .result-unit { color: var(--tint-vol-ink); }
.result-card-vol .result-sub { color: var(--tint-vol-ink); opacity: 0.7; }

.result-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.result-value {
  display: flex; align-items: baseline; gap: 4px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: -0.015em;
}
.result-value .out-of-range { color: var(--danger); }
.result-unit {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-weight: 500;
}
.result-sub { color: var(--text-3); font-size: 11px; font-family: var(--font-mono); }

.result-card-status { gap: 8px; }
.result-card-status::before { background: var(--ok); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
}
.status-pill[data-status="Adjust"] {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}
.status-pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 20%, transparent);
}

.btn-build { align-self: stretch; }

/* -- footnote ----------------------------------------------------- */
.footnote {
  margin-top: 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 11px;
}

.app-footer {
  max-width: 1100px;
  margin: 4px auto 0;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-mute);
  font-size: 11px;
}
.app-footer .app-version {
  font-family: var(--font-mono);
  color: var(--text-3);
}

/* =====================================================================
   BRIX REFERENCE VIEW (juices)
   ===================================================================== */
.juices-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.juice-row {
  position: relative;
  display: grid;
  grid-template-columns: 22px 24px minmax(0, 1fr) 110px 92px 92px auto auto;
  align-items: end;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.juice-row .drag-handle { opacity: 1; }

/* Drop indicator: a line in the gap between rows, not a box around the row. */
.juice-row.drop-above,
.juice-row.drop-below { box-shadow: none; }
.juice-row.drop-above::after,
.juice-row.drop-below::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.juice-row.drop-above::after { top: -4px; }
.juice-row.drop-below::after { bottom: -4px; }
.juice-type {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 22px 6px 8px;
  font-size: 12px;
  color: var(--text-2);
  outline: 0;
  min-width: 0;
  width: 100%;
  height: 30px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 51%),
                    linear-gradient(-45deg, transparent 50%, var(--text-3) 51%);
  background-size: 4px 4px, 4px 4px;
  background-position: right 8px top 50%, right 5px top 50%;
  background-repeat: no-repeat;
}
.juice-type:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.juice-num {
  font-family: var(--font-mono);
  color: var(--text-mute);
  font-size: 12px;
  align-self: end;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.juice-row .drag-handle { align-self: end; height: 30px; }
.juice-name {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  outline: 0;
  min-width: 0;
  width: 100%;
}
.juice-name:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.juice-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-3);
  min-width: 0;
}
.juice-field input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-align: right;
  outline: 0;
  height: 30px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.juice-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.juice-add {
  width: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--accent);
}
.juice-remove { width: 26px; height: 26px; }

@media (max-width: 720px) {
  .juice-row {
    grid-template-columns: 16px 18px minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    gap: 6px 8px;
  }
  .juice-row .drag-handle { grid-column: 1; grid-row: 1 / -1; align-self: center; }
  .juice-num { grid-column: 2; grid-row: 1 / -1; align-self: center; height: auto; }
  .juice-name { grid-column: 3 / 5; grid-row: 1; }
  .juice-remove { grid-column: 5; grid-row: 1; justify-self: end; }
  .juice-type { grid-column: 3 / 5; grid-row: 2; }
  .juice-field:nth-of-type(1) { grid-column: 3; grid-row: 3; }
  .juice-field:nth-of-type(2) { grid-column: 4; grid-row: 3; }
  .juice-add { grid-column: 5; grid-row: 3; justify-self: end; }
}

/* =====================================================================
   BUILD VIEW
   ===================================================================== */
.build-hero {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface) 60%);
  border: 1px solid var(--accent-soft-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.build-hero-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.btn-back { padding: 0 12px; }

.build-title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  color: var(--text);
  font-style: normal;
  font-variation-settings: normal;
  letter-spacing: -0.01em;
}
.build-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  font-size: 12px;
  color: var(--text-2);
}
.build-meta em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-3);
  margin-right: 3px;
}
.build-meta b { font-weight: 500; color: var(--text); font-family: var(--font-mono); }
.build-meta-batch b {
  color: var(--accent);
  font-size: 13px;
}
.build-meta-sep { color: var(--border); }
.build-status-pill { margin-left: auto; }

.build-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}
.build-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  transition: background .15s, border-color .15s, opacity .15s;
}
.build-row-adj {
  background: var(--accent-soft);
  border-color: transparent;
}
.build-row.checked {
  background: var(--ok-soft);
  border-color: transparent;
  opacity: 0.6;
}
.build-row.checked .build-name-main {
  text-decoration: line-through;
  text-decoration-color: var(--text-mute);
}

.build-check {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: transparent;
  transition: border-color .15s, background .15s, color .15s;
}
.build-check:hover { border-color: var(--accent); }
.build-row.checked .build-check {
  background: var(--ok);
  border-color: var(--ok);
  color: white;
}

.build-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.build-name-main {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-style: normal;
  font-variation-settings: normal;
  line-height: 1.2;
  word-break: break-word;
  letter-spacing: -0.005em;
}
.build-name-sub {
  font-size: 11px;
  color: var(--text-3);
  text-transform: none;
  letter-spacing: 0;
}

.build-amount {
  display: flex; align-items: baseline; gap: 4px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.build-amount .build-unit {
  font-size: 11px;
  color: var(--text-3);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-mono);
  font-weight: 400;
}
.build-amount-alt {
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
}
.build-amount-alt .build-unit { font-size: 10px; }

.build-footnote {
  text-align: center;
  color: var(--text-mute);
  font-size: 11px;
  margin: 20px 0 10px;
}

/* -- flash toast -------------------------------------------------- */
.flash {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.flash.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 720px) {
  .ingredients-table-wrap { display: none; }
  .ingredients-cards { display: block; }

  .recipe-bar-right { width: 100%; flex-wrap: wrap; gap: 6px; }
  .recipe-bar-right .bar-divider { display: none; }
  #btn-save, #btn-new, #btn-dup, #btn-delete { flex: 1 1 0; min-width: 0; }
  #btn-cloud { flex: 1 1 auto; justify-content: center; }
  .recipe-bar-right .btn-icon { flex: 0 0 auto; }

  .topbar { flex-wrap: wrap; gap: 10px; }
  .view-switch { width: 100%; }
  .view-switch button { flex: 1; }

  .build-row {
    grid-template-columns: 28px 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
    padding: 8px 10px;
  }
  .build-check { grid-row: 1 / -1; }
  .build-name { grid-column: 2; grid-row: 1; }
  .build-amount { grid-column: 3; grid-row: 1; }
  .build-amount-alt {
    grid-column: 2 / -1;
    grid-row: 2;
    justify-self: end;
    font-size: 12px;
  }
}

/* strip native number arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }
