    *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

    :root {
      --font-brush: 'Ma Shan Zheng', cursive;
      --font-display: 'Cormorant Garamond', serif;
      --font-body: 'Crimson Pro', serif;
    }

    html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
    body { font-family: var(--font-body); background: transparent; color: var(--ink); overflow-x: hidden; min-height: 100vh; opacity: 1; }
    body.bg-ready { opacity: 1; }
    ::selection { background: var(--selection-bg); color: var(--selection-fg); }
    a { color: inherit; text-decoration: none; }

    /* ─── Background — body class selectors to match theme.js ─── */
    .bg-ink {
      position: fixed; inset: 0; z-index: 0;
      pointer-events: none; background-color: #1a1816;
    }
    
    .bg-layer {
      position: absolute;
      inset: 0;
      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;
      opacity: 0;
      transition: opacity 0.55s ease-in-out;
    }

    .bg-layer.light-img { background-image: var(--bg-light); }
    .bg-layer.dark-img  { background-image: var(--bg-dark); }

    body.light-theme .bg-ink { background-color: #f4efe6; }
    .bg-layer.light-img { opacity: var(--bg-opacity-light); }
    .bg-layer.dark-img { opacity: var(--bg-opacity-dark); }

    body.dark-theme .bg-ink { background-color: #050505; }

/*     /* ─── Readability: gallery text against Gargantua ─── */

    /* Light mode — use theme variables for consistent site-wide color source */
    body.light-theme .gallery-item-title { color: var(--gallery-item-title); font-weight: 600; }
    body.light-theme .gallery-item-title-cn { color: var(--ink); }
    body.light-theme .gallery-item-date { color: var(--ink-light); font-weight: 500; }
    body.light-theme .sidebar .cat-btn { color: var(--gallery-sidebar-cat-btn); }
    body.light-theme .sidebar .cat-btn.active { color: var(--gallery-sidebar-cat-btn-active); }
    body.light-theme .sidebar-label { color: var(--gallery-sidebar-label); }
    body.light-theme .sidebar .cat-count { color: var(--gallery-sidebar-cat-count); }
    body.light-theme .page-title { color: var(--gallery-page-title); }
    body.light-theme .page-subtitle { color: var(--gallery-page-subtitle); }

    /* Dark mode — use theme variables for consistent site-wide color source */
    body.dark-theme .gallery-item-title { color: var(--gallery-item-title); font-weight: 500; }
    body.dark-theme .gallery-item-title-cn { color: var(--ink); }
    body.dark-theme .gallery-item-date { color: var(--ink-light); font-weight: 400; }
    body.dark-theme .sidebar .cat-btn { color: var(--gallery-sidebar-cat-btn); }
    body.dark-theme .sidebar .cat-btn.active { color: var(--gallery-sidebar-cat-btn-active); }
    body.dark-theme .sidebar-label { color: var(--gallery-sidebar-label); }
    body.dark-theme .sidebar .cat-count { color: var(--gallery-sidebar-cat-count); }
    body.dark-theme .page-title { color: var(--gallery-page-title); }
    body.dark-theme .page-subtitle { color: var(--gallery-page-subtitle); }

    /* ─── Top Bar ─── */
    .top-bar {
      position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100;
      padding: 10px 24px; border-radius: 100px;
      background: var(--glass-bg); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
      border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow), var(--glass-inset);
      display: flex; align-items: center; gap: 14px;
    }
    .top-seal { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--vermillion); color: var(--seal-color); font-family: var(--font-brush); font-size: 20px; border-radius: 3px; }
    .top-title { font-family: var(--font-body); font-size: 16px; color: var(--ink-light); display: flex; align-items: center; gap: 5px; }
    .top-title .cn { font-family: var(--font-brush); font-size: 19px; }

    /* ─── Filter Toggle (mobile) ─── */
    .filter-toggle { display: none; background: none; border: none; padding: 6px; cursor: pointer; color: var(--ink-light); -webkit-tap-highlight-color: transparent; }
    .filter-toggle svg { width: 18px; height: 18px; }

    /* ─── Filter Overlay (mobile) ─── */
    .filter-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(42,38,34,0.15); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
    .filter-overlay.open { opacity: 1; pointer-events: auto; }

    .filter-panel {
      position: absolute; top: 64px; right: 16px; width: 220px; padding: 20px; border-radius: 16px;
      background: var(--glass-bg-solid); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
      border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow), var(--glass-inset);
      transform: translateY(-8px); transition: transform 0.3s ease;
    }
    .filter-overlay.open .filter-panel { transform: translateY(0); }
    .filter-panel .cat-list { list-style: none; max-height: 441px; overflow-y: auto; }
    .filter-panel .cat-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 4px; background: none; border: none; font-family: var(--font-body); font-size: 15px; color: var(--ink-wash); cursor: pointer; text-align: left; border-bottom: 1px solid var(--border); transition: color 0.3s ease; }
    .filter-panel .cat-btn:last-child { border-bottom: none; }
    .filter-panel .cat-btn.active { color: var(--vermillion); font-weight: 500; }
    .filter-panel .cat-btn .cn { font-family: var(--font-brush); font-size: 22px; min-width: 20px; }
    .filter-panel .cat-btn.active .cn { color: var(--vermillion); }
    .filter-panel .cat-count { font-size: 15px; color: var(--ink); margin-left: auto; }

    /* ─── Layout ─── */
    .layout { position: relative; z-index: 1; display: grid; grid-template-columns: 185px 1fr; gap: 0; min-height: 100vh; padding-top: 72px; }

    /* ─── Desktop Sidebar ─── */
    .sidebar { position: sticky; top: 72px; height: calc(100vh - 72px); padding: 32px 24px 32px 40px; border-right: 1px solid var(--border); overflow-y: auto; }
    .sidebar-label { font-size: 14px; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 16px; }
    .sidebar .cat-list { list-style: none; }
    .sidebar .cat-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 0; background: none; border: none; font-family: var(--font-body); font-size: 18px; color: var(--ink-wash); cursor: pointer; text-align: left; transition: color 0.3s ease, transform 0.3s ease, background 0.3s ease; }
    body.light-theme .sidebar .cat-btn:hover { color: var(--vermillion) !important; transform: translateX(6px); border-radius: 4px; padding-left: 8px; transition: all 1s ease; }
    body.dark-theme .sidebar .cat-btn:hover { color: var(--vermillion) !important; transform: translateX(6px); border-radius: 4px; padding-left: 8px; transition: all 1s ease; }
    .sidebar .cat-btn.active { color: var(--vermillion); }
    .sidebar .cat-btn .cn { font-family: var(--font-brush); font-size: 22px; line-height: 1; min-width: 20px; }
    body.light-theme .sidebar .cat-btn:hover { color: var(--vermillion) !important; transform: translateX(6px); border-radius: 4px; padding-left: 8px; transition: all 1s ease; }
    body.dark-theme .sidebar .cat-btn:hover { color: var(--vermillion) !important; transform: translateX(6px); border-radius: 4px; padding-left: 8px; transition: all 1s ease; }
    body.light-theme .sidebar .cat-btn.active .cn { color: var(--vermillion); }
    body.dark-theme .sidebar .cat-btn.active .cn { color: var(--vermillion); }
    .sidebar .cat-count { font-size: 14px; color: var(--ink); margin-left: auto; }

    /* ─── Main ─── */
    .main { padding: 32px 48px 80px; min-width: 0; }
    .page-title { font-family: var(--font-display); font-weight: 400; font-size: clamp(32px,4vw,48px); display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
    .page-title .cn { font-family: var(--font-brush); font-size: clamp(28px,3.5vw,38px); color: var(--seal-color); background: var(--vermillion); padding: 4px 10px; border-radius: 4px; line-height: 1.2; }
    .page-subtitle { font-size: 19px; font-weight: 300; color: var(--ink-wash); font-style: italic; margin-bottom: 32px; }

    /* ─── Grid ─── */
    .gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
    .gallery-item {
      display: block;
      -webkit-tap-highlight-color: transparent;
      opacity: 0;
      transform: translateY(14px);
      transition: opacity 0.55s ease, transform 0.55s ease;
      will-change: opacity, transform;
    }
    .gallery-item.visible { opacity: 1; transform: translateY(0); }
    /* .gallery-item.filtered-out { display: none; } */
    .gallery-item.filtered-out {
      opacity: 0;
      transform: translateY(14px);
      pointer-events: none;
      position: absolute;
      visibility: hidden;
    }

    /*.gallery-thumb { position: relative; aspect-ratio: 3/2; overflow: hidden; background: var(--card-bg); box-shadow: var(--card-shadow); border: 1px solid var(--card-border); transition: border-color 0.4s ease, box-shadow 0.4s ease; }*/
	   .gallery-thumb {
       position: relative;
       aspect-ratio: 3/2;
       overflow: hidden;
       background: var(--card-bg);
       transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.4s ease;
     
       /* MODIFIED: Matching the main card rounded corners */
       border-radius: 20px;
       
       /* MODIFIED: A heavier shadow to separate the images from the stars */
       border: 1px solid var(--card-border);
       box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
     }
	 
	 
	 /* Add a hover lift effect to make the cards feel responsive */
     .gallery-item:hover .gallery-thumb {
       border-color: var(--card-hover-border);
       box-shadow: var(--card-hover-shadow);
       transform: translateY(-6px); /* Gentle lift on hover, increase to 6px from 4px*/
     }
	 
	 
     	 /* Ensure the image takes the rounded shape from the container */
     .gallery-thumb img {
       width: 100%;
       height: 100%;
       object-fit: cover;
       border-radius: inherit; /* Copies the 20px radius from .gallery-thumb */
       opacity: 0;
       transition: opacity 0.45s ease;
     }
     .gallery-thumb img.loaded { opacity: 1; 
         --glass-bg: rgba(255, 255, 255, 0.95); /* Thicker shield for text */
     }
	 
	 
    /*.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }*/
	
    .gallery-item:hover .gallery-thumb { border-color: var(--card-hover-border); box-shadow: var(--card-hover-shadow); }
    .gallery-meta { padding: 12px 0 0; }
    .gallery-item-title { font-family: var(--font-display); font-size: 20px; font-weight: 300; color: var(--ink); transition: color 0.3s ease; }
    .gallery-item-title-cn { display: block; font-family: var(--font-brush); font-size: 20px; font-weight: 100; color: var(--ink-wash); margin-top: 2px; transition: color 0.3s ease; }
    .gallery-item-date { font-size: 14px; font-weight: 300; color: var(--ink-faint); margin-top: 2px; transition: color 0.3s ease; }

    body.light-theme a.gallery-item:hover .gallery-item-title,
    body.light-theme a.gallery-item:hover .gallery-item-title-cn,
    body.light-theme a.gallery-item:hover .gallery-item-date {
      color: var(--vermillion) !important;
    }

    body.dark-theme a.gallery-item:hover .gallery-item-title,
    body.dark-theme a.gallery-item:hover .gallery-item-title-cn,
    body.dark-theme a.gallery-item:hover .gallery-item-date {
      color: var(--vermillion) !important;
    }

    /* ─── Footer ─── */
    .footer { position: relative; z-index: 1; padding: 24px 48px 24px 210px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
    .footer-text { font-size: 16px; color: var(--ink-faint); }
    .footer-link { font-size: 16px; color: var(--ink-wash); display: inline-flex; align-items: center; gap: 4px; transition: color 0.3s ease; }
    .footer-link .cn { font-family: var(--font-brush); font-size: 22px; }
    body.light-theme .footer-link:hover { color: var(--ink-dark); }
    body.dark-theme .footer-link:hover { color: var(--ink); }

    /* ─── Theme Toggle ─── */
    .theme-toggle { background: none; border: none; padding: 6px; cursor: pointer; color: var(--ink-faint); font-size: 18px; line-height: 1; transition: color 0.3s ease; margin-left: auto; }
    .theme-toggle:hover { color: var(--ink); }

    .reveal { opacity: 0; transition: opacity 0.8s ease; }
    .reveal.revealed { opacity: 1; }

    /* ─── Responsive ─── */
    @media (max-width: 900px) {
      .filter-toggle { display: block; }
      .filter-overlay { display: block; }
      .layout { grid-template-columns: 1fr; }
      .sidebar { display: none; }
      .main { padding: 24px 24px 60px; }
      .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
      .footer { padding: 24px; }
    }
    @media (max-width: 600px) {
      .gallery-grid { gap: 14px; }
      .gallery-item-title { font-size: 14px; }
      .footer { flex-direction: column; gap: 10px; }
    }
    @media (max-width: 560px) {
      .top-bar { left: 12px; right: 12px; transform: none; justify-content: flex-start; }
    }

    /* ─── Smooth Theme Transition ─── */
    html.theme-transitioning,
    html.theme-transitioning *,
    html.theme-transitioning *::before,
    html.theme-transitioning *::after {
      transition: background 0.5s ease, color 0.5s ease,
                  border-color 0.5s ease, box-shadow 0.5s ease !important;
    }
