/*
 * 出海发资讯主题 · 深夜领航台
 * 深色默认（data-theme="dark"），日间模式 data-theme="light"
 * 令牌与出海发导航站共用同一套 OKLCH 调色板（hue 235 / 琥珀 65 / 海图青 215）
 */

:root {
  --abyss: oklch(13.5% 0.012 235);
  --depth: oklch(17.5% 0.014 235);
  --shoal: oklch(21.5% 0.016 235);
  --line: oklch(28% 0.018 235);
  --line-strong: oklch(35% 0.02 235);
  --foam: oklch(93% 0.006 235);
  --mist: oklch(71% 0.012 235);
  --faint: oklch(60% 0.014 235);
  --beacon-fill: oklch(80% 0.17 65);
  --beacon-fill-hover: oklch(86% 0.14 70);
  --beacon-ink: oklch(80% 0.17 65);
  --beacon-dim: oklch(64% 0.12 60);
  --on-beacon: oklch(13.5% 0.012 235);
  --chart: oklch(72% 0.09 215);
  --chart-deep: oklch(64% 0.1 215);
  --stripe: oklch(100% 0 0 / 0.02);
  --grid: oklch(100% 0 0 / 0.025);
  --shadow-panel: 0 1px 0 oklch(100% 0 0 / 0.03) inset, 0 10px 30px oklch(0% 0 0 / 0.35);
  color-scheme: dark;
}

html[data-theme="light"] {
  --abyss: oklch(96.5% 0.005 235);
  --depth: oklch(99.4% 0.002 235);
  --shoal: oklch(93.5% 0.008 235);
  --line: oklch(88% 0.01 235);
  --line-strong: oklch(79% 0.014 235);
  --foam: oklch(24% 0.02 235);
  --mist: oklch(42% 0.018 235);
  --faint: oklch(53% 0.015 235);
  --beacon-fill: oklch(74% 0.16 62);
  --beacon-fill-hover: oklch(70% 0.16 62);
  --beacon-ink: oklch(56% 0.14 60);
  --beacon-dim: oklch(66% 0.12 60);
  --on-beacon: oklch(18% 0.015 235);
  --chart: oklch(46% 0.09 215);
  --chart-deep: oklch(40% 0.09 215);
  --stripe: oklch(0% 0 0 / 0.03);
  --grid: oklch(35% 0.03 235 / 0.06);
  --shadow-panel: 0 1px 0 oklch(100% 0 0 / 0.6) inset, 0 8px 24px oklch(45% 0.05 235 / 0.14);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background-color: var(--abyss);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  color: var(--foam);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.65;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; transition: color 150ms; }
a:hover { color: var(--beacon-ink); }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { text-wrap: balance; }

::selection { background: var(--beacon-fill); color: var(--on-beacon); }
:focus-visible { outline: 2px solid var(--beacon-ink); outline-offset: 2px; border-radius: 2px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }

.readout {
  font-family: "Martian Mono", ui-monospace, "Cascadia Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* ---------- 页面骨架 ---------- */

.chf-page { min-height: 100vh; display: flex; flex-direction: column; }
.chf-main { flex: 1; padding: 20px 24px 64px; }
.chf-layout {
  margin: 0 auto;
  max-width: 1200px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

/* ---------- 顶栏 ---------- */

.chf-header {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
  background: var(--abyss);
}
.chf-header-inner {
  margin: 0 auto; max-width: 1200px;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 24px;
}
.chf-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chf-brand:hover { color: inherit; }
.chf-brand-logo { display: block; height: 44px; width: auto; flex-shrink: 0; }
.chf-brand-logo-sm { height: 30px; }
html[data-theme="dark"] .chf-logo-light { display: none; }
html[data-theme="light"] .chf-logo-dark { display: none; }
.chf-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.chf-brand-text strong { font-size: 16px; color: var(--foam); white-space: nowrap; }
.chf-brand-text small { font-size: 11px; color: var(--mist); white-space: nowrap; }

.chf-nav { display: flex; align-items: center; gap: 2px; overflow-x: auto; }
.chf-nav a {
  display: flex; align-items: center; height: 36px;
  padding: 0 12px; border-radius: 6px;
  font-size: 14px; font-weight: 500; color: var(--mist);
  white-space: nowrap; transition: background-color 150ms, color 150ms;
}
.chf-nav a:hover { background: var(--shoal); color: var(--foam); }

.chf-header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chf-search input {
  height: 36px; width: 160px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--depth); color: var(--foam);
  padding: 0 12px; font-size: 13px; outline: none;
  transition: border-color 150ms, width 200ms;
}
.chf-search input::placeholder { color: var(--faint); }
.chf-search input:focus { border-color: var(--beacon-dim); width: 200px; }

.chf-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 6px;
  border: none; background: transparent; color: var(--mist);
  cursor: pointer; font-size: 15px;
  transition: background-color 150ms, color 150ms;
}
.chf-icon-btn:hover { background: var(--shoal); color: var(--foam); }
html[data-theme="dark"] .chf-icon-moon { display: none; }
html[data-theme="light"] .chf-icon-sun { display: none; }

