/* ============================================================
   图片画廊 —— 样式
   沿用「镜音铃的终端」的暖色调（应援黄 + 樱花粉 + 奶油白），
   与漫画阅读器、图书馆保持一致；含深色模式与移动端适配。

   配色都按 WCAG 实算过：
     正文 #4A3B27 on #FFFDF6  ≈ 11.5:1
     次要 #6E5E44 on #FFFDF6  ≈  6.0:1
     占位 #877252 on #FFFFFF  ≈  4.6:1
     白字按钮 #2AA396→#177E75 ≈  4.9:1
   ============================================================ */

:root {
    --ga-gold:       #FFD93B;
    --ga-gold-deep:  #9E6200;   /* 数字强调 4.91:1（卡片底） */
    --ga-pink:       #FF8FC0;
    --ga-pink-deep:  #D62E78;   /* 白字按钮底 */
    --ga-teal:       #2AA396;
    --ga-teal-deep:  #177E75;   /* 链接文字 4.51:1 */
    --ga-teal-dark:  #116E66;   /* 渐变深端，白字 6.09:1（整条渐变都达标） */
    --ga-cream:      #FFFDF6;
    --ga-ink:        #4A3B27;
    --ga-ink-soft:   #6E5E44;
    --ga-placeholder:#877252;
    --ga-line:       #FFE9A8;
    --ga-line-soft:  #F2E6CE;
    --ga-focus:      #0F7A7E;
    --ga-shadow:     0 10px 28px rgba(196, 154, 40, .18);
    --ga-shadow-hi:  0 18px 42px rgba(196, 154, 40, .30);
    --ga-radius:     18px;
    --ga-card:       rgba(255, 253, 246, .94);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; max-width: 100%; overflow-x: hidden; }

