  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  :root {
    color-scheme: dark;
    --bg-0: #050810;
    --bg-1: #0a0f1c;
    --bg-2: #0f1729;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --surface-active: rgba(34, 211, 238, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.14);
    --border-active: rgba(34, 211, 238, 0.5);
    --text: #e8ecf4;
    --text-dim: #b8c7d6;
    --text-faint: #9aaec0;
    --accent: #22d3ee;
    --accent-2: #a78bfa;
    --accent-glow: rgba(34, 211, 238, 0.4);
    --warn: #fb923c;
    --error: #f87171;
    --good: #34d399;
  }

  html, body {
    background: var(--bg-0);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', system-ui, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
  }

  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
      radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 211, 238, 0.12), transparent),
      radial-gradient(ellipse 60% 50% at 80% 80%, rgba(167, 139, 250, 0.08), transparent),
      radial-gradient(ellipse 50% 40% at 10% 60%, rgba(34, 211, 238, 0.06), transparent);
    pointer-events: none;
    z-index: 0;
  }

  .container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    padding-top: max(48px, env(safe-area-inset-top));
  }

  .lang-switcher {
    position: absolute;
    top: max(24px, env(safe-area-inset-top));
    right: max(24px, env(safe-area-inset-right));
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
    backdrop-filter: blur(8px);
    z-index: 10;
  }

  .lang-btn {
    background: transparent;
    border: none;
    width: 36px;
    height: 28px;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.55;
    padding: 0;
    overflow: hidden;
  }
  .lang-btn:hover {
    opacity: 0.9;
    background: var(--surface-hover);
  }
  .lang-btn.active {
    opacity: 1;
    background: var(--surface-active);
    box-shadow: 0 0 0 1px var(--border-active);
  }
  .lang-btn svg {
    width: 22px;
    height: 16px;
    border-radius: 2px;
    display: block;
  }

  .mode-toggle {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* four modes wrap 2×2 on narrow screens */
    gap: 8px;
    margin-bottom: 32px;
  }

  .mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    touch-action: manipulation;
  }

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

  .mode-btn.active {
    background: var(--surface-active);
    border-color: var(--border-active);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
  }

  .mode-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .header {
    text-align: center;
    margin-bottom: 48px;
    padding-top: 8px;
  }

  .header .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 16px;
  }

  .header .badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-glow);
    animation: pulse 2s ease-in-out infinite;
  }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }

  .header h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 60%, #22d3ee 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    line-height: 1.1;
  }

  .header p {
    color: var(--text-dim);
    font-size: 15px;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
  }

  .layout {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 24px;
    align-items: stretch; /* beide Karten gleich hoch */
  }

  /* Grid items must be allowed to shrink below their content's min width —
     otherwise wide content (e.g. the blend units table) inflates the whole
     column instead of scrolling inside its own container. */
  .layout > * { min-width: 0; }

  .card {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .step {
    margin-bottom: 28px;
  }
  .step:last-child { margin-bottom: 0; }

  .step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }

  .step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .step.complete .step-num {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #000;
  }

  .step-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text);
  }

  .step-hint {
    font-size: 11px;
    color: var(--text-faint);
    margin-left: auto;
  }

  .step-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    margin-left: 4px;
    opacity: 0.7;
    transition: all 0.3s ease;
  }

  .step.complete .step-icon {
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.4));
  }

  .pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .pill {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
    position: relative;
    touch-action: manipulation;
  }

  .pill:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text);
  }

  .pill.active {
    background: var(--surface-active);
    border-color: var(--border-active);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
  }

  .pill.recommended {
    border-color: rgba(167, 139, 250, 0.4);
    background: rgba(167, 139, 250, 0.06);
    color: #c4b5fd;
  }

  .pill.recommended::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: var(--accent-2);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.7);
  }

  .pill.recommended.active {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(167, 139, 250, 0.12));
    border-color: var(--border-active);
    color: var(--accent);
  }

  .custom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
  }

  .input-wrap {
    position: relative;
    flex: 1;
  }

  input[type="text"], select {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 10px 14px;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: all 0.15s ease;
  }

  input[type="text"]:focus, select:focus {
    border-color: var(--border-active);
    background: var(--surface-active);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
  }

  select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%238b95ad' d='M6 8L2 4h8z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
  }

  /* Style options for dark theme - works in most browsers */
  select option {
    background-color: #0f1729;
    color: var(--text);
    padding: 8px;
  }

  .unit-suffix {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 12px;
    pointer-events: none;
  }

  .dose-row {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .solve-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
  }

  .solve-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
  }

  .solve-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
  }

  .solve-desc {
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-faint);
    margin: 0;
  }

  .unit-toggle-group {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
  }

  .unit-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    touch-action: manipulation;
  }

  .unit-toggle-btn.active {
    background: var(--surface-active);
    color: var(--accent);
  }

  .peptide-info {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(167, 139, 250, 0.05);
    border: 1px solid rgba(167, 139, 250, 0.18);
    border-radius: 10px;
    font-size: 11px;
    color: #c4b5fd;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }

  .peptide-info svg { flex-shrink: 0; margin-top: 1px; }

  /* Results use a rounded, high-legibility system font (no web font needed).
     Scoped to the result card so the rest of the UI keeps its typography. */
  .result-card {
    font-family: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN",
                 "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  .result-card {
    position: relative;
    overflow: visible;
    /* flex column so #result-content can fill the full card height */
    display: flex;
    flex-direction: column;
  }

  /* Result card: right column, same grid row as form — both stretch to equal height */
  .layout .result-card {
    grid-column: 2;
    grid-row: 1;
    padding-right: 8px; /* syringe closer to right edge */
  }

  /* The inner content div must also fill the card */
  #result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  /* Result layout: stats left, syringe right */
  .result-layout {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 16px;
  }

  .result-info {
    flex: 1;
    min-width: 0;
  }

  /* Stats grid must never shrink */
  .result-layout .stats-grid {
    flex-shrink: 0;
  }

  .result-layout .primary-result {
    text-align: center;
  }

  .result-syringe {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
  }

  /* Syringe: clamped height so it stays readable on all screen sizes */
  .result-syringe .syringe-viz {
    height: clamp(260px, 52vh, 500px);
    width: auto;
    display: block;
  }

  /* Tablet (≤920 px): single column — result card moves below form */
  @media (max-width: 920px) {
    .layout .result-card { grid-column: 1; grid-row: auto; padding-right: 24px; }
    .result-syringe .syringe-viz { height: clamp(240px, 45vh, 380px); }
  }

  /* Mobile (≤560 px): keep syringe side-by-side, shrink spacing */
  @media (max-width: 560px) {
    .result-layout { gap: 12px; align-items: stretch; }
    .result-info { flex: 1; min-width: 0; }
    .result-syringe { flex: 1; align-self: stretch; }
    .result-syringe .syringe-viz { height: 100%; width: 100%; flex-shrink: 0; object-fit: contain; }
  }

  .result-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg, transparent 0%, rgba(34, 211, 238, 0.3) 50%, transparent 100%);
    border-radius: 20px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
  }

  .result-card.ready::before { opacity: 1; }

  .result-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-faint);
    font-size: 13px;
  }

  .result-empty svg { margin: 0 auto 12px; opacity: 0.4; display: block; }

  .syringe-viz {
    display: block;
  }

  .primary-result {
    text-align: center;
    margin-bottom: 24px;
  }

  .primary-result .label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 4px;
  }

  .primary-result .value {
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
  }

  .primary-result .unit-label {
    font-size: 18px;
    color: var(--text-dim);
    font-weight: 500;
    margin-left: 4px;
    -webkit-text-fill-color: var(--text-dim);
  }

  /* Plain-language instruction — the sentence users actually read.
     Left-aligned so longer sentences stay easy to scan when they wrap. */
  .primary-result .sub {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    margin-top: 10px;
    text-align: left;
    font-variant-numeric: tabular-nums;
  }

  /* Secondary ml / syringe details under the plain sentence */
  .primary-result .sub .sub-tech {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-faint);
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
  }

  .stat .stat-label {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 4px;
  }

  .stat .stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  .stat .stat-sub {
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--text-dim);
    margin-top: 4px;
  }

  .actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  .btn {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    touch-action: manipulation;
  }

  .btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
  }

  .btn.primary {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(167, 139, 250, 0.15));
    border-color: rgba(34, 211, 238, 0.3);
    color: var(--accent);
  }

  .btn.primary:hover {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(167, 139, 250, 0.25));
  }

  /* ---------- Blend builder ---------- */
  .blend-row-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .blend-row-item .bb-dot { flex-shrink: 0; }

  /* min-width: 0 everywhere — inputs otherwise refuse to shrink below their
     intrinsic size in flex rows and overflow the card on mobile */
  .blend-name { flex: 1; min-width: 0; }

  .blend-amount {
    flex: 0 0 64px;
    width: 64px;
    min-width: 0;
    text-align: right;
  }

  .blend-unit-toggle { flex-shrink: 0; }

  .blend-unit-toggle .unit-toggle-btn {
    padding: 7px 9px;
    font-size: 11px;
  }

  /* Anchor peptide selector in the dose step */
  .blend-anchor { margin-bottom: 12px; }

  .blend-anchor-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 8px;
  }

  .blend-anchor-pill,
  #blend-anchor-pills .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .bb-row.bb-anchor .bb-name { font-weight: 700; }
  .bb-anchor-tag { font-size: 11px; opacity: 0.8; }

  @media (max-width: 560px) {
    .blend-row-item { gap: 5px; }
    .blend-amount { flex-basis: 52px; width: 52px; }
    .blend-unit-toggle .unit-toggle-btn { padding: 6px 6px; font-size: 10px; }
    .blend-remove { width: 28px; }
  }

  .blend-remove {
    flex-shrink: 0;
    width: 34px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-faint);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
  }
  .blend-remove:hover:not(:disabled) {
    border-color: rgba(248, 113, 113, 0.5);
    color: var(--error);
    background: rgba(248, 113, 113, 0.08);
  }
  .blend-remove:disabled { opacity: 0.3; cursor: default; }

  .blend-add-btn {
    flex: none;
    width: auto;
    margin-top: 2px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--accent);
    border-color: rgba(34, 211, 238, 0.3);
  }

  /* Composition panel in the result card */
  .blend-breakdown {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 16px;
  }

  .blend-breakdown .bb-title {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 8px;
  }

  .bb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
  }

  .bb-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bb-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .bb-val {
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
  }

  .bb-share { color: var(--text-faint); font-weight: 400; }

  /* Units reference table (full width under the result layout) */
  .blend-table-wrap { margin-top: 4px; margin-bottom: 0; }

  .blend-table-scroll { overflow-x: auto; }

  .blend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .blend-table th {
    text-align: right;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }

  .blend-table th .bb-dot {
    width: 7px;
    height: 7px;
    margin-right: 5px;
  }

  .blend-table td {
    text-align: right;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: nowrap;
  }

  .blend-table th:first-child,
  .blend-table td:first-child { text-align: left; }

  .blend-table td:first-child { color: var(--text); font-weight: 600; }

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

  /* The row matching the user's calculated draw */
  .blend-table tr.near td {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent);
    font-weight: 600;
  }

  .blend-table tr.near td:first-child {
    box-shadow: inset 2px 0 0 var(--accent);
  }

  .tbl-tag {
    font-family: inherit;
    font-size: 9.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
    margin-left: 4px;
  }

  /* "How long this lasts" table — two columns, no horizontal scroll needed */
  .freq-table-wrap { margin-top: 4px; margin-bottom: 0; }

  /* Longer, descriptive title reads better as a sentence than in caps */
  .freq-table-wrap .bb-title {
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-dim);
  }

  .freq-table { font-size: 12.5px; }

  .freq-table td { font-family: inherit; }

  .freq-table td:last-child {
    color: var(--accent);
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  }

  .btn.danger {
    background: rgba(248, 113, 113, 0.10);
    border-color: rgba(248, 113, 113, 0.45);
    color: var(--error);
    font-weight: 600;
    padding: 12px 16px;
  }

  .btn.danger:hover {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.7);
  }

  .alert {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    margin-top: 12px;
  }

  .alert.warn {
    background: rgba(251, 146, 60, 0.08);
    border: 1px solid rgba(251, 146, 60, 0.2);
    color: var(--warn);
  }

  .alert.error {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--error);
  }

  /* Icon is centred vertically against the whole message block */
  .alert svg {
    flex-shrink: 0;
    width: 1.4em;
    height: 1.4em;
  }

  /* When the alert leads the result card it needs no top gap */
  #result-content > .alert:first-child {
    margin-top: 0;
    margin-bottom: 16px;
  }

  .peptide-row {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
  }

  .legend {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 11px;
    color: var(--text-faint);
    flex-wrap: wrap;
  }

  .legend-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .legend-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-2);
    box-shadow: 0 0 6px rgba(167, 139, 250, 0.6);
  }

  /* Add-to-home-screen hint */
  .a2hs {
    position: relative;
    margin-top: 24px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.05), rgba(167, 139, 250, 0.05));
    border: 1px solid var(--border);
    border-radius: 14px;
  }

  .a2hs-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-faint);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
  }
  .a2hs-close:hover { background: var(--surface-hover); color: var(--text); }

  .a2hs-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
  }
  .a2hs-title svg { color: var(--accent); flex-shrink: 0; }

  .a2hs-sub {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 12px;
  }

  .a2hs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .a2hs-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
  }

  .a2hs-os {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
  }
  .a2hs-os svg { color: var(--accent-2); flex-shrink: 0; }

  .a2hs-steps {
    font-size: 11px;
    line-height: 1.55;
    color: var(--text-faint);
  }

  @media (max-width: 560px) {
    .a2hs-grid { grid-template-columns: 1fr; }
  }

  .disclaimer {
    margin-top: 24px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-faint);
  }

  .disclaimer strong { color: var(--text-dim); }

  /* Doubles as a hidden link to the analytics dashboard — must look like plain text */
  .version-tag {
    display: block;
    text-align: right;
    margin-top: 8px;
    padding-right: 4px;
    font-size: 10px;
    color: var(--text-faint);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.04em;
    opacity: 0.55;
    text-decoration: none;
    cursor: default;
    -webkit-tap-highlight-color: transparent;
  }
  .version-tag:hover, .version-tag:visited, .version-tag:active {
    color: var(--text-faint);
    text-decoration: none;
  }

  .fill-rect {
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-2);
    border: 1px solid var(--border-active);
    color: var(--accent);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
    z-index: 100;
  }

  .toast.show { transform: translateX(-50%) translateY(0); }

  /* Tablet */
  @media (max-width: 920px) {
    .layout { grid-template-columns: 1fr; }
    .header h1 { font-size: 32px; }
    .container {
      padding: 70px 16px 60px;
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
      /* Clear the floating language switcher below the safe area (home-screen mode) */
      padding-top: max(70px, calc(env(safe-area-inset-top) + 48px));
    }
    .lang-switcher { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); }
  }

  /* Mobile */
  @media (max-width: 560px) {
    .container {
      padding: 64px 12px 60px;
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
      /* Clear the floating language switcher below the safe area (home-screen mode) */
      padding-top: max(64px, calc(env(safe-area-inset-top) + 48px));
    }
    /* Shrink the mode toggle so all three buttons + the active glow ring
       fit within the viewport without their rounded corners being clipped. */
    .mode-toggle { gap: 6px; }
    .mode-btn { padding: 11px 14px; gap: 6px; font-size: 13px; }
    .mode-btn svg { width: 18px; height: 18px; }
    .card { padding: 18px 16px; border-radius: 16px; }
    .header { margin-bottom: 28px; }
    .header h1 { font-size: 26px; }
    .header p { font-size: 13px; }
    .header .badge { font-size: 10px; padding: 5px 10px; }
    .step { margin-bottom: 22px; }
    .step-header { gap: 8px; }
    .step-icon { width: 30px; height: 30px; }
    .step-title { font-size: 12px; }
    .pill { padding: 9px 12px; font-size: 13px; }
    .primary-result .value { font-size: 44px; }
    .primary-result .unit-label { font-size: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .actions { flex-direction: column; }
    .lang-switcher { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
    .lang-btn { width: 32px; height: 26px; }
    .lang-btn svg { width: 20px; height: 14px; }
    .disclaimer { font-size: 10px; padding: 12px 14px; }
    .syringe-viz { margin-bottom: 18px; }
  }

  /* Very small */
  @media (max-width: 380px) {
    .header h1 { font-size: 22px; }
    .pill { padding: 8px 11px; font-size: 12px; }
    .pills { gap: 5px; }
  }

  /* ---------- Touch & motion polish ---------- */

  /* Press feedback — mobile has no hover, so buttons need a tactile response */
  .pill:active,
  .mode-btn:active,
  .unit-toggle-btn:active,
  .lang-btn:active,
  .btn:active {
    transform: scale(0.96);
  }

  /* Keyboard focus rings (invisible for mouse/touch) */
  .pill:focus-visible,
  .mode-btn:focus-visible,
  .unit-toggle-btn:focus-visible,
  .lang-btn:focus-visible,
  .btn:focus-visible,
  select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* Result content gently fades in whenever it (re)renders */
  @keyframes resultIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
  }
  .result-card.ready .result-layout {
    animation: resultIn 0.3s ease-out;
  }

  /* Respect users who prefer reduced motion */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
