/* wee image — 单文件样式表，无外部依赖 */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #16181d;
    --muted: #6b7280;
    --border: #e3e6ea;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    --danger: #dc2626;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
    --radius: 12px;
}

html[data-theme="dark"] {
    --bg: #0c0e12;
    --surface: #15181e;
    --surface-2: #1c2027;
    --text: #e7e9ee;
    --muted: #98a0ad;
    --border: #262b34;
    --accent: #4f8cff;
    --accent-ink: #08111f;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
kbd {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 5px;
    font-size: .82em;
}
.muted { color: var(--muted); }

/* ---------- topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    letter-spacing: .2px;
    color: var(--text);
}
.brand-mark { width: 26px; height: 26px; color: var(--accent); }

.stats {
    display: flex;
    gap: 22px;
    margin: 0;
    margin-left: auto;
}
.stats div { display: flex; align-items: baseline; gap: 6px; }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .06s, color .15s;
    white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 8px; }

.icon-btn {
    width: 36px; height: 36px;
    display: inline-grid; place-items: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- layout ---------- */
.wrap {
    max-width: 1240px;
    margin: 0 auto;
    padding: 26px 24px 60px;
}

/* ---------- uploader ---------- */
.uploader {
    border: 2px dashed var(--border);
    border-radius: 16px;
    background: var(--surface);
    padding: 34px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s, background .18s, transform .18s;
    outline: none;
}
.uploader:hover,
.uploader:focus-visible { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.uploader.drag {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--surface));
    transform: scale(1.004);
}
.dz-icon { width: 44px; height: 44px; color: var(--muted); margin-bottom: 6px; }
.dz-title { margin: 6px 0 4px; font-size: 17px; font-weight: 600; }
.dz-hint { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.dz-warn {
    margin: -8px 0 16px;
    font-size: 12.5px;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 6px 12px;
    display: inline-block;
}
html[data-theme="dark"] .dz-warn {
    color: #fbbf24;
    background: rgba(251, 191, 36, .1);
    border-color: rgba(251, 191, 36, .25);
}

.dz-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 14px;
}
.dz-bar[hidden] { display: none; }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toolbar ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 22px 0 16px;
}
.field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
}
.field.grow { flex: 1 1 240px; }
.field svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.field label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.field input,
.field select {
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    outline: none;
    min-width: 0;
    width: 100%;
}
.field input[type="date"] { width: 128px; }
.field input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1); }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}
.switch input { accent-color: var(--accent); }

/* ---------- grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.grid:empty { display: none; }

.card {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: transform .16s, box-shadow .16s, border-color .16s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(10, 12, 16, .62);
    color: #fff;
    font-size: 11px;
    letter-spacing: .3px;
    backdrop-filter: blur(6px);
}

.card-badge.stale {
    left: auto;
    right: 8px;
    background: rgba(180, 83, 9, .82);
}

.card-actions {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    gap: 6px;
    padding: 8px;
    background: linear-gradient(to top, rgba(8, 10, 14, .78), rgba(8, 10, 14, 0));
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .16s, transform .16s;
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; transform: none; }

.mini {
    flex: 1;
    height: 28px;
    border-radius: 7px;
    border: 0;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background .14s;
}
.mini:hover { background: rgba(255, 255, 255, .28); }
.mini.danger:hover { background: rgba(220, 38, 38, .8); }

/* ---------- states ---------- */
.state {
    padding: 40px 0;
    text-align: center;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.state[hidden] { display: none; }
.state p { margin: 4px 0; }

.loadmore { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; }
.loadmore .btn[hidden] { display: none; }

.foot {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-top: 44px;
    color: var(--muted);
    font-size: 12.5px;
}
.foot a:hover { color: var(--accent); }
.foot .dot { opacity: .5; }

/* ---------- lightbox ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 40px 60px;
    background: rgba(6, 8, 12, .86);
    backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }
.lb-figure {
    margin: 0;
    max-width: min(1100px, 92vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.lb-figure img {
    max-width: 100%;
    max-height: calc(88vh - 90px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    background: #000;
}
.lb-figure figcaption { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.lb-meta { color: rgba(255, 255, 255, .72); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lb-note {
    margin: 0;
    font-size: 12.5px;
    color: #fbbf24;
    background: rgba(251, 191, 36, .12);
    border: 1px solid rgba(251, 191, 36, .25);
    border-radius: 8px;
    padding: 6px 12px;
}
.lb-note[hidden] { display: none; }
.lb-actions { display: flex; gap: 8px; }
.lb-actions .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.lb-actions .btn:hover { background: rgba(255, 255, 255, .2); }

.lb-close, .lb-nav {
    position: absolute;
    border: 0;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .15s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .2); }
.lb-close { top: 18px; right: 20px; width: 38px; height: 38px; border-radius: 50%; font-size: 15px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 44px; height: 68px; border-radius: 10px; font-size: 30px; line-height: 1; }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }

/* ---------- modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(6, 8, 12, .55);
    backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 6px; font-size: 18px; }
.modal-card p { margin: 0 0 16px; font-size: 13.5px; }
.modal-card input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    outline: none;
}
.modal-card input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.admin-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
.admin-actions[hidden] { display: none; }

/* ---------- toasts ---------- */
.toasts {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}
.toast {
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(17, 20, 26, .94);
    color: #fff;
    font-size: 13.5px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
    animation: toast-in .18s ease-out;
    max-width: 84vw;
}
.toast.err { background: rgba(185, 28, 28, .96); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* 触屏没有 hover，操作条常驻 */
@media (hover: none) {
    .card-actions { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .topbar { gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
    .stats { gap: 14px; margin-left: 0; order: 3; width: 100%; }
    .topbar-actions { margin-left: auto; }
    .wrap { padding: 18px 14px 48px; }
    .uploader { padding: 26px 16px; }
    .dz-title { font-size: 15px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .lightbox { padding: 16px 10px; }
    .lb-nav { display: none; }
    .field input[type="date"] { width: 110px; }
}
