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

:root {
  --primary: #FF2442;
  --primary-light: #fff0f2;
  --text: #1a1a1a;
  --text-muted: #888;
  --border: #e8e8e8;
  --bg: #f5f5f7;
  --white: #fff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ─── Header ─────────────────────────────── */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.header-logo {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.header-title { font-size: 17px; font-weight: 700; color: var(--text); }

/* ─── Main container ──────────────────────── */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* ─── Card ────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ─── Claim hero (before claim) ──────────── */
.claim-hero {
  text-align: center;
  padding: 40px 20px;
}
.claim-hero .emoji { font-size: 56px; margin-bottom: 12px; }
.claim-hero h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.claim-hero p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ─── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 50px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-copy {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 20px;
  border: none;
}
.btn-copy.copied { background: #e8f5e9; color: #388e3c; }
.btn-block { width: 100%; }

/* ─── Content card ──────────────────────── */
.content-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
  font-weight: 600;
}
.content-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.content-text { flex: 1; font-size: 15px; line-height: 1.7; word-break: break-all; }
.title-text { font-size: 17px; font-weight: 700; }

/* ─── Images grid ───────────────────────── */
.images-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.images-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .15s;
}
.images-grid img:active { opacity: .8; }

/* ─── Notice / badge ────────────────────── */
.notice {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 16px;
}
.badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ─── Admin layout ──────────────────────── */
.admin-body { background: #f0f2f5; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card .logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; display: block; }
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.form-group input:focus { border-color: var(--primary); }

.error-msg { color: var(--primary); font-size: 13px; margin: -8px 0 12px; min-height: 20px; }

/* ─── Admin main ────────────────────────── */
.admin-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 100;
}
.admin-nav .brand {
  font-size: 16px; font-weight: 700;
  padding: 16px 0;
  margin-right: 24px;
  color: var(--primary);
  white-space: nowrap;
}
.nav-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-tab {
  padding: 16px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.nav-logout {
  margin-left: auto;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 20px;
  transition: background .15s;
  white-space: nowrap;
}
.nav-logout:hover { background: var(--bg); color: var(--text); }

.admin-container { max-width: 760px; margin: 0 auto; padding: 28px 16px 60px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.section-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.section-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

/* ─── Upload zone ───────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone .icon { font-size: 40px; margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); font-size: 14px; }
.upload-zone strong { color: var(--primary); }

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 14px;
}
.file-info .file-icon { font-size: 24px; }

.result-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 14px;
  display: none;
}
.result-box.success { background: #e8f5e9; color: #2e7d32; }
.result-box.error { background: #fce4ec; color: #c62828; }

/* ─── Image upload grid ──────────────────── */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.preview-item { position: relative; }
.preview-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
}
.preview-item img.uploading { opacity: .5; }
.preview-item img.done { border-color: #4caf50; }

/* ─── Stats ──────────────────────────────── */
.stats-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.stats-tab {
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  transition: all .15s;
}
.stats-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stats-table th { font-weight: 600; color: var(--text-muted); background: var(--bg); }
.stats-table tr:last-child td { border-bottom: none; }
.stats-table .count-cell { font-weight: 700; color: var(--primary); font-size: 16px; }
.stats-table tfoot td { font-weight: 700; background: var(--bg); }

.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }

/* ─── Loading spinner ───────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Overview cards ────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 16px;
  text-align: center;
}
.stat-number {
  font-size: 40px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 10px;
}
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── Delete modal ───────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--white);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ─── Content list table ─────────────────── */
.content-list-table { width: 100%; border-collapse: collapse; }
.content-list-table th,
.content-list-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.content-list-table th { background: var(--bg); font-weight: 600; color: var(--text-muted); font-size: 12px; }
.content-list-table tr:last-child td { border-bottom: none; }
.badge-claimed {
  background: #e8f5e9; color: #2e7d32;
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.badge-unclaimed {
  background: var(--bg); color: var(--text-muted);
  padding: 3px 10px; border-radius: 12px; font-size: 12px;
}

/* ─── Admin image library ────────────────── */
.admin-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.admin-image-item img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px; border: 1.5px solid var(--border);
  cursor: pointer; transition: opacity .15s;
}
.admin-image-item img:hover { opacity: .85; }
.img-name {
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Danger button ──────────────────────── */
.btn-danger {
  background: #fff0f0; color: #c62828;
  border: 1.5px solid #ffcdd2; border-radius: 50px;
}
.btn-danger:hover { background: #ffcdd2; }

/* ─── Body formatted paragraphs ─────────── */
.content-body-formatted { line-height: 1.85; }
.content-body-formatted p {
  margin: 0 0 1em 0;
  line-height: 1.85;
  word-break: break-all;
}
.content-body-formatted p:last-child { margin-bottom: 0; }

/* ─── Responsive ─────────────────────────── */
@media (max-width: 480px) {
  .overview-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-number { font-size: 28px; }
  .images-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .nav-tab { padding: 14px 12px; font-size: 13px; }
}
