/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --bg2: #1a1d27;
    --bg3: #22263a;
    --border: #2e3250;
    --text: #e8eaf0;
    --text2: #9aa0b8;
    --text3: #6b7191;
    --primary: #6366f1;
    --primary-hover: #4f52d8;
    --primary-light: rgba(99,102,241,0.12);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: rgba(239,68,68,0.1);
    --success: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.18s ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Marquee ===== */
@keyframes marquee-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}
.marquee-bar {
    overflow: hidden;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
    cursor: default;
    user-select: none;
}
.marquee-bar:hover .marquee-track { animation-play-state: paused; }
.marquee-track {
    display: inline-flex;
    white-space: nowrap;
    animation: marquee-scroll 30s linear infinite;
}
.marquee-track span {
    display: inline-block;
    padding: 0 64px;
    font-size: 0.85rem;
    color: var(--text2);
}

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15,17,23,0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    transition: color var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
}
.site-logo:hover { color: var(--primary); }
.site-logo svg { width: 22px; height: 22px; color: var(--primary); }
.site-logo-img { height: 26px; width: 26px; object-fit: contain; }
.header-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text2);
    background: var(--bg3);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}
.user-badge svg { width: 16px; height: 16px; }

/* ===== Main Content ===== */
.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg3); color: var(--text); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg3);
    color: var(--text2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-icon-danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.search-wrap {
    display: flex;
    align-items: center;
}
.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition);
}
.search-input-wrap:focus-within {
    border-color: var(--primary);
}
.search-input-wrap input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.9rem;
    padding: 7px 10px;
    width: 200px;
}
.search-input-wrap input::placeholder { color: var(--text3); }
.search-clear {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 10px;
    line-height: 1;
    transition: color var(--transition);
}
.search-clear:hover { color: var(--text); }

/* ===== Items Grid ===== */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}
.item-card {
    position: relative;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
    overflow: hidden;
}
.item-card:hover {
    border-color: var(--primary);
    background: var(--bg3);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.item-card-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.item-card-icon svg { width: 22px; height: 22px; }
.item-card-body { flex: 1; min-width: 0; }
.item-card-body h3 {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.item-date { font-size: 0.78rem; color: var(--text3); }
.item-size { font-size: 0.78rem; color: var(--text3); }
.item-views { font-size: 0.78rem; color: var(--text3); }
.item-updated { font-size: 0.78rem; color: var(--text3); }
@keyframes hot-pulse {
    0%   { box-shadow: 0 0 6px 0px rgba(255,69,0,0.7), 0 2px 8px rgba(255,69,0,0.4); background-size: 100%; }
    50%  { box-shadow: 0 0 14px 4px rgba(255,140,0,0.8), 0 2px 12px rgba(255,69,0,0.6); background-size: 200%; }
    100% { box-shadow: 0 0 6px 0px rgba(255,69,0,0.7), 0 2px 8px rgba(255,69,0,0.4); background-size: 100%; }
}
@keyframes hot-shimmer {
    0%   { background-position: -100% center; }
    100% { background-position: 200% center; }
}
.item-hot-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    background: linear-gradient(100deg, #ff4500 0%, #ff8c00 40%, #ffcc00 55%, #ff8c00 70%, #ff4500 100%);
    background-size: 250%;
    background-position: -100% center;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: 0.06em;
    pointer-events: none;
    z-index: 2;
    animation: hot-pulse 2s ease-in-out infinite, hot-shimmer 2.5s linear infinite;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.btn-hot-active {
    background: linear-gradient(135deg, #ff4500, #ff8c00);
    color: #fff;
    border: none;
}
.btn-hot-active:hover {
    background: linear-gradient(135deg, #e03e00, #e07a00);
    color: #fff;
}
.item-lock-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #f59e0b;
    background: rgba(245,158,11,0.08);
    border-top: 1px solid rgba(245,158,11,0.2);
    padding: 5px 8px;
}
.item-lock-badge svg { width: 11px; height: 11px; }
.item-card:has(.item-lock-badge) { padding-bottom: 32px; }
.item-card:has(.item-hot-badge) .item-card-body h3 { padding-right: 52px; }

/* ===== Drag Handle ===== */
.drag-handle {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    color: var(--text2);
    cursor: grab;
    padding: 6px 4px;
    border-radius: 6px;
    opacity: 0.45;
    transition: opacity var(--transition), color var(--transition), background var(--transition);
    z-index: 2;
    display: flex;
    align-items: center;
}
.drag-handle:active { cursor: grabbing; }
.item-card:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: var(--text); background: var(--bg3); }

/* shift card content right when logged in to make room for handle */
.item-card:has(.drag-handle) { padding-left: 36px; }

/* Sortable states */
.card-ghost  { opacity: 0.35; background: var(--bg3); border-color: var(--primary); }
.card-chosen { box-shadow: 0 8px 32px rgba(0,0,0,0.5); border-color: var(--primary); }
.card-drag   { opacity: 0.95; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text3);
}
.empty-state svg {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
}
.empty-state p { font-size: 1rem; margin-bottom: 20px; }

/* ===== Item Detail Page ===== */
.breadcrumb {
    margin-bottom: 20px;
}
.breadcrumb a {
    color: var(--text2);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition);
}
.breadcrumb a:hover { color: var(--primary); }

.item-header {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 24px;
}
.item-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.item-title-row h1 { font-size: 1.6rem; font-weight: 700; }
.item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 0.83rem;
    color: var(--text3);
}
.item-dates {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}
.badge-lock {
    background: rgba(251,191,36,0.1);
    color: #fbbf24;
    border: 1px solid rgba(251,191,36,0.3);
}
.badge-lock svg { width: 12px; height: 12px; }

