/* ============================================================
   PhotoVault — 用户端 UI
   移动端优先 · 深色主题 · 响应式
   ============================================================ */

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

:root {
    --bg: #0b0f19;
    --surface: #151a28;
    --surface2: #1c2333;
    --border: rgba(255,255,255,.06);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99,102,241,.25);
    --danger: #ef4444;
    --text: #e2e8f0;
    --text2: #94a3b8;
    --text3: #64748b;
    --white: #fff;
    --radius: 16px;
    --radius-sm: 10px;
}

html { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
}

/* ── Container ── */
.page {
    width: 100%; max-width: 420px; padding: 24px 20px; text-align: center;
    animation: fadeUp .5s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ── Header ── */
.header { margin-bottom: 28px; }
.header .icon {
    width: 64px; height: 64px; border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 30px; margin-bottom: 14px;
    box-shadow: 0 12px 32px var(--accent-glow);
}
.header h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.header p  { font-size: 14px; color: var(--text2); margin-top: 6px; }

/* ── Password Dots ── */
.pwd-row {
    display: flex; justify-content: center; gap: 16px;
    margin: 0 0 36px; padding: 8px 0;
}
.pwd-dot {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--surface2); border: 2px solid var(--text3);
    transition: .2s;
}
.pwd-dot.fill { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px var(--accent-glow); transform: scale(1.15); }
.pwd-dot.err  { animation: shake .5s; background: var(--danger); border-color: var(--danger); }
@keyframes shake {
    0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)}
}

/* ── Dial Pad ── */
.dial-pad { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 8px; }
.key {
    aspect-ratio: 1; border-radius: 50%; background: var(--surface);
    border: 1px solid var(--border); display: flex; flex-direction: column;
    align-items: center; justify-content: center; cursor: pointer;
    transition: .12s; position: relative; overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.key:active { background: var(--surface2); transform: scale(.94); }
.key .n { font-size: 28px; font-weight: 500; line-height: 1; }
.key .sub { font-size: 9px; color: var(--text3); letter-spacing: 1.5px; margin-top: 2px; font-weight: 600; }
.key.del { background: transparent; border-color: transparent; }
.key.del .n { font-size: 18px; color: var(--text3); }
.key.del:active { background: rgba(239,68,68,.08); }
.key.void { background: transparent; border-color: transparent; pointer-events: none; }

/* ── Messages ── */
.msg-err  { color: var(--danger); font-size: 13px; margin-top: 16px; min-height: 20px; }
.msg-lock { color: #fbbf24; font-size: 13px; margin-top: 16px; }
.loader  { display: none; margin-top: 20px; }
.spin {
    width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.08);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Ripple ── */
.ripple {
    position: absolute; border-radius: 50%; background: rgba(255,255,255,.12);
    transform: scale(0); animation: rip .5s ease-out; pointer-events: none;
}
@keyframes rip { to { transform: scale(4); opacity: 0; } }

/* ── Viewer (image / video) ── */
.viewer {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: #000;
}
.viewer.on { display: flex; flex-direction: column; }
.viewer-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    background: rgba(0,0,0,.85); backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-shrink: 0;
}
.viewer-top .back {
    padding: 7px 14px; border-radius: 18px; border: none;
    font-size: 13px; cursor: pointer; font-weight: 500;
    background: rgba(255,255,255,.1); color: #fff;
    white-space: nowrap;
}
.viewer-top .dl {
    padding: 7px 14px; border-radius: 18px; border: none;
    font-size: 13px; cursor: pointer; font-weight: 500;
    background: var(--accent); color: #fff;
    white-space: nowrap;
}
.viewer-top .name {
    flex: 1; text-align: center; font-size: 14px; font-weight: 500; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.viewer-body {
    flex: 1; display: flex; align-items: center; justify-content: center;
    overflow: auto; -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.viewer-body img, .viewer-body video {
    max-width: 100%; max-height: 100%; object-fit: contain;
}

/* ── Gallery ── */
#galPage {
    width: 100%; max-width: 100%; padding: 0; text-align: left;
    align-self: flex-start;
}
.gal-top {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; background: var(--surface); position: sticky; top: 0; z-index: 10;
    border-bottom: 1px solid var(--border);
}
.gal-top h2 { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-top .back { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text2); font-size: 13px; cursor: pointer; }
.gal-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px; padding: 8px;
}
@media (min-width: 600px) { .gal-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; padding: 12px; } }

.gal-item {
    background: var(--surface); border-radius: var(--radius-sm); overflow: hidden;
    cursor: pointer; transition: .15s; border: 1px solid var(--border);
}
.gal-item:active { transform: scale(.97); }
.gal-thumb { position: relative; width: 100%; padding-top: 75%; background: #0b0f19; overflow: hidden; }
.gal-thumb img, .gal-thumb video {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.gal-badge {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,.65); color: #fff; font-size: 12px;
    padding: 2px 8px; border-radius: 8px;
}
.gal-name { padding: 6px 8px 0; font-size: 11px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-meta { padding: 2px 8px 6px; font-size: 10px; color: var(--text3); }
.gal-foot {
    display: flex; justify-content: center; align-items: center; gap: 10px;
    padding: 16px 12px;
}
.gal-foot .btn { padding: 8px 18px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer; }
.gal-foot .btn:disabled { opacity: .35; pointer-events: none; }
.gal-foot .info { font-size: 13px; color: var(--text3); }
.gal-empty { text-align: center; padding: 48px 20px; color: var(--text3); }

/* ── Utils ── */
.hide { display: none !important; }
.btn { display: inline-block; padding: 8px 18px; border-radius: 20px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; }