.chf-lang-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border: 1px solid var(--line); border-radius: 6px;
  color: var(--mist); font-size: 11px; font-weight: 700;
  font-family: "Martian Mono", ui-monospace, monospace;
  transition: border-color 150ms, color 150ms, background-color 150ms;
}
.chf-lang-btn:hover {
  border-color: var(--beacon-dim); background: var(--shoal); color: var(--beacon-ink);
}

.chf-portal-btn {
  display: flex; align-items: center; height: 36px;
  padding: 0 14px; border-radius: 6px;
  border: 1px solid var(--beacon-dim);
  font-size: 13px; font-weight: 500; color: var(--beacon-ink);
  white-space: nowrap; transition: background-color 150ms, color 150ms;
}
.chf-portal-btn:hover { background: var(--beacon-fill); color: var(--on-beacon); }

.chf-announce {
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid var(--line); background: var(--depth);
  padding: 7px 24px; font-size: 13px;
}
.chf-announce p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mist); }
.chf-announce-chip {
  flex-shrink: 0; border: 1px solid var(--beacon-dim); border-radius: 2px;
  padding: 0 8px; font-size: 12px; font-weight: 500; color: var(--beacon-ink);
}

/* ---------- 文章卡片流 ---------- */

.chf-stream { min-width: 0; }
.chf-stream-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 14px; }
.chf-stream-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--foam); }
.chf-stream-count { font-size: 12px; color: var(--faint); }

.chf-card {
  position: relative;
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px; margin-bottom: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--depth);
  transition: border-color 150ms, background-color 150ms;
}
.chf-card:hover { border-color: var(--beacon-dim); background: var(--shoal); }
.chf-card-link { position: absolute; inset: 0; z-index: 1; border-radius: 8px; }
.chf-card-thumb {
  overflow: hidden; border-radius: 6px; border: 1px solid var(--line);
  background: var(--abyss); aspect-ratio: 16 / 9;
}
.chf-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.chf-thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  background-image: repeating-linear-gradient(45deg, transparent 0 10px, var(--stripe) 10px 12px);
  color: var(--faint); font-size: 10px; letter-spacing: 0;
}
.chf-card-body { min-width: 0; display: flex; flex-direction: column; }
.chf-card-meta { display: flex; align-items: center; gap: 10px; }
.chf-card-meta time { font-size: 11px; color: var(--faint); }
.chf-card-title {
  margin: 8px 0 0; font-size: 17px; font-weight: 600; line-height: 1.5; color: var(--foam);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.chf-card:hover .chf-card-title { color: var(--beacon-ink); }
.chf-card-excerpt {
  margin: 6px 0 0; font-size: 13px; line-height: 22px; color: var(--mist);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}

.chf-chip, .chf-chip a {
  font-family: "Martian Mono", ui-monospace, monospace; letter-spacing: 0;
  font-size: 10px; color: var(--faint);
}
.chf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 2px; padding: 1px 6px;
  position: relative; z-index: 2;
}
.chf-chip a:hover { color: var(--beacon-ink); }
.chf-chip-link { padding: 3px 9px; font-size: 11px; transition: border-color 150ms, color 150ms; }
.chf-chip-link:hover { border-color: var(--beacon-dim); color: var(--beacon-ink); }