/* ===== Item Tags ===== */
.item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 2px;
}
.item-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
}
.item-tag-text  { background: rgba(99,102,241,0.15); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }
.item-tag-image { background: rgba(34,197,94,0.12);  color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.item-tag-video { background: rgba(251,191,36,0.1);  color: #fde68a; border: 1px solid rgba(251,191,36,0.25); }
.btn-tag-edit {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    transition: color var(--transition);
}
.btn-tag-edit:hover { color: var(--text); }
.tag-checkboxes {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.tag-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text2);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.tag-checkbox:hover { border-color: var(--primary); color: var(--text); }
.tag-checkbox input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

/* ===== Content Area ===== */
.content-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 24px;
}
.content-block {
    animation: fadeIn 0.3s ease;
}
.content-block[data-type="text"] {
    width: 100%;
}
.content-block[data-type="image"],
.content-block[data-type="video"] {
    width: 160px;
    flex-shrink: 0;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.content-text {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    position: relative;
}
.content-text-body {
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}
/* text block controls (hover) */
.content-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity var(--transition);
}
.content-text:hover .content-controls { opacity: 1; }

/* media block */
.content-media {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.media-thumb-btn {
    display: block;
    width: 160px;
    height: 160px;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.media-thumb {
    width: 160px;
    height: 160px;
    display: block;
    object-fit: cover;
    transition: opacity var(--transition);
}
.media-thumb-btn:hover .media-thumb { opacity: 0.85; }

/* hover overlay for name + controls */
.media-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    gap: 4px;
    background: linear-gradient(transparent, rgba(0,0,0,0.72));
    opacity: 0;
    transition: opacity var(--transition);
}
.content-media:hover .media-footer { opacity: 1; }
.media-name {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.85);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.media-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.video-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    background: #000;
    width: 160px;
    height: 160px;
    border: none;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
}
.video-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}
.video-play-btn {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    transition: background var(--transition), transform var(--transition);
}
.video-thumb:hover .video-play-btn {
    background: rgba(0,0,0,0.3);
    transform: scale(1.08);
}
.video-play-btn svg {
    width: 20px;
    height: 20px;
    color: #fff;
    margin-left: 3px;
}

/* ===== Active Button State ===== */
.btn-active { background: var(--primary-light) !important; color: var(--primary) !important; border-color: var(--primary) !important; }

.content-block { position: relative; }

.empty-content {
    text-align: center;
    padding: 60px 20px;
    color: var(--text3);
    background: var(--bg2);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-content svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ===== Action Bar (top of content) ===== */
.action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}



/* ===== Password Gate ===== */
.password-gate {
    display: flex;
    justify-content: center;
    padding: 60px 20px;
}
.password-gate-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}
.password-gate-card svg {
    width: 56px;
    height: 56px;
    color: var(--text3);
    margin-bottom: 16px;
}
.password-gate-card h3 { font-size: 1.2rem; margin-bottom: 8px; }
.password-gate-card p { color: var(--text3); font-size: 0.9rem; margin-bottom: 24px; }
.password-gate-form { text-align: left; }

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
}
.modal-overlay-top {
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayIn 0.15s ease;
}
@keyframes overlayIn { from { opacity:0; } to { opacity:1; } }

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 480px;
    animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 640px; }
