/* ═══════════════════════════════════════════════════════════════
   MN Knowledgebase — Modern 2026 stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --bg:           #F8F8FA;
  --bg-card:      #FFFFFF;
  --surface:      #F2F2F5;
  --border:       #E4E4E8;
  --border-strong:#C8C8D0;

  --text:         #18181B;
  --text-muted:   #6B7280;
  --text-subtle:  #A1A1AA;

  --accent:       #6366F1;
  --accent-hover: #4F46E5;
  --accent-light: #EEF2FF;
  --accent-dark:  #3730A3;

  --green:        #10B981;
  --amber:        #F59E0B;
  --red:          #EF4444;

  --header-bg:    #0C0C0F;
  --header-border:#1F1F27;

  --code-bg:      #1E1E2E;
  --code-text:    #CDD6F4;

  --shadow-xs:    0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:    0 2px 6px rgba(0,0,0,.08);
  --shadow:       0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:    0 12px 32px rgba(0,0,0,.14);

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --radius-full:  9999px;

  --font:         "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:    "Fira Code", "Cascadia Code", "Consolas", monospace;

  --transition:   150ms cubic-bezier(.4,0,.2,1);
  --max-w:        1280px;
  --content-w:    760px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; color: var(--text); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition); border: 1.5px solid transparent;
  white-space: nowrap; text-decoration: none;
}
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: .8125rem; }

/* ── IP bar ─────────────────────────────────────────────────── */
.ip-bar {
  background: #09090C;
  border-bottom: 1px solid #1a1a24;
  padding: 5px 24px;
  font-size: .75rem;
  color: #6B7280;
}
.ip-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ip-bar code { color: #A5B4FC; font-family: var(--font-mono); font-size: .75rem; background: rgba(99,102,241,.1); padding: 1px 6px; border-radius: 4px; }

/* ── Header ─────────────────────────────────────────────────── */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--header-bg); border-bottom: 1px solid var(--header-border); backdrop-filter: blur(12px); }

.header-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 24px;
}