.chf-empty {
  border: 1px dashed var(--line-strong); border-radius: 8px;
  padding: 40px 24px; text-align: center; color: var(--faint); font-size: 14px;
}

/* ---------- 广告位 ---------- */

.chf-strip-ad, .chf-rail-ad { margin-bottom: 12px; }
.chf-strip-ad img, .chf-rail-ad img { border-radius: 8px; width: 100%; }
.chf-ad-placeholder {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--line-strong); border-radius: 8px;
  background: var(--depth);
  background-image: repeating-linear-gradient(45deg, transparent 0 10px, var(--stripe) 10px 12px);
  aspect-ratio: 6 / 5; padding: 16px;
}
.chf-strip-ad .chf-ad-placeholder { aspect-ratio: auto; height: 88px; }
.chf-ad-chip {
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--abyss); padding: 2px 7px;
  font-size: 10px; color: var(--faint);
}
.chf-ad-note { font-size: 12px; color: var(--faint); }

/* ---------- 侧栏 ---------- */

.chf-rail { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 84px; }
.chf-panel {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--depth); padding: 14px 18px 10px;
  box-shadow: var(--shadow-panel);
}
.chf-panel-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--foam); }
.chf-rail-list { margin: 6px 0 0; padding: 0; list-style: none; }
.chf-rail-list li { border-bottom: 1px solid var(--line); }
.chf-rail-list li:last-child { border-bottom: none; }
.chf-rail-list a { display: flex; align-items: flex-start; gap: 8px; padding: 9px 0; }
.chf-rail-list a:hover .chf-rail-title { color: var(--beacon-ink); }
.chf-rail-title {
  min-width: 0; flex: 1; font-size: 13px; line-height: 20px; color: var(--mist);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  transition: color 150ms;
}
.chf-rail-list .chf-chip { margin-top: 2px; flex-shrink: 0; }
.chf-tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 8px; }

/* ---------- 文章页 ---------- */

.chf-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; font-size: 13px; color: var(--faint); }
.chf-crumbs a { color: var(--chart-deep); }
.chf-crumbs a:hover { color: var(--chart); }
.chf-crumbs-sep { color: var(--faint); }

.chf-article {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--depth); padding: 28px 32px;
  box-shadow: var(--shadow-panel);
}
.chf-article-title { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.4; color: var(--foam); }
.chf-article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.chf-article-meta .readout { font-size: 11px; color: var(--faint); }

.chf-article-content { margin-top: 20px; font-size: 15px; line-height: 1.9; color: var(--mist); }
.chf-article-content h2 { margin: 28px 0 10px; font-size: 19px; color: var(--foam); }
.chf-article-content h3 { margin: 22px 0 8px; font-size: 16px; color: var(--foam); }
.chf-article-content p { margin: 0 0 14px; }
.chf-article-content a { color: var(--chart-deep); border-bottom: 1px solid transparent; }
.chf-article-content a:hover { color: var(--chart); border-bottom-color: var(--chart); }
.chf-article-content img { border-radius: 8px; border: 1px solid var(--line); margin: 16px 0; }
.chf-article-content blockquote {
  margin: 16px 0; padding: 10px 16px;
  border-left: 2px solid var(--beacon-dim);
  background: var(--shoal); border-radius: 0 6px 6px 0;
}
.chf-article-content pre {
  overflow-x: auto; padding: 14px 16px;
  background: var(--abyss); border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; line-height: 1.7;
}
.chf-article-content code { font-family: "Martian Mono", ui-monospace, monospace; font-size: 0.88em; }
.chf-article-content table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 13px; }
.chf-article-content th, .chf-article-content td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.chf-article-content th { background: var(--shoal); color: var(--foam); }

.chf-article-source { margin: 18px 0 0; font-size: 12px; color: var(--faint); word-break: break-all; }
.chf-article-source a { color: var(--chart-deep); }

.chf-article-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.chf-article-tags a {
  font-family: "Martian Mono", ui-monospace, monospace; letter-spacing: 0;
  display: inline-flex; border: 1px solid var(--line); border-radius: 2px;
  padding: 2px 8px; font-size: 11px; color: var(--faint);
  transition: border-color 150ms, color 150ms;
}
.chf-article-tags a:hover { border-color: var(--beacon-dim); color: var(--beacon-ink); }

