:root {
  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --card: rgba(255, 255, 255, .65);
  --fg: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #10b981;
  --success-soft: #d1fae5;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --warning: #f59e0b;

  --code-bg: #f6f6f7;
  --code-border: #e5e5e7;
  --code-text: #1d1d1f;
  --code-inline-bg: rgba(0, 0, 0, .06);
  --code-inline-text: #c7254e;
  --code-comment: #8e8e93;
  --code-keyword: #af52de;
  --code-string: #d33948;
  --code-number: #1c6dd0;
  --code-function: #0066cc;
  --code-type: #5856d6;
  --code-builtin: #ff9500;
  --code-symbol: #ff2d55;
  --code-meta: #8e8e93;
  --code-traffic-red: #ff5f57;
  --code-traffic-yellow: #febc2e;
  --code-traffic-green: #28c840;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 24px -8px rgba(15, 23, 42, .12);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 120ms;
  --t: 180ms;
  --t-slow: 280ms;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;

  --body-gradient: rgba(79, 70, 229, .06);
  --primary-glow: rgba(79, 70, 229, .12);
  --primary-glow-strong: rgba(79, 70, 229, .18);
  --selection-bg: rgba(79, 70, 229, .18);
  --header-bg: rgba(255, 255, 255, .6);
  --footer-bg: rgba(255, 255, 255, .6);
  --admin-bar-bg: rgba(255, 255, 255, .5);
  --article-bg: rgba(255, 255, 255, .65);
  --input-bg: #ffffff;
  --kbd-shadow: rgba(0, 0, 0, .05);
  --select-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-soft: #131a36;
  --card: rgba(22, 31, 61, .7);
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --border: #1f2a4a;
  --border-strong: #2a3a5f;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, .15);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .15);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .15);
  --warning: #fbbf24;
  --code-bg: #0d1424;
  --code-border: #1f2a4a;
  --code-text: #e2e8f0;
  --code-inline-bg: rgba(255, 255, 255, .08);
  --code-inline-text: #fca5a5;
  --code-comment: #6b7280;
  --code-keyword: #c084fc;
  --code-string: #86efac;
  --code-number: #93c5fd;
  --code-function: #93c5fd;
  --code-type: #a5b4fc;
  --code-builtin: #fbbf24;
  --code-symbol: #f9a8d4;
  --code-meta: #6b7280;
  --code-addition-bg: rgba(40, 200, 64, .15);
  --code-deletion-bg: rgba(255, 95, 87, .18);
  --code-traffic-red: #ff5f57;
  --code-traffic-yellow: #febc2e;
  --code-traffic-green: #28c840;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, .5);
  --body-gradient: rgba(129, 140, 248, .12);
  --primary-glow: rgba(129, 140, 248, .25);
  --primary-glow-strong: rgba(129, 140, 248, .3);
  --selection-bg: rgba(129, 140, 248, .3);
  --header-bg: rgba(11, 16, 32, .65);
  --footer-bg: rgba(11, 16, 32, .65);
  --admin-bar-bg: rgba(11, 16, 32, .55);
  --article-bg: rgba(22, 31, 61, .65);
  --input-bg: #1e293b;
  --kbd-shadow: rgba(0, 0, 0, .4);
  --icon-invert: 1;
  --select-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

:root[data-theme="dark"] mark,
:root[data-theme="dark"] .search-result mark {
  background: rgba(251, 191, 36, .2);
  color: #fcd34d;
}
:root[data-theme="dark"] .markdown kbd {
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --bg-soft: #131a36;
    --card: rgba(22, 31, 61, .7);
    --fg: #e2e8f0;
    --muted: #94a3b8;
    --muted-2: #64748b;
    --border: #1f2a4a;
    --border-strong: #2a3a5f;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, .15);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, .15);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .15);
    --warning: #fbbf24;
    --code-bg: #0d1424;
    --code-border: #1f2a4a;
    --code-text: #e2e8f0;
    --code-inline-bg: rgba(255, 255, 255, .08);
    --code-inline-text: #fca5a5;
    --code-comment: #6b7280;
    --code-keyword: #c084fc;
    --code-string: #86efac;
    --code-number: #93c5fd;
    --code-function: #93c5fd;
    --code-type: #a5b4fc;
    --code-builtin: #fbbf24;
    --code-symbol: #f9a8d4;
    --code-meta: #6b7280;
    --code-addition-bg: rgba(40, 200, 64, .15);
    --code-deletion-bg: rgba(255, 95, 87, .18);
    --code-traffic-red: #ff5f57;
    --code-traffic-yellow: #febc2e;
    --code-traffic-green: #28c840;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, .5);
    --shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, .5);
    --body-gradient: rgba(129, 140, 248, .12);
    --primary-glow: rgba(129, 140, 248, .25);
    --primary-glow-strong: rgba(129, 140, 248, .3);
    --selection-bg: rgba(129, 140, 248, .3);
    --header-bg: rgba(11, 16, 32, .65);
    --footer-bg: rgba(11, 16, 32, .65);
    --admin-bar-bg: rgba(11, 16, 32, .55);
  --article-bg: rgba(22, 31, 61, .7);
    --input-bg: #1e293b;
    --kbd-shadow: rgba(0, 0, 0, .4);
    --icon-invert: 1;
    --select-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  }
  :root:not([data-theme="light"]) mark,
  :root:not([data-theme="light"]) .search-result mark {
    background: rgba(251, 191, 36, .2);
    color: #fcd34d;
  }
  :root:not([data-theme="light"]) .markdown kbd {
    box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
*::selection { background: var(--selection-bg); color: var(--fg); }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -100px, var(--body-gradient), transparent 60%),
    var(--site-bg, none);
  background-attachment: fixed;
  background-size: 100% auto, cover;
  background-position: top center, center;
  background-repeat: no-repeat, no-repeat;
  color: var(--fg);
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  accent-color: var(--primary);
}

