  *, *::before, *::after {
    box-sizing: border-box; margin: 0; padding: 0;
    /* Suppress the blue/grey tap flash on iOS WKWebView and Safari */
    -webkit-tap-highlight-color: transparent;
  }

  :root {
    --bg: #1a1208;
    --surface: #2a1f0e;
    --surface2: #3a2c18;
    --border: #4a3920;
    --text: #f5e6c8;
    --text-dim: #a08060;
    --accent: #d4a843;
    --accent-dim: #8a6a20;
    --green: #5a9a5a;
    --red: #c04040;
    --timer-warn: #e07020;
  }

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    /* Prevent rubber-band / bounce scroll on full-page overlay screens in WKWebView */
    overscroll-behavior: none;
  }

  /* ── Start screen ─────────────────────────────── */
  #start-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 24px calc(80px + env(safe-area-inset-bottom));
  }

  #photo-btn {
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); font-size: 0.95rem; font-weight: 600;
    border-radius: 12px; padding: 14px 16px; cursor: pointer;
    width: 100%; max-width: 340px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: border-color 0.15s, background 0.15s;
  }
  #photo-btn:hover { border-color: var(--accent); background: var(--surface2); }
  #photo-btn:active { opacity: 0.8; }
  #photo-btn:disabled { opacity: 0.45; cursor: default; }

  #start-screen h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 700; color: var(--accent); }
  #start-screen > p {
    color: var(--text-dim); font-size: 1.05rem;
    text-align: center; max-width: 300px; line-height: 1.6;
  }

  #url-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; }
  #url-input {
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-size: 0.95rem; padding: 13px 14px; width: 100%;
  }
  #url-input:focus { outline: none; border-color: var(--accent); }
  #url-input::placeholder { color: var(--text-dim); }
  #load-btn {
    background: var(--accent); color: #1a1208;
    font-size: 1.05rem; font-weight: 700; border: none;
    border-radius: 12px; padding: 16px; cursor: pointer;
    transition: transform 0.1s, opacity 0.1s;
    touch-action: manipulation;
  }
  #load-btn:active { transform: scale(0.97); opacity: 0.85; }
  #carbonara-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 0.9rem; cursor: pointer; text-decoration: underline;
    padding: 4px;
  }

  /* ── Loading screen ────────────────────────────── */
  #loading-screen {
    display: none; flex: 1;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 20px; padding: 40px 24px;
  }
  #loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  #loading-text { color: var(--text-dim); font-size: 1rem; text-align: center; }

  #loading-steps {
    display: none; flex-direction: column; gap: 10px;
    width: 100%; max-width: 300px;
  }
  .loading-step {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; font-size: 0.92rem;
    color: var(--text-dim);
    transition: border-color 0.3s, color 0.3s;
  }
  .loading-step.active {
    border-color: var(--accent); color: var(--text);
  }
  .loading-step.done {
    opacity: 0.55;
  }
  .step-icon {
    flex-shrink: 0; width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
  }
  .step-pulse {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent);
    animation: stepPulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
  }
  @keyframes stepPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50%       { opacity: 1;   transform: scale(1.2); }
  }

  #loading-progress-wrap {
    display: none; width: 100%; max-width: 300px;
    height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
  }
  #loading-progress-fill {
    height: 100%; width: 0%; background: var(--accent);
    border-radius: 2px;
    transition: width 0.35s ease;
  }

  #loading-error {
    display: none; color: var(--red); font-size: 0.9rem;
    text-align: center; max-width: 300px; line-height: 1.5;
  }
  .parse-error-hint {
    display: block; color: var(--text-dim); font-size: 0.8rem; margin-top: 6px;
  }
  #retry-btn {
    display: none; background: var(--surface); border: 1px solid var(--border);
    color: var(--text); border-radius: 10px; padding: 12px 24px;
    font-size: 0.95rem; cursor: pointer;
  }

  /* ── Parse-confirm dialog card ────────────────── */
  #parse-confirm-card {
    display: none; flex-direction: column; gap: 14px;
    width: 100%; max-width: 320px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 18px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  }
  #parse-confirm-card.visible { display: flex; }
  #parse-confirm-icon { font-size: 2rem; text-align: center; }
  #parse-confirm-msg {
    color: var(--text); font-size: 0.92rem; line-height: 1.6;
    text-align: center;
  }
  #parse-confirm-btns { display: flex; gap: 10px; flex-direction: column; }
  #parse-confirm-go {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 10px; padding: 13px 16px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: opacity 0.1s;
  }
  #parse-confirm-go:active { opacity: 0.8; }
  #parse-confirm-cancel {
    background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 16px;
    font-size: 0.95rem; cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
  }
  #parse-confirm-cancel:hover { border-color: var(--accent); color: var(--text); }

  /* ── Parse-warning banner (amber, auto-dismisses) ── */
  .parse-warning-banner {
    display: flex; align-items: flex-start; gap: 10px;
    width: 100%; max-width: 300px;
    background: rgba(212,168,67,0.12); border: 1px solid rgba(212,168,67,0.4);
    border-radius: 10px; padding: 10px 14px;
    font-size: 0.85rem; color: var(--accent); line-height: 1.5;
    animation: fadeInDown 0.3s ease;
  }
  @keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Servings screen ───────────────────────────── */
  #servings-screen {
    display: none; flex: 1;
    flex-direction: column; overflow: hidden;
    max-width: 600px; width: 100%; margin: 0 auto;
  }
  #servings-screen.visible { display: flex; }

  #servings-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
  }
  #servings-header-left { display: flex; align-items: center; gap: 0; }
  #servings-badge {
    background: var(--accent-dim); color: var(--accent);
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
    padding: 2px 7px; border-radius: 4px; text-transform: uppercase;
    margin-right: 8px; flex-shrink: 0;
  }
  #servings-header-title { font-size: 1rem; font-weight: 700; color: var(--text); }

  #servings-body {
    flex: 1; overflow-y: auto; padding: 20px 16px;
    display: flex; flex-direction: column; gap: 20px;
  }

  #servings-stepper-wrap {
    display: flex; align-items: center; justify-content: center; gap: 24px;
    padding: 8px 0;
  }
  .stepper-btn {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--surface2); border: 1.5px solid var(--border);
    color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s, background 0.15s;
    flex-shrink: 0;
  }
  .stepper-btn:active { background: var(--accent-dim); border-color: var(--accent); }

  #servings-count-display {
    display: flex; flex-direction: column; align-items: center; min-width: 80px;
  }
  #servings-count-num {
    font-size: 2.8rem; font-weight: 800; color: var(--accent); line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  #servings-count-label {
    font-size: 0.78rem; color: var(--text-dim); margin-top: 3px;
  }

  #servings-ingredients-area {
    display: flex; flex-direction: column; gap: 10px;
  }
  .servings-category-section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden;
  }
  .servings-category-heading {
    padding: 7px 14px;
    background: var(--surface2);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-dim);
    border-bottom: 1px solid var(--border);
  }
  .servings-ingredient-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 9px 14px; border-bottom: 1px solid var(--border);
    gap: 10px;
  }
  .servings-ingredient-row:last-child { border-bottom: none; }
  .servings-ingredient-left { flex: 1; min-width: 0; }
  .servings-ingredient-name { font-size: 0.92rem; color: var(--text); }
  .servings-ingredient-notes {
    font-size: 0.78rem; color: var(--text-dim); margin-top: 1px;
    font-style: italic;
  }
  .servings-ingredient-qty {
    font-size: 0.92rem; font-weight: 700; color: var(--accent);
    white-space: nowrap; flex-shrink: 0; padding-top: 1px;
  }
  .servings-ingredient-qty.taste {
    color: var(--text-dim); font-weight: 400; font-style: italic;
  }
  .servings-no-ingredients {
    padding: 24px 16px; text-align: center;
    color: var(--text-dim); font-size: 0.9rem; line-height: 1.6;
  }

  #servings-actions {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 14px 16px; display: flex; flex-direction: column;
    align-items: center; gap: 10px; flex-shrink: 0;
  }
  #servings-confirm-btn {
    width: 100%; background: var(--accent); color: #1a1208; border: none;
    border-radius: 10px; padding: 14px 16px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: opacity 0.1s;
    touch-action: manipulation;
  }
  #servings-confirm-btn:active { opacity: 0.85; }
  #servings-skip-btn {
    background: none; border: none; color: var(--text-dim);
    font-size: 0.88rem; cursor: pointer; padding: 4px 16px;
    transition: color 0.15s;
  }
  #servings-skip-btn:hover { color: var(--text); }

  /* ── Prep screen ───────────────────────────────── */
  #prep-screen {
    display: none; flex: 1;
    flex-direction: column; overflow: hidden;
    max-width: 600px; width: 100%; margin: 0 auto;
  }
  #prep-screen.visible { display: flex; }

  #prep-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  }
  #prep-badge {
    background: var(--accent-dim); color: var(--accent);
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
    padding: 2px 7px; border-radius: 4px; text-transform: uppercase;
    margin-right: 8px;
  }
  #prep-header-title { font-size: 1rem; font-weight: 700; color: var(--text); }
  #prep-progress-text { font-size: 0.85rem; color: var(--accent); font-weight: 600; }

  #prep-messages-area {
    flex: 1; overflow-y: auto; padding: 16px 14px;
    display: flex; flex-direction: column; gap: 12px;
  }

  #prep-input-area {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  }
  #prep-mic-status-row {
    display: flex; align-items: center; gap: 8px;
  }
  #prep-mic-indicator {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface2); border: 2px solid var(--border);
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 14px; transition: border-color 0.2s, background 0.2s;
  }
  #prep-mic-indicator.listening {
    border-color: var(--accent); background: rgba(212,168,67,0.15);
    animation: pulse 1.4s ease-in-out infinite;
  }
  #prep-heard-text {
    flex: 1; font-size: 0.85rem; color: var(--text-dim); font-style: italic;
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #prep-done-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 8px; padding: 8px 14px; font-size: 0.85rem;
    font-weight: 700; cursor: pointer; white-space: nowrap; display: none;
  }

  #prep-skip-area {
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 12px 10px; display: flex; justify-content: center;
    flex-shrink: 0;
  }
  #prep-skip-btn {
    background: none; border: none; color: var(--text-dim);
    font-size: 0.85rem; cursor: pointer; padding: 4px 16px;
    transition: color 0.15s;
  }
  #prep-skip-btn:hover { color: var(--text); }
  #prep-skip-btn:active { opacity: 0.7; }

  /* ── Main app ─────────────────────────────────── */
  #app { flex: 1; display: none; flex-direction: column; max-width: 600px; width: 100%; margin: 0 auto; }
  #app.visible { display: flex; }

  /* header */
  #app-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 10;
  }
  #title-with-icon { display: flex; align-items: center; gap: 7px; }
  #recipe-title { font-size: 1rem; font-weight: 700; color: var(--accent); }
  .recipe-source-icon { display: flex; align-items: center; flex-shrink: 0; line-height: 0; }
  .recipe-source-icon svg { display: block; }
  #progress-text { font-size: 0.85rem; color: var(--text-dim); }

  #recipe-meta, #prep-meta {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 3px 16px 7px; font-size: 0.78rem; color: var(--text-dim);
    display: none;
  }

  /* ── Collapsible ingredients panel (cooking + prep screens) ── */
  #ingredients-panel, #prep-ingredients-panel {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  #ingredients-toggle, #prep-ingredients-toggle {
    width: 100%; display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer;
    padding: 10px 16px; color: var(--text);
    font-size: 0.85rem; font-weight: 600;
    text-align: left;
  }
  #ingredients-toggle:active, #prep-ingredients-toggle:active { opacity: 0.75; }
  #ingredients-toggle > span:first-child, #prep-ingredients-toggle > span:first-child { flex: 1; }

  #ingredients-count, #prep-ingredients-count {
    font-size: 0.78rem; font-weight: 400; color: var(--text-dim);
  }
  #ingredients-arrow, #prep-ingredients-arrow {
    font-size: 0.9rem; color: var(--text-dim);
    transition: transform 0.2s ease;
    flex-shrink: 0;
  }
  #ingredients-panel.open #ingredients-arrow,
  #prep-ingredients-panel.open #prep-ingredients-arrow { transform: rotate(180deg); }

  #ingredients-list-area, #prep-ingredients-list-area {
    max-height: 0; overflow: hidden;
    transition: max-height 0.25s ease;
  }
  #ingredients-panel.open #ingredients-list-area,
  #prep-ingredients-panel.open #prep-ingredients-list-area {
    max-height: 60vh;
    overflow-y: auto;
  }

  #ingredients-list-area .servings-category-section,
  #prep-ingredients-list-area .servings-category-section {
    border-radius: 0; border-left: none; border-right: none; border-top: none;
  }
  #ingredients-list-area .servings-category-section:first-child,
  #prep-ingredients-list-area .servings-category-section:first-child {
    border-top: 1px solid var(--border);
  }

  .cooking-ingredient-row {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s;
  }
  .cooking-ingredient-row:active { opacity: 0.7; }
  .cooking-ingredient-check {
    font-size: 0.88rem; font-weight: 700; color: var(--green);
    flex-shrink: 0; opacity: 0; transition: opacity 0.15s;
    padding-top: 1px; margin-left: 4px;
  }
  .cooking-ingredient-row.checked .cooking-ingredient-check { opacity: 1; }
  .cooking-ingredient-row.checked .servings-ingredient-name {
    text-decoration: line-through;
    color: var(--text-dim);
  }
  .cooking-ingredient-row.checked .servings-ingredient-notes { color: var(--text-dim); opacity: 0.6; }
  .cooking-ingredient-row.checked .servings-ingredient-qty {
    color: var(--text-dim); font-weight: 400;
  }

  /* timers */
  #timers-area {
    background: var(--surface); border-bottom: 1px solid var(--border);
    overflow: hidden; max-height: 0; transition: max-height 0.3s ease;
  }
  #timers-area.has-timers { max-height: 200px; }

  .timer-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-bottom: 1px solid var(--border); gap: 12px;
  }
  .timer-row:last-child { border-bottom: none; }
  .timer-label { font-size: 0.85rem; color: var(--text-dim); flex: 1; }
  .timer-count {
    font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums;
    color: var(--accent); min-width: 56px; text-align: right;
  }
  .timer-count.warn { color: var(--timer-warn); }
  .timer-count.urgent { color: var(--red); }

  /* messages */
  #messages-area {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
  }

  .msg { max-width: 88%; padding: 12px 15px; border-radius: 16px; font-size: 0.95rem; line-height: 1.55; }

  .msg.chef {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px 16px 16px 16px; align-self: flex-start;
  }
  .msg.chef .msg-label {
    font-size: 0.72rem; font-weight: 600; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px;
  }
  .msg.user {
    background: var(--accent-dim); border-radius: 16px 4px 16px 16px;
    align-self: flex-end; color: var(--text); font-size: 0.9rem;
  }
  .msg.system-msg {
    align-self: center; background: transparent;
    color: var(--text-dim); font-size: 0.8rem; font-style: italic;
  }

  /* thinking indicator */
  .msg.thinking {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px 16px 16px 16px; align-self: flex-start;
    padding: 14px 18px; display: flex; gap: 5px; align-items: center;
  }
  .thinking-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-dim);
    animation: bounce 1.1s ease-in-out infinite;
  }
  .thinking-dot:nth-child(2) { animation-delay: 0.18s; }
  .thinking-dot:nth-child(3) { animation-delay: 0.36s; }
  @keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%           { transform: translateY(-6px); opacity: 1; }
  }

  /* active steps */
  #active-steps-area {
    border-top: 1px solid var(--border); background: var(--surface);
    padding: 12px 16px; display: flex; flex-direction: column; gap: 8px;
  }
  #active-steps-label {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-dim); font-weight: 600;
  }

  .step-confirm-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px; gap: 12px;
  }
  .step-confirm-name { font-size: 0.9rem; color: var(--text); font-weight: 500; flex: 1; }
  .confirm-btn {
    background: var(--green); color: white; border: none;
    border-radius: 8px; padding: 8px 14px; font-size: 0.82rem;
    font-weight: 700; cursor: pointer; white-space: nowrap; transition: opacity 0.1s;
  }
  .confirm-btn:active { opacity: 0.75; }

  /* recovery state — amber chef message */
  .msg.chef.recovery {
    border-color: #c87c20;
    background: rgba(200, 100, 20, 0.12);
  }
  .msg.chef.recovery .msg-label {
    color: #e08030;
  }
  .msg.chef.recovery .recovery-icon {
    display: inline-block;
    margin-right: 5px;
  }

  /* recovery button row */
  #recovery-btn-row {
    border-top: 1px solid #4a3920; background: rgba(200, 100, 20, 0.08);
    padding: 12px 16px; display: none; flex-direction: column; gap: 8px;
  }
  #recovery-btn-row.visible { display: flex; }
  #recovery-label {
    font-size: 0.75rem; color: #c87c20; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    display: flex; align-items: center; gap: 5px;
  }
  #recovery-btn {
    width: 100%; background: #c87c20; color: #1a1208;
    border: none; border-radius: 10px; padding: 14px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: opacity 0.1s;
    touch-action: manipulation;
  }
  #recovery-btn:active { opacity: 0.8; }

  /* ready-to-start button */
  #ready-btn-row {
    border-top: 1px solid var(--border); background: var(--surface);
    padding: 12px 16px; display: none;
  }
  #ready-btn {
    width: 100%; background: var(--accent); color: #1a1208;
    border: none; border-radius: 10px; padding: 14px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: opacity 0.1s;
    touch-action: manipulation;
  }
  #ready-btn:active { opacity: 0.8; }

  /* input area */
  #input-area {
    border-top: 1px solid var(--border); background: var(--surface);
    padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  }

  #mic-status-row {
    display: flex; align-items: center; gap: 8px;
  }

  #mic-indicator {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface2); border: 2px solid var(--border);
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 14px; transition: border-color 0.2s, background 0.2s;
  }
  #mic-indicator.listening {
    border-color: var(--accent); background: rgba(212,168,67,0.15);
    animation: pulse 1.4s ease-in-out infinite;
  }
  @keyframes pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(212,168,67,0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(212,168,67,0); }
  }

  #heard-text {
    flex: 1; font-size: 0.85rem; color: var(--text-dim); font-style: italic;
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ── Push-to-talk button ─────────────────── */
  .ptt-btn {
    width: 100%;
    background: var(--surface2); border: 2px solid var(--border);
    color: var(--text); font-size: 1rem; font-weight: 700;
    border-radius: 14px; padding: 14px 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: border-color 0.15s, background 0.15s, transform 0.1s, box-shadow 0.15s;
    touch-action: none; user-select: none; -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .ptt-btn:hover { border-color: var(--accent); background: var(--surface); }
  .ptt-btn.ptt-active {
    background: rgba(212,168,67,0.18); border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 4px rgba(212,168,67,0.18);
    transform: scale(0.97);
  }
  .ptt-btn.ptt-disabled, .ptt-btn:disabled {
    opacity: 0.4; cursor: not-allowed; border-color: var(--border);
  }
  .ptt-btn.ptt-speaking {
    border-color: var(--accent-dim);
    color: var(--text-dim);
    background: rgba(212,168,67,0.07);
    animation: pttSpeakingPulse 1.8s ease-in-out infinite;
  }
  @keyframes pttSpeakingPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212,168,67,0.35); }
    50%       { box-shadow: 0 0 0 8px rgba(212,168,67,0); }
  }

  #text-row {
    display: flex; align-items: center; gap: 8px;
  }

  #text-input {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 0.9rem;
    padding: 8px 11px; flex: 1; outline: none; min-width: 0;
  }
  #text-input:focus { border-color: var(--accent); }
  #text-input::placeholder { color: var(--text-dim); }

  #send-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 8px; padding: 8px 14px; font-size: 0.85rem;
    font-weight: 700; cursor: pointer; white-space: nowrap;
    touch-action: manipulation;
  }

  /* completion */
  #completion-screen {
    display: none; flex-direction: column; align-items: center;
    justify-content: center; gap: 20px; padding: 40px 24px; text-align: center; flex: 1;
  }
  #completion-screen.visible { display: flex; }
  #completion-screen h2 { font-size: 2rem; color: var(--accent); }
  #completion-screen p { color: var(--text-dim); line-height: 1.6; }

  /* ── Audio toggle ──────────────────────────── */
  #audio-toggle {
    position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 12px; z-index: 9999;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 50%; width: 40px; height: 40px;
    font-size: 1.2rem; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: background 0.15s, opacity 0.15s;
  }
  #audio-toggle:hover { background: var(--surface); }
  #audio-toggle.muted { opacity: 0.5; }

  /* ── Settings panel ────────────────────────── */
  #settings-btn {
    position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 60px; z-index: 9999;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 50%; width: 40px; height: 40px;
    font-size: 1.1rem; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: background 0.15s;
  }
  #settings-btn:hover { background: var(--surface); }

  #settings-panel {
    display: none;
    position: fixed; top: calc(60px + env(safe-area-inset-top)); right: 12px; z-index: 9998;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 16px 18px;
    width: 280px; box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    flex-direction: column; gap: 14px;
  }
  #settings-panel.open { display: flex; }

  .settings-title {
    font-size: 0.8rem; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.07em;
    padding-bottom: 4px; border-bottom: 1px solid var(--border);
  }

  .settings-row {
    display: flex; flex-direction: column; gap: 5px;
  }
  .settings-label {
    font-size: 0.78rem; color: var(--text-dim); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .settings-select {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 0.88rem;
    padding: 7px 10px; width: 100%; outline: none; cursor: pointer;
  }
  .settings-select:focus { border-color: var(--accent); }
  .settings-select option { background: var(--surface2); }

  .settings-note {
    font-size: 0.75rem; color: var(--text-dim); line-height: 1.5;
    background: var(--surface2); border-radius: 7px; padding: 8px 10px;
    border: 1px solid var(--border);
  }
  .settings-note strong { color: var(--accent); }

  .wake-lock-note {
    display: flex; align-items: center; gap: 6px;
    transition: color 0.2s, border-color 0.2s;
  }
  .wake-lock-note.active {
    color: var(--green); border-color: var(--green);
  }

  .settings-divider {
    height: 1px; background: var(--border); margin: 2px 0;
  }

  .settings-unit-toggle {
    display: flex; gap: 6px;
  }
  .unit-btn {
    flex: 1; background: var(--surface2); border: 1px solid var(--border);
    color: var(--text-dim); font-size: 0.78rem; font-weight: 600;
    border-radius: 8px; padding: 8px 6px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    text-align: center;
  }
  .unit-btn.active {
    border-color: var(--accent); background: var(--accent);
    color: #1a1208;
  }
  .unit-btn:not(.active):hover { border-color: var(--accent); color: var(--text); }

  /* ── Auth overlay ───────────────────────────── */
  #auth-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: var(--bg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; padding: 24px;
    transition: opacity 0.2s;
  }
  #auth-overlay.hidden { display: none; }
  #auth-overlay-brand { color: var(--accent); font-size: 2.2rem; font-weight: 700; }
  #auth-overlay-subtitle { color: var(--text-dim); font-size: 1rem; text-align: center; }
  #auth-overlay-inner { width: 100%; max-width: 420px; }
  #auth-loading-msg { color: var(--text-dim); font-size: 0.9rem; margin-top: 8px; }

  /* Dark-mode Clerk card overrides — forces the embedded SignIn card
     to respect the app's dark background even though Clerk defaults to light */
  .cl-card, .cl-cardBox { background: var(--surface) !important; }
  .cl-headerTitle, .cl-headerSubtitle, .cl-formFieldLabel,
  .cl-dividerText, .cl-footerActionText { color: var(--text) !important; }
  .cl-formFieldInput {
    background: var(--surface2) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
  }
  .cl-formButtonPrimary {
    background: var(--accent) !important;
    color: #1a1208 !important;
  }
  .cl-footerActionLink { color: var(--accent) !important; }
  .cl-socialButtonsBlockButton {
    background: var(--surface2) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
  }

  /* ── Dev identity widget (bypass mode) ────── */
  #dev-identity-widget {
    display: none;
    position: fixed; bottom: 12px; left: 12px; z-index: 9997;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 7px 12px;
    font-size: 0.76rem; color: var(--text-dim);
    flex-direction: row; align-items: center; gap: 8px;
  }
  #dev-identity-widget.visible { display: flex; }
  #dev-identity-input {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-size: 0.8rem;
    padding: 4px 8px; width: 120px; outline: none;
  }
  #dev-identity-input:focus { border-color: var(--accent); }

  /* ── Sign out button (real auth) ─────────── */
  #signout-btn {
    display: none;
    position: fixed; bottom: 12px; left: 12px; z-index: 9997;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 6px 12px;
    font-size: 0.78rem; color: var(--text-dim); cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
  }
  #signout-btn:hover { border-color: var(--accent); color: var(--text); }
  #signout-btn.visible { display: block; }

  /* ── Library screen (full-page) ─────────────── */
  #library-screen {
    display: none; flex: 1;
    flex-direction: column;
    max-width: 600px; width: 100%; margin: 0 auto;
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }

  #library-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; flex-direction: column; gap: 10px;
    position: sticky; top: 0; z-index: 10;
  }
  #library-header-top {
    display: flex; align-items: center; gap: 12px;
  }
  #library-back-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px;
    line-height: 1; transition: color 0.15s, background 0.15s;
    display: flex; align-items: center; gap: 6px;
  }
  #library-back-btn:hover { color: var(--text); background: var(--surface2); }
  #library-header h2 { font-size: 1rem; font-weight: 700; color: var(--accent); flex: 1; }
  #library-count { font-size: 0.8rem; color: var(--text-dim); }

  #library-sort-bar {
    display: flex; gap: 6px;
  }
  .library-sort-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text-dim);
    border-radius: 20px; padding: 3px 12px; font-size: 0.78rem; cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    touch-action: manipulation;
  }
  .library-sort-btn:hover { border-color: var(--accent); color: var(--text); }
  .library-sort-btn.active {
    border-color: var(--accent); color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }

  #library-list {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
  }

  /* ── Recipe cards (shared) ───────────────────── */
  .recipe-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 14px 16px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex; flex-direction: column; gap: 6px;
  }
  .recipe-card:hover { border-color: var(--accent); background: var(--surface2); }
  .recipe-card:active { opacity: 0.8; }

  .recipe-card-header {
    display: flex; align-items: center; gap: 8px;
  }
  /* alias used by start-screen embedded cards */
  .recipe-card-top {
    display: flex; align-items: center; gap: 8px;
  }
  .recipe-card-title {
    font-size: 0.95rem; font-weight: 600; color: var(--text);
    flex: 1; min-width: 0; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .recipe-card-actions {
    display: flex; gap: 4px; flex-shrink: 0;
  }
  .action-btn {
    background: transparent; border: 1px solid var(--border);
    border-radius: 7px; padding: 5px 8px; font-size: 0.95rem;
    cursor: pointer; transition: background 0.12s, border-color 0.12s;
    line-height: 1;
    touch-action: manipulation;
  }
  .action-btn:hover { background: var(--surface2); border-color: var(--accent); }
  .action-btn.active { border-color: var(--accent); background: rgba(212,168,67,0.12); }
  .cooked-badge {
    font-size: 0.72rem; font-weight: 600; color: var(--accent);
    background: rgba(212,168,67,0.15); border: 1px solid rgba(212,168,67,0.4);
    border-radius: 20px; padding: 2px 9px; white-space: nowrap; flex-shrink: 0;
  }
  .recipe-card-last-cooked {
    font-size: 0.75rem; color: var(--text-dim); margin-top: 2px;
  }
  .recipe-card-meta {
    font-size: 0.78rem; color: var(--text-dim);
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  }
  .recipe-card-notes {
    font-size: 0.8rem; color: var(--text-dim); font-style: italic;
    line-height: 1.4; border-left: 2px solid var(--border);
    padding-left: 8px; margin-top: 2px;
  }
  .recipe-card-meta-chip {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; padding: 1px 6px; font-size: 0.72rem;
    color: var(--text-dim);
  }
  .recipe-card-arrow {
    color: var(--text-dim); font-size: 1rem; flex-shrink: 0;
    align-self: center;
  }
  .recipe-card-delete {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    border-radius: 50%; color: var(--text-dim);
    font-size: 1rem; line-height: 1;
    opacity: 0; transition: opacity 0.15s, background 0.15s, color 0.15s;
    padding: 0;
  }
  .recipe-card:hover .recipe-card-delete { opacity: 1; }
  .recipe-card-delete:hover { background: rgba(220,60,60,0.15); color: #e05555; }
  .recipe-card-delete:focus-visible { opacity: 1; outline: 2px solid var(--accent); }
  @media (hover: none) {
    .recipe-card-delete { opacity: 0.6; }
  }

  #library-empty {
    display: none; flex-direction: column; align-items: center;
    justify-content: center; gap: 16px; padding: 60px 24px;
    text-align: center; flex: 1;
  }
  #library-empty .empty-icon { font-size: 3rem; opacity: 0.4; }
  #library-empty h3 { font-size: 1.15rem; color: var(--text-dim); font-weight: 600; }
  #library-empty p { font-size: 0.9rem; color: var(--text-dim); line-height: 1.6; max-width: 260px; }

  #library-loading {
    display: none; align-items: center; justify-content: center;
    gap: 12px; padding: 40px; color: var(--text-dim); font-size: 0.9rem;
  }
  #library-loading-spinner {
    width: 20px; height: 20px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite; flex-shrink: 0;
  }

  #library-load-more {
    display: none; background: var(--surface); border: 1px solid var(--border);
    color: var(--text-dim); border-radius: 10px; padding: 12px;
    font-size: 0.9rem; cursor: pointer; width: 100%;
    transition: border-color 0.15s, color 0.15s;
  }
  #library-load-more:hover { border-color: var(--accent); color: var(--text); }

  /* ── People button ───────────────────────── */
  #people-btn {
    display: none;
    position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 108px; z-index: 9999;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 50%; width: 40px; height: 40px;
    font-size: 1.1rem; cursor: pointer;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: background 0.15s;
  }
  #people-btn:hover { background: var(--surface); }
  #people-btn.visible { display: flex; }

  /* ── People screen overlay ───────────────── */
  #people-screen {
    display: none;
    position: fixed; inset: 0; z-index: 10000;
    background: var(--bg);
    flex-direction: column;
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }
  #people-screen.visible { display: flex; }

  #people-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 10;
  }
  #people-close-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 1.3rem; cursor: pointer; line-height: 1;
    padding: 0 4px; flex-shrink: 0;
    transition: color 0.15s;
  }
  #people-close-btn:hover { color: var(--text); }
  #people-header h2 { font-size: 1rem; font-weight: 700; color: var(--accent); flex: 1; }

  #people-tabs {
    display: flex; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .people-tab {
    flex: 1; padding: 10px 8px; font-size: 0.82rem; font-weight: 600;
    color: var(--text-dim); border: none; background: transparent;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    text-transform: uppercase; letter-spacing: 0.05em;
    touch-action: manipulation;
  }
  .people-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  #people-content {
    flex: 1; overflow-y: auto; padding: 14px 14px;
    display: flex; flex-direction: column; gap: 10px;
  }

  /* Search input */
  #people-search-wrap {
    display: flex; gap: 8px; margin-bottom: 4px;
  }
  #people-search-input {
    flex: 1; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 0.92rem;
    padding: 11px 14px; outline: none;
  }
  #people-search-input:focus { border-color: var(--accent); }
  #people-search-input::placeholder { color: var(--text-dim); }
  #people-search-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 10px; padding: 10px 18px; font-size: 0.88rem;
    font-weight: 700; cursor: pointer; white-space: nowrap;
    touch-action: manipulation;
  }

  /* User card */
  .user-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px;
  }
  .user-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--surface2); border: 1px solid var(--border);
    flex-shrink: 0; overflow: hidden; display: flex; align-items: center;
    justify-content: center; font-size: 1rem; color: var(--text-dim);
  }
  .user-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .user-name { flex: 1; font-size: 0.92rem; font-weight: 600; color: var(--text); }

  .follow-btn {
    border: none; border-radius: 8px; padding: 7px 14px;
    font-size: 0.8rem; font-weight: 700; cursor: pointer; white-space: nowrap;
    transition: opacity 0.1s;
    touch-action: manipulation;
  }
  .follow-btn.following {
    background: var(--surface2); color: var(--text-dim);
    border: 1px solid var(--border);
  }
  .follow-btn.not-following { background: var(--accent); color: #1a1208; }
  .follow-btn:active { opacity: 0.75; }

  /* People loading / empty states */
  .people-empty {
    text-align: center; color: var(--text-dim); font-size: 0.88rem;
    padding: 28px 0; font-style: italic;
  }
  .people-loading {
    text-align: center; color: var(--text-dim); font-size: 0.88rem; padding: 28px 0;
  }
  .activity-load-more {
    align-self: center; margin: 10px auto 4px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--accent); border-radius: 20px; padding: 7px 22px;
    font-size: 0.88rem; cursor: pointer; transition: background 0.15s;
  }
  .activity-load-more:hover { background: var(--surface-raised); }

  /* Invite section */
  #invite-section {
    margin-top: 6px; border-top: 1px solid var(--border); padding-top: 14px;
  }
  #invite-section h3 {
    font-size: 0.82rem; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px;
  }
  #invite-form { display: flex; gap: 8px; }
  #invite-email-input {
    flex: 1; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-size: 0.92rem;
    padding: 11px 14px; outline: none;
  }
  #invite-email-input:focus { border-color: var(--accent); }
  #invite-email-input::placeholder { color: var(--text-dim); }
  #invite-send-btn {
    background: var(--surface2); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 16px; font-size: 0.88rem;
    font-weight: 700; cursor: pointer; white-space: nowrap;
    transition: border-color 0.15s;
    touch-action: manipulation;
  }
  #invite-send-btn:hover { border-color: var(--accent); }
  #invite-send-btn:disabled { opacity: 0.5; cursor: default; }
  #invite-status { font-size: 0.82rem; margin-top: 6px; }
  #invite-status.ok { color: var(--green); }
  #invite-status.err { color: var(--red); }

  /* ── Start-screen embedded library section ── */
  #library-section {
    display: none; flex-direction: column; gap: 14px;
    width: 100%; max-width: 340px; margin-top: 8px;
  }
  #library-section.visible { display: flex; }

  .lib-divider {
    display: flex; align-items: center; gap: 10px;
  }
  .lib-divider-line { flex: 1; height: 1px; background: var(--border); }
  .lib-divider-label {
    font-size: 0.75rem; color: var(--text-dim); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
  }

  .lib-tabs {
    display: flex; gap: 6px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; padding: 4px;
  }
  .lib-tab {
    flex: 1; text-align: center; font-size: 0.82rem; font-weight: 600;
    padding: 7px 6px; border-radius: 7px; cursor: pointer;
    color: var(--text-dim); border: none; background: transparent;
    transition: background 0.15s, color 0.15s;
    touch-action: manipulation;
  }
  .lib-tab.active { background: var(--accent); color: #1a1208; }

  #lib-cards { display: flex; flex-direction: column; gap: 8px; }

  .lib-empty {
    text-align: center; color: var(--text-dim); font-size: 0.88rem;
    padding: 16px 0; line-height: 1.6;
  }
  .lib-loading {
    text-align: center; color: var(--text-dim); font-size: 0.85rem; padding: 10px 0;
  }

  /* ── Phase badge (multi-phase recipes) ─────── */
  #phase-badge {
    display: none; font-size: 0.68rem; font-weight: 700;
    background: rgba(212,168,67,0.18); color: var(--accent);
    border: 1px solid rgba(212,168,67,0.4); border-radius: 12px;
    padding: 2px 8px; white-space: nowrap; flex-shrink: 0; line-height: 1.5;
  }

  /* ── Phase complete bottom sheet ─────────── */
  #phase-complete-overlay {
    display: none; position: fixed; inset: 0; z-index: 12200;
    background: rgba(0,0,0,0.6); align-items: flex-end; justify-content: center;
  }
  #phase-complete-overlay.visible { display: flex; }
  #phase-complete-sheet {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px 18px 0 0; padding: 32px 24px 40px;
    width: 100%; max-width: 480px; display: flex; flex-direction: column;
    gap: 14px; align-items: center; text-align: center;
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
  #phase-complete-icon { font-size: 2.6rem; line-height: 1; }
  #phase-complete-label {
    font-size: 0.72rem; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.08em;
  }
  #phase-complete-title {
    font-size: 1.15rem; font-weight: 700; color: var(--text); line-height: 1.35;
    margin: 0;
  }
  #phase-complete-lead-time {
    color: var(--text-dim); font-size: 0.9rem; line-height: 1.6;
    background: var(--surface2); border-radius: 10px; padding: 12px 16px;
    width: 100%; box-sizing: border-box; text-align: left; margin: 0;
  }
  #phase-complete-next {
    color: var(--text-dim); font-size: 0.85rem; margin: 0;
  }
  #phase-complete-done-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 12px; padding: 15px 24px; font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: opacity 0.1s; width: 100%; margin-top: 4px;
    touch-action: manipulation;
  }
  #phase-complete-done-btn:active { opacity: 0.8; }

  /* ── Exit confirmation bottom sheet ───────── */
  #exit-confirm-overlay {
    display: none; position: fixed; inset: 0; z-index: 12500;
    background: rgba(0,0,0,0.55); align-items: flex-end; justify-content: center;
  }
  #exit-confirm-overlay.visible { display: flex; }
  #exit-confirm-sheet {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px 18px 0 0; padding: 28px 20px 32px;
    width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 16px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
  #exit-confirm-sheet h3 {
    font-size: 1.2rem; font-weight: 700; color: var(--text); text-align: center;
  }
  #exit-confirm-sheet p {
    color: var(--text-dim); font-size: 0.9rem; text-align: center; line-height: 1.5;
    margin-top: -4px;
  }
  #exit-confirm-leave {
    background: var(--red); color: #fff; border: none;
    border-radius: 12px; padding: 15px; font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: opacity 0.1s;
    touch-action: manipulation;
  }
  #exit-confirm-leave:active { opacity: 0.8; }
  #exit-confirm-stay {
    background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 12px; padding: 13px; font-size: 0.95rem;
    font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s;
    touch-action: manipulation;
  }
  #exit-confirm-stay:hover { border-color: var(--accent); background: var(--surface2); }

  /* ── Cooked prompt bottom sheet ───────────── */
  #cooked-overlay {
    display: none; position: fixed; inset: 0; z-index: 11000;
    background: rgba(0,0,0,0.55); align-items: flex-end; justify-content: center;
  }
  #cooked-overlay.visible { display: flex; }
  #cooked-sheet {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px 18px 0 0; padding: 24px 20px calc(32px + env(safe-area-inset-bottom));
    width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 16px;
  }
  #cooked-sheet h3 { font-size: 1.3rem; color: var(--accent); text-align: center; }
  #cooked-sheet p { color: var(--text-dim); font-size: 0.9rem; text-align: center; line-height: 1.5; }
  .cooked-actions { display: flex; flex-direction: column; gap: 10px; }
  #cooked-mark-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 12px; padding: 15px; font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: opacity 0.1s;
    touch-action: manipulation;
  }
  #cooked-mark-btn:active { opacity: 0.8; }
  #cooked-fav-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 12px; padding: 13px; font-size: 0.95rem;
    font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s;
    touch-action: manipulation;
  }
  #cooked-fav-btn:hover { border-color: var(--accent); background: var(--surface2); }
  #cooked-fav-btn.selected { border-color: var(--accent); background: rgba(212,168,67,0.12); }
  #cooked-notes {
    background: var(--surface2); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; font-family: inherit;
    resize: vertical; width: 100%; box-sizing: border-box; line-height: 1.5;
    transition: border-color 0.15s;
  }
  #cooked-notes:focus { outline: none; border-color: var(--accent); }
  #cooked-notes::placeholder { color: var(--text-dim); }
  #cooked-skip-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 0.85rem; cursor: pointer; padding: 4px; text-decoration: underline;
    align-self: center;
  }

  /* ── Recipe detail bottom sheet ───────────── */
  #recipe-detail-overlay {
    display: none; position: fixed; inset: 0; z-index: 11500;
    background: rgba(0,0,0,0.55); align-items: flex-end; justify-content: center;
  }
  #recipe-detail-overlay.visible { display: flex; }
  #recipe-detail-sheet {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px 18px 0 0; padding: 20px 20px calc(32px + env(safe-area-inset-bottom));
    width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 14px;
    max-height: 85vh; overflow-y: auto;
  }
  #recipe-detail-handle {
    width: 36px; height: 4px; background: var(--border);
    border-radius: 2px; align-self: center; flex-shrink: 0; margin-bottom: 2px;
  }
  #recipe-detail-header {
    display: flex; align-items: flex-start; gap: 10px;
  }
  #recipe-detail-title {
    font-size: 1.1rem; font-weight: 700; color: var(--text);
    flex: 1; line-height: 1.35;
  }
  #recipe-detail-close {
    background: none; border: none; color: var(--text-dim);
    font-size: 1rem; cursor: pointer; padding: 2px 4px; flex-shrink: 0;
    line-height: 1; border-radius: 6px;
  }
  #recipe-detail-close:hover { color: var(--text); }
  #recipe-detail-meta {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  }
  .rd-chip {
    font-size: 0.75rem; color: var(--text-dim);
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 20px; padding: 3px 10px; white-space: nowrap;
  }
  #recipe-detail-dates {
    font-size: 0.8rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 3px;
  }
  /* ── Nutrition section (recipe detail sheet + servings screen) ── */
  .nutrition-section {
    display: flex; flex-direction: column; gap: 8px;
  }
  .nutrition-section-label {
    font-size: 0.72rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.06em;
  }
  .nutrition-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px;
  }
  .nutrition-cell {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 10px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
  }
  .nutrition-cell-value {
    font-size: 1rem; font-weight: 800; color: var(--accent);
    font-variant-numeric: tabular-nums; line-height: 1.1;
  }
  .nutrition-cell-label {
    font-size: 0.68rem; color: var(--text-dim); text-align: center;
  }
  .nutrition-secondary-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 4px;
    margin-top: 2px;
  }
  .nutrition-secondary-cell {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 5px 8px;
    display: flex; justify-content: space-between; align-items: center; gap: 6px;
  }
  .nutrition-secondary-label {
    font-size: 0.72rem; color: var(--text-dim);
  }
  .nutrition-secondary-value {
    font-size: 0.78rem; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums;
  }
  .nutrition-total-note {
    font-size: 0.72rem; color: var(--text-dim); text-align: center; margin-top: 2px;
  }

  #recipe-detail-notes-section {
    display: flex; flex-direction: column; gap: 6px;
  }
  #recipe-detail-notes-label {
    font-size: 0.72rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.06em;
    display: flex; align-items: center; gap: 8px;
  }
  #recipe-detail-notes-edit-btn {
    background: none; border: none; cursor: pointer;
    font-size: 0.9rem; padding: 0 2px; line-height: 1;
    opacity: 0.6; transition: opacity 0.15s;
  }
  #recipe-detail-notes-edit-btn:hover { opacity: 1; }
  #recipe-detail-notes {
    font-size: 0.9rem; color: var(--text); line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
    border-left: 2px solid var(--accent); padding-left: 10px;
    cursor: pointer;
  }
  #recipe-detail-notes:hover { opacity: 0.8; }
  #recipe-detail-no-notes {
    font-size: 0.85rem; color: var(--text-dim); font-style: italic;
    cursor: pointer;
  }
  #recipe-detail-no-notes:hover { color: var(--text); }
  #recipe-detail-notes-textarea {
    width: 100%; box-sizing: border-box;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); border-radius: 10px; padding: 10px 12px;
    font-size: 0.9rem; line-height: 1.6; resize: vertical;
    font-family: inherit;
  }
  #recipe-detail-notes-textarea:focus { outline: none; border-color: var(--accent); }
  #recipe-detail-notes-edit-actions {
    display: flex; gap: 8px; margin-top: 8px;
  }
  #recipe-detail-notes-save-btn {
    flex: 1; background: var(--accent); color: #1a1208;
    border: none; border-radius: 10px; padding: 10px;
    font-size: 0.9rem; font-weight: 700; cursor: pointer;
    transition: opacity 0.1s;
  }
  #recipe-detail-notes-save-btn:active { opacity: 0.8; }
  #recipe-detail-notes-cancel-btn {
    flex: 1; background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 10px; padding: 10px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: border-color 0.15s;
  }
  #recipe-detail-notes-cancel-btn:hover { border-color: var(--accent); }
  #recipe-detail-cook-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 12px; padding: 15px; font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: opacity 0.1s; width: 100%;
    touch-action: manipulation;
  }
  #recipe-detail-cook-btn:active { opacity: 0.8; }
  .rd-secondary-actions {
    display: flex; gap: 10px;
  }
  .rd-secondary-actions button {
    flex: 1; background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 12px; padding: 13px; font-size: 0.95rem;
    font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    touch-action: manipulation;
  }
  .rd-secondary-actions button:hover { border-color: var(--accent); background: var(--surface2); }
  .rd-secondary-actions button.active { border-color: var(--accent); background: rgba(212,168,67,0.12); }

  /* ── WKWebView: suppress text selection on non-editable UI chrome ──────────
     Dragging over labels, chips, message bubbles, timer displays, and nav items
     triggers the iOS text-selection loupe. These regions are read-only UI chrome,
     so we disable selection there. Text inputs and textareas override this with
     user-select: text (below) so they still receive normal text-editing behaviour.  */

  /* Message bubble containers — chef and user speech */
  #messages-area,
  #prep-messages-area {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Chip / badge elements */
  .recipe-card-meta-chip,
  .cooked-badge,
  .rd-chip,
  #servings-badge,
  #prep-badge,
  #phase-badge,
  #phase-complete-label,
  .nutrition-cell-label,
  .nutrition-cell-value,
  .nutrition-secondary-label,
  .nutrition-secondary-value {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Timer display */
  .timer-count,
  .timer-label {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Progress and status text */
  #progress-text,
  #prep-progress-text,
  #loading-text,
  #heard-text,
  #prep-heard-text {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Recipe title and step-card labels */
  #recipe-title,
  #servings-header-title,
  #prep-header-title,
  #phase-complete-title,
  .step-confirm-name,
  #active-steps-label,
  .servings-ingredient-name,
  .servings-ingredient-notes,
  .servings-ingredient-qty,
  .servings-category-heading {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Navigation labels (bottom nav, people tabs, lib tabs) */
  .nav-btn,
  .people-tab,
  .lib-tab,
  .library-sort-btn,
  #people-header h2,
  #feed-header h2,
  #library-header h2 {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Ensure all text inputs and textareas remain selectable and editable
     (overrides the broad rules above for any ancestor that may apply them) */
  input[type="text"],
  input[type="url"],
  input[type="email"],
  textarea {
    -webkit-user-select: text;
    user-select: text;
  }

  /* ── Toast ────────────────────────────────── */
  #toast {
    position: fixed; bottom: calc(72px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    background: var(--surface2); border: 1px solid var(--accent);
    color: var(--text); font-size: 0.85rem; padding: 9px 18px;
    border-radius: 20px; z-index: 12000; pointer-events: none;
    opacity: 0; transition: opacity 0.2s;
    white-space: nowrap; display: flex; align-items: center; gap: 10px;
  }
  #toast.show { opacity: 1; }
  #toast.interactive { pointer-events: auto; }
  #toast-undo-btn {
    background: none; border: 1px solid var(--accent);
    color: var(--accent); font-size: 0.8rem; padding: 3px 10px;
    border-radius: 12px; cursor: pointer; font-weight: 600;
    white-space: nowrap;
  }
  #toast-undo-btn:hover { background: var(--accent); color: #fff; }

  /* ── Resume banner ────────────────────────── */
  #resume-banner {
    display: none;
    width: 100%; max-width: 340px;
    background: var(--surface2); border: 1px solid var(--accent-dim);
    border-radius: 14px; padding: 14px 16px;
    flex-direction: column; gap: 10px;
    animation: fadeIn 0.25s ease;
  }
  #resume-banner.visible { display: flex; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  #resume-banner-label {
    font-size: 0.95rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #resume-banner-progress {
    font-size: 0.8rem; color: var(--text-dim);
  }
  #resume-banner-btns {
    display: flex; gap: 8px;
  }
  #resume-yes-btn {
    flex: 1; background: var(--accent); color: #1a1208;
    font-size: 0.95rem; font-weight: 700; border: none;
    border-radius: 10px; padding: 11px 12px; cursor: pointer;
    transition: opacity 0.1s;
  }
  #resume-yes-btn:active { opacity: 0.8; }
  #resume-no-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-dim); font-size: 0.9rem;
    border-radius: 10px; padding: 11px 14px; cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
  }
  #resume-no-btn:hover { border-color: var(--text-dim); color: var(--text); }

  /* ── Bottom nav bar ───────────────────────── */
  #bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 9996;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    flex-direction: row; justify-content: space-around; align-items: stretch;
  }
  #bottom-nav.visible { display: flex; }

  .nav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; padding: 10px 6px 8px;
    background: transparent; border: none; cursor: pointer;
    color: var(--text-dim); font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    transition: color 0.15s; -webkit-tap-highlight-color: transparent;
  }
  .nav-btn .nav-icon { font-size: 1.3rem; line-height: 1; }
  .nav-btn:hover { color: var(--text); }
  .nav-btn.active { color: var(--accent); }

  /* ── Feed screen (full-page overlay) ─────── */
  #feed-screen {
    display: none;
    position: fixed; inset: 0; z-index: 10000;
    background: var(--bg);
    flex-direction: column;
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }
  #feed-screen.visible { display: flex; }

  #feed-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 10;
    flex-shrink: 0;
  }
  #feed-header h2 { font-size: 1rem; font-weight: 700; color: var(--accent); flex: 1; }
  #feed-refresh-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 1.1rem; cursor: pointer; padding: 4px 6px; border-radius: 6px;
    line-height: 1; transition: color 0.15s;
  }
  #feed-refresh-btn:hover { color: var(--accent); }

  #feed-list {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
  }

  /* Feed activity card */
  .feed-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 12px 14px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex; flex-direction: column; gap: 8px;
  }
  .feed-card:hover { border-color: var(--accent); background: var(--surface2); }
  .feed-card:active { opacity: 0.8; }

  .feed-card-top {
    display: flex; align-items: center; gap: 10px;
  }
  .feed-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--surface2); border: 1px solid var(--border);
    flex-shrink: 0; overflow: hidden; display: flex; align-items: center;
    justify-content: center; font-size: 0.95rem; font-weight: 700;
    color: var(--accent);
  }
  .feed-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .feed-card-meta {
    flex: 1; min-width: 0;
  }
  .feed-card-who {
    font-size: 0.88rem; font-weight: 600; color: var(--text);
  }
  .feed-card-action {
    font-size: 0.8rem; color: var(--text-dim); margin-top: 1px;
  }
  .feed-card-time {
    font-size: 0.75rem; color: var(--text-dim); flex-shrink: 0;
    white-space: nowrap;
  }

  .feed-card-recipe {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px;
  }
  .feed-card-recipe-title {
    flex: 1; font-size: 0.88rem; font-weight: 600; color: var(--text);
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .feed-card-recipe-arrow {
    color: var(--text-dim); font-size: 1rem; flex-shrink: 0;
  }

  /* Feed loading / empty / error states */
  #feed-loading {
    display: none; align-items: center; justify-content: center;
    gap: 12px; padding: 40px; color: var(--text-dim); font-size: 0.9rem;
    flex-direction: column;
  }
  #feed-loading-spinner {
    width: 24px; height: 24px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  #feed-empty {
    display: none; flex-direction: column; align-items: center;
    justify-content: center; gap: 16px; padding: 60px 24px;
    text-align: center; flex: 1;
  }
  #feed-empty .empty-icon { font-size: 3rem; opacity: 0.4; }
  #feed-empty h3 { font-size: 1.1rem; color: var(--text-dim); font-weight: 600; }
  #feed-empty p { font-size: 0.88rem; color: var(--text-dim); line-height: 1.6; max-width: 260px; }
  #feed-find-people-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 12px; padding: 13px 24px; font-size: 0.95rem;
    font-weight: 700; cursor: pointer; transition: opacity 0.1s;
  }
  #feed-find-people-btn:active { opacity: 0.8; }

  /* Sentinel element for IntersectionObserver pagination */
  #feed-sentinel { height: 1px; }

  /* ── Session exit / cancel / home buttons ─────── */
  .session-exit-btn {
    background: transparent; border: none; color: var(--text-dim);
    font-size: 1.15rem; cursor: pointer; padding: 6px 8px; border-radius: 6px;
    line-height: 1; transition: color 0.15s, background 0.15s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .session-exit-btn:hover { color: var(--text); background: var(--surface2); }

  #loading-cancel-btn {
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-dim); border-radius: 10px; padding: 12px 24px;
    font-size: 0.95rem; cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
  }
  #loading-cancel-btn:hover { border-color: var(--accent); color: var(--text); }

  #completion-home-btn {
    background: var(--accent); color: #1a1208; border: none;
    border-radius: 12px; padding: 14px 28px; font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: opacity 0.1s; margin-top: 8px;
  }
  #completion-home-btn:active { opacity: 0.8; }