body {
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
                 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--ga-ink);
    background-color: #FFF7DC;
    background-image:
        radial-gradient(1100px 560px at 12% -12%, rgba(255, 233, 150, .45), transparent 62%),
        radial-gradient(820px 480px at 96% 4%, rgba(255, 183, 214, .38), transparent 62%),
        linear-gradient(180deg, #FFFDF4 0%, #FFFAE8 45%, #FFF5D6 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

img { display: block; max-width: 100%; }

.ga-wrap { max-width: 1320px; margin: 0 auto; padding: 18px 20px 60px; }

/* 焦点环：键盘用户能看清自己在哪 */
a:focus-visible, button:focus-visible, select:focus-visible,
input:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--ga-focus);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ===================== 顶栏 ===================== */
.ga-topbar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    background: var(--ga-card);
    border: 1px solid var(--ga-line);
    border-radius: var(--ga-radius);
    padding: 12px 16px;
    box-shadow: var(--ga-shadow);
    backdrop-filter: blur(8px);
    position: sticky; top: 10px; z-index: 40;
}
.ga-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ga-logo {
    width: 40px; height: 40px; flex: 0 0 40px;
    display: grid; place-items: center;
    font-size: 21px; border-radius: 13px;
    background: linear-gradient(140deg, var(--ga-gold) 0%, #FFC94D 100%);
    box-shadow: 0 6px 16px rgba(245, 179, 1, .35);
}
.ga-brand h1 { font-size: 19px; font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.ga-brand .ga-sub { font-size: 11.5px; color: var(--ga-ink-soft); }

.ga-search {
    flex: 1 1 200px; min-width: 150px;
    display: flex; align-items: center; gap: 8px;
    background: var(--ga-cream);
    border: 1px solid var(--ga-line);
    border-radius: 12px; padding: 7px 12px;
}
.ga-search:focus-within { border-color: var(--ga-gold-deep); box-shadow: 0 0 0 3px rgba(255, 217, 59, .30); }
.ga-search input {
    flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
    font-size: 14px; color: var(--ga-ink); font-family: inherit;
}
.ga-search input::placeholder { color: var(--ga-placeholder); }
.ga-search .ico { opacity: .6; font-size: 14px; }
.ga-clear {
    flex: 0 0 auto; width: 22px; height: 22px; display: grid; place-items: center;
    border-radius: 50%; color: var(--ga-ink-soft); font-size: 12px; text-decoration: none;
    background: var(--ga-line-soft);
}
.ga-clear:hover { background: var(--ga-pink); color: #fff; }

.ga-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ga-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 12px; border-radius: 11px;
    font-size: 13px; font-weight: 600; font-family: inherit;
    color: var(--ga-ink); text-decoration: none; cursor: pointer;
    background: linear-gradient(140deg, #FFFDF6, #FFF1C4);
    border: 1px solid var(--ga-line);
    box-shadow: 0 3px 10px rgba(196, 154, 40, .14);
    transition: transform .15s, box-shadow .15s, background .15s;
}
.ga-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(196, 154, 40, .26); }
.ga-btn:active { transform: translateY(0); }

.ga-sort { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ga-ink-soft); }
.ga-sort select {
    padding: 7px 9px; border-radius: 11px; font-size: 13px; font-family: inherit;
    border: 1px solid var(--ga-line); background: var(--ga-cream); color: var(--ga-ink); cursor: pointer;
}
.ga-user {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12.5px; color: var(--ga-ink-soft);
    padding: 6px 10px; border-radius: 999px;
    background: rgba(255, 233, 168, .55);
    border: 1px solid var(--ga-line);
    white-space: nowrap;
}

/* ===================== 面包屑 ===================== */
.ga-crumbs {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    margin: 16px 2px 4px; font-size: 13.5px; min-height: 22px;
}
.ga-crumbs a { color: var(--ga-teal-deep); text-decoration: none; font-weight: 600; }
.ga-crumbs a:hover { text-decoration: underline; }
.ga-crumbs .sep { color: var(--ga-ink-soft); opacity: .6; }
.ga-crumbs .cur { color: var(--ga-ink); font-weight: 700; }

/* ===================== 信息条 ===================== */
.ga-metabar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin: 8px 2px 6px; font-size: 13px; color: var(--ga-ink-soft);
}
.ga-metabar b { color: var(--ga-gold-deep); font-size: 15px; }
.ga-metabar a {
    margin-left: auto; color: var(--ga-teal-deep); font-weight: 600; text-decoration: none;
    padding: 5px 11px; border-radius: 999px;
    background: rgba(42, 163, 150, .10); border: 1px solid rgba(42, 163, 150, .32);
}
.ga-metabar a:hover { background: rgba(42, 163, 150, .20); }
.ga-metabar .pg { margin-left: auto; }

/* ===================== 区块标题 ===================== */
.ga-h2 {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 800; color: var(--ga-ink);
    margin: 20px 2px 11px;
}
.ga-h2 small { font-weight: 600; font-size: 12px; color: var(--ga-ink-soft); }

