@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #15181C;
  --surface: #1C2126;
  --border: #2B323A;
  --text: #E7ECF1;
  --text-muted: #8A96A3;
  --accent: #4C7BDB;
  --accent-dark: #2E5AAC;
  --tag-bg: #163832;
  --tag-text: #6FD9BE;
  --danger: #E2645B;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  line-height: 1.55;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Layout shell ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}

.site-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.site-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
}

.site-title a { color: var(--text); }
.site-title a:hover { text-decoration: none; }

.site-tagline {
  margin: 2px 0 0;
}

.search-form {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 380px;
  min-width: 220px;
}

.search-form input[type="search"] {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
}

.search-form input[type="search"]::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover { background: var(--tag-bg); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover { background: #8f3129; border-color: #8f3129; }

main.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Sidebar: dossier-style category tabs ---------- */
.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.category-list li { border-bottom: 1px solid var(--border); }
.category-list li:last-child { border-bottom: none; }

.category-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  color: var(--text);
  border-left: 3px solid transparent;
}

.category-list a:hover {
  background: var(--bg);
  text-decoration: none;
}

.category-list a.active {
  border-left-color: var(--accent);
  background: var(--tag-bg);
  font-weight: 600;
}

.category-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---------- Article cards ---------- */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
}

.article-card:hover { border-color: var(--accent); }

.ref-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--tag-bg);
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 8px;
}

.article-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.article-title a { color: var(--text); }

.article-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.tag-chip {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.76rem;
  padding: 2px 9px;
  border-radius: 999px;
  margin-right: 6px;
}

/* ---------- Article detail ---------- */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.article-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
}

.article-detail h1 {
  font-size: 1.5rem;
  margin: 8px 0 4px;
}

.article-body ul { padding-left: 22px; }
.article-body ol { padding-left: 22px; }
.article-body p { margin: 0 0 14px; }
.article-body h2 { font-size: 1.2rem; margin: 24px 0 10px; }
.article-body h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.article-body h4 { font-size: 0.95rem; margin: 16px 0 6px; }

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 6px 0;
}

.article-body code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
  background: var(--bg);
  padding: 2px 5px;
  border-radius: 4px;
}

.article-body pre {
  background: #0F1317;
  color: #E7ECF1;
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0 0 14px;
}

.article-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 14px;
  padding: 4px 16px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.article-body blockquote p { margin: 0; }

.attachments-block {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.attachment-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.attachment-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.attachment-list li:last-child { border-bottom: none; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ---------- Admin ---------- */
.admin-bar {
  background: var(--accent-dark);
  color: #fff;
  padding: 8px 24px;
  font-size: 0.85rem;
  font-family: 'IBM Plex Mono', monospace;
}

.admin-bar a { color: #fff; text-decoration: underline; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.admin-table th {
  background: var(--bg);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.admin-actions { display: flex; gap: 10px; }

.form-field { margin-bottom: 18px; }
.form-field label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-field input[type="text"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
}

.form-field input[type="text"]::placeholder,
.form-field textarea::placeholder { color: var(--text-muted); }

.form-field input[type="file"] { color: var(--text); }

.form-field textarea { min-height: 220px; resize: vertical; font-family: 'IBM Plex Mono', monospace; font-size: 0.88rem; }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  position: relative;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  cursor: pointer;
  color: var(--text);
}

.toolbar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--tag-bg);
}

.toolbar-btn .chevron { opacity: 0.6; }

.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-dropdown { position: relative; }

.toolbar-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  min-width: 160px;
  overflow: hidden;
}

.toolbar-menu button {
  background: none;
  border: none;
  text-align: left;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
}

.toolbar-menu button:hover {
  background: var(--tag-bg);
  color: var(--accent);
}

.toolbar-menu[hidden] { display: none; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.login-shell {
  max-width: 360px;
  margin: 80px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.alert-error { background: #3A211E; color: #FF9D91; border: 1px solid #5C2E28; }
.alert-success { background: var(--tag-bg); color: var(--tag-text); border: 1px solid #1F5548; }