@keyframes modalIn { from { opacity:0; transform:scale(0.95) translateY(-10px); } to { opacity:1; transform:none; } }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 1.4rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all var(--transition);
    line-height: 1;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-group label small { color: var(--text3); font-weight: 400; }
input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 10px 14px;
    font-size: 0.925rem;
    font-family: var(--font);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    resize: vertical;
}
input:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
input::placeholder, textarea::placeholder { color: var(--text3); }

/* ===== Alerts ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 14px;
}
.alert-error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
}
.alert-success {
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.3);
    color: #86efac;
}

/* ===== Auth Page ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.12) 0%, transparent 60%), var(--bg);
}
.auth-container { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    box-shadow: var(--shadow);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
.auth-logo img { height: 60px; width: 60px; object-fit: contain; }
.auth-card h1 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text3);
    font-size: 0.875rem;
    margin-bottom: 24px;
}
.auth-form { margin-top: 20px; }
.auth-back {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--text3);
    font-size: 0.875rem;
    text-decoration: none;
    transition: color var(--transition);
}
.auth-back:hover { color: var(--primary); }

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayIn 0.15s ease;
}
.lightbox-content {
    position: relative;
    width: 100%;
    max-width: min(90vw, 1200px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    object-fit: contain;
}
.lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 2001;
    line-height: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }
.lightbox-footer {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 10px;
}
.lightbox-caption {
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lightbox-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.lightbox-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.lightbox-size, .lightbox-dl-count {
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
}
.lightbox-counter {
    color: rgba(255,255,255,0.5);
    font-size: 0.78rem;
}
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 2.2rem;
    width: 48px;
    height: 72px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    z-index: 2001;
    user-select: none;
    line-height: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.22); }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
@media (max-width: 640px) {
    .lightbox-nav { width: 36px; height: 56px; font-size: 1.7rem; }
    .lightbox-prev { left: 4px; }
    .lightbox-next { right: 4px; }
}

/* ===== Download Stats ===== */
.dl-stats-list { display: flex; flex-direction: column; }
.dl-stats-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
.dl-stats-row:last-child { border-bottom: none; }
.dl-stats-type {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}
.dl-stats-type-image { background: rgba(34,197,94,0.12); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.dl-stats-type-video { background: rgba(251,191,36,0.1); color: #fde68a; border: 1px solid rgba(251,191,36,0.25); }
.dl-stats-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dl-stats-name { font-size: 0.88rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-stats-item { font-size: 0.78rem; color: var(--text3); }
.dl-stats-count { font-size: 0.88rem; font-weight: 600; color: var(--primary); flex-shrink: 0; }
.lightbox-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.75);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.2);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.lightbox-download svg { width: 14px; height: 14px; }
.lightbox-download:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* ===== Upload Progress ===== */
/* ===== Back to Top ===== */
#backToTop {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease, background var(--transition), color var(--transition);
    z-index: 900;
    box-shadow: var(--shadow-sm);
}
#backToTop svg { width: 20px; height: 20px; }
#backToTop.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#backToTop:hover {
    background: var(--bg3);
    color: var(--text);
}

