
  /* ─── SYSTEM COLOR TOKENS (Light & Dark adaptive) ─── */
  :root {
    --sys-bg:               #F2F2F7;
    --sys-bg2:              #FFFFFF;
    --sys-bg3:              #F2F2F7;
    --sys-separator:        rgba(60,60,67,0.18);
    --sys-shadow:           rgba(0,0,0,0.06);
    --sys-label:            rgba(0,0,0,0.85);
    --sys-label2:           rgba(60,60,67,0.6);
    --sys-plus:             rgba(60,60,67,0.28);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --sys-bg:             #1C1C1E;
      --sys-bg2:            #2C2C2E;
      --sys-bg3:            #3A3A3C;
      --sys-separator:      rgba(84,84,88,0.45);
      --sys-shadow:         rgba(0,0,0,0.35);
      --sys-label:          rgba(255,255,255,0.92);
      --sys-label2:         rgba(235,235,245,0.6);
      --sys-plus:           rgba(235,235,245,0.25);
    }
  }

  :root {
    --blue: #0284C7;
    --blue-light: #38BDF8;
    --teal: #0D9488;
    --teal-light: #2DD4BF;
    --bg: #0D1B2A;
    --card: #162535;
    --card2: #1E3248;
    --text: #E8F4FD;
    --text-muted: #7BAFD4;
    --text-accent: #E8F4FD;
    --border: rgba(56,189,248,0.15);
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --radius: 18px;
    --radius-sm: 10px;
    --header-glow: rgba(2,132,199,0.35);
    --modal-bg: #0D1B2A;
    --input-bg: #162535;
    --nav-bg: #162535;
    --cell-bg: rgba(56,189,248,0.07);
    --cell-border: rgba(56,189,248,0.18);
    --cell-glow: rgba(56,189,248,0.28);
    --cell-add: rgba(56,189,248,0.3);
    --card-tint: rgba(56,189,248,0.08);
    --card-border-tint: rgba(56,189,248,0.18);
    --bg-tint: rgba(56,189,248,0.04);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html, body { height: 100%; font-family: 'Nunito', sans-serif; background: var(--sys-bg); color: var(--text); overflow-x: hidden; touch-action: pan-x pan-y; }
  #app { min-height: 100vh; }
  #calendarPage, #statsPage, #profilePage { background: var(--sys-bg); }
  .stats-body, .profile-body { background: var(--sys-bg); }

  /* ─── LOGIN ─── */
  #loginScreen {
    min-height: 100vh;
    background: linear-gradient(145deg, #0C4A6E 0%, #0284C7 40%, #0D9488 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px 24px;
  }
  .login-logo { font-size: 52px; margin-bottom: 8px; }
  .login-title { font-size: 32px; font-weight: 900; color: #fff; letter-spacing: -1px; margin-bottom: 4px; }
  .login-sub { font-size: 15px; color: rgba(255,255,255,0.7); margin-bottom: 40px; }
  .login-card {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 24px;
    padding: 32px 28px;
    width: 100%; max-width: 360px;
  }
  .login-label { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.8); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; display: block; }
  .login-input {
    width: 100%; padding: 14px 18px; border-radius: 14px;
    border: 1.5px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.15); color: #fff;
    font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600;
    margin-bottom: 18px; outline: none; transition: border 0.2s;
  }
  .login-input::placeholder { color: rgba(255,255,255,0.45); }
  .login-input:focus { border-color: rgba(255,255,255,0.7); }
  .login-btn {
    width: 100%; padding: 15px; border-radius: 14px; border: none;
    background: #fff; color: var(--blue); font-family: 'Nunito', sans-serif;
    font-size: 16px; font-weight: 800; cursor: pointer; transition: transform 0.15s, opacity 0.15s;
    margin-bottom: 14px;
  }
  .login-btn:active { transform: scale(0.97); opacity: 0.9; }
  .login-divider { text-align: center; color: rgba(255,255,255,0.5); font-size: 13px; margin: 6px 0 14px; }
  .login-register-btn {
    width: 100%; padding: 14px; border-radius: 14px;
    border: 1.5px solid rgba(255,255,255,0.35);
    background: transparent; color: #fff; font-family: 'Nunito', sans-serif;
    font-size: 15px; font-weight: 700; cursor: pointer; transition: background 0.2s;
  }
  .login-register-btn:active { background: rgba(255,255,255,0.1); }
  .login-error { color: #FCA5A5; font-size: 13px; font-weight: 600; margin-top: -10px; margin-bottom: 12px; text-align: center; display: none; }

  /* ─── REGISTER ─── */
  #registerScreen {
    min-height: 100vh;
    background: linear-gradient(145deg, #0C4A6E 0%, #0284C7 40%, #0D9488 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px 24px; display: none;
  }
  .back-btn {
    background: rgba(255,255,255,0.15); border: none; border-radius: 50%;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 20px; align-self: flex-start; margin-bottom: 20px;
    color: #fff;
  }

  /* ─── APP ─── */
  #app { display: none; min-height: 100vh; flex-direction: column; }

  /* Header */
  .header {
    background: linear-gradient(135deg, #0C4A6E 0%, #0284C7 60%, #0D9488 100%);
    padding: 52px 20px 0;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 4px 20px var(--header-glow, rgba(2,132,199,0.3));
  }
  .header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
  .header-user { display: flex; align-items: center; gap: 10px; }
  .user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.5);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800; color: #fff;
  }
  .user-name { font-size: 15px; font-weight: 700; color: var(--text-accent); }
  .user-sub { font-size: 11px; color: var(--text-accent); opacity: 0.65; }
  .header-actions { display: flex; gap: 8px; }
  .icon-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,0.15); border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; color: var(--text-accent); transition: background 0.2s;
  }
  .icon-btn:active { background: rgba(255,255,255,0.3); }

  /* Month nav */
  .month-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 0 14px; }
  .month-title { font-size: 22px; font-weight: 900; color: var(--text-accent); letter-spacing: -0.5px; }
  @keyframes btnFlash {
    0%   { background: rgba(255,255,255,0.15); box-shadow: none; transform: scale(1); }
    25%  { background: rgba(255,255,255,0.65); box-shadow: 0 0 20px rgba(255,255,255,0.7); transform: scale(1.15); }
    100% { background: rgba(255,255,255,0.15); box-shadow: none; transform: scale(1); }
  }
  .month-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,0.15); border: none;
    color: var(--text-accent); font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .month-btn.flash { animation: btnFlash 0.32s ease-out forwards; }

  /* Weekday row */
  .weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
    padding: 8px 0 6px;
    background: rgba(0,0,0,0.50);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky; top: 0; z-index: 10;
    margin: 0 0 5px 0;
  }
  .weekday { text-align: center; font-size: 11px; font-weight: 800; color: var(--text-accent); opacity: 0.75; text-transform: uppercase; letter-spacing: 0.5px; padding-bottom: 8px; }

  /* Calendar */
  .calendar-wrap { padding: 10px; flex: 1; background: var(--sys-bg); }
  .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

  .day-cell {
    border-radius: 14px;
    height: 118px;
    background: var(--cell-bg);
    border: 1.5px solid var(--cell-border);
    display: flex; flex-direction: column;
    overflow: hidden; cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
  }
  .day-cell:active { transform: scale(0.95); }
  .day-cell.empty { background: transparent; border-color: transparent; cursor: default; pointer-events: none; }
  .day-cell.today { border-color: var(--blue); box-shadow: 0 0 0 2px var(--cell-glow); }

  /* Top strip: day number */
  .day-num {
    font-size: 11px; font-weight: 800;
    padding: 5px 6px 3px;
    color: var(--text);
    flex-shrink: 0; z-index: 2; position: relative;
  }
  .day-cell.today .day-num {
    color: #fff;
  }
  .today-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--blue); color: #fff;
    width: 20px; height: 20px; border-radius: 50%;
    font-size: 10px; font-weight: 900;
  }

  /* Colored meal area – bottom 80% */
  .day-meal-area {
    flex: 1; border-radius: 11px; margin: 0 4px 4px;
    overflow: hidden; display: flex; flex-direction: row;
    position: relative; align-items: stretch;
  }
  .day-meal-img {
    height: 100%; width: 50%; object-fit: cover; display: block;
    flex-shrink: 0;
  }
  .day-meal-name {
    font-size: 10.5px; font-weight: 900;
    color: #fff;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: normal;
    word-break: break-word;
    overflow: hidden;
    padding: 4px 3px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    flex: 1;
    line-height: 1.35;
    max-height: 100%;
    width: 100%;
  }
  .day-add-icon {
    flex: 1; display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: rgba(2,132,199,0.35); font-weight: 300;
  }

  /* Bottom Nav */
  .bottom-nav {
    display: flex;
    background: var(--nav-bg);
    border-top: 1px solid var(--cell-border);
    padding: 8px 0 max(10px, env(safe-area-inset-bottom));
    position: sticky; bottom: 0; z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.35);
  }
  .nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 8px 4px; cursor: pointer; border: none; background: none;
    color: var(--text-accent); opacity: 0.5; font-family: 'Nunito', sans-serif; font-size: 10px; font-weight: 700;
    transition: color 0.2s;
  }
  .nav-item.active { color: var(--text-accent); opacity: 1; }
  .nav-svg {
    width: 26px; height: 26px;
    stroke: var(--text-accent); opacity: 0.5;
    fill: none;
    transition: stroke 0.2s;
    flex-shrink: 0;
  }
  .nav-item .nav-icon-wrap {
    width: 52px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 99px;
    transition: background 0.25s;
  }
  .nav-item.active .nav-icon-wrap {
    background: var(--cell-bg);
  }
  .nav-item.active .nav-svg {
    stroke: var(--text-accent);
    opacity: 1;
  }

  /* ─── MODAL ─── */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.3s;
  }
  .modal-overlay.open { opacity: 1; pointer-events: all; }
  .modal {
    background: var(--sys-bg); border-radius: 28px 28px 0 0;
    width: 100%; max-width: 500px; max-height: 92vh;
    overflow-y: auto; padding: 0;
    transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  }
  .modal-overlay.open .modal { transform: translateY(0); }
  .modal-top {
    background: linear-gradient(135deg, #0C4A6E 0%, #0284C7 60%, #0D9488 100%);
    border-radius: 28px 28px 0 0;
    padding: 14px 20px 20px;
  }
  .modal-handle { width: 40px; height: 4px; background: rgba(255,255,255,0.35); border-radius: 99px; margin: 0 auto 14px; }
  .modal-header {
    display: flex; align-items: center; justify-content: space-between;
  }
  .modal-title { font-size: 20px; font-weight: 900; color: var(--text-accent); }
  .modal-date { font-size: 13px; color: var(--text-accent); opacity: 0.7; font-weight: 600; margin-top: 2px; }
  .modal-close {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.2); border: none;
    font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: #fff;
  }



  /* Form */
  .form-body { padding: 16px 16px 32px; }
  .form-label { font-size: 12px; font-weight: 800; color: var(--blue); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; display: block; }
  .form-input {
    width: 100%; padding: 13px 16px; border-radius: 14px;
    border: 1px solid var(--sys-separator); background: var(--sys-bg2);
    font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 600; color: var(--text);
    outline: none; transition: border 0.2s; margin-bottom: 16px;
    box-shadow: 0 1px 3px var(--sys-shadow);
  }
  .form-input:focus { border-color: var(--cell-glow, var(--blue)); box-shadow: 0 0 0 3px rgba(var(--cell-glow-rgb,56,189,248),0.15); }
  .form-textarea {
    width: 100%; padding: 13px 16px; border-radius: 14px;
    border: 1px solid var(--sys-separator); background: var(--sys-bg2);
    font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 600; color: var(--text);
    outline: none; resize: none; height: 90px; transition: border 0.2s; margin-bottom: 16px;
    box-shadow: 0 1px 3px var(--sys-shadow);
  }
  .form-textarea:focus { border-color: var(--cell-glow, var(--blue)); box-shadow: 0 0 0 3px rgba(var(--cell-glow-rgb,56,189,248),0.15); }

  /* Custom color picker */
  .color-picker-row {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  }
  .color-presets { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
  .color-dot {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    transition: transform 0.2s; border: 3px solid transparent; flex-shrink: 0;
  }
  .color-dot:active { transform: scale(1.2); }
  .color-dot.selected { border-color: #0C1A2E; transform: scale(1.2); box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0C1A2E; }
  .color-custom-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0;
  }
  .color-custom-label { font-size: 9px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
  .color-custom-input {
    width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--border);
    padding: 0; cursor: pointer; overflow: hidden; background: none;
  }
  .color-preview-bar {
    height: 10px; border-radius: 99px; margin-bottom: 16px;
    transition: background 0.2s;
  }

  /* Autocomplete */
  .autocomplete-wrap { position: relative; margin-bottom: 16px; }
  .autocomplete-wrap .form-input { margin-bottom: 0; }
  .autocomplete-list {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--card); border-radius: 14px; border: 1.5px solid var(--border);
    box-shadow: var(--shadow); z-index: 50; overflow: hidden; display: none;
  }
  .autocomplete-list.show { display: block; }
  .autocomplete-item {
    padding: 12px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 0.15s; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border);
  }
  .autocomplete-item:last-child { border-bottom: none; }
  .autocomplete-item:active { background: var(--bg); }
  .autocomplete-emoji { font-size: 18px; }

  /* Save btn */
  .save-btn {
    width: 100%; padding: 15px; border-radius: 16px; border: none;
    background: var(--btn-grad, linear-gradient(135deg, #38BDF8, #2DD4BF));
    color: #fff; font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 800;
    cursor: pointer; transition: opacity 0.2s, transform 0.15s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }
  .save-btn:active { opacity: 0.85; transform: scale(0.98); }
  .delete-btn {
    width: 100%; padding: 13px; border-radius: 16px; border: 1.5px solid #FCA5A5;
    background: rgba(239,68,68,0.1); color: #F87171; font-family: 'Nunito', sans-serif;
    font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 10px;
    transition: background 0.2s;
  }
  .delete-btn:active { background: #FEF2F2; }



  .theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
  .theme-swatch {
    height: 52px; border-radius: 14px; cursor: pointer;
    border: 2px solid transparent; transition: transform 0.2s, border-color 0.2s;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 800; color: rgba(255,255,255,0.85);
    letter-spacing: 0.3px;
  }
  .theme-swatch:active { transform: scale(0.95); }
  .theme-swatch.active { border-color: #fff; transform: scale(1.05); }


  /* ─── DATE PICKER ─── */
  .dp-year-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
  }
  .dp-year-label {
    font-size: 22px; font-weight: 900; color: var(--text-accent);
  }
  .dp-year-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--cell-bg); border: 1px solid var(--cell-border);
    color: var(--blue); font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
  }
  .dp-year-btn:active { background: var(--cell-border); }
  .dp-month-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  }
  .dp-month-btn {
    padding: 10px 4px; border-radius: 12px; border: 1px solid var(--cell-border);
    background: var(--cell-bg); color: var(--blue);
    font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 700;
    cursor: pointer; transition: background 0.2s, color 0.2s;
    text-align: center;
  }
  .dp-month-btn.current { background: var(--blue); color: #fff; border-color: transparent; }
  .dp-month-btn:active { opacity: 0.75; }


  /* ─── SHOPPING LIST ─── */
  #shopPage { display: none; flex-direction: column; min-height: 100vh; }
  .shop-header {
    background: linear-gradient(135deg, #0C4A6E 0%, #0284C7 60%, #0D9488 100%);
    padding: 52px 20px 24px;
  }
  /* applyTheme targets .shop-header via querySelectorAll */
  .shop-title { font-size: 26px; font-weight: 900; color: var(--text-accent); display: flex; align-items: center; gap: 12px; }
  .shop-sub { font-size: 13px; color: var(--text-accent); opacity: 0.7; margin-top: 4px; }
  .shop-body { padding: 16px; flex: 1; overflow-y: auto; }

  .shop-add-row {
    display: flex; gap: 10px; margin-bottom: 18px;
  }
  .shop-input {
    flex: 1; padding: 13px 16px; border-radius: 14px;
    border: 1px solid var(--sys-separator); background: var(--sys-bg2);
    font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 600;
    color: var(--text); outline: none;
    box-shadow: 0 1px 3px var(--sys-shadow);
  }
  .shop-input:focus { border-color: var(--blue); }
  .shop-add-btn {
    width: 48px; height: 48px; border-radius: 14px; border: none;
    background: var(--blue); color: #fff; font-size: 24px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity 0.2s;
    box-shadow: 0 4px 12px -2px var(--blue);
  }
  .shop-add-btn:active { opacity: 0.75; }

  .shop-list { display: flex; flex-direction: column; gap: 8px; }
  .shop-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-radius: 16px;
    background: var(--card-tint); border: 1px solid var(--card-border-tint);
    box-shadow: 0 0 0 1px var(--card-border-tint), 0 0 14px -4px var(--blue);
    transition: opacity 0.2s;
  }
  .shop-item.done { opacity: 0.45; }
  .shop-check {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--blue); background: transparent;
    flex-shrink: 0; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: background 0.2s; color: #fff; font-size: 13px;
  }
  .shop-item.done .shop-check { background: var(--blue); border-color: var(--blue); }
  .shop-item-text {
    flex: 1; font-size: 15px; font-weight: 700; color: var(--text);
    text-decoration: none;
  }
  .shop-item.done .shop-item-text { text-decoration: line-through; color: var(--text-muted); }
  .shop-delete {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: rgba(239,68,68,0.1); color: #F87171;
    font-size: 16px; cursor: pointer; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    transition: background 0.2s;
  }
  .shop-delete:active { background: rgba(239,68,68,0.25); }

  .shop-empty {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted); font-size: 15px; font-weight: 700;
  }
  .shop-empty-icon { font-size: 40px; margin-bottom: 12px; }

  .shop-sync-info {
    text-align: center; font-size: 11px; color: var(--text-muted);
    margin-top: 20px; opacity: 0.6;
  }



  /* ─── UNIFIED COLOR PICKER SLIDERS ─── */
  .color-adj-panel {
    margin-top: 14px; padding: 14px 12px; border-radius: 14px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    display: none;
  }
  .color-adj-panel.visible { display: block; }
  .slider-row { margin-bottom: 10px; }
  .slider-row:last-child { margin-bottom: 0; }
  .slider-label-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 5px;
  }
  .slider-label { font-size: 11px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
  .slider-val { font-size: 11px; font-weight: 900; color: var(--blue); }
  .color-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 5px; border-radius: 99px;
    background: rgba(255,255,255,0.15); outline: none;
    cursor: pointer;
  }
  .color-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--blue); border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(0,0,0,0.4); cursor: pointer;
  }
  .color-preview-bar-adj {
    height: 10px; border-radius: 99px; margin-top: 12px;
    transition: background 0.2s; border: 1px solid rgba(255,255,255,0.1);
  }


  /* ─── FARBPALETTE PICKER ─── */
  .cp-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
  }
  .cp-overlay.open { opacity: 1; pointer-events: all; }
  .cp-box {
    background: #1C1C1E; border-radius: 22px 22px 0 0;
    width: 100%; max-width: 500px; padding: 14px 16px 32px;
    transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
    max-height: 90vh; overflow-y: auto;
  }
  .cp-overlay.open .cp-box { transform: translateY(0); }
  .cp-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 99px; margin: 0 auto 14px; }
  .cp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .cp-title { font-size: 17px; font-weight: 900; color: #fff; }
  .cp-close { background: rgba(255,255,255,0.12); border: none; border-radius: 50%; width: 32px; height: 32px; color: rgba(255,255,255,0.7); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

  /* Color grid */
  .cp-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5px;
    border-radius: 14px; overflow: hidden;
    margin-bottom: 14px; cursor: crosshair;
    background: #2C2C2E;
  }
  .cp-cell {
    aspect-ratio: 1; cursor: pointer;
    transition: transform 0.12s;
  }
  .cp-cell:hover { transform: scale(1.15); z-index: 2; position: relative; border-radius: 2px; }
  .cp-cell:active { transform: scale(1.3); z-index: 1; position: relative; }

  /* Sliders */
  .cp-slider-section { margin-bottom: 12px; }
  .cp-slider-row { margin-bottom: 8px; }
  .cp-slider-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
  .cp-slider-label { font-size: 11px; font-weight: 800; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.5px; }
  .cp-slider-val { font-size: 11px; font-weight: 900; color: #fff; }
  .cp-range {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 5px; border-radius: 99px;
    outline: none; cursor: pointer;
  }
  .cp-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 2px solid rgba(0,0,0,0.3);
    box-shadow: 0 1px 6px rgba(0,0,0,0.5); cursor: pointer;
  }
  #cpBrightTrack { background: linear-gradient(to right, #000, #fff); }
  #cpOpacityTrack { background: repeating-conic-gradient(#808080 0% 25%, transparent 0% 50%) 0 0 / 10px 10px; }

  /* Preview + apply */
  .cp-bottom { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
  .cp-preview { width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.15); }
  .cp-hex { flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.06); color: #fff; font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 700; outline: none; letter-spacing: 1px; }
  .cp-apply { padding: 13px 20px; border-radius: 12px; border: none; background: #fff; color: #000; font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 900; cursor: pointer; white-space: nowrap; }


  /* ─── RECENT COLORS ─── */
  .cp-recent-row {
    display: flex; gap: 8px; margin-bottom: 14px; align-items: center;
  }
  .cp-recent-label {
    font-size: 10px; font-weight: 900; color: rgba(255,255,255,0.4);
    text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0;
    width: 44px;
  }
  .cp-recent-colors { display: flex; gap: 7px; flex-wrap: nowrap; overflow-x: auto; flex: 1; }
  .cp-recent-dot {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    cursor: pointer; border: 2px solid rgba(255,255,255,0.15);
    transition: transform 0.15s, border-color 0.15s;
  }
  .cp-recent-dot:active { transform: scale(1.2); border-color: rgba(255,255,255,0.6); }
  .cp-recent-empty {
    font-size: 11px; color: rgba(255,255,255,0.25); font-style: italic;
  }


  /* ─── COLOR PROFILES ─── */
  .color-profiles-section {
    margin: 0 16px 14px;
  }
  .color-profiles-title {
    font-size: 11px; font-weight: 900; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px;
    padding: 0 4px;
  }
  .color-profiles-list {
    display: flex; flex-direction: column; gap: 8px;
  }
  .color-profile-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: 14px;
    background: var(--card-tint); border: 1px solid var(--card-border-tint);
    box-shadow: 0 0 14px -4px var(--blue);
    cursor: pointer; transition: opacity 0.2s;
  }
  .color-profile-item.active-profile {
    border-color: var(--blue);
    box-shadow: 0 0 18px -4px var(--blue);
  }
  .color-profile-item:active { opacity: 0.75; }
  .color-profile-swatches {
    display: flex; gap: 4px; flex-shrink: 0;
  }
  .color-profile-dot {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
  }
  .color-profile-dot--empty {
    background: transparent !important;
    border: 1.5px dashed rgba(255,255,255,0.2);
  }
  .color-profile-name {
    flex: 1; font-size: 14px; font-weight: 800; color: var(--text);
  }
  .color-profile-active-badge {
    font-size: 10px; font-weight: 900; color: var(--blue);
    background: rgba(var(--blue-rgb,56,189,248),0.12);
    padding: 3px 8px; border-radius: 99px; display: none;
  }
  .color-profile-item.active-profile .color-profile-active-badge { display: block; }
  .color-profile-delete {
    width: 28px; height: 28px; border-radius: 50%; border: none;
    background: rgba(239,68,68,0.1); color: #F87171;
    font-size: 14px; cursor: pointer; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    transition: background 0.2s;
  }
  .color-profile-delete:active { background: rgba(239,68,68,0.25); }
  .color-profile-add {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px; border-radius: 14px;
    border: 2px dashed var(--cell-border);
    color: var(--blue); font-size: 13px; font-weight: 800;
    cursor: pointer; transition: background 0.2s;
    background: transparent;
  }
  .color-profile-add:active { background: var(--cell-bg); }

  /* Save profile modal */
  .save-profile-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
  }
  .save-profile-overlay.open { opacity: 1; pointer-events: all; }
  .save-profile-box {
    background: #1C1C1E; border-radius: 20px; padding: 24px 20px;
    width: calc(100% - 48px); max-width: 320px;
    border: 1px solid rgba(255,255,255,0.1);
  }
  .save-profile-title { font-size: 17px; font-weight: 900; color: #fff; margin-bottom: 16px; text-align: center; }
  .save-profile-input {
    width: 100%; padding: 13px 16px; border-radius: 12px; box-sizing: border-box;
    border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06);
    color: #fff; font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 700;
    outline: none; margin-bottom: 16px;
  }
  .save-profile-btns { display: flex; gap: 10px; }
  .save-profile-cancel {
    flex: 1; padding: 12px; border-radius: 12px; border: none;
    background: rgba(255,255,255,0.08); color: #fff;
    font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 800; cursor: pointer;
  }
  .save-profile-save {
    flex: 1; padding: 12px; border-radius: 12px; border: none;
    background: var(--blue); color: #fff;
    font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 900; cursor: pointer;
  }

  @keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
  }

  /* ─── BG COLOR PICKER ─── */
  .bg-swatch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
  .bg-swatch {
    height: 52px; border-radius: 12px; cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 6px;
    font-size: 9px; font-weight: 900; letter-spacing: 0.2px;
  }
  .bg-swatch:active { transform: scale(0.93); }
  .bg-swatch.active { border-color: var(--blue); box-shadow: 0 0 10px -2px var(--blue); transform: scale(1.04); }

  /* ─── NOTE INDICATOR ─── */
  .note-dot {
    position: absolute;
    top: 5px; right: 5px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--blue);
    opacity: 0.85;
    z-index: 3;
    flex-shrink: 0;
    box-shadow: 0 0 4px var(--blue);
  }

  /* ─── CONFIRM MODAL ─── */
  .confirm-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.65);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    opacity: 0; pointer-events: none; transition: opacity 0.25s;
  }
  .confirm-overlay.open { opacity: 1; pointer-events: all; }
  .confirm-box {
    background: var(--nav-bg); border-radius: 24px;
    padding: 28px 24px; width: 100%; max-width: 320px;
    text-align: center; border: 1px solid var(--cell-border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    transform: scale(0.9); transition: transform 0.25s;
  }
  .confirm-overlay.open .confirm-box { transform: scale(1); }
  .confirm-icon { font-size: 40px; margin-bottom: 12px; }
  .confirm-title { font-size: 20px; font-weight: 900; color: var(--text-accent); margin-bottom: 8px; }
  .confirm-sub { font-size: 13px; color: var(--text-muted); font-weight: 600; margin-bottom: 24px; line-height: 1.5; }
  .confirm-yes {
    width: 100%; padding: 14px; border-radius: 14px; border: none;
    background: rgba(239,68,68,0.2); color: #F87171;
    font-family: 'Nunito', sans-serif; font-size: 15px; font-weight: 800;
    cursor: pointer; margin-bottom: 10px; transition: background 0.2s;
  }
  .confirm-yes:active { background: rgba(239,68,68,0.35); }
  .confirm-no {
    width: 100%; padding: 13px; border-radius: 14px;
    border: 1.5px solid var(--border); background: transparent;
    color: var(--text-muted); font-family: 'Nunito', sans-serif;
    font-size: 15px; font-weight: 700; cursor: pointer; transition: background 0.2s;
  }
  .confirm-no:active { background: var(--card2, rgba(255,255,255,0.05)); }

  /* ─── STATS PAGE ─── */
  #statsPage { display: none; flex-direction: column; min-height: 100vh; }
  .stats-header {
    background: linear-gradient(135deg, #0C4A6E 0%, #0284C7 60%, #0D9488 100%);
    padding: 52px 20px 24px;
  }
  .stats-title { font-size: 26px; font-weight: 900; color: var(--text); }
  .stats-sub { font-size: 13px; color: var(--text-accent); opacity: 0.7; margin-top: 2px; }
  .stats-body { padding: 16px; flex: 1; }
  .stats-card {
    background: var(--card-tint); border-radius: 20px; padding: 20px;
    margin-bottom: 14px;
    border: 1px solid var(--card-border-tint);
    box-shadow: 0 0 0 1px var(--card-border-tint), 0 4px 24px rgba(0,0,0,0.15), 0 0 18px -4px var(--blue);
    transition: box-shadow 0.2s;
  }
  .stats-card-title { font-size: 13px; font-weight: 800; color: var(--text); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 12px; }
  .stat-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .stat-row:last-child { border-bottom: none; }
  .stat-meal { font-size: 15px; font-weight: 700; color: var(--text-accent); }
  .stat-count { font-size: 13px; font-weight: 800; color: var(--text); background: var(--bg); padding: 3px 10px; border-radius: 99px; }

  .stats-card:active { box-shadow: 0 0 0 1px var(--card-border-tint), 0 4px 24px rgba(0,0,0,0.2), 0 0 28px -2px var(--blue) !important; }
  .profile-card:active { box-shadow: 0 0 0 1px var(--card-border-tint), 0 4px 24px rgba(0,0,0,0.2), 0 0 28px -2px var(--blue) !important; }

  /* ─── PROFILE PAGE ─── */
  #profilePage { display: none; flex-direction: column; min-height: 100vh; }
  .profile-header {
    background: linear-gradient(135deg, #0C4A6E 0%, #0284C7 60%, #0D9488 100%);
    padding: 52px 20px 32px; text-align: center;
  }
  .profile-avatar-big {
    width: 80px; height: 80px; border-radius: 50%;
    background: rgba(255,255,255,0.2); border: 3px solid rgba(255,255,255,0.5);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 900; color: #fff; margin: 0 auto 12px;
  }
  .profile-name { font-size: 24px; font-weight: 900; color: var(--text-accent); }
  .profile-body { padding: 20px; }
  .profile-card { background: var(--card-tint); border-radius: 20px; overflow: hidden; border: 1px solid var(--card-border-tint); margin-bottom: 14px; box-shadow: 0 0 0 1px var(--card-border-tint), 0 4px 24px rgba(0,0,0,0.15), 0 0 18px -4px var(--blue); transition: box-shadow 0.2s; }
  .profile-item {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px; border-bottom: 1px solid var(--border); cursor: pointer;
  }
  .profile-item:last-child { border-bottom: none; }
  .profile-item-icon { font-size: 22px; width: 40px; text-align: center; }
  .profile-item-label { font-size: 15px; font-weight: 700; color: var(--text-accent); }
  .profile-item-arrow { margin-left: auto; color: var(--text-muted); font-size: 16px; }
  .logout-btn {
    width: 100%; padding: 15px; border-radius: 16px; border: none;
    background: rgba(239,68,68,0.1); color: #F87171; font-family: 'Nunito', sans-serif;
    font-size: 16px; font-weight: 800; cursor: pointer;
  }

  /* Toast */
  .toast {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--card); color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    padding: 12px 24px; border-radius: 99px;
    font-size: 14px; font-weight: 700; z-index: 999; opacity: 0;
    transition: opacity 0.3s, transform 0.3s; white-space: nowrap;
    backdrop-filter: blur(12px);
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 0; }

  /* ─── SHOP FOLDERS ─── */
  .shop-folder-bar {
    display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 4px;
    scrollbar-width: none; flex-shrink: 0;
  }
  .shop-folder-bar::-webkit-scrollbar { display: none; }
  .shop-folder-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 16px; border-radius: 20px; white-space: nowrap;
    font-size: 13px; font-weight: 800; border: 1.5px solid var(--border);
    background: transparent; cursor: pointer; transition: all 0.18s;
    flex-shrink: 0;
  }
  .shop-folder-tab.active {
    background: var(--blue); border-color: transparent;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  }
  .shop-folder-tab .folder-tab-edit {
    opacity: 0.55; font-size: 11px; padding: 1px 3px;
    border-radius: 5px; margin-left: 2px;
  }
  .shop-folder-tab:active { transform: scale(0.95); }
  .shop-folder-add {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    border: 1.5px dashed var(--border); background: transparent;
    color: var(--text-muted); font-size: 20px; font-weight: 300;
    cursor: pointer; flex-shrink: 0; transition: all 0.18s;
  }
  .shop-folder-add:active { transform: scale(0.9); }
  .folder-color-dot {
    width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; border: 2.5px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
    flex-shrink: 0;
  }
  .folder-color-dot.selected { border-color: var(--text); transform: scale(1.15); }
  .folder-color-dot:active { transform: scale(0.9); }