/* WebKit scrollbar */
body::-webkit-scrollbar { width: 12px; height: 12px; }
body::-webkit-scrollbar-track { background: transparent; }
body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--bg);
  border-radius: 999px;
}
body::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }
/* Firefox */
html { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- Friend links page ---------- */
.friend-links-grid {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.friend-link-card {
  background: var(--article-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.friend-link-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.friend-link-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  color: var(--fg);
  text-decoration: none;
}
.friend-link-inner:hover { color: var(--fg); }
.friend-link-logo {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: 700;
  font-size: 1.2rem;
}
.friend-link-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.friend-link-logo .friend-link-initial { line-height: 1; }
.friend-link-body { min-width: 0; flex: 1; }
.friend-link-name {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0 0 .15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-link-desc {
  color: var(--muted);
  font-size: .85rem;
  margin: 0 0 .25rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.friend-link-url {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-link-arrow {
  color: var(--muted-2);
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.friend-link-card:hover .friend-link-arrow {
  color: var(--primary);
  transform: translate(2px, -2px);
}

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { color: var(--fg); letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 1.875rem; font-weight: 700; margin: 0 0 .25rem; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

p { margin: 0 0 1rem; }
small { font-size: .85rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
img { max-width: 100%; height: auto; display: block; }
.muted { color: var(--muted); }
.muted.small { color: #000; }
.text-muted { color: var(--muted-2); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.inline { display: inline; }
.flex-grow { flex: 1; }

main {
  flex: 1;
  width: 100%;
}
.container { max-width: 1400px; margin: 0 auto; padding: 0 1.25rem; width: 100%; }
.main { padding: 2rem 1.25rem 3rem; }

aside { display: block; }

/* ---------- Header ---------- */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--fg);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.01em;
}
.logo:hover { color: var(--fg); }
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 10px -2px rgba(79, 70, 229, .35);
}
.logo-mark--img {
  background: transparent;
  box-shadow: none;
  object-fit: contain;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 640px) {
  .primary-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .primary-nav::-webkit-scrollbar { display: none; }
}
.nav-link {
  color: var(--muted);
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--fg); background: var(--bg); }
.nav-link.active { color: var(--fg); }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .7rem;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 500;
}
.role-tag {
  font-size: .68rem;
  padding: .08rem .45rem;
  background: rgba(99, 102, 241, .18);
  color: var(--primary-hover);
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: .02em;
}
.role-tag.role-admin  { background: rgba(99, 102, 241, .22); color: var(--primary-hover); }
.role-tag.role-editor { background: rgba(16, 185, 129, .18); color: #047857; }
.role-tag.role-guest  { background: rgba(148, 163, 184, .22); color: #475569; }
.user-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
}
.user-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  object-fit: cover; flex: 0 0 auto;
  background: var(--bg-soft);
}

/* ---------- Admin sub-bar ---------- */
.admin-bar {
  background: var(--admin-bar-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--border);
}
.admin-bar-inner {
  display: flex;
  align-items: center;
  gap: .25rem;
  height: 44px;
  overflow-x: auto;
}
.admin-tab {
  color: var(--muted);
  padding: .4rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.admin-tab:hover { color: var(--fg); background: var(--bg); }
.admin-tab.active {
  color: var(--primary);
  background: var(--primary-soft);
}
.admin-tab--right { margin-left: auto; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

/* ---------- Flash / alerts ---------- */
.flash, .alert {
  margin: 1rem 0 0;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.flash-success, .alert-success {
  background: var(--success-soft);
  border-color: #a7f3d0;
  color: #065f46;
}
.flash-error, .alert-error {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}
.flash-info, .alert-info {
  background: var(--primary-soft);
  border-color: #c7d2fe;
  color: #3730a3;
}

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card-head { margin-bottom: 1.25rem; }
.card-head h1 { margin-bottom: .25rem; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head p { margin: .25rem 0 0; }

.centered-card {
  max-width: 420px;
  margin: 3rem auto;
}

/* ---------- Profile layout (sidebar + pane) ---------- */
.profile-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.25rem;
  align-items: start;
}
.profile-menu {
  padding: .5rem;
  position: sticky;
  top: 1rem;
}
.profile-menu-list {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--fg);
  text-decoration: none;
  font-size: .92rem;
  transition:
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.profile-menu-item:hover {
  background: var(--bg-soft);
  color: var(--primary);
}
.profile-menu-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.profile-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  color: currentColor;
  flex: 0 0 auto;
}
.profile-pane { min-width: 0; }
@media (max-width: 720px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-menu { position: static; }
  .profile-menu-list { flex-direction: row; }
  .profile-menu-item { flex: 1 1 auto; justify-content: center; }
}

/* ---------- Install wizard ---------- */
.install-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(900px 500px at 50% -50px, var(--body-gradient), transparent 65%),
    var(--bg);
}
.install-wrap { width: 100%; max-width: 580px; }
.install-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 2.25rem 2.25rem;
}
.install-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.install-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1.6rem;
  margin-bottom: .75rem;
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, .4);
}
.install-title { font-size: 1.6rem; margin: 0 0 .25rem; }
.install-sub { color: var(--muted); margin: 0; font-size: .95rem; }
.install-alert { margin: 0 0 1.25rem; }
.install-form { display: flex; flex-direction: column; gap: 1.25rem; }
.install-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  margin: 0;
}
.install-section legend {
  padding: 0 .5rem;
  font-weight: 600;
  font-size: .9rem;
  color: var(--muted);
}
.install-section .field { display: block; margin-top: .65rem; }
.install-section .field:first-of-type { margin-top: 0; }
.install-actions { display: flex; justify-content: flex-end; }
.install-actions .btn-lg { padding: .65rem 1.5rem; font-size: 1rem; }
.install-foot { text-align: center; margin: 1.25rem 0 0; }

@media (max-width: 600px) {
  .install-card { padding: 1.5rem 1.25rem 1.75rem; }
  .install-title { font-size: 1.35rem; }
}

/* ---------- Home / post list ---------- */
.hero { margin-bottom: 1.75rem; }
.hero h1 { font-size: 2.1rem; }
.hero-sub { color: var(--muted); font-size: 1.05rem; margin: 0; }
.hero-hitokoto { font-style: italic; }

.post-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

.post-card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  aspect-ratio: 16 / 9;
  min-height: 180px;
  contain: layout paint;
  isolation: isolate;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.post-card:focus-within {
  box-shadow: 0 0 0 2px var(--primary);
}

.post-card-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-soft);
  pointer-events: none;
}
.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform .55s var(--ease);
}
.post-card:hover .post-card-image img { transform: scale(1.06); }
.post-card-image--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-soft) 100%);
  color: rgba(255, 255, 255, .6);
  font-size: 3rem;
  line-height: 1;
}
.post-card-image--placeholder::after {
  content: '\270E';
}