.chf-prevnext {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--faint);
}
.chf-prevnext a { color: var(--mist); }
.chf-prevnext a:hover { color: var(--beacon-ink); }
.chf-prevnext-next { text-align: right; }

.chf-related { margin-top: 20px; }
.chf-related-grid {
  margin-top: 10px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px;
}
.chf-related-card {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--depth); padding: 12px;
  transition: border-color 150ms, background-color 150ms;
}
.chf-related-card:hover { border-color: var(--beacon-dim); background: var(--shoal); color: inherit; }
.chf-related-card .chf-chip { align-self: flex-start; }
.chf-related-card .readout { font-size: 10px; color: var(--faint); }

/* ---------- 分页 ---------- */

.chf-pagenav { margin-top: 20px; }
.chf-pagenav .page-navigator { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chf-pagenav .page-navigator a, .chf-pagenav .page-navigator span {
  display: flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; color: var(--mist);
  font-family: "Martian Mono", ui-monospace, monospace;
  transition: border-color 150ms, color 150ms;
}
.chf-pagenav .page-navigator a:hover { border-color: var(--beacon-dim); color: var(--beacon-ink); }
.chf-pagenav .page-navigator .current a,
.chf-pagenav .page-navigator li.current span {
  border-color: var(--beacon-dim); color: var(--beacon-ink);
}

/* ---------- 评论 ---------- */

.chf-comments { margin-top: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--depth); padding: 20px 24px; }
.chf-comment-list { margin: 10px 0 0; padding: 0; list-style: none; }
.chf-comment-list li { border-bottom: 1px solid var(--line); padding: 12px 0; font-size: 14px; }
.chf-comment-list .comment-author { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--foam); }
.chf-comment-list .comment-author img { border-radius: 999px; }
.chf-comment-list .comment-meta a { font-size: 11px; color: var(--faint); font-family: "Martian Mono", ui-monospace, monospace; }
.chf-comment-list .comment-content { margin-top: 6px; color: var(--mist); }
.chf-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.chf-comment-form input, .chf-comment-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  background: var(--abyss); color: var(--foam);
  padding: 10px 12px; font-size: 14px; outline: none;
}
.chf-comment-form input:focus, .chf-comment-form textarea:focus { border-color: var(--beacon-dim); }
.chf-submit {
  margin-top: 10px; height: 38px; padding: 0 18px;
  border: none; border-radius: 6px;
  background: var(--beacon-fill); color: var(--on-beacon);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background-color 150ms;
}
.chf-submit:hover { background: var(--beacon-fill-hover); }
.chf-comments-closed { color: var(--faint); font-size: 13px; }

/* ---------- 404 / 页脚 ---------- */

.chf-404 { border: 1px solid var(--line); border-radius: 8px; background: var(--depth); padding: 60px 32px; text-align: center; }
.chf-404-code { font-size: 44px; color: var(--beacon-ink); margin: 0 0 8px; }

.chf-footer { border-top: 1px solid var(--line); background: var(--depth); }
.chf-footer-inner {
  margin: 0 auto; max-width: 1200px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 20px; padding: 20px 24px; font-size: 13px; color: var(--mist);
}
.chf-footer-brand { display: flex; align-items: center; gap: 8px; }

.chf-footer-brand a { color: var(--mist); }
.chf-footer-brand a:hover { color: var(--beacon-ink); }
.chf-footer-sep { color: var(--faint); }
.chf-footer-meta { display: flex; gap: 16px; font-size: 11px; color: var(--faint); }
.chf-footer-meta a { color: var(--faint); }

/* ---------- 响应式 ---------- */

@media (max-width: 960px) {
  .chf-layout { grid-template-columns: 1fr; }
  .chf-rail { position: static; }
  .chf-nav { display: none; }
  .chf-header-actions .chf-portal-btn { display: none; }
}
@media (max-width: 640px) {
  .chf-header-inner { gap: 8px; padding: 0 12px; }
  .chf-brand-logo { height: 36px; }
  .chf-header-actions { gap: 4px; }
  .chf-card { grid-template-columns: 1fr; }
  .chf-article { padding: 20px; }
  .chf-search input { width: 92px; }
  .chf-search input:focus { width: 118px; }
  .chf-form-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
