:root {
  --bg: #08090d;
  --bg-soft: #0d0f15;
  --surface: #11131b;
  --surface-2: #171a23;
  --text: #f3f4f6;
  --muted: #a7adb8;
  --border: #2a2e39;
  --accent: #e32b3a;
  --accent-2: #ff5b66;
  --accent-soft: rgba(227, 43, 58, .14);
  --danger: #ff5b66;
  --shadow: 0 18px 48px rgba(0, 0, 0, .28);
  --radius: 18px;
  --max: 1140px;
}

html[data-theme="light"] {
  --bg: #f7f7f8;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #101218;
  --muted: #5d6470;
  --border: #d9dce2;
  --accent: #c5162b;
  --accent-2: #e32b3a;
  --accent-soft: rgba(197, 22, 43, .10);
  --shadow: 0 16px 34px rgba(16, 18, 24, .08);
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
html[data-theme="light"] { color-scheme: light; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.58;
  background:
    radial-gradient(circle at 18% -10%, rgba(227, 43, 58, .22), transparent 32rem),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  color: var(--text);
  min-width: 280px;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 70%);
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
.container { width: min(var(--max), calc(100% - 2rem)); margin: 0 auto; }
.skip-link { position: absolute; left: -9999px; top: 1rem; }
.skip-link:focus { left: 1rem; z-index: 20; background: var(--surface); padding: .6rem .8rem; border-radius: 10px; }

.site-header, .admin-topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 9, 13, .88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 70px; gap: 1rem; position: relative; }
.brand { display: inline-flex; align-items: center; color: var(--text); font-weight: 800; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: auto; max-width: 200px; max-height: 60px; object-fit: contain; }
.header-actions { display: flex; gap: .45rem; align-items: center; margin-left: auto; }
.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav a { color: var(--muted); padding: .5rem .72rem; border-radius: 999px; font-weight: 650; font-size: .95rem; }
.site-nav a:hover, .site-nav a.active { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav-toggle, .theme-toggle { display: inline-flex; width: auto; padding: .5rem 1.25rem; }
.nav-toggle { display: none; }
.site-main { min-height: 70vh; }

.page-hero, .hero { padding: clamp(2.4rem, 8vw, 5rem) 0 clamp(1.4rem, 4vw, 2.4rem); }
.page-hero.narrow { padding-bottom: 1rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(260px, .82fr); gap: 1.2rem; align-items: center; }
.eyebrow { color: var(--accent-2); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .76rem; margin: 0 0 .75rem; }
h1, h2, h3 { line-height: 1.14; margin: 0 0 .8rem; text-wrap: balance; }
h1 { font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.045em; max-width: 850px; }
h2 { font-size: clamp(1.35rem, 3.2vw, 2.15rem); letter-spacing: -.025em; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1rem; }
.lede { font-size: clamp(1rem, 2.5vw, 1.14rem); color: var(--muted); max-width: 64ch; }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.35rem; margin-bottom: 1.35rem;}
.button, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .68rem .95rem;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 42px;
}
.button.primary, button.primary, input[type="submit"].primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button:hover, button:hover, input[type="submit"]:hover { text-decoration: none; filter: brightness(1.08); }
.button.ghost { background: transparent; }
.button.danger, button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .6; cursor: not-allowed; }
.liked { background: var(--accent); color: #fff; border-color: var(--accent); }

.card, .post-card, .panel, .admin-card, .note-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.signal { border: 1px solid var(--border); background: var(--accent-soft); border-radius: 999px; padding: .55rem .75rem; color: var(--text); font-weight: 700; font-size: .92rem; }
.icon { display: inline-block; margin-right: .28rem; }
.section { padding: clamp(2rem, 5vw, 3.2rem) 0; }
.section-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.2rem; }
.section-head p { color: var(--muted); margin: 0; }

.post-list { display: grid; gap: 1rem; }
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.post-card { display: flex; flex-direction: column; gap: .75rem; overflow: hidden; padding: 0; }
.post-card-body { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: .65rem; flex: 1; }
.post-card h2, .post-card h3 { margin-bottom: 0; }
.post-card p { color: var(--muted); margin: 0; }
.post-image { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.post-image img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.post-card:hover .post-image img { transform: scale(1.025); }
.article-image { aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); margin: 1.5rem 0 0; background: var(--surface-2); }
.article-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { display: flex; flex-wrap: wrap; gap: .4rem .65rem; color: var(--muted); font-size: .88rem; align-items: center; }
.tag, .category-pill { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: .18rem .52rem; color: var(--muted); font-size: .82rem; align-items: center; }
.category-pill { color: var(--accent-2); background: var(--accent-soft); }
.tags { display: flex; flex-wrap: wrap; gap: .38rem; }

