
    :root {
      --navy:    #0d1b2a;
      --navy2:   #162032;
      --navy3:   #1e2d42;
      --navy4:   #243650;
      --gold:    #f5a623;
      --gold2:   #ffc55a;
      --gold3:   rgba(245,166,35,0.12);
      --cream:   #ede0cc;
      --muted:   #7a9abf;
      --green:   #4caf7d;
      --red:     #e05c5c;
      --radius:  10px;
      --tr:      0.18s ease;

      /* Typography & layout */
      --font-ui:    'Segoe UI', system-ui, sans-serif;
      --font-deva:  'Noto Serif Devanagari', 'Tiro Devanagari Sanskrit', serif;
      --font-serif: 'Noto Serif', Georgia, serif;   /* Latin w/ full IAST diacritics */
      --translit:   #b9cfe7;                         /* brighter than --muted for readability */
      --content-max: 1020px;                         /* reading-column cap */
    }
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: var(--font-ui);
      background: var(--navy);
      color: var(--cream);
      height: 100dvh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    /* ── Header ── */
    header {
      background: var(--navy2);
      border-bottom: 1px solid var(--navy3);
      box-shadow: 0 1px 0 rgba(245,166,35,.16);   /* faint gold hairline */
      padding: 0 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      flex-shrink: 0;
      height: 56px;
    }
    .header-brand { display: flex; align-items: center; gap: 12px; cursor: pointer; border-radius: 8px; transition: opacity var(--tr); }
    .header-brand .brand-logo { width: 36px; height: 36px; flex-shrink: 0; }
    .header-brand:hover { opacity: .8; }
    .header-brand:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
    .header-brand h1 { font-size: 1.1rem; font-weight: 700; color: var(--gold); letter-spacing: .03em; white-space: nowrap; }
    .header-brand p  { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
    .header-right { display: flex; align-items: center; gap: 14px; }

    /* Nav tabs */
    .nav-tabs { display: flex; gap: 4px; }
    .nav-tab {
      padding: 6px 16px;
      border-radius: 20px;
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid transparent;
      color: var(--muted);
      background: transparent;
      transition: all var(--tr);
    }
    .nav-tab:hover { color: var(--cream); }
    .nav-tab.active { background: var(--gold3); border-color: var(--gold); color: var(--gold); }

    /* API status */
    .api-status { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--muted); }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #444; transition: background var(--tr); }
    .status-dot.ok  { background: var(--green); box-shadow: 0 0 5px var(--green); }
    .status-dot.err { background: var(--red);   box-shadow: 0 0 5px var(--red); }

    /* ── Views ── */
    #app { flex: 1; overflow: hidden; position: relative; }
    .view {
      position: absolute; inset: 0;
      overflow-y: auto;
      padding: 24px 20px 48px;   /* extra bottom space so the last row clears the footer */
      display: none;
    }
    .view.active { display: block; }
    /* Cap the reading column — verse rows were stretching the full screen width,
       stranding the star button far from the text. */
    .view > * {
      width: 100%;
      max-width: var(--content-max);
      margin-left: auto;
      margin-right: auto;
    }
    .view::-webkit-scrollbar { width: 4px; }
    .view::-webkit-scrollbar-track { background: transparent; }
    .view::-webkit-scrollbar-thumb { background: var(--navy3); border-radius: 4px; }

    /* ── View header (breadcrumb bar) ── */
    .view-bar {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 18px;
      flex-wrap: wrap;
    }
    .btn-back {
      display: inline-flex; align-items: center; gap: 5px;
      background: var(--navy3); border: 1px solid var(--navy4);
      color: var(--muted); padding: 6px 14px;
      border-radius: 20px; font-size: 0.8rem; cursor: pointer;
      transition: color var(--tr), border-color var(--tr);
    }
    .btn-back:hover { color: var(--cream); border-color: var(--muted); }
    .breadcrumb { font-size: 0.85rem; color: var(--muted); }
    .breadcrumb strong { color: var(--gold); }
    .breadcrumb .bc-hi { font-family: var(--font-deva); color: var(--gold2); }

    /* ── Chapters grid ── */
    .chapters-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
      gap: 12px;
    }
    .chapter-card {
      background: var(--navy2);
      border: 1px solid var(--navy3);
      border-radius: var(--radius);
      padding: 16px 18px;
      cursor: pointer;
      transition: border-color var(--tr), transform var(--tr);
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .chapter-card:hover { border-color: var(--gold); transform: translateY(-2px); }
    .scripture-card.disabled { cursor: not-allowed; opacity: .45; }
    .scripture-card.disabled:hover { border-color: var(--navy3); transform: none; }
    .ch-num    { font-size: 0.68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
    .ch-hi     { font-family: var(--font-deva); font-size: 1.15rem; color: var(--gold2); line-height: 1.5; margin-top: 2px; }
    .ch-en     { font-size: 0.8rem; color: var(--muted); }
    .ch-count  { font-size: 0.72rem; color: var(--navy4); background: var(--navy3); padding: 2px 8px; border-radius: 20px; align-self: flex-start; margin-top: 8px; color: var(--muted); }

    /* ── Verse list ── */
    .verse-list { display: flex; flex-direction: column; gap: 8px; }
    .verse-row {
      background: var(--navy2);
      border: 1px solid var(--navy3);
      border-radius: var(--radius);
      padding: 13px 16px;
      display: flex;
      align-items: flex-start;
      gap: 14px;
      cursor: pointer;
      transition: border-color var(--tr), background var(--tr);
    }
    .verse-row:hover { border-color: var(--gold); background: var(--navy3); }
    .verse-row:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
    .verse-row.is-fav { border-left: 3px solid var(--gold); }
    .vrow-badge {
      background: var(--gold3);
      border: 1px solid rgba(245,166,35,.3);
      color: var(--gold);
      font-size: 0.7rem;
      font-weight: 700;
      padding: 3px 9px;
      border-radius: 20px;
      white-space: nowrap;
      flex-shrink: 0;
      margin-top: 4px;
    }
    .vrow-body { flex: 1; min-width: 0; }
    .vrow-speaker { font-family: var(--font-deva); font-size: 0.74rem; color: var(--muted); line-height: 1.4; margin-bottom: 1px; }
    .vrow-slok { font-family: var(--font-deva); font-size: 1.02rem; color: var(--gold2); line-height: 1.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .vrow-trans { font-family: var(--font-serif); font-size: 0.78rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .vrow-fav-btn {
      background: transparent; border: none; cursor: pointer;
      font-size: 1.15rem; color: var(--muted); flex-shrink: 0;
      padding: 2px 6px; transition: color var(--tr), transform var(--tr);
    }
    .vrow-fav-btn:hover { color: var(--gold); transform: scale(1.15); }
    .vrow-fav-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
    .vrow-fav-btn.active { color: var(--gold); }

    /* ── Verse detail ── */
    .verse-detail { max-width: 820px; margin: 0 auto; }
    .vd-header {
      display: flex; align-items: flex-start;
      justify-content: space-between; gap: 14px;
      margin-bottom: 20px; flex-wrap: wrap;
    }
    .vd-meta {}
    .vd-badge { font-size: 0.72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }
    .vd-chapter-name { font-size: 0.82rem; color: var(--muted); }
    .vd-fav-btn {
      display: flex; align-items: center; gap: 6px;
      padding: 8px 18px; border-radius: 20px;
      font-size: 0.82rem; font-weight: 600; cursor: pointer;
      border: 1px solid var(--navy3); background: var(--navy2);
      color: var(--muted); transition: all var(--tr); white-space: nowrap;
    }
    .vd-fav-btn:hover { border-color: var(--gold); color: var(--gold); }
    .vd-fav-btn.active { background: var(--gold3); border-color: var(--gold); color: var(--gold); }

    /* Sanskrit block */
    .vd-slok {
      background: var(--navy2); border: 1px solid var(--navy3);
      border-radius: var(--radius); padding: 22px 24px;
      margin-bottom: 16px;
    }
    .vd-slok-text  { font-family: var(--font-deva); font-size: 1.35rem; color: var(--gold2); line-height: 2; white-space: pre-line; }
    .vd-translit   { font-family: var(--font-serif); font-size: 0.95rem; color: var(--translit); margin-top: 12px; line-height: 1.8; white-space: pre-line; }
    .vd-vedabase   { font-size: 0.75rem; color: var(--muted); margin-top: 10px; display: inline-block; text-decoration: none; transition: color var(--tr); }
    .upanishad-hindi-block { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 18px 24px; margin-bottom: 14px; }
    .upanishad-hindi-block .content-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
    .upanishad-hindi-block .content-text  { font-size: 0.92rem; line-height: 2; color: var(--cream); }
    .vrow-trans.hindi { font-family: var(--font-deva); font-size: 0.82rem; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .vd-vedabase:hover { color: var(--gold); }

    /* Author tabs */
    .author-tabs {
      display: flex; gap: 6px; flex-wrap: wrap;
      margin-bottom: 16px;
    }
    .author-tab {
      padding: 7px 16px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
      cursor: pointer; border: 1px solid var(--navy3);
      background: var(--navy2); color: var(--muted);
      transition: all var(--tr);
    }
    .author-tab:hover { border-color: var(--muted); color: var(--cream); }
    .author-tab.active { background: var(--gold3); border-color: var(--gold); color: var(--gold); }
    .author-tab .lang-badge {
      font-size: 0.62rem; padding: 1px 5px; border-radius: 4px;
      background: var(--navy3); margin-left: 5px; vertical-align: middle;
    }

    /* Author content */
    .author-content {
      background: var(--navy2); border: 1px solid var(--navy3);
      border-radius: var(--radius); padding: 20px;
    }
    .author-name { font-size: 0.72rem; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
    .content-block { margin-bottom: 18px; }
    .content-block:last-child { margin-bottom: 0; }
    .content-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
    .content-text  { font-size: 0.9rem; line-height: 1.85; color: var(--cream); }
    .content-text.hindi { font-family: var(--font-deva); font-size: 0.98rem; }

    /* Note on verse detail */
    .vd-note-section { margin-top: 16px; background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 16px 20px; }
    .vd-note-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
    .vd-note-display { font-size: 0.85rem; color: var(--muted); font-style: italic; }
    .vd-note-display.has-note { color: var(--cream); font-style: normal; }
    .note-editor { display: none; flex-direction: column; gap: 8px; margin-top: 8px; }
    .note-editor.open { display: flex; }
    .note-editor textarea {
      background: var(--navy); border: 1px solid var(--navy3);
      border-radius: 8px; color: var(--cream); padding: 10px;
      font-size: 0.85rem; resize: vertical; min-height: 70px; font-family: inherit;
    }
    .note-editor textarea:focus { outline: none; border-color: var(--gold); }
    .note-editor-btns { display: flex; gap: 8px; }
    .vd-note-actions { display: flex; gap: 8px; margin-top: 10px; }

    /* ── Favorites toolbar ── */
    .fav-toolbar {
      background: var(--navy2);
      border: 1px solid var(--navy3);
      border-radius: var(--radius);
      padding: 14px 18px;
      margin-bottom: 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .ftb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .ftb-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; min-width: 52px; }
    .ftb-pills { display: flex; gap: 6px; flex-wrap: wrap; }
    .ftb-pill {
      padding: 5px 13px; border-radius: 20px; font-size: 0.76rem; font-weight: 600;
      cursor: pointer; border: 1px solid var(--navy3);
      background: var(--navy); color: var(--muted);
      transition: all var(--tr);
    }
    .ftb-pill:hover { border-color: var(--muted); color: var(--cream); }
    .ftb-pill.active { background: var(--gold3); border-color: var(--gold); color: var(--gold); }

    /* ── Favorites view ── */
    .fav-list { display: flex; flex-direction: column; gap: 12px; }
    .fav-card {
      background: var(--navy2); border: 1px solid var(--navy3);
      border-radius: var(--radius); padding: 16px 18px;
      border-left: 3px solid var(--gold);
    }
    .fav-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
    .fav-card-meta {}
    .fav-badge { font-size: 0.7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-bottom: 3px; }
    .fav-ch-name { font-size: 0.75rem; color: var(--muted); }
    .fav-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
    .fav-slok    { font-family: var(--font-deva); font-size: 1.08rem; color: var(--gold2); line-height: 1.9; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .fav-trans   { font-size: 0.82rem; color: var(--cream); line-height: 1.6; margin-bottom: 8px; }
    .fav-note    { font-size: 0.8rem; color: var(--muted); font-style: italic; margin-bottom: 4px; }
    .fav-note.has-note { color: var(--cream); font-style: normal; }
    .fav-date      { font-size: 0.7rem; color: rgba(122,154,191,.6); }
    .fav-translit  { font-family: var(--font-serif); font-size: 0.85rem; color: var(--translit); line-height: 1.75; margin-bottom: 8px; white-space: pre-line; }
    .fav-content-block { margin-bottom: 12px; }
    .fav-content-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 5px; }

    /* ── Buttons ── */
    .btn {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 7px 14px; border: none; border-radius: 7px;
      font-size: 0.78rem; font-weight: 600; cursor: pointer;
      transition: background var(--tr), opacity var(--tr);
    }
    .btn:disabled { opacity: .4; cursor: not-allowed; }
    .btn-primary  { background: var(--gold); color: var(--navy); }
    .btn-primary:hover:not(:disabled) { background: var(--gold2); }
    .btn-ghost    { background: var(--navy3); color: var(--cream); border: 1px solid var(--navy4); }
    .btn-ghost:hover { background: var(--navy4); }
    .btn-danger   { background: rgba(224,92,92,.15); color: var(--red); border: 1px solid rgba(224,92,92,.3); }
    .btn-danger:hover { background: rgba(224,92,92,.25); }
    .btn-save     { background: var(--green); color: #fff; }
    .btn-save:hover { background: #3c9c6a; }
    .btn-cancel   { background: transparent; color: var(--muted); border: 1px solid var(--navy3); }
    .btn-cancel:hover { color: var(--cream); }
    .btn-view     { background: var(--navy3); color: var(--muted); border: 1px solid var(--navy4); }
    .btn-view:hover { color: var(--cream); border-color: var(--muted); }
    .fav-star-btn { background: var(--gold3); color: var(--gold); border: 1px solid rgba(245,166,35,.3); font-size: 1rem; line-height: 1; }
    .fav-star-btn:hover { background: rgba(245,166,35,.22); color: var(--gold2); }

    /* ── Skeleton ── */
    .skeleton { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 16px; }
    .skel-line { background: linear-gradient(90deg,var(--navy3) 25%,var(--navy4) 50%,var(--navy3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; margin-bottom: 10px; height: 11px; }
    @keyframes shimmer { to { background-position: -200% 0; } }

    /* ── Empty state ── */
    .empty { text-align: center; padding: 60px 20px; color: var(--muted); }
    .empty .icon { font-size: 2.5rem; margin-bottom: 12px; }
    .empty p { font-size: 0.88rem; line-height: 1.7; }

    /* ── Toast ── */
    #toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
    .toast { background: var(--navy2); border: 1px solid var(--navy3); color: var(--cream); padding: 10px 22px; border-radius: 999px; font-size: 0.82rem; box-shadow: 0 4px 20px rgba(0,0,0,.5); animation: toast-in .22s ease; pointer-events: all; white-space: nowrap; }
    .toast.success { border-color: var(--green); color: var(--green); }
    .toast.error   { border-color: var(--red);   color: var(--red); }
    .toast.info    { border-color: var(--gold);  color: var(--gold); }
    @keyframes toast-in { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

    /* ── Confirm modal ── */
    .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; align-items: center; justify-content: center; }
    .modal-overlay.open { display: flex; }
    .modal { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 28px 32px; max-width: 320px; width: 90%; text-align: center; }
    .modal h3 { color: var(--cream); margin-bottom: 8px; font-size: .95rem; }
    .modal p  { color: var(--muted); font-size: .82rem; margin-bottom: 20px; }
    .modal-btns { display: flex; justify-content: center; gap: 10px; }

    /* ── Responsive ── */

    /* Tablets / narrow desktops */
    @media (max-width: 860px) {
      header { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
      .header-right { flex-wrap: wrap; gap: 10px; width: 100%; justify-content: space-between; }
      .nav-tabs { order: 2; }
      .chapters-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
      .view { padding: 16px; }
    }

    /* Phones */
    @media (max-width: 560px) {
      body { height: auto; min-height: 100dvh; overflow: visible; }
      header { position: sticky; top: 0; z-index: 50; }
      .header-brand p { display: none; }
      .header-brand h1 { font-size: 1rem; }
      .nav-tab { padding: 6px 11px; font-size: .76rem; }
      .api-status { order: 3; }
      .user-menu { order: 4; }
      #app { overflow: visible; }
      .view { position: relative; inset: auto; overflow-y: visible; padding: 14px; }

      .chapters-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
      .chapter-card { padding: 12px 14px; }

      .verse-row { padding: 10px 12px; gap: 10px; }
      .vrow-slok { white-space: normal; font-size: .95rem; }

      .vd-header { gap: 10px; }
      .vd-fav-btn { width: 100%; justify-content: center; }
      .vd-slok { padding: 16px 16px; }
      .vd-slok-text { font-size: 1.12rem; }
      .vd-translit  { font-size: .88rem; }
      .fav-slok { white-space: normal; }

      .author-tabs { gap: 4px; }
      .author-tab { padding: 6px 10px; font-size: .72rem; }

      .ftb-row { gap: 6px; }
      .ftb-pill { padding: 5px 10px; font-size: .72rem; }

      .fav-card-top { flex-direction: column; align-items: stretch; }
      .fav-card-actions { justify-content: flex-end; }

      .view-bar { gap: 8px; }
      .breadcrumb { font-size: .8rem; }

      .modal { padding: 22px 20px; }
      #toast-container { bottom: 14px; width: calc(100% - 28px); align-items: center; }
      .toast { white-space: normal; text-align: center; }
    }

    /* Very small phones */
    @media (max-width: 380px) {
      .chapters-grid { grid-template-columns: 1fr; }
      .nav-tab { padding: 5px 9px; font-size: .72rem; }
      .header-brand h1 { font-size: .92rem; }
    }

    /* ── Site footer ── */
    .site-footer {
      flex-shrink: 0;
      background: var(--navy2);
      border-top: 1px solid var(--navy3);
      padding: 8px 20px;
      display: flex; align-items: center; justify-content: space-between;
      gap: 12px; flex-wrap: wrap;
      font-size: 0.74rem;
    }
    .footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
    .footer-links a { color: var(--muted); text-decoration: none; transition: color var(--tr); }
    .footer-links a:hover { color: var(--gold); }
    .footer-copy { color: var(--muted); opacity: .7; white-space: nowrap; }
    @media (max-width: 560px) {
      .site-footer { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 14px; }
    }

    /* ── Auth-specific additions ── */
    .user-menu { display: flex; align-items: center; gap: 10px; }
    .user-name  { font-size: .78rem; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .btn-logout {
      display: inline-flex; align-items: center; justify-content: center;
      width: 34px; height: 34px; padding: 0; border-radius: 50%;
      background: transparent; border: 1px solid var(--navy3);
      color: var(--muted); cursor: pointer; transition: all var(--tr);
    }
    .btn-logout:hover { border-color: var(--red); color: var(--red); }
    @media (max-width: 560px) { .user-name { display: none; } }

    .btn-signin-header {
      display: inline-block; padding: 6px 16px; border-radius: 20px;
      background: var(--gold); color: var(--navy);
      font-size: .78rem; font-weight: 700; text-decoration: none;
      transition: opacity var(--tr);
    }
    .btn-signin-header:hover { opacity: .85; }

    /* ── Reduced motion ── */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
      }
    }
