    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

    :root {
      --bg:         #F9F7F2;
      --card:       #FFFFFF;
      --accent:     #4A6741;
      --accent-dk:  #3A5032;
      --secondary:  #C86B4F;
      --text:       #2B2E24;
      --text-mid:   #5C6152;
      --text-lt:    #666A5A;
      --border:     #DDD9CE;
      --success:    #5B8C5A;
      --danger:     #C45B4A;
      --green-bg:   #EEF3E8;
      --amber:      #B5860D;
      --amber-bg:   #FFF8E6;
      --serif:      'Crimson Pro', Georgia, serif;
      --sans:       'Cabin', system-ui, sans-serif;
      --radius:     12px;
      --radius-card: 24px;
      --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    }

    :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }

    #app {
      display: flex;
      flex-direction: column;
      height: 100dvh;
      max-width: 480px;
      margin: 0 auto;
      position: relative;
    }

    /* ── Header ── */
    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 18px 10px;
      background: var(--bg);
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      position: sticky;
      top: 0;
      z-index: 10;
    }
    .logo {
      font-family: var(--serif);
      font-size: 26px;
      font-weight: 600;
      color: var(--text);
      letter-spacing: -0.5px;
    }
    .logo span { color: var(--accent); }
    #city-select {
      font-family: var(--sans);
      font-size: 13px;
      color: var(--text-mid);
      background: transparent;
      border: 1px solid var(--border);
      border-radius: 20px;
      padding: 5px 10px;
      cursor: pointer;
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A8E7E'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 8px center;
      padding-right: 22px;
    }

    /* ── Main scroll area ── */
    main {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding-bottom: 120px;
    }

    .tab-content { display: none; padding: 16px; }
    .tab-content.active { display: block; }

    /* ── Bottom nav ── */
    nav {
      position: fixed;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 100%;
      max-width: 480px;
      display: flex;
      background: var(--card);
      border-top: 1px solid var(--border);
      z-index: 20;
    }
    nav button {
      flex: 1;
      padding: 3px 8px 6px;
      background: none;
      border: none;
      border-top: 3px solid transparent;
      cursor: pointer;
      font-family: var(--sans);
      font-size: 11px;
      font-weight: 500;
      color: var(--text-lt);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      transition: color 0.15s, border-color 0.15s;
    }
    nav button .nav-icon { font-size: 20px; }
    nav button.active { color: var(--accent); border-top-color: var(--accent); }

    /* Action bar above nav */
    #action-bar {
      position: fixed;
      bottom: 52px;
      left: 50%;
      transform: translateX(-50%);
      width: 100%;
      max-width: 480px;
      padding: 8px 16px;
      background: var(--bg);
      border-top: 1px solid var(--border);
      display: flex;
      gap: 10px;
      z-index: 20;
    }

    /* ── Buttons ── */
    .btn {
      font-family: var(--sans);
      font-size: 14px;
      font-weight: 500;
      border: none;
      border-radius: var(--radius);
      padding: 12px 18px;
      cursor: pointer;
      transition: opacity 0.15s, background 0.15s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      white-space: nowrap;
    }
    .btn:active { opacity: 0.8; }
    .btn-primary { background: var(--accent); color: #fff; flex: 1; box-shadow: 4px 4px 0 var(--accent); }
    .btn-primary:hover { background: var(--accent-dk); }
    .btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); flex: 1; }
    .btn-success { background: var(--success); color: #fff; flex: 1; }
    .btn-icon { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 12px 14px; flex: none; }
    .btn:disabled { opacity: 0.5; cursor: not-allowed; }

    /* ── Cards ── */
    .card {
      background: var(--card);
      border-radius: var(--radius-card);
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      margin-bottom: 12px;
      overflow: hidden;
    }
    .card-header {
      padding: 14px 16px 10px;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 8px;
    }
    .card-title {
      font-family: var(--serif);
      font-size: 19px;
      font-weight: 500;
      color: var(--text);
      line-height: 1.2;
    }
    .card-meta {
      font-size: 12px;
      color: var(--text-lt);
      margin-top: 3px;
    }
    .card-body { padding: 0 16px 14px; }
    .card-photo {
      height: 130px;
      position: relative;
      cursor: pointer;
    }
    .card-season-tag {
      position: absolute;
      top: 10px;
      left: 12px;
      background: rgba(0,0,0,0.32);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      color: #fff;
      font-family: var(--sans);
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      padding: 4px 10px;
      border-radius: 20px;
    }
    .card-footer {
      padding: 8px 16px 12px;
      border-top: 1px solid var(--border);
    }
    .card-find-similar {
      font-family: var(--sans);
      font-size: 13px;
      font-weight: 500;
      color: var(--accent);
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .card-find-similar:hover { color: var(--accent-dk); }
    /* Share FAB */
    .share-fab {
      position: fixed;
      bottom: 76px;
      right: 18px;
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: var(--accent);
      color: #fff;
      border: none;
      font-size: 20px;
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(74,103,65,0.4), 3px 3px 0 var(--accent-dk);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 25;
      transition: opacity 0.15s;
    }
    .share-fab:active { opacity: 0.8; }

    /* ── Ingredient list ── */
    .ingredient-list { list-style: none; }
    .ingredient-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 0;
      border-bottom: 1px solid var(--border);
    }
    .ingredient-item:last-child { border-bottom: none; }
    .ingredient-text {
      flex: 1;
      font-size: 14px;
      color: var(--text);
      cursor: pointer;
    }
    .ingredient-text .qty { color: var(--text-mid); }
    .low-confidence { color: var(--amber); }
    .ingredient-text .confidence-dot {
      display: inline-block;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--amber);
      margin-left: 4px;
      vertical-align: middle;
    }
    .ingredient-edit-form {
      display: flex;
      align-items: center;
      gap: 6px;
      flex: 1;
    }
    .ingredient-edit-input {
      flex: 1;
      font-family: var(--sans);
      font-size: 16px; /* prevents iOS zoom */
      padding: 4px 8px;
      border: 1px solid var(--accent);
      border-radius: 6px;
      color: var(--text);
    }
    .edit-confirm { background: none; border: none; cursor: pointer; font-size: 18px; padding: 2px; }
    .edit-cancel  { background: none; border: none; cursor: pointer; font-size: 18px; padding: 2px; color: var(--text-lt); }
    .edit-trigger { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text-lt); padding: 2px 4px; opacity: 0.4; transition: opacity 0.15s; }
    .ingredient-item:hover .edit-trigger,
    .ingredient-item:focus-within .edit-trigger { opacity: 1; }

    .delete-btn {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--text-lt);
      font-size: 16px;
      padding: 4px;
      transition: color 0.15s;
    }
    .delete-btn:hover { color: var(--danger); }

    /* ── Empty state ── */
    .empty-state {
      text-align: center;
      padding: 56px 24px;
      color: var(--text-lt);
    }
    .empty-state .empty-icon { font-size: 48px; margin-bottom: 14px; }
    .empty-state h3 { font-family: var(--serif); font-size: 22px; color: var(--text-mid); margin-bottom: 8px; }
    .empty-state p { font-size: 14px; line-height: 1.5; }

    /* ── Progress bar ── */
    .progress-bar {
      background: var(--border);
      border-radius: 4px;
      height: 6px;
      margin-bottom: 16px;
      overflow: hidden;
    }
    .progress-fill {
      height: 100%;
      background: var(--success);
      border-radius: 4px;
      transition: width 0.3s ease;
    }
    .progress-label {
      font-size: 12px;
      color: var(--text-lt);
      text-align: right;
      margin-bottom: 6px;
    }

    /* ── Shopping list ── */
    .list-header {
      font-family: var(--serif);
      font-size: 15px;
      font-weight: 500;
      color: var(--text-mid);
      letter-spacing: 0.5px;
      text-transform: uppercase;
      font-size: 11px;
      padding: 10px 0 6px;
      margin-top: 6px;
    }
    .shop-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px 0;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      transition: opacity 0.2s;
    }
    .shop-item:last-child { border-bottom: none; }
    .shop-item.checked { opacity: 0.45; }
    .shop-item.checked .shop-name { text-decoration: line-through; color: var(--text-lt); }
    .shop-checkbox {
      width: 20px;
      height: 20px;
      border: 2px solid var(--border);
      border-radius: 50%;
      flex-shrink: 0;
      margin-top: 1px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s;
    }
    .shop-item.checked .shop-checkbox,
    .shop-checkbox.checked {
      background: var(--success);
      border-color: var(--success);
    }
    .shop-item.checked .shop-checkbox::after,
    .shop-checkbox.checked::after { content: '✓'; color: white; font-size: 11px; font-weight: 600; }
    .shop-name { font-size: 15px; color: var(--text); line-height: 1.3; }
    .shop-qty  { font-size: 13px; color: var(--text-mid); margin-top: 1px; }
    .shop-note {
      font-size: 12px;
      margin-top: 2px;
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .shop-note.seasonal { color: var(--success); }

    /* ── Collapsible sections ── */
    details { margin-bottom: 12px; }
    details summary {
      font-family: var(--serif);
      font-size: 17px;
      font-weight: 500;
      color: var(--text);
      cursor: pointer;
      padding: 12px 16px;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      list-style: none;
      display: flex;
      align-items: center;
      gap: 8px;
      user-select: none;
    }
    details summary::-webkit-details-marker { display: none; }
    details summary::after { content: '›'; margin-left: auto; color: var(--text-lt); font-size: 18px; transition: transform 0.2s; }
    details[open] summary::after { transform: rotate(90deg); }
    details[open] summary {
      border-bottom-left-radius: 0;
      border-bottom-right-radius: 0;
      border-bottom-color: transparent;
    }
    .details-body {
      background: var(--card);
      border: 1px solid var(--border);
      border-top: none;
      border-bottom-left-radius: var(--radius);
      border-bottom-right-radius: var(--radius);
      padding: 12px 16px;
    }

    /* ── Seasonal tips ── */
    .seasonal-tip {
      font-size: 14px;
      color: var(--text);
      line-height: 1.5;
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      display: flex;
      gap: 8px;
      align-items: flex-start;
    }
    .seasonal-tip:last-child { border-bottom: none; padding-bottom: 0; }
    .tip-dot { color: var(--success); font-size: 16px; flex-shrink: 0; margin-top: 1px; }

    /* ── Greens suggestions ── */
    .greens-recipe {
      margin-bottom: 14px;
    }
    .greens-recipe:last-child { margin-bottom: 0; }
    .greens-recipe-name {
      font-family: var(--serif);
      font-size: 15px;
      font-weight: 500;
      color: var(--text-mid);
      margin-bottom: 6px;
    }
    .greens-item {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      padding: 6px 0;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      transition: background 0.12s;
    }
    .greens-item:hover { background: var(--green-bg); border-radius: 6px; }
    .greens-item:last-child { border-bottom: none; }
    .greens-icon { color: var(--success); flex-shrink: 0; }
    .greens-name { font-size: 14px; font-weight: 500; color: var(--text); }
    .greens-qty  { font-size: 13px; color: var(--text-mid); }
    .greens-how  { font-size: 12px; color: var(--text-lt); font-style: italic; margin-top: 1px; }
    .greens-add-all {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 0 12px;
      margin-bottom: 10px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      font-size: 14px;
      color: var(--text-mid);
      user-select: none;
    }
    .greens-add-all:hover { color: var(--text); }

    /* ── Greens add checkbox ── */
    .greens-add-btn {
      width: 22px;
      height: 22px;
      border: 2px solid var(--border);
      border-radius: 50%;
      flex-shrink: 0;
      margin-top: 2px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: none;
      padding: 0;
      color: transparent;
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.15s;
      pointer-events: none;
    }
    .greens-add-btn.added {
      background: var(--success);
      border-color: var(--success);
      color: #fff;
    }

    /* ── Pantry modal ── */
    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(43,46,36,0.45);
      z-index: 150;
      align-items: flex-end;
      justify-content: center;
    }
    .modal-overlay.visible { display: flex; }
    .modal-sheet {
      background: var(--card);
      border-radius: 18px 18px 0 0;
      padding: 16px 20px 40px;
      width: 100%;
      max-width: 480px;
    }
    .modal-handle {
      width: 36px; height: 4px;
      background: var(--border);
      border-radius: 2px;
      margin: 0 auto 16px;
    }
    .modal-title {
      font-family: var(--serif);
      font-size: 20px;
      font-weight: 500;
      color: var(--text);
      margin-bottom: 4px;
    }
    .modal-sub {
      font-size: 13px;
      color: var(--text-lt);
      margin-bottom: 14px;
      line-height: 1.5;
    }
    .pantry-textarea {
      width: 100%;
      min-height: 90px;
      font-family: var(--sans);
      font-size: 16px;
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      resize: vertical;
      margin-bottom: 10px;
      background: var(--bg);
      line-height: 1.5;
    }
    .pantry-textarea:focus { border-color: var(--accent); }
    .modal-actions { display: flex; gap: 8px; align-items: center; }
    .voice-btn {
      flex-shrink: 0;
      background: var(--green-bg);
      border: 1px solid #C4D4B0;
      border-radius: 10px;
      padding: 11px 14px;
      font-size: 18px;
      cursor: pointer;
      line-height: 1;
      transition: background 0.15s;
    }
    .voice-btn.recording {
      background: #FFE8E5;
      border-color: var(--danger);
      animation: mic-pulse 1s ease-in-out infinite;
    }
    @keyframes mic-pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }

    /* ── Ingredient suggestion response ── */
    .suggestion-headline {
      font-family: var(--serif);
      font-size: 18px;
      color: var(--text);
      margin-bottom: 14px;
      line-height: 1.4;
    }
    .suggestion-section-title {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-lt);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 8px;
      margin-top: 16px;
    }
    .suggestion-idea {
      font-size: 14px;
      color: var(--text);
      line-height: 1.5;
      padding: 8px 0;
      border-bottom: 1px solid var(--border);
      display: flex;
      gap: 8px;
    }
    .suggestion-idea:last-child { border-bottom: none; }
    .suggestion-sub {
      background: var(--green-bg);
      border-radius: 8px;
      padding: 10px 12px;
      margin-bottom: 8px;
    }
    .suggestion-sub-recipe { font-size: 12px; color: var(--text-lt); margin-bottom: 3px; }
    .suggestion-sub-text { font-size: 14px; color: var(--text); }
    .suggestion-sub-note { font-size: 12px; color: var(--text-mid); font-style: italic; margin-top: 3px; }
    .suggestion-add-btn {
      font-family: var(--sans);
      font-size: 12px;
      background: none;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 4px 10px;
      cursor: pointer;
      color: var(--accent);
      margin-top: 6px;
      display: inline-block;
      transition: background 0.15s;
    }
    .suggestion-add-btn:hover { background: var(--green-bg); }
    .suggestion-add-btn:disabled { color: var(--text-lt); cursor: default; background: none; }
    .recipe-note {
      display: flex;
      gap: 6px;
      font-size: 12px;
      color: var(--accent);
      padding: 3px 0;
    }

    /* ── Email capture ── */
    #email-capture {
      background: var(--green-bg);
      border: 1px solid #C4D4B0;
      border-radius: var(--radius);
      padding: 14px 16px;
      margin-bottom: 12px;
      display: none;
    }
    #email-capture.visible { display: block; }
    .email-capture-label {
      font-family: var(--serif);
      font-size: 16px;
      color: var(--text);
      margin-bottom: 8px;
    }
    .email-capture-sub {
      font-size: 12px;
      color: var(--text-mid);
      margin-bottom: 10px;
    }
    .email-capture-row {
      display: flex;
      gap: 8px;
      align-items: center;
    }
    .email-input {
      flex: 1;
      font-family: var(--sans);
      font-size: 16px;
      padding: 9px 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--card);
      color: var(--text);
    }
    .email-input:focus { border-color: var(--accent); }
    .email-dismiss {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--text-lt);
      font-size: 13px;
      padding: 6px 0;
      text-align: center;
      width: 100%;
      margin-top: 6px;
    }

    /* ── Loading overlay ── */
    #loading-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(244, 242, 236, 0.88);
      z-index: 100;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      gap: 14px;
    }
    #loading-overlay.visible { display: flex; }
    .spinner {
      width: 36px;
      height: 36px;
      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 {
      font-family: var(--serif);
      font-size: 18px;
      color: var(--text-mid);
    }

    /* ── Toast ── */
    #toast {
      position: fixed;
      bottom: 120px;
      left: 50%;
      transform: translateX(-50%) translateY(20px);
      background: var(--text);
      color: #fff;
      padding: 10px 18px;
      border-radius: 20px;
      font-size: 13px;
      font-family: var(--sans);
      opacity: 0;
      transition: opacity 0.2s, transform 0.2s;
      pointer-events: none;
      white-space: nowrap;
      z-index: 200;
      max-width: calc(100vw - 48px);
      text-align: center;
    }
    #toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    /* ── Hidden file inputs ── */
    #file-input-camera, #file-input-upload { display: none; }

    /* ── How it works modal ── */
    .howto-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(43,46,36,0.52); z-index: 200;
      align-items: center; justify-content: center; padding: 20px 16px;
    }
    .howto-overlay.visible { display: flex; }
    .howto-sheet {
      background: var(--card); border-radius: 18px;
      padding: 28px 20px 24px; width: 100%; max-width: 400px;
      max-height: 88vh; overflow-y: auto;
    }
    .howto-title {
      font-family: var(--serif); font-size: 26px; font-weight: 400;
      color: var(--accent); text-align: center; margin-bottom: 22px;
    }
    .howto-step { display: flex; align-items: flex-start; gap: 14px; }
    .howto-icon {
      flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px;
      background: var(--green-bg); border: 1.5px solid var(--accent);
      display: flex; align-items: center; justify-content: center; padding: 8px;
    }
    .howto-icon svg { width: 100%; height: 100%; }
    .howto-icon-hi  { background: var(--accent); border-color: var(--accent-dk); }
    .howto-icon-ck  { background: #FFF8E6; border-color: #B5860D; }
    .howto-text { flex: 1; padding-top: 2px; }
    .howto-label { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
    .howto-label-ck { color: #7a5800; }
    .howto-sub { font-size: 12px; color: var(--text-mid); line-height: 1.4; }
    .howto-subitems { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
    .howto-subitem { font-size: 11.5px; color: var(--text-mid); padding: 2px 0; }
    .howto-subitem::before { content: '–\00a0'; color: var(--accent); }
    .howto-arrow { text-align: center; color: var(--border); font-size: 16px; padding: 3px 0 3px 26px; }
    .howto-close { display: block; width: 100%; padding: 14px; background: var(--accent);
      color: white; border: none; border-radius: 12px; font-size: 15px; font-weight: 500;
      font-family: var(--sans); cursor: pointer; margin-top: 20px; }
    .howto-close:active { opacity: .85; }
    .logo { cursor: pointer; user-select: none; }

    /* ── Recipe search ── */
    .recipe-search-wrap { padding: 12px 0 4px; }
    .recipe-search-input {
      width: 100%;
      font-family: var(--sans);
      font-size: 14px;
      color: var(--text);
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 10px 14px;
    }
    .recipe-search-input::placeholder { color: var(--text-lt); }
    .recipe-search-input:focus { border-color: var(--accent); }