.filters { display: grid; grid-template-columns: 1.5fr repeat(2, minmax(130px, .65fr)); gap: .65rem; margin: 1rem 0 1.35rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: .72rem .78rem;
  font: inherit;
}
textarea { min-height: 280px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
label { display: grid; gap: .35rem; color: var(--muted); font-weight: 700; }
.form-grid { display: grid; gap: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.help { color: var(--muted); font-size: .92rem; }
.error { color: var(--danger); }
.success { color: var(--accent-2); }
.markdown-guide { display: grid; gap: .8rem; }
.markdown-guide pre { margin: 0; white-space: pre-wrap; }

.article { max-width: 860px; margin: 0 auto; padding: clamp(2.2rem, 6vw, 4rem) 1rem; }
.article h1 { font-size: clamp(2rem, 5.5vw, 3.35rem); }
.article-content { margin-top: 2rem; }
.article-content p, .article-content li { color: var(--muted); text-align: justify;line-height: 2;}
.article-content h2, .article-content h3 { margin-top: 1.7rem; }
.article-content pre { overflow-x: auto; background: #050608; border: 1px solid var(--border); border-radius: 14px; padding: 1rem; }
html[data-theme="light"] .article-content pre { background: #f0f1f4; }
.article-content code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: .3rem .45rem; }
.article-content pre code { border: 0; padding: 0; background: transparent; }
.article-content blockquote { border-left: 3px solid var(--accent); margin-left: 0; padding-left: 1rem; color: var(--muted); line-height: 2;}
.article-content img { border-radius: 14px; border: 1px solid var(--border); }
.post-cta { margin-top: 2rem; padding: 1rem; border: 1px solid var(--border); background: var(--accent-soft); border-radius: var(--radius); }
.like-row { display: flex; align-items: center; gap: .8rem; margin-top: 1rem; flex-wrap: wrap; }
.heart-button { min-width: 74px; }

.pagination { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.5rem; }
.pagination a, .pagination span { padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); }
.pagination .current { color: var(--text); background: var(--surface-2); }

.site-footer { margin-top: 3rem; border-top: 1px solid var(--border); padding: 2rem 0; color: var(--muted); }
.footer-grid { display: flex; justify-content: space-between; gap: 1.5rem; }
.footer-grid div:last-child { display: flex; gap: .8rem; flex-wrap: wrap; align-content: start; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 1.4rem; padding-top: 1rem; font-size: .9rem; }

.admin-main { padding-top: 2rem; padding-bottom: 2rem; }
.admin-main h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
.admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 800; }
.inline-form { display: inline; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.current-image { max-width: 260px; border-radius: 14px; border: 1px solid var(--border); aspect-ratio: 16 / 9; object-fit: cover; }

@media (max-width: 980px) {
  .post-grid, .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .header-inner { min-height: 64px; }
  .brand img { max-width: 200px; max-height: 60px; }
  .hero-grid, .card-grid, .post-grid, .admin-grid, .form-row, .filters { grid-template-columns: 1fr; }
  .section-head { display: block; }
  .actions .button, .actions button { width: 100%; }
  .nav-toggle { display: inline-flex; }
  .site-nav { display: none; position: absolute; top: 64px; left: .5rem; right: .5rem; flex-direction: column; align-items: stretch; padding: .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .site-nav.open { display: flex; }
  .admin-nav { position: static; display: flex; flex-wrap: wrap; flex-direction: row; background: transparent; border: 0; padding: 0; }
  .footer-grid { flex-direction: column; }
  .post-card-body { padding: 0 .9rem .95rem; }
}

@media (max-width: 375px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.28rem; }
  .brand img { max-width: 200px; }
  .button, button, input[type="submit"] { padding: .62rem .78rem; }
  .site-nav a { padding: .5rem .6rem; }
  .meta { font-size: .82rem; }
}

/* 16:9 media fallback for older mobile Safari */
.post-image, .article-image { position: relative; height: 0; padding-top: 56.25%; aspect-ratio: auto; }
.post-image img, .article-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.current-image { aspect-ratio: auto; }

.editor-panel {
  display: grid;
  gap: .65rem;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  padding: .65rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}
.editor-toolbar button {
  min-height: 38px;
  padding: .52rem .8rem;
}
.editor-panel textarea {
  min-height: 460px;
}
.editor-panel.is-dragging textarea {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.article-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.1rem 0;
}

@media (max-width: 480px) {
  .editor-toolbar {
    align-items: stretch;
  }
  .editor-toolbar button {
    width: 100%;
  }
  .editor-panel textarea {
    min-height: 360px;
  }
}