/* ===================== 相册卡片 ===================== */
.ga-albums {
    display: grid; gap: 15px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.ga-album {
    display: flex; flex-direction: column; gap: 9px;
    padding: 11px; border-radius: var(--ga-radius);
    background: var(--ga-card);
    border: 1px solid var(--ga-line);
    box-shadow: var(--ga-shadow);
    text-decoration: none; color: inherit;
    transition: transform .18s cubic-bezier(.2, .7, .3, 1), box-shadow .18s;
}
.ga-album:hover { transform: translateY(-3px); box-shadow: var(--ga-shadow-hi); }
.ga-album .cover {
    position: relative; display: block;
    aspect-ratio: 4 / 3; border-radius: 13px; overflow: hidden;
    background: linear-gradient(140deg, #FFF3CC, #FFE9A8);
}
.ga-album .cover img { width: 100%; height: 100%; object-fit: cover; }
.ga-album .cover .noimg { display: grid; place-items: center; height: 100%; font-size: 34px; opacity: .55; }
.ga-album .cover .cnt {
    position: absolute; right: 8px; bottom: 8px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700; color: #fff;
    background: rgba(20, 110, 102, .94);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .22);
}
.ga-album .nm {
    font-size: 14px; font-weight: 700; line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ga-album .ds {
    font-size: 12px; color: var(--ga-ink-soft); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ===================== 图片网格 ===================== */
.ga-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.ga-cell {
    position: relative; margin: 0;
    aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden;
    background: linear-gradient(140deg, #FFF6DA, #FFEDBB);
    border: 1px solid var(--ga-line);
    box-shadow: 0 6px 16px rgba(196, 154, 40, .14);
    cursor: zoom-in;
    transition: transform .18s cubic-bezier(.2, .7, .3, 1), box-shadow .18s;
}
.ga-cell:hover { transform: translateY(-3px); box-shadow: var(--ga-shadow-hi); }
.ga-cell img {
    width: 100%; height: 100%; object-fit: cover;
    opacity: 0; transition: opacity .35s ease;
}
.ga-cell img.on { opacity: 1; }
/* 缩略图没到位前的骨架微光 */
.ga-cell .ph {
    position: absolute; inset: 0;
    background: linear-gradient(100deg, #FFF6DA 30%, #FFFDF0 50%, #FFF6DA 70%);
    background-size: 220% 100%;
    animation: gaShimmer 1.4s linear infinite;
}
.ga-cell.ready .ph { display: none; }
@keyframes gaShimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.ga-cell figcaption {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 22px 10px 8px;
    background: linear-gradient(180deg, rgba(30, 22, 10, 0), rgba(30, 22, 10, .78));
    color: #fff;
    opacity: 0; transition: opacity .2s ease;
    pointer-events: none;
}
.ga-cell:hover figcaption,
.ga-cell:focus-within figcaption { opacity: 1; }

/* 铺满整格的「打开」链接：键盘可达、点了开灯箱、无 JS 时退化为打开原图 */
.ga-open {
    position: absolute; inset: 0; z-index: 2;
    border-radius: inherit;
    cursor: zoom-in;
    text-decoration: none;
}
.ga-open:focus-visible { outline: 3px solid #fff; outline-offset: -4px; }
.ga-cell figcaption .nm {
    display: block; font-size: 12.5px; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ga-cell figcaption .ds {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    margin-top: 2px; font-size: 11.5px; line-height: 1.4; color: #F0E4CE;
    overflow: hidden; white-space: pre-line; word-break: break-word;
}
.ga-cell .dl {
    position: absolute; top: 8px; right: 8px; z-index: 3;
    width: 30px; height: 30px; display: grid; place-items: center;
    border-radius: 50%; font-size: 14px; text-decoration: none;
    color: #fff; background: rgba(23, 126, 117, .92);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .24);
    opacity: 0; transition: opacity .2s ease, transform .15s;
}
.ga-cell:hover .dl, .ga-cell:focus-within .dl { opacity: 1; }
.ga-cell .dl:hover { transform: scale(1.08); }
/* 触屏设备没有 hover：常驻显示文件名与下载键 */
@media (hover: none) {
    .ga-cell figcaption { opacity: 1; }
    .ga-cell .dl { opacity: 1; }
}

/* ===================== 分页 ===================== */
.ga-pager {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    flex-wrap: wrap; margin: 26px 0 6px;
}
.ga-pg {
    min-width: 36px; padding: 7px 10px; text-align: center;
    border-radius: 11px; font-size: 13px; font-weight: 700; text-decoration: none;
    color: var(--ga-ink); background: var(--ga-cream);
    border: 1px solid var(--ga-line);
}
.ga-pg:hover { background: #FFF1C4; }
.ga-pg.cur {
    color: #fff; border-color: transparent;
    background: linear-gradient(140deg, var(--ga-teal-deep), var(--ga-teal-dark));
    box-shadow: 0 4px 12px rgba(23, 126, 117, .30);
}

/* ===================== 空状态 ===================== */
.ga-empty {
    text-align: center; padding: 62px 20px;
    background: var(--ga-card); border: 1px dashed var(--ga-line);
    border-radius: var(--ga-radius); margin-top: 18px;
}
.ga-empty .big { font-size: 46px; margin-bottom: 12px; }
.ga-empty p { font-size: 14px; color: var(--ga-ink-soft); margin-bottom: 16px; line-height: 1.7; }
.ga-empty code {
    background: rgba(255, 233, 168, .6); padding: 2px 6px; border-radius: 6px;
    font-size: 12.5px; color: #6B4E12;
}

/* ===================== 页脚 ===================== */
.ga-foot {
    margin-top: 44px; padding: 18px 20px;
    text-align: center; font-size: 12.5px; line-height: 1.9;
    color: var(--ga-ink-soft);
    background: var(--ga-card);
    border: 1px solid var(--ga-line);
    border-radius: var(--ga-radius);
}
.ga-foot code {
    background: rgba(255, 233, 168, .6); padding: 1px 6px; border-radius: 6px;
    color: #6B4E12; font-size: 12px;
}

/* ===================== 提示条 ===================== */
.ga-toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(14px);
    max-width: min(90vw, 520px);
    padding: 11px 22px; border-radius: 999px;
    font-size: 13.5px; font-weight: 700; color: #fff;
    background: linear-gradient(140deg, var(--ga-teal-deep), var(--ga-teal-dark));
    box-shadow: 0 12px 30px rgba(23, 126, 117, .34);
    opacity: 0; pointer-events: none; z-index: 9500;
    transition: opacity .25s ease, transform .25s ease;
}
.ga-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ga-toast.err { background: linear-gradient(140deg, #FF9C93, #C0392B); }

/* ===================== 灯箱 ===================== */
.ga-lb { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; }
.ga-lb-mask { position: absolute; inset: 0; background: rgba(24, 18, 10, .88); backdrop-filter: blur(3px); }
.ga-lb-panel {
    position: relative; z-index: 1;
    width: min(96vw, 1240px); height: min(94vh, 940px);
    display: flex; flex-direction: column;
    border-radius: 16px; overflow: hidden;
    background: #1E1913;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
    animation: gaPop .22s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes gaPop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }

.ga-lb-bar {
    display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
    padding: 9px 12px; background: rgba(255, 255, 255, .06);
    border-bottom: 1px solid rgba(255, 255, 255, .10);
}
.ga-lb-bar .t {
    flex: 1; min-width: 0; color: #F5EEDF; font-size: 13.5px; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ga-lb-tools { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.ga-lb-b {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 11px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .10); color: #F5EEDF;
    font-size: 12.5px; font-weight: 600; font-family: inherit;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background .15s;
}
.ga-lb-b:hover { background: rgba(255, 255, 255, .24); }
.ga-lb-b:focus-visible { outline-color: #7FE3E8; }

.ga-lb-stage {
    position: relative; flex: 1 1 auto; min-height: 0;
    display: grid; place-items: center; padding: 10px;
}
.ga-lb-stage img {
    max-width: 100%; max-height: 100%;
    object-fit: contain; border-radius: 8px;
    background: #14100C;
    transition: opacity .2s ease;
}
.ga-lb-stage.loading img { opacity: .35; }
.ga-lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 46px; height: 74px; display: grid; place-items: center;
    border: 0; border-radius: 12px; cursor: pointer;
    font-size: 26px; line-height: 1; color: #fff;
    background: rgba(255, 255, 255, .12);
    transition: background .15s;
}
.ga-lb-nav:hover { background: rgba(255, 255, 255, .28); }
.ga-lb-nav.prev { left: 12px; }
.ga-lb-nav.next { right: 12px; }
.ga-lb-nav[disabled] { opacity: .2; cursor: default; }

.ga-lb-foot {
    flex: 0 0 auto; display: flex; align-items: flex-start; gap: 14px;
    padding: 11px 14px; background: rgba(255, 255, 255, .06);
    border-top: 1px solid rgba(255, 255, 255, .10);
}
.ga-lb-foot .txt { flex: 1; min-width: 0; }
.ga-lb-foot .nm { color: #FFF8E7; font-size: 14px; font-weight: 700; word-break: break-word; }
.ga-lb-foot .ds { margin-top: 4px; color: #DCCFB4; font-size: 12.5px; line-height: 1.65; word-break: break-word; white-space: pre-wrap; }
.ga-lb-foot .mt { margin-top: 5px; color: #B7A98C; font-size: 11.5px; }
.ga-lb-foot .cnt { flex: 0 0 auto; color: #B7A98C; font-size: 12px; align-self: center; }

/* ===================== 窄屏 ===================== */
@media (max-width: 820px) {
    .ga-wrap { padding: 12px 13px 46px; }
    .ga-topbar { position: static; gap: 10px; padding: 11px 12px; }
    .ga-brand h1 { font-size: 17px; }
    .ga-search { order: 3; flex: 1 1 100%; }
    .ga-actions { gap: 6px; }
    .ga-sort .lbl { display: none; }
    .ga-albums { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 11px; }
    .ga-grid { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 9px; }
    .ga-lb-panel { width: 100vw; height: 100vh; border-radius: 0; }
    .ga-lb-nav { width: 38px; height: 60px; font-size: 22px; }
    .ga-lb-nav.prev { left: 6px; }
    .ga-lb-nav.next { right: 6px; }
    .ga-lb-bar .t { font-size: 12.5px; }
    .ga-lb-b { padding: 6px 9px; font-size: 12px; }
    .ga-metabar a { margin-left: 0; }
}

@media (max-width: 420px) {
    .ga-grid { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); }
    .ga-albums { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
    .ga-user { display: none; }
}

/* ===================== 动效降级 ===================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
    .ga-cell .ph { animation: none; background: #FFF6DA; }
}

/* ===================== 深色模式 ===================== */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --ga-cream:      #241F19;
        --ga-ink:        #F2E7D5;
        --ga-ink-soft:   #C0AE94;
        --ga-placeholder:#9C8A72;
        --ga-gold-deep:  #FFC85A;
        --ga-line:       #4A3E2C;
        --ga-line-soft:  #3A3125;
        --ga-focus:      #7FE3E8;
        --ga-card:       rgba(34, 29, 23, .92);
        --ga-shadow:     0 10px 28px rgba(0, 0, 0, .40);
        --ga-shadow-hi:  0 18px 42px rgba(0, 0, 0, .55);
    }
    body {
        background-color: #17130F;
        background-image:
            radial-gradient(1100px 560px at 12% -12%, rgba(120, 92, 20, .30), transparent 62%),
            radial-gradient(820px 480px at 96% 4%, rgba(120, 60, 90, .26), transparent 62%),
            linear-gradient(180deg, #1B1713 0%, #161210 50%, #12100C 100%);
    }
    .ga-logo { background: linear-gradient(140deg, #6B5A16, #4A3E10); box-shadow: none; }
    .ga-search { background: #241F19; }
    .ga-btn {
        background: linear-gradient(140deg, #2E2720, #3A3125);
        border-color: #4A3E2C; color: var(--ga-ink);
        box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
    }
    .ga-btn:hover { box-shadow: 0 8px 18px rgba(0, 0, 0, .45); }
    .ga-sort select { background: #241F19; border-color: #4A3E2C; color: var(--ga-ink); }
    .ga-user { background: rgba(80, 68, 34, .5); }
    .ga-search input::placeholder { color: var(--ga-placeholder); }
    .ga-album .cover { background: linear-gradient(140deg, #33291B, #2A2216); }
    .ga-album .cover .cnt { background: rgba(20, 110, 102, .96); }
    .ga-cell { background: linear-gradient(140deg, #2A2318, #322A1C); border-color: #4A3E2C; }
    .ga-cell .ph { background: linear-gradient(100deg, #2A2318 30%, #3A3125 50%, #2A2318 70%); background-size: 220% 100%; }
    .ga-crumbs a { color: #7FE3E8; }
    .ga-metabar a { color: #7FE3E8; background: rgba(127, 227, 232, .12); border-color: rgba(127, 227, 232, .34); }
    .ga-metabar a:hover { background: rgba(127, 227, 232, .22); }
    .ga-empty code, .ga-foot code { background: rgba(120, 92, 20, .35); color: #FFD98A; }
    .ga-pg { background: #241F19; border-color: #4A3E2C; }
    .ga-pg:hover { background: #322A1C; }
}
