@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ubuntu-400.woff2") format("woff2");
}
@font-face {
  font-family: "Ubuntu";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ubuntu-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ubuntu-700.woff2") format("woff2");
}
@font-face {
  font-family: "Spectral";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/spectral-400.woff2") format("woff2");
}
@font-face {
  font-family: "Spectral";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/spectral-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Spectral";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/spectral-700.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/manrope-400.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-700.woff2") format("woff2");
}

:root {
  --bg: #0f0f0f;
  --bg2: #181818;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #7aa2f7;
  --accent2: #9ece6a;
  --tag-bg: #1e2030;
  --font: "Ubuntu", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  --max-w: 720px;
}

html[data-theme="light"] {
  --bg: #fbfbfa;
  --bg2: #f0f0ee;
  --border: #dcdcda;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #3b5bdb;
  --accent2: #2f9e44;
  --tag-bg: #e7ebff;
}

html[data-theme="light"] .highlight {
  background: #272822 !important;
  color: #f8f8f2;
}

html[data-font="spectral"] { --font: "Spectral", Georgia, serif; }
html[data-font="manrope"] { --font: "Manrope", system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}

header nav {
  max-width: var(--max-w);
  margin: 0 auto;
}

.site-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: -0.02em;
}

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

main {
  flex: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
}

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

/* Index */
.blog-description {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}

.tag {
  background: var(--tag-bg);
  color: var(--text-muted);
  padding: 0.2rem 0.7rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: var(--mono);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

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

.tag-count {
  opacity: 0.6;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.article-card {
  border-bottom: 1px solid var(--border);
  padding-bottom: 2rem;
}

.article-card:last-child {
  border-bottom: none;
}

.article-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-family: var(--mono);
}

.dot { margin: 0 0.35rem; }

.tag-inline {
  color: var(--accent2);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.article-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

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

.article-card h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.article-summary {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.4rem;
}

/* Article */
.page-article {
  max-width: 680px;
}

.article-header {
  margin-bottom: 2.5rem;
}

.article-header h1 {
  font-size: 2rem;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.article-body p { margin-bottom: 1.2rem; }

.article-body ul,
.article-body ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.article-body li { margin-bottom: 0.3rem; }

.article-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 1.5rem 0;
  font-style: italic;
}

.article-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg2);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.article-body pre {
  background: var(--bg2) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.2rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.9rem;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.article-body th {
  background: var(--bg2);
  color: var(--text-muted);
}

.article-body img {
  display: block;
  max-width: 100%;
  margin: 1.2rem auto;
  border-radius: 6px;
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 6px;
}

.article-body p:has(img + img) {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: flex-start;
}

.article-body p:has(img + img) img {
  margin: 0;
  flex: 1 1 0;
  min-width: 200px;
  max-width: calc(50% - 0.5rem);
}

.article-body a { color: var(--accent); }

.article-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Tag page */
.tag-heading {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  color: var(--accent2);
  font-family: var(--mono);
}

.back-link {
  margin-top: 2rem;
}

/* Admin */
.page-admin {
  max-width: 100%;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.admin-header h1 {
  font-size: 1.5rem;
}

.btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--mono);
}

.btn:hover { opacity: 0.85; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  font-family: var(--mono);
  color: var(--accent);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

section {
  margin-bottom: 2rem;
}

section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
  font-weight: normal;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-family: var(--mono);
  font-weight: normal;
  font-size: 0.8rem;
}

td code {
  font-family: var(--mono);
  font-size: 0.85em;
}

.flag { vertical-align: middle; margin-right: 0.4rem; border-radius: 2px; }

.bar {
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.7;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 0.5rem 0.2rem 0;
  white-space: nowrap;
}

.country-count {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8em;
  margin-left: 0.25rem;
}

.country-more {
  display: inline;
}

.country-more summary {
  display: inline;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.country-more[open] summary {
  display: block;
  margin-bottom: 0.3rem;
}

/* Preview banner */
.preview-banner {
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.4rem 1rem;
  margin-bottom: 2rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.preview-banner--draft {
  background: #2a2000;
  color: #f0a500;
  border: 1px solid #f0a500;
}

.preview-banner--internal {
  background: #0a1a2a;
  color: #7aa2f7;
  border: 1px solid #7aa2f7;
}

.empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Pygments highlight */
.highlight {
  background: var(--bg2) !important;
}

/* Font switcher */
.font-switch, .theme-switch {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.theme-switch button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
}

.theme-switch button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.font-switch button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.font-switch button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.font-switch button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.font-switch button[data-set="ubuntu"] { font-family: "Ubuntu", system-ui, sans-serif; }
.font-switch button[data-set="spectral"] { font-family: "Spectral", Georgia, serif; }
.font-switch button[data-set="manrope"] { font-family: "Manrope", system-ui, sans-serif; }

@media (max-width: 640px) {
  main { padding: 1.5rem 1rem; }
  .admin-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .article-header h1 { font-size: 1.5rem; }
}
