/* ===== Design Tokens ===== */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --code-bg: #1f2428;
  --radius: 6px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; }

/* ===== Layout ===== */
.container { max-width: 780px; margin: 0 auto; padding: 0 20px; width: 100%; }
main.container { flex: 1; padding-top: 48px; padding-bottom: 64px; }

/* ===== Nav ===== */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand { color: var(--text); font-size: 1.1rem; font-weight: 700; letter-spacing: -.5px; }
.nav-brand:hover { color: var(--accent); text-decoration: none; }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { color: var(--muted); font-size: .9rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.admin-nav .nav-links a { color: var(--muted); }

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

/* ===== Page Header ===== */
.page-header { margin-bottom: 40px; }
.page-header h1 { font-size: 1.8rem; font-weight: 700; color: var(--text); }
.admin-page-header { display: flex; align-items: center; justify-content: space-between; }

/* ===== Post List ===== */
.post-list { list-style: none; display: flex; flex-direction: column; gap: 24px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .15s;
}
.post-card:hover { border-color: var(--accent); }
.post-title { font-size: 1.2rem; font-weight: 600; color: var(--text); display: block; margin-bottom: 8px; }
.post-title:hover { color: var(--accent); text-decoration: none; }
.post-excerpt { color: var(--muted); font-size: .9rem; margin-bottom: 12px; line-height: 1.6; }
.post-meta { display: flex; align-items: center; gap: 12px; font-size: .8rem; color: var(--muted); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .5px;
}
.badge-markdown { background: #1c2d3e; color: #58a6ff; }
.badge-html { background: #2d1c1c; color: #f0883e; }
.badge-published { background: #1a2e1a; color: var(--success); }
.badge-draft { background: var(--surface2); color: var(--muted); }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
  color: var(--muted);
}
.pagination a { color: var(--accent); }

/* ===== Single Post ===== */
.post-article { max-width: 100%; }
.post-header { margin-bottom: 40px; }
.post-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 12px; line-height: 1.3; }

.post-content { line-height: 1.8; }
.post-content h1, .post-content h2, .post-content h3, .post-content h4 {
  margin: 2em 0 .75em;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: .3em;
}
.post-content p { margin: 1em 0; }
.post-content ul, .post-content ol { margin: 1em 0; padding-left: 2em; }
.post-content li { margin: .4em 0; }
.post-content blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1em;
  color: var(--muted);
  margin: 1.5em 0;
}
.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 1.5em 0;
  font-size: .9rem;
}
.post-content code {
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: .9em;
}
.post-content :not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 6px;
  color: #f0883e;
}
.post-content table { width: 100%; border-collapse: collapse; margin: 1.5em 0; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.post-content th { background: var(--surface); }
.post-content img { border-radius: var(--radius); margin: 1em 0; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

.back-link { display: inline-block; margin-top: 48px; color: var(--muted); font-size: .9rem; }
.back-link:hover { color: var(--accent); }

/* ===== About ===== */
.about-content { line-height: 1.9; }
.about-content p { margin-bottom: 1em; }

/* ===== Error / Empty ===== */
.error-page { text-align: center; padding: 80px 0; }
.error-page h1 { font-size: 5rem; color: var(--muted); margin-bottom: 16px; }
.error-page p { color: var(--muted); margin-bottom: 24px; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.5;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: .8rem; }
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 0;
}
.btn-link:hover { color: var(--text); }

/* ===== Discord Login ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  width: 100%;
  max-width: 360px;
}
.login-box h1 { font-size: 1.5rem; margin-bottom: 8px; }
.login-sub { color: var(--muted); margin-bottom: 32px; font-size: .9rem; }
.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #5865f2;
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-discord:hover { background: #4752c4; color: #fff; text-decoration: none; }

/* ===== Admin Table ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--muted); font-weight: 600; background: var(--surface); }
.admin-table tr:hover td { background: var(--surface2); }
.actions { display: flex; gap: 8px; align-items: center; }

/* ===== Post Form ===== */
.post-form { display: flex; flex-direction: column; gap: 24px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: .9rem; font-weight: 600; color: var(--muted); }
.form-input, .form-textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  padding: 10px 14px;
  width: 100%;
  transition: border-color .15s;
  font-family: inherit;
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea {
  resize: vertical;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
  font-size: .9rem;
  line-height: 1.6;
}
.slug-preview { color: var(--muted); font-size: .85rem; }
.form-hint { font-size: .8rem; color: var(--muted); }
.radio-group { display: flex; gap: 24px; }
.radio-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; color: var(--text); }
.form-check { flex-direction: row; }
.check-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; color: var(--text); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; }
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .9rem; margin-bottom: 8px; }
.alert-error { background: #2d1a1a; border: 1px solid var(--danger); color: #ffa49d; }

/* ===== Editor toolbar ===== */
.editor-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.btn-sm { padding: 4px 12px; font-size: .8rem; }
.upload-status { font-size: .8rem; color: var(--muted); }

/* ===== Admin body bg ===== */
.admin-body { background: #0a0e14; }

/* ===== Login divider ===== */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: .8rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-error {
  color: var(--danger);
  font-size: .82rem;
  margin-top: 8px;
  min-height: 1.2em;
  text-align: center;
}

/* ===== Test post badges ===== */
.badge-test { background: #2a1a3e; color: #c792ea; }
.expires-countdown { font-size: .72rem; color: #c792ea; font-variant-numeric: tabular-nums; }
