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

/* 主题变量 */
:root, [data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-card: #1a1a1a;
  --bg-input: #0f0f0f;
  --text: #e0e0e0;
  --text-heading: #fff;
  --text-muted: #888;
  --text-dim: #666;
  --border: #333;
  --accent: #4a9eff;
  --accent-hover: #3a8eef;
  --header-bg: rgba(15,15,15,0.95);
  --header-border: #222;
  --tag-bg: #1e1e1e;
  --tag-border: #333;
  --tag-text: #aaa;
  --tag-hover-bg: #2a2a2a;
  --btn-edit-bg: #2a4a6a;
  --btn-edit-text: #8af;
  --btn-delete-bg: #4a2a2a;
  --btn-delete-text: #f88;
  --error: #ff6b6b;
  --accent-glow: rgba(74,158,255,0.05);
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-card: #fff;
  --bg-input: #f9f9f9;
  --text: #333;
  --text-heading: #1a1a1a;
  --text-muted: #888;
  --text-dim: #aaa;
  --border: #ddd;
  --accent: #2980b9;
  --accent-hover: #21618c;
  --header-bg: rgba(255,255,255,0.95);
  --header-border: #e0e0e0;
  --tag-bg: #e8e8e8;
  --tag-border: #d0d0d0;
  --tag-text: #666;
  --tag-hover-bg: #d8d8d8;
  --btn-edit-bg: #d6e4f0;
  --btn-edit-text: #2980b9;
  --btn-delete-bg: #fde0e0;
  --btn-delete-text: #c0392b;
  --error: #e74c3c;
  --accent-glow: rgba(41,128,185,0.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); transition: background 0.2s, color 0.2s; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }

/* Header */
.header { padding: 20px; text-align: center; position: sticky; top: 0; background: var(--header-bg); backdrop-filter: blur(10px); z-index: 100; border-bottom: 1px solid var(--header-border); }
.logo { font-size: 28px; font-weight: 700; color: var(--text-heading); letter-spacing: 2px; }
.subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.back-link { float: left; color: var(--accent); font-size: 14px; line-height: 28px; }

/* Grid 网格 */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px; }
@media (max-width: 1200px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(1, 1fr); } }

.grid-item { cursor: pointer; overflow: hidden; border-radius: 8px; aspect-ratio: 1; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.grid-item:hover img { transform: scale(1.05); }

.loader { text-align: center; padding: 40px; color: var(--text-dim); }

/* Detail page */
.detail-container { max-width: 900px; margin: 0 auto; padding: 24px; }
.detail-image { width: 100%; border-radius: 12px; margin-bottom: 20px; }
.detail-name { font-size: 22px; font-weight: 600; color: var(--text-heading); margin-bottom: 16px; }
.detail-actions { margin-bottom: 20px; }
.download-btn { display: inline-block; padding: 12px 32px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: background 0.2s; }
.download-btn:hover { background: var(--accent-hover); }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-link { padding: 6px 16px; background: var(--tag-bg); border: 1px solid var(--tag-border); border-radius: 20px; color: var(--tag-text); font-size: 14px; cursor: pointer; transition: all 0.2s; }
.tag-link:hover { background: var(--tag-hover-bg); color: var(--accent); }

/* Login page */
.login-container { max-width: 360px; margin: 80px auto; text-align: center; padding: 32px; background: var(--bg-card); border-radius: 12px; }
.login-container h2 { color: var(--text-heading); margin-bottom: 24px; }
.login-container input { width: 100%; padding: 12px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text-heading); font-size: 16px; margin-bottom: 16px; }
.login-container button { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; }
.login-container button:hover { background: var(--accent-hover); }
.msg { color: var(--error); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* Admin page */
.admin-header { display: flex; justify-content: space-between; align-items: center; }
.admin-header .back-link { float: none; }
.upload-section { max-width: 700px; margin: 24px auto; padding: 0 16px; }
.drop-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 60px 20px; text-align: center; color: var(--text-dim); transition: all 0.3s; cursor: pointer; }
.drop-zone.dragover { border-color: var(--accent); background: var(--accent-glow); color: var(--accent); }
.drop-zone p { margin-bottom: 4px; }
.drop-zone .small { font-size: 12px; color: var(--text-muted); }

.upload-pending { background: var(--bg-card); border-radius: 12px; padding: 20px; margin-top: 16px; text-align: center; }
.pending-preview { max-width: 300px; max-height: 200px; border-radius: 8px; margin: 0 auto 16px; }
.upload-pending input { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text-heading); font-size: 14px; margin-bottom: 12px; }
.upload-pending button { padding: 10px 24px; background: var(--accent); color: #fff; border: none; border-radius: 8px; cursor: pointer; margin: 0 4px; }
.upload-pending .btn-cancel { background: var(--border); }

.manage-section { max-width: 900px; margin: 24px auto; padding: 0 16px; }
.manage-section h2 { color: var(--text-heading); margin-bottom: 16px; }
.admin-list { display: flex; flex-direction: column; gap: 12px; }
.admin-item { display: flex; gap: 16px; align-items: center; background: var(--bg-card); border-radius: 8px; padding: 12px; }
.admin-item img { width: 100px; height: 70px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.admin-item-info { flex: 1; }
.admin-item-name { color: var(--text-heading); font-size: 14px; margin-bottom: 4px; }
.admin-item-tags { color: var(--text-muted); font-size: 12px; }
.admin-item-actions { display: flex; gap: 8px; }
.admin-item-actions button { padding: 6px 12px; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-edit { background: var(--btn-edit-bg); color: var(--btn-edit-text); }
.btn-delete { background: var(--btn-delete-bg); color: var(--btn-delete-text); }

/* Admin nav */
.admin-nav { display: flex; justify-content: center; gap: 24px; padding: 0 20px 12px; }
.admin-nav a { color: var(--text-muted); font-size: 14px; padding: 4px 12px; border-radius: 6px; transition: all 0.2s; }
.admin-nav a:hover, .admin-nav a.active { color: var(--accent); background: var(--accent-glow); }

/* Settings page */
.settings-container { max-width: 600px; margin: 24px auto; padding: 0 16px; }
.settings-group { background: var(--bg-card); border-radius: 12px; padding: 24px; margin-bottom: 16px; }
.settings-group h3 { color: var(--text-heading); font-size: 16px; margin-bottom: 16px; }
.theme-options { display: flex; gap: 16px; }
.theme-card { flex: 1; padding: 20px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; text-align: center; transition: all 0.2s; position: relative; }
.theme-card:hover { border-color: var(--accent); }
.theme-card.selected { border-color: var(--accent); background: var(--accent-glow); }
.theme-card .preview { width: 100%; height: 60px; border-radius: 8px; margin-bottom: 12px; display: flex; overflow: hidden; }
.theme-card .preview .half { flex: 1; }
.theme-card .preview .half:first-child { background: #0f0f0f; }
.theme-card .preview .half:last-child { background: #f5f5f5; }
.theme-card.light-preview .preview .half:first-child { background: #f5f5f5; }
.theme-card.light-preview .preview .half:last-child { background: #0f0f0f; }
.theme-card .label { color: var(--text); font-size: 14px; font-weight: 600; }
.theme-card .desc { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.theme-card .check { position: absolute; top: 8px; right: 8px; color: var(--accent); font-size: 18px; display: none; }
.theme-card.selected .check { display: block; }