.post-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(15, 23, 42, .78) 0%,
    rgba(15, 23, 42, .45) 45%,
    rgba(15, 23, 42, .05) 100%
  );
  pointer-events: none;
}

.post-card-link {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  text-indent: -9999em;
  overflow: hidden;
  color: transparent;
}
.post-card-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}

.post-card-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 1.1rem 1.3rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  color: #fff;
  pointer-events: none;
  max-height: 100%;
  overflow: hidden;
}
.post-card-content > a { pointer-events: auto; }

.post-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.post-card-excerpt {
  color: rgba(255, 255, 255, .82);
  font-size: .9rem;
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  color: rgba(255, 255, 255, .78);
  font-size: .82rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: auto;
}
.post-card-meta a {
  color: #fff;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.post-card-meta a:hover { color: var(--primary-soft); }
.post-card-meta .meta-category {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  padding: .05rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.post-card-meta .meta-category:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.post-card-meta .meta-dot { color: rgba(255, 255, 255, .55); }
.post-card-meta .meta-tags a {
  background: rgba(255, 255, 255, .08);
  padding: .05rem .45rem;
  border-radius: 999px;
  font-size: .75rem;
}
.post-card-meta .meta-tags a:hover {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

@media (max-width: 640px) {
  .post-card { min-height: 160px; }
  .post-card-content { padding: .9rem 1rem 1rem; }
  .post-card-title { font-size: 1.02rem; }
  .post-card-excerpt { -webkit-line-clamp: 1; }
}

:root[data-theme="dark"] .post-card-overlay {
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, .82) 0%,
    rgba(0, 0, 0, .5) 45%,
    rgba(0, 0, 0, .1) 100%
  );
}

.post-meta { color: var(--muted-2); font-size: .85rem; }

.pagination {
  display: flex;
  gap: .4rem;
  margin-top: 1.75rem;
  justify-content: center;
  align-items: center;
}
.pagination .muted.small { margin-right: .5rem; }

.kv-table {
  width: 100%;
  border-collapse: collapse;
}
.kv-table th,
.kv-table td {
  text-align: left;
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.kv-table th {
  width: 8rem;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-soft);
}
.kv-table tr:last-child th,
.kv-table tr:last-child td { border-bottom: 0; }

.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: .75rem 1rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.5;
  overflow-x: auto;
  margin: 0;
}
.page-link {
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  min-width: 38px;
  text-align: center;
}
.page-link:hover { border-color: var(--border-strong); }
.page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Article ---------- */
.article {
  background: var(--article-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
}
.article-header { margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.article-header h1 { font-size: 2.1rem; margin-bottom: .5rem; }
.article-meta { color: var(--muted); font-size: .9rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.tag-list { display: inline-flex; gap: .35rem; }
.tag {
  display: inline-block;
  padding: .15rem .55rem;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
}
.article-content { font-size: 1.05rem; line-height: 1.8; color: #1e293b; }
.article-cover {
  margin: 0 0 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.article-cover img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: cover;
}
.article-content :first-child { margin-top: 0; }
.article-content :last-child { margin-bottom: 0; }
.article-content h2, .article-content h3 { margin-top: 1.75em; scroll-margin-top: 5rem; }
.article-content p { margin: 0 0 1.1em; }
.article-content code { font-family: var(--font-mono); background: var(--bg); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.article-content pre { background: #0f172a; color: #e2e8f0; padding: 1rem 1.25rem; border-radius: var(--radius); overflow-x: auto; position: relative; }
.article-content pre code { background: transparent; padding: 0; color: inherit; }
.code-copy-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 4px;
  padding: .25rem .6rem;
  font-size: .75rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.article-content pre:hover .code-copy-btn,
.code-copy-btn:focus,
.code-copy-btn.is-copied { opacity: 1; }
.code-copy-btn:hover { background: #fff; color: #0f172a; }
.code-copy-btn.is-copied { background: #22c55e; color: #fff; border-color: #22c55e; }
.article-content blockquote { border-left: 3px solid var(--primary); padding-left: 1rem; color: var(--muted); margin: 1.25em 0; }
.article-content img { max-width: 100%; }
.article-footer { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.back-link { color: var(--muted); font-size: .9rem; }
.back-link:hover { color: var(--primary); }

.related-posts {
  margin-top: 2.5rem;
  padding: 1.25rem 1.4rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.related-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.related-title::before {
  content: "🔗";
  font-size: .95em;
}
.related-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.related-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .55rem .75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: all 0.18s ease;
}
.related-item a:hover {
  border-color: var(--primary);
  transform: translateX(4px);
  background: var(--card);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}
.related-item-title {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.related-item-cat {
  flex-shrink: 0;
  font-size: .8rem;
  color: var(--muted);
  background: var(--bg);
  padding: .15rem .55rem;
  border-radius: 999px;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: var(--warning-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .9rem;
}
.preview-back { color: var(--fg); font-weight: 500; }
.preview-back:hover { color: var(--primary); }
.preview-label {
  color: var(--muted);
  font-size: .8rem;
  padding: .15rem .55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ---------- Markdown body ---------- */
.markdown { word-wrap: break-word; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 {
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--fg);
  line-height: 1.3;
  margin: 1.6em 0 .6em;
}
.markdown h1 { font-size: 1.75rem; }
.markdown h2 { font-size: 1.45rem; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.2rem; }
.markdown h4 { font-size: 1.05rem; }
.markdown h5, .markdown h6 { font-size: 1rem; }
.markdown h1:first-child, .markdown h2:first-child, .markdown h3:first-child,
.markdown h4:first-child, .markdown h5:first-child, .markdown h6:first-child { margin-top: 0; }
.markdown p { margin: 0 0 1em; }
.markdown a { color: var(--primary); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color var(--t-fast) var(--ease); }
.markdown a:hover { color: var(--primary-hover); border-bottom-color: currentColor; }
.markdown strong { font-weight: 600; color: var(--fg); }
.markdown em { font-style: italic; }
.markdown del { color: var(--muted); }
.markdown ul, .markdown ol { padding-left: 1.5em; margin: 0 0 1em; }
.markdown li { margin: .25em 0; }
.markdown li > p { margin: .25em 0; }
.markdown li input[type="checkbox"] { margin-right: .35em; vertical-align: middle; }
.markdown blockquote {
  margin: 1em 0;
  padding: .5em 1em;
  color: var(--muted);
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.markdown blockquote > :first-child { margin-top: 0; }
.markdown blockquote > :last-child { margin-bottom: 0; }
.markdown blockquote blockquote { margin: .5em 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.markdown table {
  width: 100%;
  margin: 1em 0;
  border-collapse: collapse;
  font-size: .95em;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td {
  padding: .55em .85em;
  border: 1px solid var(--border);
  text-align: left;
}
.markdown th { background: var(--bg); font-weight: 600; }
.markdown tr:nth-child(even) td { background: rgba(241, 245, 249, .5); }
.markdown img { display: block; max-width: 100%; height: auto; margin: 1em auto; }
.markdown code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--code-inline-bg);
  padding: .15em .4em;
  border-radius: 4px;
  color: var(--code-inline-text);
}
.markdown pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  margin: 1.5em 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  overflow: hidden;
}
.markdown pre::before {
  content: '';
  position: absolute;
  top: .85rem;
  left: .9rem;
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  background: var(--code-traffic-red);
  box-shadow:
    .95rem 0 0 0 var(--code-traffic-yellow),
    1.9rem 0 0 0 var(--code-traffic-green);
  z-index: 1;
}
.markdown pre code {
  display: block;
  overflow-x: auto;
  padding: 2.4rem 1.15rem 1rem;
  background: transparent;
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: .875em;
  line-height: 1.6;
  border-radius: 0;
}
.markdown pre code::-webkit-scrollbar { height: 8px; }
.markdown pre code::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .18);
  border-radius: 999px;
}

/* highlight.js token colors (Mac aesthetic) */
.hljs-comment, .hljs-quote {
  color: var(--code-comment);
  font-style: italic;
}
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-link, .hljs-doctag, .hljs-tag {
  color: var(--code-keyword);
}
.hljs-string, .hljs-attribute, .hljs-symbol, .hljs-bullet, .hljs-meta-string, .hljs-template-tag, .hljs-template-variable {
  color: var(--code-string);
}
.hljs-number, .hljs-regexp {
  color: var(--code-number);
}
.hljs-title, .hljs-name, .hljs-selector-id, .hljs-selector-class {
  color: var(--code-function);
  font-weight: 500;
}
.hljs-built_in, .hljs-builtin-name, .hljs-type, .hljs-class .hljs-title {
  color: var(--code-type);
  font-weight: 500;
}
.hljs-attr { color: var(--code-builtin); }
.hljs-variable, .hljs-template-variable { color: var(--code-text); }
.hljs-meta, .hljs-meta-keyword, .hljs-deletion {
  color: var(--code-meta);
}
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }
.hljs-addition {
  background: rgba(40, 200, 64, .15);
  color: #18702b;
}
.hljs-deletion {
  background: rgba(255, 95, 87, .18);
  color: #b32424;
}
.markdown kbd {
  display: inline-block;
  padding: .15em .45em;
  font-family: var(--font-mono);
  font-size: .8em;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--fg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .05);
}
.markdown mark { background: #fef08a; padding: .05em .15em; border-radius: 2px; }
.markdown sub, .markdown sup { font-size: .75em; }

/* ---------- Forms ---------- */
form { margin: 0; }
.form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-row { display: flex; gap: 1rem; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field > span {
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .01em;
}
.field-group { display: flex; flex-direction: column; gap: .25rem; justify-content: center; }
.form-actions { display: flex; gap: .75rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; }

/* Unified control styles — text, email, url, number, search, password, textarea, select */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: .6rem .8rem;
  font: inherit;
  font-size: .95rem;
  color: var(--fg);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    background var(--t) var(--ease);
}
input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--border-strong);
}
input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
textarea:focus,
textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .14);
}

/* Date / time / datetime-local — color scheme + calendar icon */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"] {
  font-family: var(--font-mono);
  font-size: .9rem;
  color-scheme: light dark;
  min-height: 2.4rem;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
  width: 1.1rem;
  height: 1.1rem;
  margin-left: .25rem;
  cursor: pointer;
  opacity: .55;
  transition: opacity var(--t-fast) var(--ease);
  filter: invert(var(--icon-invert, 0));
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator,
input[type="month"]:hover::-webkit-calendar-picker-indicator,
input[type="week"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
  opacity: 1;
}
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
  opacity: .7;
}

/* Required asterisk */
.field > span:has(+ [required])::after,
.field > span:has(+ textarea[required])::after {
  content: ' *';
  color: var(--danger);
  font-weight: 600;
}
.field input[required],
.field textarea[required] { box-shadow: none; }

/* Textarea */
textarea { resize: vertical; min-height: 88px; line-height: 1.6; }
.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-right: 2.5rem; }
.emoji-picker-btn {
  position: absolute;
  right: .5rem;
  bottom: .5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .2rem .35rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
  transition: opacity var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.emoji-picker-btn:hover { opacity: 1; border-color: var(--border-strong); }

/* Custom select arrow */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.25rem;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 14px 14px;
  cursor: pointer;
}
select[multiple] { padding-right: .8rem; background-image: none; }

/* Checkbox & radio — use accent-color from :root */
input[type="checkbox"],
input[type="radio"] {
  width: 1.05em;
  height: 1.05em;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--input-bg);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  vertical-align: -.15em;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover,
input[type="radio"]:hover { border-color: var(--primary); }
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
input[type="checkbox"]:checked { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>"); background-size: 75%; background-position: center; background-repeat: no-repeat; }
input[type="radio"]:checked { background-image: radial-gradient(circle, #fff 38%, transparent 40%); }
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .25);
  border-color: var(--primary);
}

/* Search input — strip inner padding artifact */
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration { display: none; }

/* File input */
input[type="file"] {
  font-size: .9rem;
  padding: .45rem 0;
  background: transparent;
  border: none;
}
input[type="file"]::file-selector-button {
  margin-right: .75rem;
  padding: .4rem .8rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
input[type="file"]::file-selector-button:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

/* Field with checkbox row */
.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: .55rem;
  padding: .5rem 0;
}
.field-checkbox input { width: auto; }
.field-checkbox span { color: var(--fg); font-weight: 500; }

.content-area { font-family: var(--font-mono); font-size: .9rem; min-height: 320px; line-height: 1.6; }

.slug { font-family: var(--font-mono); font-size: .82rem; color: var(--muted); background: var(--bg); padding: .1rem .45rem; border-radius: 4px; }
.col-num { width: 80px; text-align: right; color: var(--muted); }
.col-cat { width: 140px; }
.settings-section {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 .5rem;
}

.captcha-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.captcha-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 40px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.captcha-input {
  flex: 1;
  min-width: 0;
  width: auto;
}
.captcha-svg svg { display: block; width: 100%; height: 100%; }
.captcha-refresh {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .4rem .7rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  transition:
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.captcha-refresh:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}
.captcha-refresh svg { display: block; flex-shrink: 0; }

.form-with-uploads {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1.5rem;
  align-items: start;
}
.upload-panel {
  position: sticky;
  top: calc(64px + 44px + .5rem);
  max-height: calc(100vh - 64px - 44px - 1rem);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.upload-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .25rem;
}
.upload-panel-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0;
}
.upload-panel-skip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.upload-panel-skip input { margin: 0; cursor: pointer; }
.upload-panel-skip:hover { color: var(--fg); }
.upload-panel-hint {
  font-size: .78rem;
  color: var(--muted-2);
  margin: 0 0 1rem;
}
.upload-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.upload-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.upload-thumb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  border: none;
  background: var(--bg-soft);
  cursor: pointer;
  aspect-ratio: 4/3;
  overflow: hidden;
  transition: background var(--t-fast) var(--ease);
}
.upload-thumb-btn:hover { background: var(--primary-soft); }
.upload-thumb-btn img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.upload-item-meta { padding: .4rem .55rem; display: flex; flex-direction: column; gap: .15rem; }
.upload-item-name {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-item-size { color: var(--muted-2); font-size: .7rem; }
.upload-item-actions { display: flex; border-top: 1px solid var(--border); }
.upload-action {
  flex: 1;
  padding: .4rem 0;
  font-size: .75rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.upload-action + .upload-action { border-left: 1px solid var(--border); }
.upload-action:hover { color: var(--primary); background: var(--primary-soft); }
.upload-action-danger:hover { color: var(--danger); background: var(--danger-soft); }
.upload-action:disabled { cursor: not-allowed; opacity: .6; }
.empty-state-small { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem .5rem; line-height: 1.5; }

@media (max-width: 960px) {
  .form-with-uploads { grid-template-columns: 1fr; }
  .upload-panel { position: static; max-height: none; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-left: .25rem;
  transition:
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Validation hint spacing */
.field > small,
.field .hint { color: var(--muted-2); font-size: .8rem; }

/* ---------- Stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.filter-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
}
.filter-field { display: inline-flex; }
.filter-field-search { flex: 1 1 200px; min-width: 180px; }
.filter-field input,
.filter-field select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: .9rem;
  font-family: inherit;
}
.filter-field input:focus,
.filter-field select:focus { outline: none; border-color: var(--primary); }
.filter-field-search input { padding-left: .9rem; }
.filter-actions { display: inline-flex; gap: .4rem; }
.filter-result { margin-top: .65rem; padding-top: .65rem; border-top: 1px dashed var(--border); }
@media (max-width: 720px) {
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-field-search, .filter-field, .filter-actions { width: 100%; }
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--muted); font-size: .85rem; margin-bottom: .25rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }

/* ---------- Data table ---------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: .85rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--bg);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.col-status { width: 110px; }
.col-date { width: 130px; color: var(--muted); }
.col-actions { width: 180px; text-align: right; white-space: nowrap; }
.col-actions .inline + .btn, .col-actions .btn + .inline { margin-left: .5rem; }
.row-title { font-weight: 600; color: var(--fg); }
.row-title:hover { color: var(--primary); }
.row-sub { font-size: .8rem; color: var(--muted-2); margin-top: .15rem; }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-success { background: var(--success-soft); color: #065f46; }
.badge-warn { background: var(--warning-soft); color: #92400e; }
.badge-error { background: var(--danger-soft); color: #991b1b; }
.badge-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.empty-emoji { font-size: 2.5rem; margin-bottom: .5rem; }
.empty-state h3 { margin: 0 0 .35rem; color: var(--fg); }
.empty-state p { margin: 0; }

/* ---------- Sidebar layout ---------- */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 2rem;
  align-items: start;
}
.main-col { min-width: 0; }
.sidebar {
  position: sticky;
  top: calc(64px + .5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.widget-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 .6rem;
}
.widget-list { list-style: none; margin: 0; padding: 0; }
.widget-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  padding: .35rem 0;
  font-size: 1rem;
  border-bottom: 1px dashed var(--border);
}
.widget-list li:last-child { border-bottom: none; }
.widget-list a { color: var(--fg); }
.widget-list a:hover { color: var(--primary); }
.widget-list .count { color: var(--muted-2); font-size: .8rem; font-variant-numeric: tabular-nums; }
.widget-list--compact li { padding: .25rem 0; }

.comment-list-widget { list-style: none; padding: 0; margin: 0; }
.comment-widget-item { border-bottom: 1px dashed var(--border); }
.comment-widget-item:last-child { border-bottom: none; }
.comment-widget-link {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .55rem 0;
  color: var(--fg);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
.comment-widget-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-soft);
  object-fit: cover;
}
.comment-widget-text { min-width: 0; flex: 1; }
.comment-widget-link:hover { color: var(--primary); }
.comment-widget-author {
  font-weight: 600;
  font-size: .85rem;
  color: var(--fg);
  margin-bottom: .15rem;
}
.comment-widget-content {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.5;
  margin-bottom: .2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.comment-widget-meta {
  color: var(--muted-2);
  font-size: .76rem;
}

.search-form { display: flex; gap: .5rem; }
.search-form input { flex: 1; min-width: 0; }
.search-form--inline { max-width: 520px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag-cloud .tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .8rem;
}
.tag-cloud .tag-count {
  color: var(--muted-2);
  font-size: .7rem;
  font-weight: 400;
  margin-left: .15rem;
}
.tag-lg { font-size: 1rem; padding: .35rem .85rem; vertical-align: middle; }
.meta-dot { color: var(--muted-2); }
.meta-category { color: var(--primary); font-weight: 500; }
.meta-tags a { color: var(--muted); margin-left: .25rem; }
.badge-category {
  background: var(--primary-soft);
  color: var(--primary-hover);
  text-decoration: none;
}
.badge-category:hover { background: var(--primary); color: #fff; }
.badge-danger { background: var(--danger-soft); color: #991b1b; }
.archive-header h1 { font-size: 1.6rem; margin-bottom: .35rem; }
.archive-list { display: grid; gap: 1rem; }
.archive-group {
  padding: 1rem 1.1rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.archive-group:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.archive-month { font-size: 1.1rem; margin: 0; font-weight: 600; }
.archive-month a { color: var(--fg); }
.archive-month a:hover { color: var(--primary); }
.archive-posts { list-style: none; padding: 0; margin: 0; }
.archive-posts li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .65rem 0;
  border-bottom: 1px dashed #1e293b;
  transition: background-color 0.15s ease;
}
.archive-posts li:last-child { border-bottom: none; }
.archive-posts li:hover { background-color: rgba(79, 70, 229, 0.05); padding-left: .35rem; padding-right: .35rem; margin: 0 -.35rem; border-radius: 4px; }
:root[data-theme="dark"] .archive-posts li { border-bottom-color: #cbd5e1; }
:root[data-theme="dark"] .archive-posts li:hover { background-color: rgba(129, 140, 248, 0.1); }
.archive-posts a { color: var(--fg); text-decoration: none; transition: color 0.15s ease; }
.archive-posts > li > a { font-weight: 500; }
.archive-posts a:hover { color: var(--primary); }
.archive-posts a .archive-posts-cat { color: var(--muted); font-weight: 400; }
.archive-posts a:hover .archive-posts-cat { color: var(--primary); }
.archive-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.mt-2 { margin-top: 2rem; }

/* ---------- Comments ---------- */
.comments { margin-top: 2.5rem; }
.comments-title { font-size: 1.3rem; margin: 0 0 1rem; }
.comments-form-title { font-size: 1.05rem; margin: 1.5rem 0 .75rem; }
.comment-list { list-style: none; padding: 0; margin: 0; }
.comment {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .85rem;
  background: var(--card);
}
.comment-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-soft);
  object-fit: cover;
}
.comment-body { min-width: 0; flex: 1; }
.comment-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .35rem;
  font-size: .9rem;
}
.comment-author { font-weight: 600; }
.comment-time { color: #000; font-size: .8rem; margin-left: auto; }
.comment-reply {
  font-size: .75rem;
  color: var(--muted-2);
  background: var(--bg);
  padding: .1rem .45rem;
  border-radius: 4px;
}
.comment-content { line-height: 1.65; }
.comment-content :first-child { margin-top: 0; }
.comment-content :last-child { margin-bottom: 0; }
.comment-form { margin-top: 1.25rem; }
.comment-form-identity {
  padding: .65rem .9rem;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1rem;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
.small { font-size: .85rem; }

/* ---------- Filter tabs (admin) ---------- */
.filter-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-tab {
  padding: .4rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--muted);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.filter-tab:hover { color: var(--fg); border-color: var(--border-strong); }
.filter-tab.active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary-soft);
  font-weight: 500;
}
.tab-count {
  background: var(--bg);
  padding: 0 .45rem;
  border-radius: 999px;
  font-size: .75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.filter-tab.active .tab-count { background: #fff; color: var(--primary); }

/* ---------- Admin comment list ---------- */
.comment-admin-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.comment-admin {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  background: var(--card);
}
.comment-admin-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-soft);
  object-fit: cover;
}
.comment-admin-body { min-width: 0; flex: 1; }
.comment-admin-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .9rem;
  margin-bottom: .5rem;
}
.comment-admin-content {
  padding: .5rem 0;
  line-height: 1.6;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  margin: .5rem 0;
}
.comment-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin-top: .5rem;
}
.reply-details summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: .35rem .75rem;
  font-size: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  background: var(--card);
}
.reply-details summary::-webkit-details-marker { display: none; }
.reply-details[open] summary { background: var(--bg); }
.reply-form { margin-top: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.reply-form textarea { min-height: 70px; }
.reply-form .btn { align-self: flex-start; }

/* ---------- Stat sub ---------- */
.stat-sub { color: var(--muted-2); font-size: .8rem; margin-top: .15rem; }

.error-trace {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: .85rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--footer-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  padding: 1.25rem 0;
  margin-top: auto;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer-main { color: var(--muted); display: inline-flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.footer-running-days strong { color: var(--primary); font-weight: 600; }
.footer-icp { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .75rem; font-size: .85rem; }
.footer-icp a { color: var(--muted); display: inline-flex; align-items: center; gap: .25rem; text-decoration: none; transition: color 0.15s ease; }
.footer-icp a:hover { color: var(--fg); }
.footer-nav { display: inline-flex; gap: 1rem; font-size: .9rem; }
.footer-nav a { color: var(--muted); }
.footer-nav a:hover { color: var(--fg); }

/* ---------- Search page ---------- */
.search-page { padding: .25rem 0 1rem; }
.search-title {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
}
.search-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 10px;
}
.search-form-large {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: .3rem .3rem .3rem 1rem;
  gap: .5rem;
  max-width: 680px;
  transition: border-color .15s, box-shadow .15s;
}
.search-form-large:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow), var(--shadow);
}
.search-form-icon {
  color: var(--muted-2);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.search-form-large input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  padding: .7rem 0;
  font-size: 1rem;
  color: var(--fg);
  box-shadow: none !important;
}
.search-form-large input:focus { border: none; box-shadow: none; }
.search-form-large input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--muted-2);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'><line x1='6' y1='6' x2='18' y2='18'/><line x1='6' y1='18' x2='18' y2='6'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'><line x1='6' y1='6' x2='18' y2='18'/><line x1='6' y1='18' x2='18' y2='6'/></svg>") center / contain no-repeat;
  cursor: pointer;
}
.search-form-large .btn { flex-shrink: 0; }

