/* Swiftwing - Rezepte & Kochen App Styles */
:root {
      --bg: #07090e;
      --surface: #0d131f;
      --card-bg: rgba(16, 22, 36, 0.7);
      --card-hover: rgba(22, 30, 48, 0.85);
      --border: rgba(255, 255, 255, 0.08);
      --border-focus: rgba(249, 115, 22, 0.4);
      --accent: #f97316;
      --accent-hover: #ea580c;
      --accent-subtle: rgba(249, 115, 22, 0.12);
      --accent-amber: #f59e0b;
      --amber-subtle: rgba(245, 158, 11, 0.12);
      --text: #f1f5f9;
      --text-muted: #94a3b8;
      --text-dim: #64748b;
      --radius-lg: 20px;
      --radius-md: 14px;
      --radius-sm: 10px;
      --shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
      --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

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

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

    body {
      background-color: var(--bg);
      color: var(--text);
      font-family: 'Inter', system-ui, -apple-system, sans-serif;
      min-height: 100vh;
      min-height: 100dvh;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin: 0;
      padding: 0;
      background-image: 
        radial-gradient(ellipse 60% 40% at 50% -10%, rgba(249, 115, 22, 0.15), transparent 70%),
        radial-gradient(ellipse 50% 30% at 90% 20%, rgba(245, 158, 11, 0.08), transparent 60%);
      background-attachment: fixed;
      overflow-x: hidden;
    }

    button, a, input, select {
      font-family: inherit;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }

    /* Header Card */
    .header-card {
      background: var(--card-bg);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      width: 100%;
    }

    .title-area h1 {
      font-size: 1.65rem;
      font-weight: 800;
      letter-spacing: -0.03em;
      display: flex;
      align-items: center;
      gap: 10px;
      background: linear-gradient(135deg, #ffffff 40%, #fed7aa 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .title-area p {
      color: var(--text-muted);
      font-size: 0.9rem;
      margin-top: 4px;
      line-height: 1.45;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
    }

    /* Buttons */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 10px 18px;
      border-radius: var(--radius-sm);
      font-size: 14px;
      font-weight: 600;
      border: none;
      cursor: pointer;
      transition: var(--transition);
      text-decoration: none;
      user-select: none;
    }
    .btn:active {
      transform: scale(0.97);
    }

    .btn-primary {
      background: linear-gradient(135deg, #f97316, #ea580c);
      color: #fff;
      box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
    }
    .btn-primary:hover {
      filter: brightness(1.1);
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
    }

    .btn-secondary {
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid var(--border);
      color: var(--text);
    }
    .btn-secondary:hover {
      background: rgba(255, 255, 255, 0.12);
      border-color: rgba(255, 255, 255, 0.18);
    }

    .btn-sm {
      padding: 6px 12px;
      font-size: 12.5px;
      border-radius: 8px;
    }

    .btn-danger-subtle {
      background: rgba(239, 68, 68, 0.1);
      border: 1px solid rgba(239, 68, 68, 0.25);
      color: #fca5a5;
    }
    .btn-danger-subtle:hover {
      background: rgba(239, 68, 68, 0.2);
      border-color: rgba(239, 68, 68, 0.5);
      color: #ef4444;
      transform: translateY(-1px);
    }

    /* Search & Filter Bar */
    .filter-bar {
      display: flex;
      align-items: center;
      gap: 12px;
      width: 100%;
    }

    .search-wrapper {
      flex: 1;
      width: 100%;
      position: relative;
    }

    .search-input {
      width: 100%;
      min-height: 44px;
      background: rgba(13, 19, 31, 0.8);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 11px 16px 11px 42px;
      border-radius: var(--radius-sm);
      font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
      outline: none;
      transition: var(--transition);
    }
    .search-input:focus {
      border-color: var(--accent);
      background: rgba(16, 22, 36, 0.95);
      box-shadow: 0 0 0 3px var(--accent-subtle);
    }
    .search-icon {
      position: absolute;
      left: 14px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
      pointer-events: none;
    }

    /* Tabs */
    .status-tabs {
      display: flex;
      gap: 6px;
      background: rgba(13, 19, 31, 0.8);
      padding: 6px;
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
      overflow-x: auto;
      width: 100%;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      scroll-snap-type: x mandatory;
    }
    .status-tabs::-webkit-scrollbar {
      display: none;
    }

    .tab-btn {
      flex: 1 0 auto;
      min-width: 110px;
      min-height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 10px 10px;
      background: transparent;
      border: none;
      border-radius: var(--radius-sm);
      color: var(--text-muted);
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: var(--transition);
      white-space: nowrap;
      scroll-snap-align: start;
      touch-action: manipulation;
    }
    .tab-btn:hover {
      color: #fff;
      background: rgba(255, 255, 255, 0.04);
    }
    .tab-btn.active {
      background: rgba(255, 255, 255, 0.09);
      color: #fff;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    .tab-badge {
      padding: 2px 7px;
      border-radius: 999px;
      font-size: 11px;
      background: rgba(255, 255, 255, 0.1);
      color: var(--text);
    }
    .tab-btn.active .tab-badge {
      background: var(--accent);
      color: #000;
      font-weight: 700;
    }

    /* Responsive Recipe Grid */
    .recipe-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 16px;
      width: 100%;
    }
    @media (min-width: 600px) {
      .recipe-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
      }
    }
    @media (min-width: 900px) {
      .recipe-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
      }
    }

    /* Recipe Card */
    .recipe-card {
      background: var(--card-bg);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      overflow: hidden;
      display: flex;
      flex-direction: column;
      transition: var(--transition);
      position: relative;
      cursor: pointer;
      touch-action: manipulation;
    }
    .recipe-card:hover {
      transform: translateY(-3px);
      border-color: rgba(255, 255, 255, 0.18);
      background: var(--card-hover);
      box-shadow: var(--shadow);
    }
    .recipe-card:active {
      transform: scale(0.99);
    }

    .card-banner {
      width: 100%;
      aspect-ratio: 16 / 9;
      height: auto;
      max-height: 200px;
      background: linear-gradient(135deg, #1f293d, #111827);
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }
    .card-banner img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.4s ease;
    }
    .recipe-card:hover .card-banner img {
      transform: scale(1.05);
    }
    .banner-fallback {
      font-size: 3rem;
      opacity: 0.85;
      user-select: none;
    }

    .card-fav-btn {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: var(--transition);
      z-index: 2;
      touch-action: manipulation;
    }
    .card-fav-btn:hover {
      transform: scale(1.1);
      background: rgba(0, 0, 0, 0.8);
    }
    .card-fav-btn.is-fav {
      color: #f43f5e;
    }

    .card-status-chip {
      position: absolute;
      top: 10px;
      left: 10px;
      padding: 4px 10px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.02em;
      text-transform: uppercase;
      backdrop-filter: blur(8px);
      z-index: 2;
    }
    .status-pool { background: rgba(59, 130, 246, 0.85); color: #fff; }
    .status-planned { background: rgba(249, 115, 22, 0.9); color: #fff; }
    .status-cooked { background: rgba(245, 158, 11, 0.9); color: #fff; }

    .card-body {
      padding: 18px 20px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      flex: 1;
    }

    .card-title {
      font-size: 1.15rem;
      font-weight: 700;
      color: #fff;
      line-height: 1.35;
    }

    .card-desc {
      font-size: 0.88rem;
      color: var(--text-muted);
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .card-meta {
      display: flex;
      align-items: center;
      gap: 12px;
      font-size: 12.5px;
      color: var(--text-dim);
      flex-wrap: wrap;
    }
    .meta-item {
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .card-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .tag {
      padding: 3px 8px;
      border-radius: 6px;
      font-size: 11.5px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border);
      color: var(--text-muted);
    }

    .card-footer {
      border-top: 1px solid var(--border);
      padding: 10px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      background: rgba(0, 0, 0, 0.18);
    }

    .status-dropdown {
      background: rgba(255, 255, 255, 0.06);
      border: 1px solid var(--border);
      color: var(--text);
      font-size: 13px;
      min-height: 38px;
      padding: 6px 10px;
      border-radius: 8px;
      outline: none;
      cursor: pointer;
      touch-action: manipulation;
    }
    .status-dropdown:focus {
      border-color: var(--accent);
    }

    .card-footer .btn-sm {
      min-height: 38px;
      padding: 8px 14px;
      font-size: 13px;
      touch-action: manipulation;
    }

    /* Empty State */
    .empty-state {
      grid-column: 1 / -1;
      background: var(--card-bg);
      backdrop-filter: blur(16px);
      border: 1px dashed rgba(255, 255, 255, 0.15);
      border-radius: var(--radius-lg);
      padding: 60px 24px;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 16px;
      max-width: 650px;
      margin: 20px auto;
    }

    .empty-icon {
      font-size: 3.5rem;
      margin-bottom: 4px;
    }

    .empty-title {
      font-size: 1.4rem;
      font-weight: 700;
      color: #fff;
    }

    .empty-desc {
      color: var(--text-muted);
      font-size: 0.95rem;
      line-height: 1.6;
      max-width: 480px;
    }

    .empty-tip-box {
      background: rgba(249, 115, 22, 0.08);
      border: 1px solid rgba(249, 115, 22, 0.2);
      border-radius: var(--radius-sm);
      padding: 14px 18px;
      color: #fed7aa;
      font-size: 13px;
      text-align: left;
      line-height: 1.5;
    }
    .empty-tip-box code {
      background: rgba(0, 0, 0, 0.3);
      padding: 2px 6px;
      border-radius: 4px;
      font-family: monospace;
      color: #fff;
    }

    /* Modals */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.75);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      z-index: 1000;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.25s ease, visibility 0.25s ease;
    }
    .modal-overlay.open {
      opacity: 1;
      visibility: visible;
    }

    .modal-content {
      background: #0e1422;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: var(--radius-lg);
      width: 100%;
      max-width: 780px;
      max-height: 90vh;
      max-height: 90dvh;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
      display: flex;
      flex-direction: column;
      position: relative;
      animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes modalSlide {
      from { transform: translateY(20px) scale(0.97); opacity: 0; }
      to { transform: translateY(0) scale(1); opacity: 1; }
    }

    /* Mobile: True Fullscreen for Recipe View (no top gap, no empty bar) */
    @media (max-width: 680px) {
      #detailModal.modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
      }
      #detailModal .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 20px));
        animation: modalSlideMobile 0.22s cubic-bezier(0.16, 1, 0.3, 1);
      }
      @keyframes modalSlideMobile {
        from { transform: translateY(20px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
      }
    }

    .modal-close-btn {
      position: absolute;
      top: 16px;
      right: 16px;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid var(--border);
      color: var(--text-muted);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 10;
      transition: var(--transition);
      touch-action: manipulation;
    }
    .modal-close-btn:hover {
      background: rgba(255, 255, 255, 0.15);
      color: #fff;
    }

    .detail-hero-wrap {
      position: relative;
      width: 100%;
      flex-shrink: 0;
      overflow: hidden;
      border-top-left-radius: inherit;
      border-top-right-radius: inherit;
    }

    .modal-top-nav {
      position: absolute;
      top: calc(14px + env(safe-area-inset-top, 0px));
      left: 14px;
      right: 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      z-index: 25;
      pointer-events: none;
    }

    .modal-action-btn {
      width: 42px;
      height: 42px;
      border-radius: 50%;
      background: rgba(13, 19, 31, 0.75);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border: 1px solid rgba(255, 255, 255, 0.25);
      color: #fff;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      cursor: pointer;
      transition: var(--transition);
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
      pointer-events: auto;
      user-select: none;
      touch-action: manipulation;
    }

    .modal-action-btn:hover {
      background: rgba(22, 30, 48, 0.95);
      border-color: rgba(255, 255, 255, 0.4);
      transform: scale(1.08);
      color: #fff;
    }
    .modal-action-btn:active {
      transform: scale(0.95);
    }

    .modal-action-btn.is-fav {
      background: rgba(244, 63, 94, 0.25);
      border-color: rgba(244, 63, 94, 0.5);
    }

    /* Recipe Detail Modal Elements */
    .detail-hero {
      position: relative;
      height: 240px;
      width: 100%;
      background: linear-gradient(135deg, #1e293b, #0f172a);
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    @media (max-width: 680px) {
      .detail-hero {
        height: calc(260px + env(safe-area-inset-top, 0px));
      }
    }
    .detail-hero img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .detail-hero-gradient {
      position: absolute;
      inset: 0;
      background: linear-gradient(to top, #0e1422 6%, transparent 65%);
    }

    .detail-body {
      padding: 24px 24px 32px;
      display: flex;
      flex-direction: column;
      gap: 22px;
    }

    @media (max-width: 680px) {
      .detail-body {
        padding: 18px 16px 24px;
        gap: 18px;
      }
      .detail-title {
        font-size: 1.45rem;
      }
    }

    .detail-header {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .detail-title {
      font-size: 1.75rem;
      font-weight: 800;
      letter-spacing: -0.02em;
      line-height: 1.25;
      color: #fff;
    }
    .detail-desc {
      color: var(--text-muted);
      font-size: 0.95rem;
      line-height: 1.6;
    }

    /* Servings Calculator */
    .servings-box {
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 14px 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 14px;
    }
    .servings-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .servings-label {
      font-size: 0.95rem;
      font-weight: 700;
      color: #fff;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .servings-sub {
      font-size: 0.8rem;
      color: var(--text-dim);
    }
    .servings-counter {
      display: flex;
      align-items: center;
      gap: 10px;
      background: rgba(0, 0, 0, 0.3);
      padding: 4px 8px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
    }
    .servings-btn {
      width: 38px;
      height: 38px;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid var(--border);
      color: #fff;
      font-size: 18px;
      font-weight: bold;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: var(--transition);
      touch-action: manipulation;
    }
    .servings-btn:hover:not(:disabled) {
      background: var(--accent);
      color: #000;
      border-color: var(--accent);
    }
    .servings-btn:disabled {
      opacity: 0.3;
      cursor: not-allowed;
    }
    .servings-count {
      font-size: 1.15rem;
      font-weight: 800;
      min-width: 32px;
      text-align: center;
      color: var(--accent);
    }

    /* Ingredients Section */
    .section-title {
      font-size: 1.2rem;
      font-weight: 700;
      color: #fff;
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 12px;
    }

    .ingredients-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }
    @media (min-width: 600px) {
      .ingredients-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }
    .ingredient-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 14px;
      min-height: 44px;
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.025);
      border: 1px solid var(--border);
      font-size: 14px;
      transition: var(--transition);
      cursor: pointer;
      user-select: none;
      touch-action: manipulation;
    }
    .ingredient-row:hover {
      background: rgba(255, 255, 255, 0.05);
    }
    .ingredient-row.checked {
      opacity: 0.45;
      text-decoration: line-through;
    }
    .ingredient-check {
      accent-color: var(--accent);
      cursor: pointer;
    }
    .ingredient-amount {
      font-weight: 700;
      color: var(--accent);
      white-space: nowrap;
    }
    .ingredient-name {
      color: var(--text);
      flex: 1;
    }
    .ingredient-note {
      font-size: 12px;
      color: var(--text-dim);
      font-style: italic;
    }

    /* Steps Section with Step Ingredients (Mise-en-place) */
    .steps-list {
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .step-card {
      background: rgba(255, 255, 255, 0.025);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 20px;
      display: flex;
      flex-direction: column;
      gap: 14px;
      transition: var(--transition);
    }
    .step-card:hover {
      border-color: rgba(255, 255, 255, 0.15);
    }

    .step-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }
    .step-num {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--accent-subtle);
      border: 1px solid rgba(249, 115, 22, 0.3);
      color: var(--accent);
      font-size: 13px;
      font-weight: 800;
    }
    .step-timer {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: 12px;
      color: var(--accent-amber);
      background: var(--amber-subtle);
      border: 1px solid rgba(245, 158, 11, 0.3);
      padding: 4px 9px;
      border-radius: 999px;
    }

    /* Step Mise-en-place Box */
    .step-mise-en-place {
      background: rgba(249, 115, 22, 0.06);
      border: 1px solid rgba(249, 115, 22, 0.2);
      border-radius: 10px;
      padding: 10px 14px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .step-mise-header {
      font-size: 11.5px;
      font-weight: 700;
      color: #fdba74;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .step-mise-items {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .step-mise-pill {
      background: rgba(249, 115, 22, 0.15);
      border: 1px solid rgba(249, 115, 22, 0.25);
      padding: 3px 8px;
      border-radius: 6px;
      font-size: 12px;
      color: #fff;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }
    .step-mise-pill strong {
      color: #fdba74;
    }

    .step-instruction {
      font-size: 0.96rem;
      color: #e2e8f0;
      line-height: 1.6;
    }

    .step-tip {
      font-size: 12.5px;
      color: #cbd5e1;
      background: rgba(255, 255, 255, 0.04);
      border-left: 3px solid var(--accent-amber);
      padding: 8px 12px;
      border-radius: 0 8px 8px 0;
      line-height: 1.45;
    }

    /* Rating & Notes Box */
    .rating-box {
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 16px 20px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .star-rating {
      display: flex;
      gap: 6px;
      font-size: 24px;
      cursor: pointer;
    }
    .star {
      color: rgba(255, 255, 255, 0.2);
      transition: var(--transition);
    }
    .star.filled {
      color: var(--accent-amber);
      transform: scale(1.08);
    }

    /* Cook Mode (Full Screen) */
    .cook-mode-overlay {
      position: fixed;
      inset: 0;
      background: #07090e;
      z-index: 2000;
      display: flex;
      flex-direction: column;
      padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(20px + env(safe-area-inset-bottom, 16px));
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.25s ease, visibility 0.25s ease;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    .cook-mode-overlay.active {
      opacity: 1;
      visibility: visible;
    }

    .cook-topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      max-width: 800px;
      width: 100%;
      margin: 0 auto 14px;
      gap: 10px;
      flex-wrap: wrap;
    }

    .cook-topbar-left {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      flex: 1;
    }

    .cook-recipe-title {
      font-size: 14px;
      font-weight: 700;
      color: #fff;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 180px;
    }

    .cook-topbar-right {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
    }

    .cook-servings-counter {
      padding: 2px 6px;
    }
    .cook-servings-counter .servings-btn {
      width: 32px;
      height: 32px;
      font-size: 16px;
      border-radius: 6px;
    }
    .cook-servings-counter .servings-count {
      font-size: 0.95rem;
      min-width: 24px;
    }

    .wake-lock-status {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 600;
      background: rgba(16, 185, 129, 0.15);
      border: 1px solid rgba(16, 185, 129, 0.35);
      color: #34d399;
      white-space: nowrap;
      cursor: pointer;
      user-select: none;
      -webkit-user-select: none;
      font-family: inherit;
      line-height: 1;
      transition: all 0.2s ease;
    }
    .wake-lock-status:active {
      transform: scale(0.95);
    }
    .wake-lock-status.inactive {
      background: rgba(245, 158, 11, 0.15);
      border-color: rgba(245, 158, 11, 0.35);
      color: #fbbf24;
    }

    .cook-progress-bar {
      width: 100%;
      max-width: 800px;
      margin: 0 auto 16px;
      height: 6px;
      background: rgba(255, 255, 255, 0.1);
      border-radius: 999px;
      overflow: hidden;
    }
    .cook-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #f97316, #f59e0b);
      transition: width 0.3s ease;
    }

    .cook-card {
      max-width: 800px;
      width: 100%;
      margin: auto;
      background: #0d131f;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: var(--radius-lg);
      padding: 28px 24px;
      display: flex;
      flex-direction: column;
      gap: 20px;
      box-shadow: var(--shadow);
    }

    @media (max-width: 600px) {
      .cook-card {
        padding: 20px 16px;
        gap: 16px;
        border-radius: 16px;
      }
      .cook-instruction {
        font-size: 1.25rem !important;
      }
      .cook-topbar {
        gap: 8px;
      }
      #cookRecipeTitle {
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }

    .cook-step-title {
      font-size: 1rem;
      font-weight: 700;
      color: var(--accent);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .cook-instruction {
      font-size: clamp(1.2rem, 3.5vw, 1.5rem);
      font-weight: 600;
      line-height: 1.5;
      color: #fff;
    }

    .cook-mise-box {
      background: rgba(249, 115, 22, 0.08);
      border: 2px solid rgba(249, 115, 22, 0.3);
      border-radius: var(--radius-md);
      padding: 14px 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .cook-mise-title {
      font-size: 0.85rem;
      font-weight: 800;
      color: #fdba74;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .cook-mise-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: 8px;
    }
    @media (max-width: 480px) {
      .cook-mise-grid {
        grid-template-columns: 1fr;
      }
    }
    .cook-mise-item {
      background: rgba(0, 0, 0, 0.3);
      padding: 8px 12px;
      border-radius: 8px;
      font-size: 13.5px;
      color: #fff;
      display: flex;
      justify-content: space-between;
      border: 1px solid rgba(255, 255, 255, 0.08);
    }
    .cook-mise-item strong {
      color: #fed7aa;
    }

    .cook-controls {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-top: 10px;
    }

    .cook-nav-btn {
      flex: 1;
      padding: 14px 16px;
      min-height: 48px;
      font-size: 14.5px;
      font-weight: 700;
      border-radius: var(--radius-md);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: var(--transition);
      border: none;
      touch-action: manipulation;
    }

    /* Ingest Guide Modal */
    .ingest-box {
      background: rgba(255, 255, 255, 0.03);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 18px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      line-height: 1.6;
    }
    .prompt-bubble {
      background: #07090e;
      border: 1px solid rgba(249, 115, 22, 0.3);
      padding: 12px 16px;
      border-radius: var(--radius-sm);
      font-family: monospace;
      font-size: 13.5px;
      color: #fdba74;
      user-select: all;
      word-break: break-word;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    .prompt-bubble:hover {
      background: rgba(249, 115, 22, 0.08);
      border-color: rgba(249, 115, 22, 0.5);
      transform: translateY(-1px);
    }
    .prompt-bubble:active {
      transform: scale(0.99);
    }
    .copy-badge {
      font-size: 11px;
      font-weight: 700;
      color: var(--accent);
      background: rgba(249, 115, 22, 0.15);
      border: 1px solid rgba(249, 115, 22, 0.3);
      padding: 3px 8px;
      border-radius: 6px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      flex-shrink: 0;
      pointer-events: none;
    }

    /* ── AI INGEST MODAL STYLES ── */
    .ai-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 999px;
      background: rgba(249, 115, 22, 0.15);
      border: 1px solid rgba(249, 115, 22, 0.3);
      color: #fdba74;
      font-size: 11.5px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    .ai-input-group {
      display: flex;
      flex-direction: column;
      gap: 7px;
      margin-bottom: 14px;
    }

    .ai-label {
      font-size: 13px;
      font-weight: 600;
      color: #e2e8f0;
    }

    .ai-textarea {
      width: 100%;
      background: #090e17;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 12px 14px;
      color: #fff;
      font-size: 14px;
      line-height: 1.5;
      resize: vertical;
      min-height: 96px;
      box-sizing: border-box;
      font-family: inherit;
      transition: var(--transition);
    }
    .ai-textarea:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
    }

    .ai-input {
      width: 100%;
      background: #090e17;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 14px;
      color: #fff;
      font-size: 14px;
      line-height: 1.5;
      box-sizing: border-box;
      font-family: inherit;
      transition: var(--transition);
    }
    .ai-input:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
    }
    select.ai-input {
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 12px center;
      padding-right: 36px;
    }

    .ai-upload-row {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-bottom: 18px;
    }

    .ai-file-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 12px 16px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px dashed rgba(255, 255, 255, 0.22);
      border-radius: var(--radius-sm);
      color: #cbd5e1;
      font-size: 13.5px;
      font-weight: 500;
      cursor: pointer;
      transition: var(--transition);
      touch-action: manipulation;
    }
    .ai-file-button:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: var(--accent);
      color: #fff;
    }

    .ai-file-preview-wrap {
      display: flex;
      align-items: center;
      gap: 12px;
      background: #090e17;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 8px 12px;
    }

    .ai-file-preview-img {
      width: 44px;
      height: 44px;
      object-fit: cover;
      border-radius: 6px;
      background: #1e293b;
      flex-shrink: 0;
    }

    .ai-file-name {
      font-size: 13px;
      color: #e2e8f0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1;
    }

    .ai-file-remove-btn {
      background: rgba(255, 255, 255, 0.08);
      border: none;
      color: var(--text-muted);
      width: 28px;
      height: 28px;
      border-radius: 50%;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      transition: var(--transition);
      touch-action: manipulation;
    }
    .ai-file-remove-btn:hover {
      background: rgba(239, 68, 68, 0.25);
      color: #fca5a5;
    }

    .ai-actions-row {
      margin-top: 8px;
    }

    .ai-error-banner {
      background: rgba(239, 68, 68, 0.12);
      border: 1px solid rgba(239, 68, 68, 0.35);
      color: #fca5a5;
      border-radius: var(--radius-sm);
      padding: 10px 14px;
      font-size: 0.88rem;
      line-height: 1.45;
      margin-bottom: 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      animation: fadeIn 0.2s ease;
    }

    .ai-submit-btn {
      width: 100%;
      padding: 14px;
      font-size: 15.5px;
      font-weight: 700;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border-radius: var(--radius-md);
      box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
      cursor: pointer;
      touch-action: manipulation;
      transition: all 0.2s ease;
    }
    .ai-submit-btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
      box-shadow: none;
    }

    .ai-progress-box {
      background: rgba(249, 115, 22, 0.06);
      border: 1px solid rgba(249, 115, 22, 0.25);
      border-radius: var(--radius-md);
      padding: 24px 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      gap: 12px;
      margin: 8px 0 16px;
    }

    .ai-spinner {
      width: 36px;
      height: 36px;
      border: 3.5px solid rgba(249, 115, 22, 0.2);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: aiSpin 0.9s linear infinite;
    }
    @keyframes aiSpin {
      to { transform: rotate(360deg); }
    }

    .ai-progress-text {
      font-size: 15px;
      font-weight: 700;
      color: #fff;
    }

    .ai-progress-sub {
      font-size: 12.5px;
      color: var(--text-muted);
    }

    .ai-progress-bar-wrap {
      width: 100%;
      height: 6px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 999px;
      overflow: hidden;
      margin-top: 4px;
    }

    .ai-progress-bar-inner {
      height: 100%;
      width: 45%;
      background: linear-gradient(90deg, #f97316, #f59e0b);
      border-radius: 999px;
      transition: width 0.4s ease;
      animation: aiProgressPulse 1.8s ease-in-out infinite alternate;
    }
    @keyframes aiProgressPulse {
      0% { opacity: 0.8; }
      100% { opacity: 1; }
    }

    .ai-modal-footer {
      margin-top: 18px;
      padding-top: 16px;
      border-top: 1px solid var(--border);
    }

    .hero-no-image-cta {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      padding: 18px;
      text-align: center;
      transition: transform 0.2s ease, opacity 0.2s ease;
      z-index: 5;
      user-select: none;
      touch-action: manipulation;
    }
    .hero-no-image-cta:hover {
      transform: scale(1.04);
    }
    .hero-no-image-cta:active {
      transform: scale(0.97);
    }

    .prompt-preview-box {
      background: #07090e;
      border: 1px solid rgba(249, 115, 22, 0.25);
      border-radius: var(--radius-sm);
      padding: 12px 14px;
      font-family: inherit;
      font-size: 13px;
      line-height: 1.55;
      color: #fed7aa;
      max-height: 125px;
      overflow-y: auto;
      user-select: all;
      word-break: break-word;
    }

/* ── APP CONTAINER & STANDARDS (SWIFTWING UNIFIED) ── */
#app {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  padding: 0 16px calc(60px + env(safe-area-inset-bottom, 20px));
  gap: 16px;
}

@media (min-width: 768px) {
  #app {
    padding: 0 24px 60px;
    gap: 20px;
  }
}

/* ── TOPBAR (STANDARDIZED) ── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  width: 100%;
}

@media (min-width: 768px) {
  #topbar {
    padding: 24px 0 20px;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#topbar-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
  flex-shrink: 0;
}

#topbar-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.2);
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

@media (max-width: 440px) {
  .sync-badge span:last-child {
    display: none;
  }
  .sync-badge {
    padding: 8px;
  }
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2.5s infinite ease-in-out;
  flex-shrink: 0;
}

.btn-icon-nav {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  flex-shrink: 0;
  touch-action: manipulation;
}

.btn-icon-nav:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
