*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --radius: 6px;
  --max-w: 760px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

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

/* Layout */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  background: var(--surface);
}
header .inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
header .site-title { font-weight: 700; font-size: 1.1rem; color: var(--text); }
header .site-title:hover { text-decoration: none; }

main {
  max-width: var(--max-w);
  margin: 2rem auto;
  padding: 0 1.5rem;
}

footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* Tags sidebar */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-badge {
  background: #eff6ff;
  color: var(--accent);
  border: 1px solid #bfdbfe;
  border-radius: 99px;
  padding: 0.15rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
}
.tag-badge:hover { background: #dbeafe; text-decoration: none; }

/* Header menu */
.menu-wrap { position: relative; }
.hamburger-btn {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; border-radius: var(--radius);
}
.hamburger-btn:hover { background: var(--bg); }
.hamburger-btn span { display: block; width: 20px; height: 2px; background: var(--text); }
.menu-dropdown {
  position: absolute; top: 44px; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); min-width: 120px; z-index: 20; overflow: hidden;
}
.menu-item {
  display: block; width: 100%; text-align: left; padding: 0.6rem 1rem;
  background: none; border: none; font-size: 0.95rem; color: var(--text); cursor: pointer;
}
.menu-item:hover { background: var(--bg); }

/* Tag popup */
.tag-popup-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 30; padding: 1.5rem;
}
.tag-popup {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.25rem; max-width: 360px; width: 100%; max-height: 70vh; overflow-y: auto;
}
.tag-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; margin-bottom: 0.75rem;
}
.tag-popup-close {
  background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted);
}
.tag-popup-close:hover { color: var(--text); }

/* Post box */
.post-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 0.75rem; height: 128px;
  display: flex; flex-direction: row; align-items: stretch; gap: 1rem;
  overflow: hidden; cursor: pointer;
}
.post-box:hover { border-color: var(--accent); }
.post-box-content {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}
.post-box-thumb {
  flex-shrink: 0; height: 100%; aspect-ratio: 1 / 1;
  object-fit: contain; background: var(--bg); border-radius: var(--radius);
}
.post-box-thumb-wrap {
  flex-shrink: 0; height: 100%; aspect-ratio: 1 / 1; position: relative;
}
.post-box-thumb-wrap .post-box-thumb {
  width: 100%; height: 100%; object-fit: cover; background: #000;
}
.post-box-play-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; line-height: 1; pointer-events: none;
}
.post-box-title { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-box-title a { color: var(--text); }
.post-box-excerpt {
  color: var(--muted); font-size: 0.88rem; line-height: 1.5; margin: 0.3rem 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-box-footer {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: nowrap;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent 100%);
}
.post-box-date { color: var(--muted); font-size: 0.78rem; flex-shrink: 0; }
.tag-badge-sm { font-size: 0.72rem; padding: 0.1rem 0.55rem; flex-shrink: 0; }
.tag-more { color: var(--muted); font-size: 0.75rem; }

/* Post card */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.post-card h2 { font-size: 1.15rem; margin-bottom: 0.25rem; }
.post-card .meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.5rem; }

/* Article */
.article-header { margin-bottom: 1.5rem; }
.article-header h1 { font-size: 1.8rem; line-height: 1.3; margin-bottom: 0.5rem; }
.article-hero-img {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  object-fit: contain; background: var(--bg); border-radius: var(--radius); margin-bottom: 1.5rem;
}
.article-hero-video {
  display: block; width: 100%; aspect-ratio: 16 / 9; border: 0;
  background: #000; border-radius: var(--radius); margin-bottom: 1.5rem;
}
.article-audio-player { display: block; width: 100%; margin-bottom: 1.5rem; }
.article-body { line-height: 1.9; }
.article-body h1,.article-body h2,.article-body h3 { margin: 1.5rem 0 0.5rem; }
.article-body p { margin-bottom: 1rem; }
.article-body pre {
  background: #1e293b; color: #e2e8f0;
  padding: 1rem; border-radius: var(--radius);
  overflow-x: auto; margin-bottom: 1rem;
}
.article-body code { font-family: "Fira Code", monospace; font-size: 0.9em; }
.article-body :not(pre) > code {
  background: #f1f5f9; padding: 0.15em 0.4em; border-radius: 3px;
}
.article-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.article-body table { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
.article-body th, .article-body td {
  border: 1px solid var(--border); padding: 0.4rem 0.75rem;
}
.article-body th { background: var(--bg); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.3rem; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 28rem; font-family: monospace; }
.form-group input:focus, .form-group textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.image-source-toggle { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.radio-pill {
  display: flex; align-items: center; gap: 0.35rem;
  border: 1px solid var(--border); border-radius: 99px;
  padding: 0.3rem 0.85rem; font-size: 0.85rem; cursor: pointer;
}
.radio-pill:has(input:checked) { border-color: var(--accent); color: var(--accent); background: #eff6ff; }
.image-preview {
  display: block; width: 100%; max-width: 320px; aspect-ratio: 16 / 9;
  object-fit: cover; border-radius: var(--radius); margin-top: 0.5rem;
  border: 1px solid var(--border);
}
.video-preview {
  display: block; width: 100%; max-width: 320px; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius); margin-top: 0.5rem;
  border: 1px solid var(--border);
}
.audio-preview { display: block; width: 100%; max-width: 320px; margin-top: 0.5rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.admin-table th { background: var(--bg); font-weight: 600; }

.error-msg { color: var(--danger); font-size: 0.9rem; margin-bottom: 0.75rem; }

.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }

.page-nav { display: flex; gap: 0.5rem; margin-top: 1.5rem; align-items: center; }