.upload-progress {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-progress-inner {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    width: min(360px, 90vw);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.upload-progress-meta {
    font-size: 0.82rem;
    color: var(--text2);
}
.upload-progress-filename {
    font-size: 0.9rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.upload-progress-bar-wrap {
    flex: 1;
    background: var(--bg3);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
}
.upload-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 100px;
    width: 0%;
    transition: width 0.15s ease;
}
.upload-progress-pct {
    font-size: 0.82rem;
    color: var(--text2);
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* ===== Password Modal helpers ===== */
.current-password-info {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 16px;
}
.current-password-info p { font-size: 0.875rem; color: var(--text2); margin-bottom: 10px; }
.current-pw-display {
    display: inline-block;
    margin-left: 10px;
    font-size: 0.875rem;
    color: var(--success);
    font-family: monospace;
}
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===== User Menu Dropdown ===== */
.user-menu { position: relative; }
.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text2);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.user-menu-btn:hover,
.user-menu-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.user-menu-btn svg { width: 18px; height: 18px; }
.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 168px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
    animation: menuIn 0.14s ease;
}
.user-menu-dropdown.open { display: block; }
@keyframes menuIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 0.875rem;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    text-align: left;
    box-sizing: border-box;
}
.user-menu-item:hover { background: var(--bg3); color: var(--text); }
.user-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.user-menu-item-danger { color: #f87171; }
.user-menu-item-danger:hover { background: rgba(239,68,68,0.08); color: var(--danger); }
.user-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== User Management Modal ===== */
.modal-wide { max-width: 520px; }
.user-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
    max-height: 260px;
    overflow-y: auto;
}
.user-list-empty { color: var(--text3); font-size: 0.9rem; text-align: center; padding: 16px 0; margin: 0; }
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    gap: 10px;
}
.user-row-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-row-name { font-weight: 500; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row-role {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}
.role-admin { background: rgba(99,102,241,0.12); color: #818cf8; }
.role-user  { background: rgba(100,116,139,0.12); color: var(--text3); }
.scope-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}
.scope-all { background: rgba(34,197,94,0.12); color: #4ade80; }
.scope-own { background: rgba(234,179,8,0.12); color: #facc15; }
.radio-group { display: flex; flex-direction: column; gap: 12px; }
.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.radio-label:hover { border-color: var(--primary); background: var(--primary-light); }
.radio-label input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.radio-label-text { display: flex; flex-direction: column; gap: 4px; }
.radio-label-title { font-weight: 500; font-size: 0.9rem; }
.radio-label-desc { font-size: 0.8rem; color: var(--text3); line-height: 1.4; }
.user-add-form h4 { font-size: 0.9rem; font-weight: 600; color: var(--text2); margin: 0 0 12px; }
.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 120px; margin-bottom: 0; }
.btn-danger {
    background: transparent;
    border: 1px solid rgba(239,68,68,0.4);
    color: #f87171;
    padding: 4px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.btn-danger:hover { background: rgba(239,68,68,0.1); }

/* ===== User Detail Log ===== */
.log-user-info {
    display: flex;
    gap: 20px;
    padding: 14px 20px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text2);
    flex-wrap: wrap;
}
.log-user-info strong { color: var(--text); }
.log-list {
    max-height: 420px;
    overflow-y: auto;
}
.log-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.log-row:last-child { border-bottom: none; }
.log-row:hover { background: var(--bg3); }
.log-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.log-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-desc { font-size: 0.875rem; color: var(--text); }
.log-meta { font-size: 0.78rem; color: var(--text3); }
.btn-outline-xs {
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}
.btn-outline-xs:hover { background: var(--bg3); color: var(--text); border-color: var(--primary); }

/* ===== Light Theme (太陽模式) ===== */
[data-theme="light"] {
    --bg: #f4f6fb;
    --bg2: #ffffff;
    --bg3: #eef0f6;
    --border: #d5d9ea;
    --text: #1a1d2e;
    --text2: #4a5272;
    --text3: #7c83a2;
    --shadow: 0 4px 24px rgba(0,0,0,0.09);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}
[data-theme="light"] .site-header {
    background: rgba(244,246,251,0.92);
}
[data-theme="light"] .item-tag-text {
    background: rgba(99,102,241,0.1); color: #4338ca; border-color: rgba(99,102,241,0.25);
}
[data-theme="light"] .item-tag-image {
    background: rgba(22,163,74,0.1); color: #15803d; border-color: rgba(22,163,74,0.25);
}
[data-theme="light"] .item-tag-video {
    background: rgba(180,83,9,0.08); color: #b45309; border-color: rgba(180,83,9,0.2);
}
[data-theme="light"] .badge-lock {
    background: rgba(180,83,9,0.08); color: #b45309; border-color: rgba(180,83,9,0.2);
}
[data-theme="light"] .item-lock-badge {
    color: #b45309; background: rgba(180,83,9,0.06); border-top-color: rgba(180,83,9,0.15);
}
[data-theme="light"] .dl-stats-type-image {
    background: rgba(22,163,74,0.1); color: #15803d; border-color: rgba(22,163,74,0.25);
}
[data-theme="light"] .dl-stats-type-video {
    background: rgba(180,83,9,0.08); color: #b45309; border-color: rgba(180,83,9,0.2);
}
[data-theme="light"] .role-admin {
    background: rgba(99,102,241,0.1); color: #4338ca;
}

/* ===== Layout Menu ===== */
.layout-menu { position: relative; }
.layout-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 148px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
    animation: menuIn 0.14s ease;
}
.layout-menu-dropdown.open { display: block; }
.layout-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 0.875rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    text-align: left;
    box-sizing: border-box;
}
.layout-menu-item:hover { background: var(--bg3); color: var(--text); }
.layout-menu-item.active { color: var(--primary); background: var(--primary-light); }
.layout-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.items-grid.grid-2col {
    grid-template-columns: repeat(2, 1fr);
}

