:root {
  --bg: #fbf7f2;
  --card: #ffffff;
  --ink: #2b2320;
  --ink-soft: #6b5f57;
  --accent: #e8823a;
  --accent-dark: #c3641f;
  --line: #ece3d8;
  --danger: #c0392b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 10px;
}

.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-link { font-weight: 600; }
.nav-link.active { text-decoration: underline; }
.nav-user { color: var(--ink-soft); font-size: .9rem; }

.admin-body { background: #22201e; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: #2f2b27; border-bottom: 1px solid #423c36;
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap; gap: 10px;
}
.admin-brand { font-weight: 700; font-size: 1.05rem; color: #f3ece3; }
.admin-topbar .nav-link, .admin-topbar .nav-user, .admin-topbar .link-btn { color: #d8cfc4; }
.admin-topbar .nav-link.active { color: var(--accent); text-decoration: none; font-weight: 700; }
.admin-body .container { background: var(--bg); border-radius: var(--radius); margin-top: 20px; padding: 24px 20px; }

.container { max-width: 880px; margin: 0 auto; padding: 20px 16px 60px; }

.hero { text-align: center; padding: 24px 0 8px; }
.hero h1 { margin: 0 0 6px; font-size: 1.8rem; }
.hero p { color: var(--ink-soft); margin: 0; }

.day-block { margin-top: 34px; }
.day-heading {
  font-size: 1.15rem;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 14px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.post-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  color: var(--ink);
  display: block;
  transition: transform .15s ease, box-shadow .15s ease;
}
.post-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); text-decoration: none; }

.post-cover { aspect-ratio: 4/3; background: #eee; position: relative; overflow: hidden; }
.post-cover img, .post-cover video { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-cover-empty { width: 100%; height: 100%; background: linear-gradient(135deg,#f1e6d8,#e8d3ba); }
.video-badge {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.5); pointer-events: none;
}

.post-card-body { padding: 10px 12px; }
.post-caption { margin: 0 0 6px; font-size: .92rem; color: var(--ink); max-height: 2.8em; overflow: hidden; }
.post-meta { margin: 0; font-size: .78rem; color: var(--ink-soft); }

.empty-hint { color: var(--ink-soft); font-style: italic; }

.back-link { display: inline-block; margin-bottom: 14px; }

.post-detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.post-caption-full { white-space: pre-wrap; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 16px 0; }
.gallery-item img, .gallery-item video { width: 100%; border-radius: 10px; display: block; background: #000; }

.share-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.share-label { font-weight: 600; }
.share-url-input { flex: 1 1 240px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #faf6f0; }
.qr-panel { margin-top: 12px; text-align: center; }
.qr-panel img { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr-panel .hint { color: var(--ink-soft); font-size: .85rem; }

.btn {
  display: inline-block; padding: 9px 18px; background: var(--accent); color: #fff !important;
  border: none; border-radius: 999px; cursor: pointer; font-size: .95rem; font-weight: 600;
  text-decoration: none !important;
}
.btn:hover { background: var(--accent-dark); }
.btn-block { width: 100%; }
.btn-small { padding: 7px 14px; font-size: .85rem; }

.link-btn { background: none; border: none; color: var(--accent-dark); cursor: pointer; padding: 0; font: inherit; }
.link-btn.danger { color: var(--danger); }
.inline-form { display: inline; }

.form-card { max-width: 420px; margin: 20px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.form-card h1 { margin-top: 0; font-size: 1.3rem; }
.form-card label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--ink-soft); }
.form-card input[type=text], .form-card input[type=password], .form-card input[type=file], .form-card select, .form-card textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink);
}
.form-card textarea { min-height: 90px; resize: vertical; }
.form-footer { text-align: center; margin-top: 10px; font-size: .9rem; }
.hint { color: var(--ink-soft); font-size: .82rem; }

.flash-stack { margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: .92rem; }
.flash-error { background: #fbe4e1; color: var(--danger); }
.flash-success { background: #e5f3e3; color: #2f7a3d; }

.comments { margin-top: 30px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.comment-form textarea { padding: 10px; border: 1px solid var(--line); border-radius: 8px; min-height: 70px; font-family: inherit; }
.comment-list { list-style: none; padding: 0; margin: 0; }
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment-author { font-weight: 700; margin-right: 8px; }
.comment-time { color: var(--ink-soft); font-size: .78rem; }
.comment-body { margin: 6px 0 0; white-space: pre-wrap; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: .9rem; }
.admin-table th { background: #f4ece1; }
.role-badge { padding: 2px 8px; border-radius: 999px; font-size: .78rem; }
.role-viewer { background: #eee; }
.role-uploader { background: #fde2c8; }
.role-admin { background: #f5c9c9; }

.error-page { text-align: center; padding: 60px 0; }
.error-page h1 { font-size: 3rem; margin-bottom: 8px; }

.footer { text-align: center; color: var(--ink-soft); font-size: .8rem; padding: 20px 0 40px; }

@media (max-width: 480px) {
  .container { padding: 14px 12px 50px; }
  .hero h1 { font-size: 1.5rem; }
}
