:root {
  --navy: #0f2d52;
  --navy-600: #173e6e;
  --ink: #0e1726;
  --text: #2a3445;
  --muted: #667085;
  --line: #e6e9ef;
  --bg: #ffffff;
  --soft: #f3f5f9;
  --chip: #e8eefb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 28px rgba(16, 24, 40, .12);
  --max: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 24px; height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 26px; color: var(--ink); letter-spacing: -0.02em; }
.brand svg { width: 42px; height: 42px; color: var(--navy); }
.tagline { color: var(--muted); font-size: 14px; padding-left: 24px; border-left: 1px solid var(--line); white-space: nowrap; }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-links a {
  padding: 8px 14px; font-weight: 500; color: var(--ink); font-size: 15px; position: relative;
}
.nav-links a.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -14px; height: 2px; background: var(--navy);
}
.icon-btn {
  background: none; border: 0; padding: 8px; cursor: pointer; color: var(--ink); border-radius: 8px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 22px; height: 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  background: var(--navy); color: #fff; font: inherit; font-weight: 600; font-size: 15px;
  padding: 9px 18px; border-radius: 8px; transition: background .15s;
}
.btn:hover { background: var(--navy-600); }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.ghost:hover { background: var(--line); }
.menu-toggle { display: none; }

/* ---------- Hero ---------- */
.hero-grid { display: grid; grid-template-columns: 2.6fr 1fr; gap: 24px; margin: 32px 0 56px; }
.hero {
  position: relative; border-radius: var(--radius); overflow: hidden; min-height: 300px;
  display: flex; align-items: flex-end; color: #fff; box-shadow: var(--shadow);
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.hero:hover img { transform: scale(1.03); }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, rgba(8,18,38,.82) 0%, rgba(8,18,38,.5) 45%, rgba(8,18,38,0) 75%);
}
.hero-body { position: relative; z-index: 2; padding: 32px 30px 26px; max-width: 520px; }
.hero h1 { color: #fff; font-size: clamp(26px, 3.2vw, 32px); font-weight: 700; margin: 14px 0 10px; }
.hero p { margin: 0 0 18px; color: rgba(255,255,255,.9); font-size: 16px; }
.hero .meta { color: rgba(255,255,255,.88); }
.hero .avatar { background: #fff; color: var(--navy); }

.chip {
  display: inline-block; background: var(--chip); color: var(--ink); font-size: 12.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--muted); }
.meta .author { font-weight: 600; color: inherit; display: flex; align-items: center; gap: 8px; }
.meta .dot { opacity: .6; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--soft); color: var(--navy); }

