/* ── BLOCK 1 ── */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }
    input, textarea, [contenteditable] { user-select: text; -webkit-user-select: text; }
    img { -webkit-touch-callout: none; user-select: none; }

    :root {
      --orange: var(--brand-primary);
      --orange-dark: var(--brand-primary-dark);
      --text: #2d2d2d;
      --text-light: #6c757d;
      --bg: var(--brand-tint);
      --card-bg: #ffffff;
      --border: #ffe0b2;
    }

    html {
      background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
    }

    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.7;
    }

    /* ── HEADER ── */
    .header {
      background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
      color: white;
      text-align: center;
      padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 24px;
      position: relative;
      border-radius: 0 0 32px 32px;
      overflow: hidden;
    }
    .header-inner {
      max-width: 480px;
      margin: 0 auto;
    }

    .home-link-btn {
      color: white; text-decoration: none; background: rgba(255,255,255,0.2);
      padding: 8px 16px; border-radius: 20px; font-size: 0.9em; font-weight: 600;
      transition: background 0.2s;
    }
    @media (hover: hover) and (pointer: fine) { .home-link-btn:hover { background: rgba(255,255,255,0.35); } }

    .signin-btn {
      background: rgba(255,255,255,0.2);
      color: white;
      border: 2px solid rgba(255,255,255,0.5);
      padding: 8px 16px;
      border-radius: 8px;
      cursor: pointer;
      font-weight: 600;
      backdrop-filter: blur(10px);
      transition: all 0.3s ease;
    }
    @media (hover: hover) and (pointer: fine) { .signin-btn:hover { background: rgba(255,255,255,0.35); } }

    .logout-btn {
      background: rgba(255,255,255,0.2);
      color: white;
      border: 2px solid rgba(255,255,255,0.5);
      padding: 8px 16px;
      border-radius: 8px;
      cursor: pointer;
      font-weight: 600;
      backdrop-filter: blur(10px);
      transition: all 0.3s ease;
    }
    @media (hover: hover) and (pointer: fine) { .logout-btn:hover { background: rgba(255,255,255,0.35); } }

    .header img {
      height: 200px;
      border-radius: 20px;
      padding: 15px;
      margin-bottom: 15px;
      box-shadow: 0 10px 30px rgba(0,0,0,0.2);
      cursor: pointer;
    }

    .header h1 {
      font-size: 2.5em;
      margin-bottom: 8px;
      text-shadow: 0 2px 10px rgba(0,0,0,0.15);
    }

    .header .subtitle {
      font-size: 1.1em;
      opacity: 0.9;
      margin-bottom: 20px;
    }

    .helped-counter {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: rgba(255,255,255,0.2);
      border: 2px solid rgba(255,255,255,0.4);
      padding: 8px 14px 8px 20px;
      border-radius: 25px;
      font-weight: 600;
      font-size: 1em;
      backdrop-filter: blur(10px);
    }
    .helped-count-wrap {
      display: inline-block;
      overflow: hidden;
      vertical-align: middle;
      line-height: 1.3;
    }
    #helpedCount {
      display: inline-block;
    }
    @keyframes rollInUp {
      from { transform: translateY(70%); opacity: 0; }
      to   { transform: translateY(0);   opacity: 1; }
    }
    @keyframes rollInDown {
      from { transform: translateY(-70%); opacity: 0; }
      to   { transform: translateY(0);    opacity: 1; }
    }
    .helped-plus-btn {
      background: rgba(255,255,255,0.15);
      border: 2px solid rgba(255,255,255,0.4);
      color: rgba(255,255,255,0.85);
      border-radius: 20px;
      padding: 3px 11px;
      font-size: 0.85em;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
      line-height: 1.5;
      -webkit-tap-highlight-color: transparent;
    }
    .helped-plus-btn.voted {
      background: white;
      border-color: white;
      color: var(--brand-primary-dark);
      box-shadow: 0 0 14px rgba(255,255,255,0.45);
    }
    @keyframes votePop {
      0%   { transform: scale(1); }
      45%  { transform: scale(1.3); }
      100% { transform: scale(1); }
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    #helpedCountSpinner {
      display: inline-block;
      width: 14px;
      height: 14px;
      border: 2px solid rgba(255,255,255,0.35);
      border-top-color: white;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      vertical-align: middle;
      margin-right: 2px;
    }

    /* ── NAV ── */
    .sticky-nav {
      position: sticky;
      top: 0;
      padding-top: env(safe-area-inset-top, 0px);
      background: white;
      border-bottom: 2px solid var(--border);
      z-index: 100;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      will-change: transform;
    }

    /* Scrolling icon strip in the middle of the nav */
    .sticky-nav-row {
      display: flex;
      align-items: stretch;
      background: white;
      flex: 1;
      min-width: 0;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      white-space: nowrap;
      justify-content: flex-start;
    }
    .sticky-nav-row::-webkit-scrollbar { display: none; }
    @media (min-width: 900px) {
      .sticky-nav-row { justify-content: center; overflow-x: visible; }
    }
    .sticky-nav-inner {
      display: flex;
      align-items: stretch;
      background: white;
      width: 100%;
    }
    .sticky-nav-home {
      flex-shrink: 0;
      background: white;
      border-right: 1px solid var(--border);
    }
    .sticky-nav-home a {
      display: inline-flex;
      align-items: center;
      padding: 14px 18px;
      text-decoration: none;
      color: #495057;
      font-size: 0.82em;
      font-weight: 600;
      white-space: nowrap;
    }
    .sticky-nav-help {
      flex-shrink: 0;
      background: white;
      border-left: 1px solid var(--border);
    }
    .sticky-nav-help a {
      display: inline-flex;
      align-items: center;
      padding: 14px 18px;
      text-decoration: none;
      color: #495057;
      font-size: 0.82em;
      font-weight: 600;
      white-space: nowrap;
    }
    @media (hover: hover) and (pointer: fine) {
      .sticky-nav-home a:hover, .sticky-nav-help a:hover { color: var(--orange); }
    }

    .sticky-nav a {
      display: inline-flex;
      align-items: center;
      padding: 14px 18px;
      color: var(--text-light);
      text-decoration: none;
      font-size: 0.85em;
      font-weight: 600;
      transition: all 0.2s;
      border-bottom: 3px solid transparent;
      flex-shrink: 0;
    }

    .sticky-nav-row a:last-child {
    }

    @media (hover: hover) and (pointer: fine) {
      .sticky-nav a:hover {
        color: var(--orange);
        border-bottom-color: var(--orange);
      }
    }

    .sticky-nav a.active {
      color: var(--orange);
      border-bottom-color: var(--orange);
      background: var(--brand-tint);
    }

    /* ── LAYOUT ── */
    .container {
      max-width: 480px;
      margin: 0 auto;
      padding: 30px 20px 100px;
    }

    /* ── SECTION ── */
    .section {
      margin-bottom: 40px;
      scroll-margin-top: calc(60px + env(safe-area-inset-top, 0px));
    }

    /* ── SECTION COLLAPSE ── */
    .section-header {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 20px;
      padding-bottom: 12px;
      border-bottom: 3px solid var(--orange);
      cursor: pointer;
      user-select: none;
    }

    @media (hover: hover) and (pointer: fine) { .section-header:hover { opacity: 0.85; } }

    .section-header h2 {
      font-size: 1.6em;
      color: var(--text);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      flex: 1;
    }

    .section-chevron {
      font-size: 0.9em;
      color: var(--orange);
      transition: transform 0.3s;
    }

    .section.collapsed .section-chevron { transform: rotate(-90deg); }
    .section.collapsed .section-body { display: none; }

    .section-icon {
      font-size: 1.8em;
    }

    /* ── CARD ── */
    .card {
      background: var(--card-bg);
      border-radius: 16px;
      padding: 24px;
      margin-bottom: 16px;
      box-shadow: 0 2px 12px rgba(0,0,0,0.06);
      border: 1px solid var(--border);
      height: fit-content;
    }

    .card h3 {
      font-size: 1.15em;
      margin-bottom: 10px;
      color: var(--text);
    }

    .card p { color: var(--text-light); margin-bottom: 10px; }
    .card p:last-child { margin-bottom: 0; }

    /* ── MOOD SCALE ── */
    .mood-card {
      border-radius: 16px;
      padding: 20px 24px;
      margin-bottom: 12px;
      border-left: 6px solid;
    }

    .mood-card.manic     { background: #fff0f0; border-color: #ff4444; }
    .mood-card.hypomanic { background: var(--brand-secondary-tint); border-color: var(--brand-primary); }
    .mood-card.stable    { background: #f0fff4; border-color: #51cf66; }
    .mood-card.depressed { background: #f0f4ff; border-color: #5c7cfa; }
    .mood-card.crisis    { background: #f5f0ff; border-color: #845ef7; }

    .mood-card h3 { font-size: 1.1em; margin-bottom: 8px; }
    .mood-card p  { font-size: 0.95em; color: var(--text); margin-bottom: 8px; }

    .action-tag {
      display: inline-block;
      background: rgba(0,0,0,0.07);
      padding: 4px 12px;
      border-radius: 20px;
      font-size: 0.85em;
      font-weight: 600;
      margin-top: 4px;
    }

    /* ── ACCORDION ── */
    .accordion {
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
      margin-bottom: 12px;
    }

    .accordion-header {
      width: 100%;
      background: white;
      border: none;
      padding: 18px 20px;
      text-align: left;
      font-size: 1em;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      color: var(--text);
      transition: background 0.2s;
    }

    @media (hover: hover) and (pointer: fine) { .accordion-header:hover { background: var(--brand-tint); } }

    .accordion-header .chevron {
      font-size: 0.8em;
      transition: transform 0.3s;
      color: var(--orange);
    }

    .accordion-header.open .chevron { transform: rotate(180deg); }

    .accordion-body {
      display: none;
      padding: 0 20px 20px;
      background: white;
      color: var(--text-light);
      font-size: 0.95em;
    }

    .accordion-body.open { display: block; }
    .accordion-body ul { padding-left: 20px; margin-top: 8px; }
    .accordion-body li { margin-bottom: 6px; }

    /* ── LINKS ── */
    .link-btn {
      display: inline-block;
      padding: 10px 20px;
      background: var(--orange);
      color: white;
      border-radius: 8px;
      text-decoration: none;
      font-weight: 600;
      font-size: 0.9em;
      transition: all 0.2s;
      margin-top: 10px;
      margin-right: 8px;
    }

    .link-btn.secondary {
      background: white;
      color: var(--orange);
      border: 2px solid var(--orange);
    }

    @media (hover: hover) and (pointer: fine) {
      .link-btn:hover {
        background: var(--orange-dark);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255,149,0,0.3);
      }
      .link-btn.secondary:hover { background: var(--brand-tint); }
    }

    /* ── STEPS ── */
    .steps-card {
      background: white;
      border-radius: 16px;
      padding: 24px;
      border: 1px solid var(--border);
      margin-bottom: 12px;
    }

    .steps-card h3 {
      font-size: 1em;
      font-weight: 700;
      margin-bottom: 10px;
      color: var(--orange);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .steps-card ul { padding-left: 20px; }
    .steps-card li { margin-bottom: 8px; color: var(--text-light); }

    /* ── QUOTE ── */
    .quote-block {
      border-left: 4px solid var(--orange);
      padding: 16px 20px;
      background: white;
      border-radius: 0 12px 12px 0;
      margin: 20px 0;
      font-style: italic;
      color: var(--text-light);
    }

    .quote-block strong { color: var(--text); font-style: normal; }

    /* ── CRISIS BOX (RED) ── */
    .crisis-box {
      background: linear-gradient(135deg, #e53935, #c62828);
      color: white;
      border-radius: 16px;
      padding: 28px;
      text-align: center;
      margin-bottom: 20px;
    }

    .crisis-box h3 { font-size: 1.4em; margin-bottom: 12px; }
    .crisis-box p  { opacity: 0.95; margin-bottom: 16px; }

    .crisis-btn {
      display: inline-block;
      background: white;
      color: #c62828;
      padding: 12px 28px;
      border-radius: 10px;
      text-decoration: none;
      font-weight: 700;
      font-size: 1.1em;
      margin: 6px;
      transition: all 0.2s;
    }

    @media (hover: hover) and (pointer: fine) { .crisis-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.2); } }

    /* ── TWO-COL GRID ── */
    .two-col {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
    }

    /* ── THREE-COL GRID ── */
    .three-col {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 16px;
    }

    /* ── FOUR-COL GRID ── */
    .four-col {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 16px;
    }

    @media (max-width: 700px) {
      .three-col { grid-template-columns: 1fr; }
      .four-col  { grid-template-columns: 1fr 1fr; }
    }

    @media (max-width: 600px) {
      .two-col   { grid-template-columns: 1fr; }
      .four-col  { grid-template-columns: 1fr 1fr; }
      .header h1 { font-size: 1.4em; white-space: nowrap; }
    }

    /* Goals layout: mobile = stacked, desktop = wall-tracker left, goals+budget stacked right */
    .goals-desktop-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      align-items: start;
    }
    .goals-desktop-right {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }
    .goals-desktop-right .card { margin-bottom: 0; }
    @media (max-width: 640px) {
      .goals-desktop-grid {
        grid-template-columns: 1fr;
      }
    }

    /* ── STEPS TILES ── */
    @keyframes cycleBlue {
      0%, 100% { border-color: #4dabf7; box-shadow: 0 0 0 0 rgba(77,171,247,0.5); }
      50%       { border-color: #339af0; box-shadow: 0 0 0 7px rgba(77,171,247,0); }
    }
    @keyframes cycleGreen {
      0%, 100% { border-color: #51cf66; box-shadow: 0 0 0 0 rgba(81,207,102,0.5); }
      50%       { border-color: #2f9e44; box-shadow: 0 0 0 7px rgba(81,207,102,0); }
    }
    @keyframes cyclePurple {
      0%, 100% { border-color: #845ef7; box-shadow: 0 0 0 0 rgba(132,94,247,0.5); }
      50%       { border-color: #5f3dc4; box-shadow: 0 0 0 7px rgba(132,94,247,0); }
    }
    .steps-tile-blue   { border-color: #4dabf7 !important; animation: cycleBlue   2.4s ease-in-out infinite; }
    .steps-tile-green  { border-color: #51cf66 !important; animation: cycleGreen  2.4s ease-in-out infinite 0.8s; }
    .steps-tile-purple { border-color: #845ef7 !important; animation: cyclePurple 2.4s ease-in-out infinite 1.6s; }
    .steps-tile-blue .tile-num   { color: #339af0; }
    .steps-tile-green .tile-num  { color: #2f9e44; }
    .steps-tile-purple .tile-num { color: #5f3dc4; }

    .steps-tile {
      background: white;
      border: 2px solid var(--border);
      border-radius: 16px;
      padding: 24px 16px;
      text-align: center;
      cursor: pointer;
      transition: all 0.25s ease;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 10px;
      min-height: 120px;
    }

    @media (hover: hover) and (pointer: fine) {
      .steps-tile:hover { transform: translateY(-3px); }
      .steps-tile-blue:hover  { background: #e8f4ff; box-shadow: 0 6px 20px rgba(77,171,247,0.2); }
      .steps-tile-green:hover { background: #eafaf0; box-shadow: 0 6px 20px rgba(81,207,102,0.2); }
      .steps-tile-purple:hover{ background: #f3eeff; box-shadow: 0 6px 20px rgba(132,94,247,0.2); }
    }

    .steps-tile .tile-num {
      font-size: 1.6em;
      font-weight: 800;
      color: var(--orange);
    }

    .steps-tile .tile-label {
      font-size: 0.9em;
      font-weight: 600;
      color: var(--text);
      line-height: 1.3;
    }

    /* ── STEPS POPUP MODAL ── */
    .steps-modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.5);
      z-index: 1000;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      padding: 20px;
    }

    .steps-modal.active { display: flex; }

    .steps-modal-content {
      background: white;
      border-radius: 20px;
      max-width: 500px;
      width: 100%;
      max-height: 85dvh;
      overflow-y: auto;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
      animation: popIn 0.2s ease;
    }

    @keyframes popIn {
      from { transform: scale(0.9); opacity: 0; }
      to   { transform: scale(1);   opacity: 1; }
    }

    .steps-modal-header {
      background: linear-gradient(135deg, var(--orange), var(--orange-dark));
      color: white;
      padding: 20px 24px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .steps-modal-header h3 { font-size: 1.1em; }

    .steps-modal-close {
      background: rgba(255,255,255,0.2);
      border: none;
      color: white;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      font-size: 1.1em;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .steps-modal-body {
      padding: 24px;
    }

    .steps-modal-body ul { padding-left: 20px; }
    .steps-modal-body li { margin-bottom: 10px; color: var(--text-light); line-height: 1.6; }

    /* ── MOOD ICON BUTTONS ── */
    .mood-icon-grid {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 10px;
      margin-bottom: 16px;
      max-width: 500px;
      margin-left: auto;
      margin-right: auto;
    }

    .mood-icon-btn {
      background: #f8f9fa;
      border: 3px solid transparent;
      border-radius: 14px;
      padding: 14px 8px;
      text-align: center;
      cursor: pointer;
      transition: all 0.25s ease;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
    }

    .mood-icon-btn .emoji { font-size: 1.8em; }
    .mood-icon-btn .label { font-size: 0.7em; font-weight: 700; color: #495057; }

    .mood-icon-btn.selected, .mood-icon-btn.active-mood {
      transform: translateY(-3px);
      box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    }
    @media (hover: hover) and (pointer: fine) {
      .mood-icon-btn:hover {
        transform: translateY(-3px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
      }
    }

    .mood-icon-btn.manic.selected,    .mood-icon-btn.manic.active-mood    { border-color: #ff4444; background: #fff0f0; }
    .mood-icon-btn.hypomanic.selected,.mood-icon-btn.hypomanic.active-mood { border-color: var(--brand-primary); background: var(--brand-secondary-tint); }
    .mood-icon-btn.stable.selected,   .mood-icon-btn.stable.active-mood   { border-color: #51cf66; background: #f0fff4; }
    .mood-icon-btn.neutral.selected,  .mood-icon-btn.neutral.active-mood  { border-color: #74c0fc; background: #f0f8ff; }
    .mood-icon-btn.low.selected,      .mood-icon-btn.low.active-mood      { border-color: #845ef7; background: #f5f0ff; }
    .mood-icon-btn.depressed.selected,.mood-icon-btn.depressed.active-mood { border-color: #5c7cfa; background: #f0f4ff; }
    @media (hover: hover) and (pointer: fine) {
      .mood-icon-btn.manic:hover     { border-color: #ff4444; background: #fff0f0; }
      .mood-icon-btn.hypomanic:hover { border-color: var(--brand-primary); background: var(--brand-secondary-tint); }
      .mood-icon-btn.stable:hover    { border-color: #51cf66; background: #f0fff4; }
      .mood-icon-btn.neutral:hover   { border-color: #74c0fc; background: #f0f8ff; }
      .mood-icon-btn.low:hover       { border-color: #845ef7; background: #f5f0ff; }
      .mood-icon-btn.depressed:hover { border-color: #5c7cfa; background: #f0f4ff; }
    }

    .mood-detail-panel {
      border-radius: 14px;
      padding: 20px;
      display: none;
      animation: fadeSlideIn 0.2s ease;
    }

    .mood-detail-panel.visible { display: block; }

    @keyframes fadeSlideIn {
      from { opacity: 0; transform: translateY(8px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .mood-detail-panel.manic     { background: #fff0f0; border: 2px solid #ff4444; }
    .mood-detail-panel.hypomanic { background: var(--brand-secondary-tint); border: 2px solid var(--brand-primary); }
    .mood-detail-panel.stable    { background: #f0fff4; border: 2px solid #51cf66; }
    .mood-detail-panel.neutral   { background: #f0f8ff; border: 2px solid #74c0fc; }
    .mood-detail-panel.low       { background: #f5f0ff; border: 2px solid #845ef7; }
    .mood-detail-panel.depressed { background: #f0f4ff; border: 2px solid #5c7cfa; }

    .mood-detail-panel h3 { margin-bottom: 8px; font-size: 1.05em; }
    .mood-detail-panel p  { font-size: 0.92em; color: var(--text); margin-bottom: 8px; }

    @media (max-width: 500px) {
      .mood-icon-grid { grid-template-columns: repeat(5, 1fr); max-width: 100%; gap: 5px; }
      .mood-icon-btn { padding: 8px 4px; border-radius: 10px; border-width: 2px; }
      .mood-icon-btn .emoji img { width: 28px !important; height: 28px !important; }
      .mood-icon-btn .label { font-size: 0.6em; }
    }

    /* ── FOOTER ── */
    .footer {
      text-align: center;
      padding: 40px 20px;
      color: var(--text-light);
      font-size: 0.9em;
      border-top: 2px solid var(--border);
      margin-top: 20px;
    }

    .footer a { color: var(--orange); text-decoration: none; }

    /* ── MEDIA PILL ── */
    .pill {
      display: inline-block;
      background: #fff3e0;
      border: 1px solid var(--border);
      border-radius: 20px;
      padding: 6px 14px;
      font-size: 0.85em;
      font-weight: 600;
      color: var(--orange-dark);
      margin: 4px;
    }

    /* ── Prevent double-tap zoom on iOS ── */
    .footer-link {
      display: inline-block;
      font-size: 0.9em;
      color: var(--text-light);
      text-decoration: none;
      padding: 6px 14px;
      background: rgba(255,255,255,0.85);
      border-radius: 20px;
      border: 1px solid var(--border);
      white-space: nowrap;
    }
    * { touch-action: manipulation; }
    /* Prevent iOS Safari auto-zoom on input focus (triggered when font-size < 16px) */
    input, select, textarea { font-size: 16px; }
/* Force light mode — prevent OS dark mode from affecting colours */
    :root { color-scheme: light; }
    html { background-color: var(--brand-primary-dark); }

    /* ── Auth / Settings Modal ── */
    .overlay-modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.55);
      z-index: 1000;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      padding: 20px;
    }
    .overlay-modal.active { display: flex; }
    .modal-box {
      background: white;
      border-radius: 20px;
      padding: 28px;
      max-width: 400px;
      width: 100%;
      max-height: 85dvh;
      overflow-y: auto;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
    .modal-box h3 { margin-bottom: 18px; font-size: 1.3em; color: #2d2d2d; }
    .modal-input {
      width: 100%;
      padding: 12px 14px;
      border: 2px solid #e9ecef;
      border-radius: 10px;
      font-size: 1em;
      margin-bottom: 12px;
      box-sizing: border-box;
      color: #2d2d2d;
    }
    .modal-input:focus { outline: none; border-color: var(--brand-primary); }
    .modal-btn {
      width: 100%;
      padding: 13px;
      border: none;
      border-radius: 10px;
      font-size: 1em;
      font-weight: 600;
      cursor: pointer;
      margin-bottom: 10px;
      transition: all 0.2s;
    }
    .modal-btn-primary { background: var(--brand-primary); color: white; }
    .modal-btn-secondary { background: #f8f9fa; color: #495057; border: 2px solid #e9ecef; }
    @media (hover: hover) and (pointer: fine) {
      .modal-btn-primary:hover { background: var(--brand-primary-dark); }
      .modal-btn-secondary:hover { background: #e9ecef; }
    }
    /* Quick-add chips inside the My Medications modal — tapping a chip
       fills the name input so the user only has to type the dosage. */
    .med-chip-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      justify-content: center;
      margin-bottom: 12px;
    }
    .med-chip {
      padding: 6px 12px;
      background: var(--brand-tint);
      color: var(--brand-primary-dark);
      border: 1.5px solid var(--brand-primary);
      border-radius: 16px;
      font-size: 0.82em;
      font-weight: 600;
      cursor: pointer;
      font-family: inherit;
      -webkit-tap-highlight-color: transparent;
      transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    }
    .med-chip:active { transform: scale(0.96); }
    @media (hover: hover) and (pointer: fine) {
      .med-chip:hover { background: var(--brand-primary); color: white; }
    }
    .modal-toggle { text-align: center; font-size: 0.9em; color: #6c757d; margin-top: 4px; }
    .modal-toggle span { color: var(--brand-primary); cursor: pointer; font-weight: 600; }
    .modal-error { color: #ff6b6b; font-size: 0.9em; margin-bottom: 10px; display: none; }
    @keyframes hintFade { 0%,100%{opacity:0.55;transform:translateY(0)} 50%{opacity:1;transform:translateY(-4px)} }
    @keyframes bbHintNudge { 0%,100%{transform:scale(1)} 25%{transform:scale(1.18) rotate(-4deg)} 75%{transform:scale(1.12) rotate(3deg)} }

    /* ─── iPad simulator (≥ 920px) ─── */
    @media (min-width: 920px) {
      body {
        background: #eaeaea !important;
        padding: 0 !important;
        min-height: 100dvh;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        overflow: auto;
      }
      #iphone-frame {
        width: 768px;
        height: min(1024px, 96dvh);
        background: linear-gradient(160deg, #2a2a2a 0%, #111 60%, #1a1a1a 100%);
        border-radius: 40px;
        padding: 20px 16px 28px;
        position: relative;
        flex-shrink: 0;
        margin: 20px 0;
        box-shadow:
          inset 0 0 0 1px rgba(255,255,255,0.12),
          inset 0 0 0 3px #000,
          0 40px 120px rgba(0,0,0,0.95),
          0 8px 40px rgba(0,0,0,0.7);
      }
      #iphone-frame::before {
        content: '';
        position: absolute;
        left: -4px; top: 200px;
        width: 4px; height: 36px;
        background: #2a2a2a;
        border-radius: 2px 0 0 2px;
        box-shadow: 0 60px 0 #2a2a2a;
        pointer-events: none;
      }
      #iphone-frame::after {
        content: '';
        position: absolute;
        right: -4px; top: 260px;
        width: 4px; height: 80px;
        background: #2a2a2a;
        border-radius: 0 2px 2px 0;
        pointer-events: none;
      }
      #iphone-frame .dynamic-island {
        position: absolute;
        top: 12px; left: 50%;
        transform: translateX(-50%);
        width: 12px; height: 12px;
        background: #000;
        border-radius: 50%;
        z-index: 9999;
        pointer-events: none;
      }
      #iphone-frame .home-indicator {
        position: absolute;
        bottom: 8px; left: 50%;
        transform: translateX(-50%);
        width: 220px; height: 5px;
        background: rgba(255,255,255,0.28);
        border-radius: 3px;
        z-index: 9999;
        pointer-events: none;
      }
      #app-shell {
        width: 100%;
        height: 100%;
        border-radius: 30px;
        background: #FFFBF5;
        transform: translateZ(0);
      }
      #scroll-view {
        overflow: hidden;
        overflow-y: auto;
        height: 100%;
        border-radius: 30px;
        scrollbar-width: none;
        box-sizing: border-box;
      }
      #scroll-view::-webkit-scrollbar { display: none; }
    }
    @media (min-width: 920px) and (prefers-color-scheme: dark) {
      body { background: #111 !important; }
    }
