:root {
  --bg: #f6f4ee;
  --bg-soft: #efede5;
  --surface: #fffefa;
  --surface-2: #fbfaf5;
  --ink: #1d1c19;
  --ink-2: #3d3b36;
  --muted: #77736a;
  --line: #e2ded2;
  --line-strong: #cec9ba;
  --accent: #0f766e;
  --accent-ink: #0a5c56;
  --accent-soft: #e4f2ef;
  --warn: #b45309;
  --warn-soft: #fdf0e3;
  --bad: #b42318;
  --bad-soft: #fbeae7;
  --good: #18794e;
  --good-soft: #e6f4ec;
  --blue: #2f5bd3;
  --blue-soft: #e9eefb;
  --violet: #6b3fa0;
  --violet-soft: #f0eafa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(29, 28, 25, .04), 0 10px 30px rgba(29, 28, 25, .05);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 12% -10%, #fffdf6 0%, rgba(255, 253, 246, 0) 60%),
    radial-gradient(900px 420px at 95% 0%, #eef4f1 0%, rgba(238, 244, 241, 0) 55%),
    var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.01em;
}

p { margin: 0; }

.wrap { width: min(1080px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- public layout ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(246, 244, 238, .82);
  border-bottom: 1px solid rgba(226, 222, 210, .75);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 66px;
}

.brand {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.brand-dot { color: var(--accent); }

.nav { display: flex; gap: 26px; font-size: 14px; }
.nav a { color: var(--ink-2); }
.nav a:hover { color: var(--accent-ink); text-decoration: none; }

.main { padding: 56px 0 80px; min-height: calc(100vh - 160px); }

.site-footer { border-top: 1px solid var(--line); padding: 22px 0 30px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }

/* ---------- hero ---------- */

.hero { padding: 44px 0 54px; max-width: 760px; }
.eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero h1 { font-size: clamp(34px, 5vw, 58px); line-height: 1.15; letter-spacing: -.03em; }
.lede { margin-top: 20px; color: var(--muted); font-size: 17px; max-width: 640px; }
.hero .btn { margin-top: 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #000; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; justify-content: center; }
.btn.disabled { opacity: .4; pointer-events: none; }

/* ---------- posts ---------- */

.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { font-size: 24px; }
.more { font-size: 14px; color: var(--muted); }
.more:hover { color: var(--accent-ink); }

.post-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.post-card {
  display: block;
  padding: 24px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(29, 28, 25, .02);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.post-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.post-card time { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.post-card h3 { margin-top: 8px; font-size: 22px; }
.post-card p { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: .02em;
}

.page-head { padding: 8px 0 26px; max-width: 760px; }
.page-head h1 { font-size: clamp(30px, 4vw, 44px); }
.page-head.narrow { max-width: 640px; }
.page-head.split { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; max-width: none; }

.empty { padding: 28px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* ---------- article ---------- */

.article { max-width: 760px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: 26px; color: var(--muted); font-size: 14px; }
.article-head h1 { font-size: clamp(32px, 4.6vw, 46px); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 13px; }

.prose { margin-top: 34px; font-size: 17px; line-height: 1.95; color: var(--ink-2); }
.prose p { margin: 0 0 1.25em; }
.prose h2 { margin: 2em 0 .7em; font-size: 26px; color: var(--ink); }
.prose h3 { margin: 1.6em 0 .6em; font-size: 20px; color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.25em; }
.prose li { margin: .35em 0; }
.prose blockquote { margin: 1.4em 0; padding: 2px 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.prose code { padding: .15em .4em; border-radius: 6px; background: var(--bg-soft); font-family: var(--mono); font-size: .88em; }
.prose pre { overflow-x: auto; padding: 16px 18px; border-radius: 12px; background: #1f2328; color: #e8e6df; font-size: 13px; line-height: 1.65; }
.prose pre code { padding: 0; background: transparent; color: inherit; }
.prose img { max-width: 100%; border-radius: 12px; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose-page { margin-top: 8px; }

/* ---------- admin ---------- */

.admin-body { background: var(--bg); }

.admin-header { background: #1d1c19; color: #f6f4ee; }
.admin-header-inner { display: flex; align-items: center; gap: 26px; height: 58px; }
.admin-header .brand { color: #fff; font-size: 18px; }
.admin-nav { display: flex; gap: 20px; margin-left: auto; font-size: 13px; }
.admin-nav a { color: #cfcbc1; }
.admin-nav a:hover { color: #fff; text-decoration: none; }
.admin-header form { margin: 0; }
.admin-header .ghost { color: #cfcbc1; border-color: #4a4740; background: transparent; padding: 6px 12px; }
.admin-header .ghost:hover { color: #fff; border-color: #77736a; }

.admin-main { padding: 34px 0 70px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 22px; }
.cards.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.card.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.stat-value { font-family: var(--serif); font-size: 32px; line-height: 1.1; font-weight: 700; }
.stat-hint { font-size: 12px; color: var(--muted); }
.card.small .stat-label { margin-bottom: 4px; }
.card.small strong { font-size: 14px; font-weight: 600; word-break: break-all; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 0 rgba(29, 28, 25, .02);
}
.panel h2 { font-size: 19px; margin-bottom: 14px; }
.panel .section-head { margin-bottom: 12px; }
.panel .section-head h2 { margin-bottom: 0; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.chart { width: 100%; height: 280px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
table.headers td:first-child { width: 30%; white-space: nowrap; }

.mono { font-family: var(--mono); font-size: 12px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; overflow-wrap: anywhere; }
.link { background: none; border: 0; padding: 0; color: var(--accent-ink); font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--bad); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-normal { background: var(--good-soft); color: var(--good); }
.badge-proxy { background: var(--warn-soft); color: var(--warn); }
.badge-rd { background: var(--blue-soft); color: var(--blue); }
.badge-rd_proxy { background: var(--bad-soft); color: var(--bad); }
.badge-unknown { background: var(--bg-soft); color: var(--muted); }
.badge-info { background: var(--violet-soft); color: var(--violet); }

.mode {
  display: inline-flex;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--surface);
  white-space: nowrap;
}
.mode-direct { border-color: #b9d9c8; color: var(--good); }
.mode-proxy { border-color: #eccba4; color: var(--warn); }
.mode-rd { border-color: #c3d1f4; color: var(--blue); }
.mode-rd_proxy { border-color: #e8b9b3; color: var(--bad); }
.mode-unknown { color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.pager .btn { padding: 7px 14px; }

.filter-bar, .gt-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.filter-bar label, .gt-form label, .field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.filter-bar .grow, .gt-form .grow { flex: 1 1 220px; }
input[type="text"], input[type="password"], input[type="number"], select {
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  min-height: 38px;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.filter-bar .btn, .gt-form .btn { min-height: 38px; }

.inline-form { display: flex; align-items: flex-end; gap: 10px; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

.alert { padding: 10px 13px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); font-size: 13px; margin: 10px 0; }
.alert.error { background: var(--bad-soft); color: var(--bad); }

/* verdict banner */
.verdict-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  margin: 8px 0 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.verdict-banner.v-normal { border-left-color: var(--good); }
.verdict-banner.v-proxy { border-left-color: var(--warn); }
.verdict-banner.v-rd { border-left-color: var(--blue); }
.verdict-banner.v-rd_proxy { border-left-color: var(--bad); }
.verdict-banner.v-unknown { border-left-color: var(--muted); }
.verdict-main { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.verdict-gt { font-size: 13px; color: var(--ink-2); }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  min-width: 0;
}
.fact span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.fact strong { display: block; font-size: 13px; font-weight: 600; word-break: break-word; }

.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw pre {
  margin: 12px 0 0;
  padding: 16px;
  max-height: 520px;
  overflow: auto;
  border-radius: 10px;
  background: #1f2328;
  color: #e8e6df;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

.hint-list { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: 13px; }
.hint-list li { margin: .35em 0; }

/* login */
.login-wrap { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.login-card {
  width: min(380px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 28px; margin-bottom: 6px; }
.login-card .muted { font-size: 13px; margin-bottom: 18px; }
.login-card .field { margin-bottom: 16px; }
.login-card input { width: 100%; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head.split { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  .wrap { width: calc(100% - 32px); }
  .main { padding: 36px 0 60px; }
  .post-list { grid-template-columns: 1fr; }
  .header-inner { height: 58px; }
  .nav { gap: 18px; }
  .hero { padding: 20px 0 34px; }
  .cards, .cards.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts { grid-template-columns: 1fr; }
  .verdict-banner { flex-direction: column; align-items: flex-start; }
  .admin-header-inner { gap: 12px; height: auto; padding: 10px 0; flex-wrap: wrap; }
  .admin-nav { margin-left: 0; order: 3; width: 100%; }
  .footer-inner { flex-direction: column; }
  .filter-bar, .gt-form { align-items: stretch; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