/* ---------- Categories ---------- */
.panel { background: var(--soft); border-radius: var(--radius); padding: 24px 22px; }
.panel h3 { font-size: 21px; margin-bottom: 12px; }
.cat-list { list-style: none; padding: 0; margin: 0; }
.cat-list a {
  display: flex; align-items: center; gap: 16px; padding: 8px 6px; border-radius: 8px; font-size: 16px; color: var(--ink);
}
.cat-list a:hover { background: #e6eaf2; }
.cat-list svg { width: 22px; height: 22px; flex: none; }
.cat-list .count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------- Sections ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.section-head h2 { font-size: 28px; font-weight: 700; }
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); }
.link-arrow svg { width: 18px; height: 18px; transition: transform .2s; }
.link-arrow:hover svg { transform: translateX(3px); }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 64px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff;
  display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-media { position: relative; aspect-ratio: 16 / 7.4; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media .chip { position: absolute; left: 18px; bottom: 10px; }
.card-body { padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.card h3 { font-size: 18px; font-weight: 700; }
.card .excerpt { margin: -6px 0 0; font-size: 14px; color: var(--muted); }
.card .meta { margin-top: auto; }

/* ---------- Articles page ---------- */
.page-head { padding: 48px 0 24px; }
.page-head h1 { font-size: 40px; font-weight: 800; }
.page-head p { color: var(--muted); margin: 8px 0 0; font-size: 17px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.filter {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink);
}
.filter.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.empty { padding: 48px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); grid-column: 1 / -1; }

/* ---------- Post ---------- */
.post-hero { position: relative; height: 380px; overflow: hidden; }
.post-hero img { width: 100%; height: 100%; object-fit: cover; }
.post-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(8,18,38,.55), rgba(8,18,38,0) 60%); }
.post-head { max-width: 760px; margin: -110px auto 0; position: relative; z-index: 2; background: #fff; border-radius: var(--radius); padding: 32px 36px 24px; box-shadow: var(--shadow-lg); }
.post-head h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; margin: 14px 0 12px; }
.post-head .lead { font-size: 18px; color: var(--muted); margin: 0 0 18px; }
.prose { max-width: 760px; margin: 0 auto; padding: 32px 36px 72px; font-size: 17.5px; line-height: 1.8; color: #1f2937; }
.prose h2 { font-size: 26px; margin: 40px 0 12px; }
.prose h3 { font-size: 20px; margin: 28px 0 10px; }
.prose p { margin: 0 0 20px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 20px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--navy-600); text-decoration: underline; text-underline-offset: 3px; }
.prose blockquote { margin: 24px 0; padding: 4px 20px; border-left: 3px solid var(--navy); color: var(--muted); font-style: italic; }
.prose code { background: var(--soft); padding: 2px 6px; border-radius: 4px; font-size: .9em; }
.prose img { border-radius: var(--radius); margin: 24px 0; }
.post-nav { max-width: 760px; margin: 0 auto 64px; padding: 0 36px; display: flex; justify-content: space-between; gap: 16px; }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 280px 1fr; gap: 48px; padding: 56px 0 80px; align-items: start; }
.about-card { background: var(--soft); border-radius: var(--radius); padding: 28px; text-align: center; }
.about-avatar { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 16px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 40px; font-weight: 800; }
.about-card h2 { font-size: 22px; }
.about-card p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
.about-links { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.about .prose { padding: 0; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 26px; color: var(--navy); }
.stat span { font-size: 13px; color: var(--muted); }

/* ---------- Write ---------- */
.write { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding-bottom: 72px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 14px; color: var(--ink); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 300px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #c7d5ef; border-color: var(--navy-600); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.preview .prose { padding: 24px; font-size: 16px; }
.preview-title { padding: 24px 24px 0; }
.preview-title h1 { font-size: 28px; margin: 10px 0; }
.output { margin-top: 16px; }
.output pre { background: #0e1726; color: #d6e2f5; padding: 16px; border-radius: 8px; overflow: auto; max-height: 260px; font-size: 12.5px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- Search ---------- */
.search-overlay { position: fixed; inset: 0; background: rgba(14,23,38,.45); display: none; z-index: 100; padding: 10vh 16px; }
.search-overlay.open { display: block; }
.search-box { max-width: 620px; margin: 0 auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.search-box input { width: 100%; border: 0; padding: 18px 20px; font: inherit; font-size: 18px; outline: none; border-bottom: 1px solid var(--line); }
.search-results { max-height: 50vh; overflow: auto; }
.search-results a { display: block; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a:focus { background: var(--soft); outline: none; }
.search-results b { display: block; color: var(--ink); }
.search-results span { font-size: 13px; color: var(--muted); }
.search-results .none { padding: 16px 20px; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 14px; }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .tagline { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .write { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .nav { height: 64px; gap: 8px; }
  .brand { font-size: 22px; }
  .brand svg { width: 34px; height: 34px; }
  .menu-toggle { display: grid; }
  .nav-links {
    display: none; position: absolute; top: 64px; left: 0; right: 0; background: #fff; flex-direction: column; align-items: stretch;
    padding: 8px 16px 16px; border-bottom: 1px solid var(--line); gap: 2px;
  }
  .nav-links.open { display: flex; }
  .nav-links a.active::after { display: none; }
  .nav-links a.active { background: var(--soft); border-radius: 8px; }
  .nav-tools { margin-left: auto; display: flex; gap: 4px; align-items: center; }
  .btn .label { display: none; }
  .btn { padding: 9px 12px; }
  .cards { grid-template-columns: 1fr; }
  .hero { min-height: 380px; }
  .hero-body { padding: 24px 20px; }
  .post-head { margin: -60px 16px 0; padding: 24px 20px; }
  .prose { padding: 24px 16px 56px; font-size: 17px; }
  .post-nav { padding: 0 16px; }
  .about { grid-template-columns: 1fr; gap: 28px; }
  .row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 32px; }
}
@media (min-width: 721px) { .nav-tools { display: flex; gap: 8px; align-items: center; } }

/* ---------- Author login / publish ---------- */
.login-card { max-width: 440px; margin: 64px auto 96px; padding: 32px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card h1 { font-size: 28px; margin-bottom: 6px; }
.login-card details { margin-top: 16px; }
.login-card ol { padding-left: 20px; line-height: 1.7; }
.login-card a, .hint a, .site-footer a { color: var(--navy-600); text-decoration: underline; text-underline-offset: 3px; }
.hint.error { color: #b42318; }
.hint.ok { color: #067647; }
.publish-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 8px; }
.publish-bar .btn { padding: 11px 28px; }
.btn:disabled { opacity: .6; cursor: wait; }
details summary { cursor: pointer; }
.field input[type=file] { padding: 8px; }
.btn.wide { width: 100%; justify-content: center; }
.login-card details ol { margin: 8px 0 0; }
.field details { margin-top: 4px; }