.site-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.site-logo img, .site-logo-img { height: 36px; width: auto; display: block; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: var(--accent); color: #fff;
  font-size: .75rem; font-weight: 700; border-radius: var(--radius-sm); letter-spacing: 0.02em;
}
.logo-mark.small { width: 24px; height: 24px; font-size: .65rem; }
.logo-text { font-size: .9375rem; font-weight: 600; color: #F4F4F6; letter-spacing: -0.01em; }

.site-nav { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: .875rem;
  font-weight: 500; color: #9CA3AF; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.nav-link:hover, .nav-link.active { color: #F4F4F6; background: rgba(255,255,255,.08); }
.nav-link-baby  { color: #D8A8F0; border: 1px solid rgba(199,125,255,.25); margin-left: 2px; }
.nav-link-baby:hover, .nav-link-baby.active { color: #ECC8F8; background: rgba(155,89,182,.15); border-color: rgba(199,125,255,.5); }
.nav-link-admin { color: #818CF8; border: 1px solid rgba(129,140,248,.25); margin-left: 4px; }
.nav-link-admin:hover { color: #A5B4FC; background: rgba(99,102,241,.15); border-color: rgba(129,140,248,.5); }

.header-search {
  display: flex; align-items: center;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm); overflow: hidden; transition: all var(--transition); flex-shrink: 0;
}
.header-search:focus-within { background: rgba(255,255,255,.11); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.25); }
.header-search input { background: none; border: none; outline: none; color: #F4F4F6; font-size: .875rem; padding: 8px 12px; width: 200px; }
.header-search input::placeholder { color: #6B7280; }
.header-search button { padding: 8px 12px; color: #6B7280; display: flex; align-items: center; transition: color var(--transition); }
.header-search button:hover { color: #F4F4F6; }

.nav-toggle { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.nav-toggle span { display: block; width: 20px; height: 1.5px; background: #9CA3AF; border-radius: 2px; transition: all var(--transition); }

/* ── Header upload ──────────────────────────────────────────── */
.header-upload { display: flex; align-items: center; gap: 8px; flex-shrink: 0; position: relative; }
.header-upload-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm); color: #9CA3AF; font-size: .875rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.header-upload-btn:hover { background: rgba(255,255,255,.13); color: #F4F4F6; border-color: rgba(255,255,255,.22); }

.upload-popup {
  position: absolute; top: calc(100% + 10px); right: 0; width: 340px;
  background: #1C1C28; border: 1px solid #2E2E40;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden;
}
.upload-popup-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #2E2E40; }
.upload-popup-title { font-size: .875rem; font-weight: 600; color: #F4F4F6; }
.upload-popup-close { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--radius-sm); color: #6B7280; cursor: pointer; transition: all var(--transition); background: none; border: none; }
.upload-popup-close:hover { background: rgba(255,255,255,.08); color: #F4F4F6; }
.upload-popup-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.upload-popup-file { font-size: .8125rem; color: #A5B4FC; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-popup-url-row { display: flex; gap: 8px; }
.upload-popup-url { flex: 1; background: #111118; border: 1px solid #2E2E40; border-radius: var(--radius-sm); padding: 7px 10px; font-size: .8rem; font-family: var(--font-mono); color: #9CA3AF; outline: none; min-width: 0; }
.upload-popup-copy { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); font-size: .8125rem; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background var(--transition); }
.upload-popup-copy:hover { background: var(--accent-hover); }
.upload-popup-actions { display: flex; gap: 8px; }
.upload-popup-cancel { flex: 1; padding: 7px 12px; background: rgba(255,255,255,.06); color: #9CA3AF; border: 1px solid #2E2E40; border-radius: var(--radius-sm); font-size: .8125rem; font-weight: 500; cursor: pointer; transition: all var(--transition); }
.upload-popup-cancel:hover { background: rgba(255,255,255,.11); color: #F4F4F6; }
.upload-progress-info { display: flex; justify-content: space-between; font-size: .8rem; color: #9CA3AF; margin-bottom: 8px; }
.upload-progress-track { height: 8px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.upload-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #6366F1, #818CF8); border-radius: 99px; transition: width .25s ease; }
.upload-progress-speed { font-size: .75rem; color: #6B7280; margin-top: 6px; text-align: right; }

/* ── Layout ─────────────────────────────────────────────────── */
.page-wrapper {
  max-width: var(--max-w); margin: 0 auto; padding: 40px 24px;
  display: grid; grid-template-columns: 1fr 280px; gap: 40px;
  align-items: start; flex: 1;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar { position: sticky; top: 80px; }
.sidebar-widget { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow-xs); }
.widget-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-subtle); margin-bottom: 14px; }

.category-list { display: flex; flex-direction: column; gap: 2px; }
.category-link { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: var(--radius-sm); font-size: .875rem; color: var(--text-muted); font-weight: 500; transition: all var(--transition); text-decoration: none; }
.category-link:hover { background: var(--accent-light); color: var(--accent); }
.cat-count { font-size: .75rem; background: var(--surface); color: var(--text-subtle); padding: 2px 7px; border-radius: var(--radius-full); font-weight: 500; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 4px 10px; background: var(--accent-light); color: var(--accent-dark); border-radius: var(--radius-full); font-size: .8rem; font-weight: 500; text-decoration: none; transition: all var(--transition); border: 1px solid transparent; }
.tag:hover { background: var(--accent); color: #fff; }
.tag-sm { padding: 3px 8px; font-size: .75rem; }

/* ── Sidebar widget lists (for kbhost-style index) ──────────── */
.kbe-widget-list { display: flex; flex-direction: column; gap: 1px; }
.kbe-widget-list li { border-bottom: 1px solid var(--border); }
.kbe-widget-list li:last-child { border-bottom: none; }
.kbe-widget-list li a { display: block; padding: 6px 0; font-size: .875rem; color: var(--text-muted); text-decoration: none; transition: color var(--transition); line-height: 1.4; }
.kbe-widget-list li a:hover { color: var(--accent); }
.kbe-cat-list li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding: 5px 0; }
.kbe-cat-list li:last-child { border-bottom: none; }
.kbe-cat-list li a { padding: 0; color: var(--text-muted); font-size: .875rem; text-decoration: none; transition: color var(--transition); }
.kbe-cat-list li a:hover { color: var(--accent); }

/* ── Homepage logo banner ───────────────────────────────────── */
.home-logo-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.home-logo-banner img { height: 56px; width: auto; }
.home-logo-tagline { font-size: .9375rem; color: var(--text-muted); margin-top: 4px; }

/* ── Homepage search bar ────────────────────────────────────── */
.kbe-search-wrap { margin-bottom: 28px; position: relative; }
.kbe-search-wrap input {
  width: 100%; padding: 11px 16px;
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 1rem;
  font-family: var(--font); outline: none; transition: border-color var(--transition);
  box-shadow: var(--shadow-xs);
}
.kbe-search-wrap input::placeholder { color: var(--text-subtle); }
.kbe-search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ── Category sections (kbhost structure) ───────────────────── */
.kbe-categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}

.kbe-category {
  padding: 20px 24px 20px 0;
  border-bottom: 1px solid var(--border);
}
.kbe-category:nth-child(odd) { border-right: 1px solid var(--border); }
.kbe-category:nth-child(even) { padding-left: 24px; padding-right: 0; }

.kbe-category h2 {
  font-size: .9375rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  letter-spacing: -0.01em;
}
.kbe-category h2 a { color: var(--text); transition: color var(--transition); }
.kbe-category h2 a:hover { color: var(--accent); }

.kbe-count {
  font-size: .7rem; font-weight: 600; color: #fff;
  background: var(--accent); padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap; flex-shrink: 0;
}

.kbe-article-list { display: flex; flex-direction: column; }
.kbe-article-list li { border-bottom: 1px solid var(--border); }
.kbe-article-list li:last-child { border-bottom: none; }
.kbe-article-list li a {
  display: block; padding: 6px 0;
  font-size: .875rem; color: var(--text-muted);
  text-decoration: none; transition: color var(--transition); line-height: 1.4;
}
.kbe-article-list li a:hover { color: var(--accent); }

.kbe-empty { color: var(--text-muted); padding: 20px 0; }
.kbe-empty a { color: var(--accent); }
.kbe-empty a:hover { color: var(--accent-hover); }

/* ── Page header (category/tag/search) ──────────────────────── */
.page-hero { margin-bottom: 36px; padding: 36px 0 28px; border-bottom: 1px solid var(--border); }
.hero-title { font-size: clamp(2rem, 4vw, 2.75rem); font-weight: 800; letter-spacing: -0.04em; margin-bottom: 10px; }
.hero-title .accent { color: var(--accent); }
.hero-sub { color: var(--text-muted); font-size: 1.0625rem; }

.page-header { margin-bottom: 32px; }
.page-header-inner { padding: 28px 0 24px; border-bottom: 1px solid var(--border); }
.page-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: 8px; }
.page-title { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; margin-bottom: 6px; }
.page-count { font-size: .875rem; color: var(--text-muted); }

/* ── Category/tag post grid (list view) ─────────────────────── */
.post-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.post-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 7px;
  transition: all var(--transition); box-shadow: var(--shadow-xs);
}
.post-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }

.card-meta { display: flex; align-items: center; gap: 10px; font-size: .8125rem; }
.card-category { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); text-decoration: none; }
.card-category:hover { color: var(--accent-hover); }
.card-date { color: var(--text-subtle); }
.card-meta .card-category + .card-date::before { content: "·"; margin-right: 10px; color: var(--border-strong); }

.card-title { font-size: 1rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.02em; }
.card-title a { color: var(--text); text-decoration: none; transition: color var(--transition); }
.card-title a:hover { color: var(--accent); }
.card-excerpt { font-size: .875rem; color: var(--text-muted); line-height: 1.55; }

.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-read { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.read-time { font-size: .8rem; color: var(--text-subtle); white-space: nowrap; }
.read-link { display: inline-flex; align-items: center; gap: 5px; font-size: .875rem; font-weight: 500; color: var(--accent); text-decoration: none; transition: gap var(--transition); white-space: nowrap; }
.read-link:hover { gap: 8px; color: var(--accent-hover); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); }
.page-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; color: var(--text-muted); transition: all var(--transition); text-decoration: none; }
.page-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.page-info { font-size: .875rem; color: var(--text-subtle); }

/* ── Article page ───────────────────────────────────────────── */
.article { max-width: var(--content-w); }
.article-header { margin-bottom: 40px; padding-bottom: 32px; border-bottom: 1px solid var(--border); }
.article-meta-top { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--text-muted); margin-bottom: 16px; flex-wrap: wrap; }
.article-category { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); text-decoration: none; }
.article-category:hover { color: var(--accent-hover); }
.meta-sep { color: var(--border-strong); }
.article-title { font-size: clamp(1.75rem, 3.5vw, 2.5rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.2; margin-bottom: 16px; }
.article-lead { font-size: 1.125rem; color: var(--text-muted); line-height: 1.65; margin-bottom: 20px; }
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.article-footer { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--border); }
.article-nav { display: flex; align-items: center; gap: 12px; }
.btn-edit { color: var(--text-subtle); }

/* ── Prose ──────────────────────────────────────────────────── */
.prose { font-size: 1.0625rem; line-height: 1.75; color: var(--text); }
.prose h1 { font-size: 1.875rem; margin: 2.5rem 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.prose h2 { font-size: 1.5rem; margin: 2.25rem 0 .875rem; padding-bottom: .375rem; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.25rem; margin: 2rem 0 .75rem; }
.prose h4 { font-size: 1.125rem; margin: 1.75rem 0 .625rem; }
.prose h5, .prose h6 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.prose p { margin-bottom: 1.25rem; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
.prose a:hover { color: var(--accent-hover); }
.prose strong { font-weight: 700; }
.prose em { font-style: italic; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
.prose ul { list-style: disc; } .prose ol { list-style: decimal; }
.prose li { margin-bottom: .4rem; } .prose li::marker { color: var(--accent); }
.prose blockquote { border-left: 3px solid var(--accent); padding: 4px 0 4px 20px; margin: 1.5rem 0; color: var(--text-muted); font-style: italic; }
.prose blockquote p { margin: 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.prose code:not(.highlight code) { background: var(--surface); color: var(--accent-dark); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: .875em; border: 1px solid var(--border); }
.prose .highlight, .prose pre { background: var(--code-bg); border-radius: var(--radius); overflow-x: auto; margin: 1.5rem 0; border: 1px solid #2D2D42; box-shadow: var(--shadow-sm); }
.prose .highlight pre { margin: 0; border: none; box-shadow: none; border-radius: 0; background: none; }
.prose pre code, .prose .highlight code { font-family: var(--font-mono); font-size: .875rem; line-height: 1.7; color: var(--code-text); display: block; padding: 20px 24px; background: none; border: none; }
.highlight .hll { background: #2D2D42; }
.highlight .c, .highlight .cm, .highlight .c1 { color: #6272A4; font-style: italic; }
.highlight .k, .highlight .kd { color: #FF79C6; }
.highlight .o { color: #FF79C6; }
.highlight .s, .highlight .s2, .highlight .s1 { color: #F1FA8C; }
.highlight .n, .highlight .nb { color: var(--code-text); }
.highlight .nc, .highlight .nf { color: #50FA7B; }
.highlight .mi, .highlight .mf { color: #BD93F9; }
.highlight .nv { color: #8BE9FD; }
.highlight .nt { color: #FF79C6; }
.highlight .gi { color: #50FA7B; }
.highlight .gd { color: #FF5555; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: .9375rem; border-radius: var(--radius-sm); border: 1px solid var(--border); overflow: hidden; }
.prose th { background: var(--surface); padding: 10px 14px; text-align: left; font-weight: 600; font-size: .8125rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.prose td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose tr:last-child td { border-bottom: none; } .prose tr:hover td { background: var(--accent-light); }
.prose .toc-anchor { opacity: 0; margin-left: 6px; font-size: .75em; text-decoration: none; color: var(--accent); transition: opacity var(--transition); }
.prose h1:hover .toc-anchor, .prose h2:hover .toc-anchor, .prose h3:hover .toc-anchor { opacity: 1; }

/* ── TOC ────────────────────────────────────────────────────── */
.toc-widget { max-height: 60vh; overflow-y: auto; }
.toc-nav ul { list-style: none; padding: 0; }
.toc-nav li { margin-bottom: 2px; }
.toc-nav a { display: block; padding: 4px 8px; font-size: .8125rem; color: var(--text-muted); border-radius: var(--radius-sm); text-decoration: none; transition: all var(--transition); line-height: 1.4; }
.toc-nav a:hover { background: var(--accent-light); color: var(--accent); }
.toc-nav ul ul { padding-left: 14px; }
.toc-nav ul ul a { font-size: .775rem; }

/* ── Related ────────────────────────────────────────────────── */
.related-list { display: flex; flex-direction: column; gap: 4px; }
.related-link { display: block; padding: 8px 10px; border-radius: var(--radius-sm); font-size: .875rem; color: var(--text-muted); text-decoration: none; transition: all var(--transition); line-height: 1.4; }
.related-link:hover { background: var(--accent-light); color: var(--accent); }
.related-cat { display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 2px; }

/* ── Search page ────────────────────────────────────────────── */
.search-form { display: flex; gap: 12px; margin-bottom: 36px; align-items: flex-start; }
.search-input-wrap { flex: 1; position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.search-input-large { width: 100%; padding: 12px 14px 12px 44px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 1rem; background: var(--bg-card); color: var(--text); transition: all var(--transition); outline: none; }
.search-input-large:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

/* ── Empty / error ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 80px 24px; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 20px; }
.empty-state h2 { font-size: 1.375rem; margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 24px; }
.error-page { text-align: center; padding: 100px 24px; }
.error-code { font-size: clamp(5rem, 12vw, 9rem); font-weight: 900; letter-spacing: -0.05em; color: var(--surface); line-height: 1; margin-bottom: 8px; background: linear-gradient(135deg, var(--accent-light), var(--surface)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.error-title { font-size: 1.75rem; margin-bottom: 12px; }
.error-msg { color: var(--text-muted); margin-bottom: 32px; }
.error-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 20px; }
.alert-error { background: #FEF2F2; color: var(--red); border: 1px solid #FECACA; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer { background: var(--header-bg); border-top: 1px solid var(--header-border); padding: 32px 24px; margin-top: auto; }
.footer-inner { max-width: var(--max-w); margin: 0 auto; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: 10px; color: #9CA3AF; font-size: .875rem; font-weight: 500; }
.footer-copy { font-size: .8125rem; color: #6B7280; margin-right: auto; }
.footer-stats { font-size: .8125rem; color: #6B7280; display: flex; align-items: center; gap: 6px; }
.footer-nav { display: flex; gap: 20px; }
.footer-nav a { font-size: .8125rem; color: #6B7280; text-decoration: none; transition: color var(--transition); }
.footer-nav a:hover { color: #F4F4F6; }

/* ── Admin — shared ─────────────────────────────────────────── */
.admin-body { background: #F0F0F4; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #0C0C0F 0%, #1a1a2e 100%); }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 48px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { margin-bottom: 20px; }
.login-logo .logo-mark { width: 48px; height: 48px; font-size: 1rem; margin: 0 auto; }
.login-header h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login-header p { color: var(--text-muted); font-size: .9375rem; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-back { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 24px; font-size: .875rem; color: var(--text-muted); text-decoration: none; transition: color var(--transition); }
.login-back:hover { color: var(--text); }

.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 220px 1fr; }
.admin-sidebar { background: var(--header-bg); border-right: 1px solid var(--header-border); padding: 24px 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-logo { display: flex; align-items: center; gap: 10px; padding: 0 20px 24px; border-bottom: 1px solid var(--header-border); margin-bottom: 16px; font-size: .9375rem; font-weight: 600; color: #F4F4F6; text-decoration: none; }
.admin-nav { display: flex; flex-direction: column; padding: 0 10px; flex: 1; }
.admin-nav-group { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #6366F1; padding: 14px 12px 3px; user-select: none; }
.admin-sidebar-ip { padding: 10px 20px 0; font-size: .7rem; color: #6B7280; }
.admin-nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; color: #9CA3AF; text-decoration: none; transition: all var(--transition); margin-bottom: 2px; }
.admin-nav-link:hover, .admin-nav-link.active { background: rgba(255,255,255,.08); color: #F4F4F6; }
.admin-nav-logout { margin-top: auto; color: #6B7280; }
.admin-nav-logout:hover { background: rgba(239,68,68,.12); color: #F87171; }
.admin-main { padding: 32px 40px; overflow-y: auto; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.admin-page-title { font-size: 1.5rem; font-weight: 700; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow-xs); }
.stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 4px; }
.stat-label { font-size: .8125rem; color: var(--text-muted); font-weight: 500; }
.stat-published .stat-value { color: var(--green); }
.stat-draft .stat-value { color: var(--amber); }
.admin-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
.admin-card-header { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.admin-card-header h2 { font-size: 1rem; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th { padding: 10px 16px; text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #FAFAFA; }
.col-title { max-width: 320px; }
.table-title-link { font-weight: 600; color: var(--text); text-decoration: none; }
.table-title-link:hover { color: var(--accent); }
.table-slug { font-size: .75rem; color: var(--text-subtle); font-family: var(--font-mono); margin-top: 2px; }
.table-cat { font-size: .8rem; background: var(--accent-light); color: var(--accent-dark); padding: 3px 8px; border-radius: var(--radius-full); font-weight: 500; }
.col-date { white-space: nowrap; color: var(--text-muted); }
.col-actions { white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-full); font-size: .75rem; font-weight: 600; }
.status-published { background: #D1FAE5; color: #065F46; }
.status-draft { background: #FEF3C7; color: #92400E; }
.action-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text-muted); background: none; cursor: pointer; transition: all var(--transition); text-decoration: none; margin-right: 4px; }
.action-edit:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.action-view:hover { border-color: var(--text-muted); color: var(--text); background: var(--surface); }
.action-delete:hover { border-color: var(--red); color: var(--red); background: #FEF2F2; }
.inline-form { display: inline; }
.admin-empty { padding: 40px; text-align: center; color: var(--text-muted); }
.text-muted { color: var(--text-subtle); }

.editor-form { flex: 1; }
.editor-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 16px; }
.title-input { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; width: 100%; color: var(--text); background: var(--bg-card); outline: none; transition: border-color var(--transition); }
.title-input::placeholder { color: var(--text-subtle); font-weight: 400; }
.title-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.editor-meta { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.meta-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-xs); }
.meta-card-title { font-size: .8125rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 14px; }
.editor-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.upload-status { font-size: .8rem; color: var(--text-muted); margin-top: 8px; text-align: center; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.form-label { font-size: .8125rem; font-weight: 500; color: var(--text-muted); }
.label-hint { font-weight: 400; color: var(--text-subtle); }
.form-input, .form-select, .form-textarea { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; color: var(--text); background: var(--bg-card); transition: all var(--transition); outline: none; width: 100%; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.form-textarea { resize: vertical; line-height: 1.6; }
.form-textarea-sm { min-height: 72px; }

.EasyMDEContainer .CodeMirror { font-family: var(--font-mono); font-size: .9rem; border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-color: var(--border); min-height: 460px; }
.editor-toolbar { border-color: var(--border) !important; border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; }
.editor-toolbar button { color: var(--text-muted) !important; }
.editor-toolbar button:hover, .editor-toolbar button.active { background: var(--accent-light) !important; color: var(--accent) !important; }
.editor-preview { background: var(--bg); font-family: var(--font); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .page-wrapper { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .article { max-width: 100%; }
  .kbe-categories { grid-template-columns: 1fr; }
  .kbe-category:nth-child(odd) { border-right: none; padding-right: 0; }
  .kbe-category:nth-child(even) { padding-left: 0; }
}
@media (max-width: 768px) {
  /* Header */
  .header-inner { gap: 8px; padding: 0 16px; }
  .header-search { display: none; }
  .site-nav { display: none; }
  .site-nav.open { display: flex; flex-direction: column; position: fixed; top: 60px; left: 0; right: 0; background: var(--header-bg); border-bottom: 1px solid var(--header-border); padding: 12px; z-index: 99; gap: 4px; }
  .nav-toggle { display: flex; margin-left: auto; }
  /* Hide reggae dots + upload label on mobile to prevent overflow */
  .one-drop { display: none !important; }
  #uploadBtnLabel { display: none; }
  .header-upload-btn { padding: 7px 9px; max-width: unset; }
  /* Upload popup full-width safe on mobile */
  .upload-popup { width: min(340px, calc(100vw - 32px)); right: -8px; }
  /* Layout */
  .page-wrapper { padding: 20px 16px; gap: 24px; }
  .ip-bar { padding: 5px 16px; }
  /* Admin */
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .admin-main { padding: 20px 16px; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-meta { position: static; }
  .search-form { flex-direction: column; }
  .home-logo-banner img { height: 40px; }
  /* Site footer wraps nicely */
  .footer-inner { gap: 12px; flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .header-inner { padding: 0 12px; }
  .ip-bar { padding: 4px 12px; font-size: .7rem; }
  .page-wrapper { padding: 16px 12px; gap: 20px; }
  .admin-stats { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .pagination { flex-direction: column; gap: 12px; }
  .article-title { font-size: 1.5rem; }
  /* Prose tables scroll horizontally instead of breaking layout */
  .prose table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Code blocks: ensure no horizontal bleed */
  .prose pre, .prose .highlight { margin-left: 0; margin-right: 0; border-radius: var(--radius-sm); }
  /* Upload popup: full viewport width on tiny screens */
  .upload-popup { width: calc(100vw - 24px); right: -12px; }
  /* Admin sidebar compact on phone */
  .admin-sidebar-ip { display: none; }
}
