:root {
    --green-deep: #1a3a2a;
    --green-mid: #2d6a4f;
    --green-light: #52b788;
    --green-pale: #b7e4c7;
    --cream: #fefae0;
    --accent: #e9c46a;
    --text: #1e2d1f;
    --text-light: #4a6650;
    --radius: 16px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html, body { height: 100%; overflow: hidden; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f1f17;
    color: var(--text);
  }

  /* ── APP SHELL ── */
  #app { width: 100%; height: 100%; overflow: hidden; position: relative; }

  /* ── SCREENS ── */
  .screen {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s;
  }
  .screen.hidden { transform: translateX(100%); opacity: 0; pointer-events: none; }
  .screen.visible { transform: translateX(0); opacity: 1; }

  /* ── GALLERY SCREEN ── */
  #gallery-screen { background: #0f1f17; }

  .gallery-header {
    padding: 52px 20px 20px;
    background: linear-gradient(180deg, #0f1f17 60%, transparent);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .gallery-header h1 {
    font-size: 1.6em;
    color: white;
    font-weight: 700;
    letter-spacing: -0.5px;
  }
  .gallery-header p {
    color: rgba(255,255,255,0.55);
    font-size: 0.82em;
    margin-top: 3px;
  }
  .calgary-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(82,183,136,0.2);
    border: 1px solid rgba(82,183,136,0.4);
    color: var(--green-light);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.75em;
    margin-top: 8px;
    font-weight: 600;
  }

  /* ── PLANT GRID ── */
  .plant-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 12px 20px;
  }
  @media (min-width: 600px) { .plant-grid { grid-template-columns: repeat(3, 1fr); } }
  @media (min-width: 900px) { .plant-grid { grid-template-columns: repeat(4, 1fr); } }

  .plant-tile {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 3/4;
    cursor: pointer;
    background: #1a3a2a;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    transition: transform 0.18s, box-shadow 0.18s;
    -webkit-user-select: none;
    user-select: none;
  }
  .plant-tile:active { transform: scale(0.96); box-shadow: 0 2px 10px rgba(0,0,0,0.5); }
  .plant-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
  }
  .plant-tile-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.2) 45%, transparent 70%);
  }
  .plant-tile-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 10px 10px;
  }
  .plant-tile-name {
    color: white;
    font-size: 0.88em;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  }
  .plant-tile-sci {
    color: rgba(255,255,255,0.65);
    font-size: 0.68em;
    font-style: italic;
    margin-top: 2px;
  }
  .best-badge {
    position: absolute;
    top: 9px;
    right: 9px;
    background: var(--accent);
    color: #3d2a00;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.65em;
    font-weight: 800;
    letter-spacing: 0.3px;
  }

  /* ── BOTTOM TAB BAR ── */
  .tab-bar {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: rgba(15,31,23,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(82,183,136,0.15);
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 50;
  }
  .tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 4px 8px;
    cursor: pointer;
    border: none;
    background: none;
    color: rgba(255,255,255,0.4);
    font-size: 0.65em;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: color 0.2s;
  }
  .tab-btn.active { color: var(--green-light); }
  .tab-btn span { font-size: 1.5em; }

  /* bottom padding for tab bar */
  .gallery-bottom-pad { height: 80px; }

  /* ── DETAIL SCREEN ── */
  #detail-screen { background: #f4f9f1; }

  .detail-back-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(244,249,241,0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding-top: max(12px, env(safe-area-inset-top, 12px));
  }
  .back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--green-mid);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    -webkit-tap-highlight-color: transparent;
  }
  .back-btn svg { width: 20px; height: 20px; }
  .back-title {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--green-deep);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Nav arrows */
  .detail-nav-btns {
    display: flex;
    gap: 6px;
  }
  .detail-nav-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--green-mid);
    color: white;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1em;
    transition: background 0.15s;
  }
  .detail-nav-btn:active { background: var(--green-deep); }
  .detail-nav-btn:disabled { background: #ccc; cursor: default; }

  /* Detail hero photo */
  .detail-photo {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
  }
  @media (min-width: 600px) { .detail-photo { height: 380px; } }

  .detail-body { padding: 20px 18px 30px; max-width: 700px; margin: 0 auto; }

  .detail-name {
    font-size: 1.7em;
    color: var(--green-deep);
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: -0.5px;
  }
  .detail-scientific {
    color: var(--text-light);
    font-style: italic;
    font-size: 0.9em;
    margin-bottom: 14px;
  }
  .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
  .badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.2px;
  }
  .badge-easy { background: #d4edda; color: #155724; }
  .badge-med  { background: #fff3cd; color: #856404; }
  .badge-hard { background: #f8d7da; color: #721c24; }
  .badge-purifier { background: #d1ecf1; color: #0c5460; }
  .badge-petok  { background: #e8f5e9; color: #2e7d32; }
  .badge-toxic  { background: #fbe9e7; color: #bf360c; }

  /* Care grid */
  .care-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
  }
  .care-chip {
    background: white;
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }
  .care-chip-icon { font-size: 1.4em; }
  .care-chip-label { font-size: 0.6em; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin: 3px 0 2px; font-weight: 600; }
  .care-chip-val { font-size: 0.72em; font-weight: 700; color: var(--green-deep); line-height: 1.2; }

  /* Info cards */
  .info-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  }
  .info-card-title {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--green-mid);
    font-weight: 700;
    margin-bottom: 7px;
    display: flex; align-items: center; gap: 5px;
  }
  .info-card p {
    font-size: 0.9em;
    color: var(--text);
    line-height: 1.7;
  }

  /* Calgary tip */
  .calgary-card {
    background: linear-gradient(135deg, #e8f5ee, #f1f9f4);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--green-light);
  }
  .calgary-card-title {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--green-mid);
    font-weight: 700;
    margin-bottom: 7px;
    display: flex; align-items: center; gap: 5px;
  }
  .calgary-card p {
    font-size: 0.88em;
    color: var(--text);
    line-height: 1.7;
  }

  /* ── INFO SCREEN (Science + Calgary) ── */
  #info-screen { background: #f4f9f1; padding-bottom: 80px; }
  .info-header {
    background: linear-gradient(135deg, var(--green-deep), var(--green-mid));
    color: white;
    padding: 52px 20px 28px;
  }
  .info-header h2 { font-size: 1.5em; margin-bottom: 5px; }
  .info-header p { font-size: 0.88em; opacity: 0.75; }
  .info-section { padding: 20px 16px 10px; max-width: 700px; margin: 0 auto; }
  .info-section h3 {
    font-size: 1em;
    color: var(--green-deep);
    margin-bottom: 12px;
    font-weight: 700;
    display: flex; align-items: center; gap: 7px;
  }
  .stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-chip {
    background: white;
    border-radius: 14px;
    padding: 14px 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }
  .stat-chip .stat-icon { font-size: 1.8em; margin-bottom: 5px; }
  .stat-chip .stat-label { font-size: 0.7em; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
  .stat-chip .stat-val { font-size: 0.95em; font-weight: 700; color: var(--green-deep); margin-top: 3px; }

  .science-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-top: 4px solid var(--green-light);
  }
  .science-card h4 {
    font-size: 0.9em;
    color: var(--green-deep);
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
  }
  .science-card p, .science-card li {
    font-size: 0.86em;
    color: var(--text);
    line-height: 1.7;
  }
  .science-card ul { padding-left: 16px; }
  .science-card li { margin-bottom: 4px; }

  .formula-box {
    background: linear-gradient(135deg, var(--green-mid), var(--green-deep));
    color: white;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 12px;
    text-align: center;
  }
  .formula-box h4 { color: var(--green-pale); font-size: 0.9em; margin-bottom: 10px; }
  .formula-text {
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.82em;
    line-height: 2;
  }

  .zone-table-wrap { overflow-x: auto; margin-bottom: 12px; }
  table { width: 100%; border-collapse: collapse; font-size: 0.8em; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); min-width: 420px; }
  th { background: var(--green-mid); color: white; padding: 10px 12px; text-align: left; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.5px; }
  td { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; }
  tr:last-child td { border-bottom: none; }
  tr:nth-child(even) td { background: #f9fdf9; }
  .zone-highlight td { background: #fff9e0 !important; font-weight: bold; }

  /* ── TRANSITIONS ── */
  #gallery-screen { transition: transform 0.35s cubic-bezier(0.4,0,0.2,1); }

  .formula-explanation { opacity: 0.75; }
  .section-spacer { height: 20px; }

  .detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
  }
  .detail-action {
    flex: 1;
    padding: 13px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 700;
    cursor: pointer;
  }
  .detail-action-secondary {
    border: 2px solid var(--green-mid);
    background: white;
    color: var(--green-mid);
  }
  .detail-action-primary {
    border: none;
    background: var(--green-mid);
    color: white;
  }