/* ===== Filter Chips ===== */
.filter-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filter-chip {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text2);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
    white-space: nowrap;
}
.filter-chip:hover { border-color: var(--primary); color: var(--text); }
.filter-chip.filter-chip-active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* ===== Stats Modal ===== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}
.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.stat-label { font-size: 0.78rem; color: var(--text3); margin-top: 4px; }
.stats-chart-section { margin-top: 8px; }
.stats-chart-title { font-size: 0.85rem; color: var(--text2); font-weight: 500; margin-bottom: 10px; }
.stats-chart-svg {
    width: 100%;
    height: 140px;
    display: block;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    overflow: visible;
}
.stats-chart-labels { margin-top: 2px; }

/* ===== Orphan Files List ===== */
.orphan-list { max-height: 380px; overflow-y: auto; }
.orphan-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}
.orphan-row:hover { background: var(--bg3); }
.orphan-row:last-child { border-bottom: none; }
.orphan-row input[type="checkbox"] { flex-shrink: 0; accent-color: var(--primary); }
.orphan-name { flex: 1; font-size: 0.82rem; font-family: monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.orphan-size { flex-shrink: 0; font-size: 0.78rem; color: var(--text3); }

/* ===== Password Log Modal ===== */
.pwlog-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    gap: 0;
}
.pwlog-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text2);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}
.pwlog-tab:hover { color: var(--text); }
.pwlog-tab.pwlog-tab-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.pwlog-table-wrap {
    overflow-x: auto;
    max-height: 420px;
    overflow-y: auto;
}
.pwlog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.pwlog-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg2);
    color: var(--text2);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.pwlog-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.pwlog-table tbody tr:hover { background: var(--primary-light); }
.pwlog-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(46,50,80,0.5);
    vertical-align: middle;
}
.pwlog-td-time { color: var(--text3); white-space: nowrap; font-size: 0.8rem; }
.pwlog-td-ip   { font-family: monospace; white-space: nowrap; }
.pwlog-td-pw   { word-break: break-all; font-family: monospace; color: var(--danger); }
.pwlog-empty   { text-align: center; padding: 32px; color: var(--text3); font-size: 0.9rem; }
/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* Items grid: 2 cols on tablet */
    .items-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 640px) {
    /* ── Header ── */
    .header-inner { padding: 0 14px; gap: 8px; }
    .header-nav { gap: 6px; }

    /* ── Main ── */
    .main-content { padding: 18px 14px 60px; }

    /* ── Items grid: single col ── */
    .items-grid { grid-template-columns: 1fr; gap: 10px; }
    .items-grid.grid-2col { grid-template-columns: repeat(2, 1fr); }

    /* ── Page header ── */
    .page-header { margin-bottom: 18px; }
    .page-header h2 { font-size: 1.2rem; }

    /* ── Item detail header ── */
    .item-header { padding: 16px; }
    .item-title-row { flex-direction: column; gap: 12px; }
    .item-title-row h1 { font-size: 1.3rem; }
    .item-actions { width: 100%; flex-wrap: wrap; }
    .item-actions .btn { flex: 1; justify-content: center; min-width: 80px; }

    /* ── Action bar (文字/圖片/影片 buttons) ── */
    .action-bar { gap: 8px; flex-wrap: wrap; }
    .action-bar .btn { flex: 1; justify-content: center; }

    /* ── Media blocks ── */
    .content-block[data-type="image"], .content-block[data-type="video"] { width: calc(50% - 4px); }
    .content-media { width: 100%; height: 0; padding-bottom: 100%; position: relative; }
    .media-thumb-btn, .video-thumb { position: absolute; inset: 0; width: 100%; height: 100%; }
    .media-thumb { width: 100%; height: 100%; }

    /* ── Password gate ── */
    .password-gate { padding: 32px 0; }
    .password-gate-card { padding: 28px 20px; }

    /* ── Modals ── */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal, .modal-wide {
        max-width: 100%;
        border-radius: var(--radius) var(--radius) 0 0;
        max-height: 90svh;
        overflow-y: auto;
    }
    .modal-body { padding: 16px; }
    .modal-header, .modal-footer { padding: 14px 16px; }

    /* ── User management form ── */
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: unset; width: 100%; }
    .form-row > .btn { width: 100%; justify-content: center; }

    /* ── Auth page ── */
    .auth-card { padding: 24px 18px; }
    .auth-logo img { height: 48px; width: 48px; }
    .auth-card h1 { font-size: 1.3rem; }

    /* ── Breadcrumb ── */
    .breadcrumb { margin-bottom: 14px; }

    /* ── Stats ── */
    .stats-cards { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 1.25rem; }
}