.search-stat {
  color: var(--muted);
  margin: 1.25rem 0 1rem;
  font-size: .95rem;
}
.search-stat strong { color: var(--fg); }

.search-results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .85rem; }
.search-result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.4rem;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.search-result:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.search-result-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 .35rem;
  line-height: 1.4;
}
.search-result-title a { color: var(--fg); }
.search-result-title a:hover { color: var(--primary); }
.search-result-excerpt {
  color: var(--muted);
  margin: 0 0 .6rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-meta {
  font-size: .85rem;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
}
.search-result-meta a { color: var(--muted); }
.search-result-meta a:hover { color: var(--primary); }
.meta-tags-inline a { color: var(--muted); }
.meta-tags-inline a:hover { color: var(--primary); }

mark, .search-result mark {
  background: #fef3c7;
  color: inherit;
  padding: 0 .2em;
  border-radius: 3px;
  font-weight: 600;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.search-tips {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.search-tips .tag-cloud { justify-content: center; }
.search-suggest-list {
  list-style: none;
  padding: 0;
  margin: .5rem 0 0;
  text-align: left;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.search-suggest-list li {
  padding: .35rem 0;
  border-bottom: 1px dashed var(--border);
}
.search-suggest-list li:last-child { border-bottom: none; }
.search-suggest-list a { color: var(--fg); }
.search-suggest-list a:hover { color: var(--primary); }

/* ---------- Homepage / Search / Article password ---------- */
.homepage-main, .search-main, .article-main, .page-main { max-width: 760px; margin: 0 auto; width: 100%; box-sizing: border-box; }

/* ---------- Admin layout ---------- */
body.is-admin .container { max-width: 1080px; }

.category-checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem;
  padding: .5rem 0;
  max-height: 240px;
  overflow-y: auto;
  padding-right: .5rem;
}
.cat-search-input {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-size: .9rem;
  margin-bottom: .5rem;
}
.cat-search-input:focus { outline: none; border-color: var(--primary); }
.category-checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .85rem;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  transition: all 0.15s ease;
  user-select: none;
  position: relative;
}
.category-checkbox:hover { border-color: var(--primary); background: var(--card); }
.category-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin: 0;
}
.category-checkbox:has(input:checked) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.category-checkbox:has(input:checked) input[type="checkbox"] { accent-color: #fff; }
.category-checkbox .cat-count {
  margin-left: auto;
  font-size: .75rem;
  opacity: .6;
}

/* ---------- Nice checkbox ---------- */
.nice-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  line-height: 1;
}
.nice-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}
.nice-checkbox-box {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  transition: all 0.18s ease;
  flex-shrink: 0;
}
.nice-checkbox-box::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 5px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.18s ease;
}
.nice-checkbox:hover .nice-checkbox-box {
  border-color: var(--primary);
}
.nice-checkbox input[type="checkbox"]:focus-visible + .nice-checkbox-box {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
.nice-checkbox input[type="checkbox"]:checked + .nice-checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}
.nice-checkbox input[type="checkbox"]:checked + .nice-checkbox-box::after {
  transform: rotate(45deg) scale(1);
}
.nice-checkbox-label {
  color: var(--fg);
  font-size: 0.9rem;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.col-checkbox { width: 3rem; text-align: center; padding-left: 0.5rem; padding-right: 0.5rem; }

/* ---------- Article TOC layout ---------- */
.article-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 220px;
  gap: 2.5rem;
  align-items: start;
}
.article-toc {
  position: sticky;
  top: calc(64px + 1rem);
  max-height: calc(100vh - 64px - 2rem);
  overflow-y: auto;
}
.toc-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 .6rem;
}
.toc-nav { display: flex; flex-direction: column; gap: .15rem; }
.toc-link {
  font-size: .95rem;
  color: var(--fg);
  padding: .3rem .5rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  line-height: 1.4;
  display: block;
}
.toc-link:hover { color: var(--primary); background: var(--bg-secondary); }
.toc-level-1 { font-weight: 600; }
.toc-level-2 { padding-left: 1rem; }
.toc-level-3 { padding-left: 1.75rem; font-size: .85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .article-layout { grid-template-columns: 160px minmax(0, 1fr) 200px; gap: 2rem; }
}
@media (max-width: 960px) {
  .layout-with-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .article-layout { grid-template-columns: 1fr; }
  .article-toc { position: static; max-height: none; border-left: 1px solid var(--border); padding-left: 1rem; margin-bottom: 1rem; }
  .toc-nav { flex-direction: row; flex-wrap: wrap; gap: .35rem; }
  .toc-link { border-left: none; background: var(--bg-secondary); }
}
@media (max-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .article { padding: 1.5rem 1.25rem; }
  .article-header h1 { font-size: 1.6rem; }
  .hero h1 { font-size: 1.6rem; }
  .col-date, .col-cat { display: none; }
  .col-actions { width: auto; }
  .data-table th.col-date, .data-table td.col-date,
  .data-table th.col-cat,  .data-table td.col-cat { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .meta-tags { display: none; }
}
