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

:root {
  --bg: #0e0e0e;
  --bg2: #161616;
  --bg3: #1f1f1f;
  --border: #2a2a2a;
  --accent: #c8a96e;
  --accent2: #e8c990;
  --text: #e8e8e8;
  --text2: #999;
  --text3: #666;
  --radius: 8px;
  --font: 'Noto Sans TC', 'Segoe UI', sans-serif;
  --font-title: 'Playfair Display', 'Noto Serif TC', serif;
}

html { scroll-behavior: smooth; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

img { max-width: 100%; display: block; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(14, 14, 14, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.navbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.navbar-brand {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.navbar-links { display: flex; gap: 32px; }
.navbar-links a {
  color: var(--text2);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.navbar-links a:hover, .navbar-links a.active { color: var(--accent); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70vh; text-align: center; padding: 80px 24px;
  background: radial-gradient(ellipse at 50% 60%, rgba(200,169,110,0.08) 0%, transparent 70%);
}
.hero-title {
  font-family: var(--font-title);
  font-size: clamp(2.5rem, 6vw, 5rem);
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}
.hero-sub {
  font-size: 1.1rem; color: var(--text2); margin-bottom: 48px;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.hero-actions { display: flex; gap: 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s; border: none; font-family: var(--font);
}
.btn-primary { background: var(--accent); color: #0e0e0e; }
.btn-primary:hover { background: var(--accent2); color: #0e0e0e; }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent); color: #0e0e0e; }
.btn-ghost { background: var(--bg3); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 6px 16px; font-size: 0.85rem; }

/* ── Section ──────────────────────────────────────────────────────────────── */
.section { padding: 80px 0; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 48px;
}
.section-title {
  font-family: var(--font-title);
  font-size: 2rem; color: var(--accent);
}
.section-title::after {
  content: ''; display: block; width: 48px; height: 2px;
  background: var(--accent); margin-top: 8px;
}

/* ── Tag Filter ───────────────────────────────────────────────────────────── */
.tag-filter { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 40px; }
.tag-chip {
  padding: 6px 16px; border-radius: 999px; font-size: 0.85rem; cursor: pointer;
  background: var(--bg3); color: var(--text2); border: 1px solid var(--border);
  transition: all 0.2s;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent); color: #0e0e0e; border-color: var(--accent); }

/* ── Artwork Grid ─────────────────────────────────────────────────────────── */
.artwork-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.artwork-card {
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
}
.artwork-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.artwork-card-img {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; display: block;
  background: var(--bg3);
}
.artwork-card-img-placeholder {
  width: 100%; aspect-ratio: 1;
  background: var(--bg3); display: flex; align-items: center;
  justify-content: center; color: var(--text3);
}
.artwork-card-body { padding: 14px 16px; }
.artwork-card-title { font-size: 0.95rem; font-weight: 500; margin-bottom: 6px; }
.artwork-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-badge {
  padding: 2px 10px; border-radius: 999px; font-size: 0.75rem;
  background: rgba(200,169,110,0.15); color: var(--accent); border: 1px solid rgba(200,169,110,0.3);
}

/* ── Comics Grid ──────────────────────────────────────────────────────────── */
.comics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}
.comic-card {
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}
.comic-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.comic-cover {
  width: 100%; aspect-ratio: 2/3;
  object-fit: cover; background: var(--bg3);
}
.comic-cover-placeholder {
  width: 100%; aspect-ratio: 2/3;
  background: var(--bg3); display: flex; align-items: center;
  justify-content: center; color: var(--text3); font-size: 3rem;
}
.comic-body { padding: 14px 16px; }
.comic-title { font-size: 0.95rem; font-weight: 500; margin-bottom: 4px; }
.comic-meta { font-size: 0.8rem; color: var(--text2); margin-bottom: 12px; }
.comic-actions { display: flex; gap: 8px; }

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.95);
  align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 20px; right: 28px;
  font-size: 2rem; color: var(--text2); cursor: pointer; background: none; border: none;
  transition: color 0.2s;
}
.lightbox-close:hover { color: var(--text); }
.lightbox-info {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  text-align: center;
}
.lightbox-title { font-size: 1.1rem; color: var(--text); }
.lightbox-tags { margin-top: 6px; display: flex; gap: 6px; justify-content: center; }

/* ── Comic Reader ─────────────────────────────────────────────────────────── */
.reader-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14,14,14,0.97); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; gap: 16px;
}
.reader-title { font-size: 1rem; font-weight: 500; flex: 1; }
.reader-pages {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 0; gap: 4px;
}
.reader-page { width: 100%; max-width: 900px; display: block; }
.reader-loading {
  display: flex; align-items: center; justify-content: center;
  height: 60vh; font-size: 1.1rem; color: var(--text2);
}

/* ── Admin ────────────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 24px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  padding: 0 20px 24px; font-family: var(--font-title);
  font-size: 1.2rem; color: var(--accent); border-bottom: 1px solid var(--border);
}
.sidebar-nav { padding: 16px 0; }
.sidebar-nav a {
  display: block; padding: 10px 20px; color: var(--text2);
  font-size: 0.9rem; transition: all 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--bg3); color: var(--accent);
  border-left: 3px solid var(--accent); padding-left: 17px;
}
.admin-main { flex: 1; padding: 40px 48px; overflow-y: auto; }
.admin-page-title {
  font-family: var(--font-title); font-size: 1.8rem;
  color: var(--accent); margin-bottom: 32px;
}

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--text2); }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: 0.95rem;
  transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.8rem; color: var(--text3); margin-top: 4px; }

/* ── Upload Zone ──────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg3);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: rgba(200,169,110,0.05);
}
.upload-zone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone-text { color: var(--text2); font-size: 0.95rem; }
.upload-preview {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 12px;
}
.upload-preview-item {
  position: relative; width: 100px; height: 100px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
}
.upload-preview-item img { width: 100%; height: 100%; object-fit: cover; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 12px 16px; color: var(--text2); border-bottom: 1px solid var(--border); font-weight: 500; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg3); }
.td-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; top: 80px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 0.9rem; min-width: 240px; max-width: 380px;
  animation: slideIn 0.3s ease;
}
.toast-success { background: #1a4a1a; border: 1px solid #2d7a2d; color: #7dcc7d; }
.toast-error { background: #4a1a1a; border: 1px solid #7a2d2d; color: #cc7d7d; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
}
.login-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 48px 40px; width: 380px;
}
.login-title {
  font-family: var(--font-title); font-size: 1.8rem;
  color: var(--accent); text-align: center; margin-bottom: 8px;
}
.login-sub { text-align: center; color: var(--text2); font-size: 0.9rem; margin-bottom: 32px; }

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 24px; color: var(--text3); text-align: center;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border); padding: 32px 24px;
  text-align: center; color: var(--text3); font-size: 0.85rem;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar-links { gap: 16px; }
  .admin-sidebar { display: none; }
  .admin-main { padding: 24px 16px; }
  .artwork-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .comics-grid { grid-template-columns: repeat(2, 1fr); }
}
