/* ==========================================================================
   鸿蒙手记 · dh5.de5.net
   纯手写 CSS，无框架、无构建。改主题色只改 :root 里的变量即可。
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --bg-soft: #f3f0e9;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #16181c;
  --ink-soft: #3d4249;
  --muted: #767b83;
  --line: #e7e2d8;
  --accent: #cf0a2c;
  --accent-ink: #a80723;
  --accent-soft: #fde9ec;
  --shadow: 0 1px 2px rgba(22, 24, 28, .04), 0 8px 24px -12px rgba(22, 24, 28, .16);
  --shadow-lg: 0 2px 4px rgba(22, 24, 28, .05), 0 24px 48px -24px rgba(22, 24, 28, .28);
  --radius: 16px;
  --maxw: 1080px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1013;
  --bg-soft: #14171c;
  --surface: #171b21;
  --surface-2: #1c2027;
  --ink: #eceae6;
  --ink-soft: #c6c9cf;
  --muted: #9096a0;
  --line: #262b33;
  --accent: #ff5d78;
  --accent-ink: #ff8095;
  --accent-soft: #2a1620;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -16px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 30px 60px -30px rgba(0, 0, 0, .85);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "HarmonyOS Sans SC", "HarmonyOS Sans", -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

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

img { max-width: 100%; display: block; }

::selection { background: var(--accent); color: #fff; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .02em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #8e041c);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 12px -4px rgba(207, 10, 44, .55);
}

.brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topbar-spacer { flex: 1; }

.nav-links { display: flex; gap: 18px; }
.nav-links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.nav-links a:hover { color: var(--ink); text-decoration: none; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 16px;
  transition: transform .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.icon-btn:active { transform: scale(.96); }
html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

/* ---------- 头部 ---------- */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 56px 22px 8px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 6px 12px;
}

.hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(30px, 5.2vw, 46px);
  line-height: 1.2;
  letter-spacing: -.02em;
  font-weight: 750;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 16.5px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}
.hero-stats li {
  font-size: 13.5px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
}
.hero-stats b { color: var(--accent-ink); font-weight: 700; }

/* ---------- 工具条：搜索 + 分类 ---------- */
.toolbar {
  position: sticky;
  top: 67px;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.toolbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  flex: 1 1 auto;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .16s var(--ease);
}
.tab:hover { color: var(--ink); background: var(--bg-soft); }
.tab[aria-selected="true"] {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}
html[data-theme="dark"] .tab[aria-selected="true"] { color: #0e1013; }
.tab .count {
  font-size: 11.5px;
  opacity: .6;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

.search {
  position: relative;
  flex: 0 1 260px;
  min-width: 160px;
}
.search input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 34px 9px 34px;
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search .lens {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.search .kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- 列表 ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 30px 22px 80px; }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 18px;
}
.list-head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-soft);
  margin: 0;
}
.list-head .result { font-size: 13px; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .25s var(--ease);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.card:hover::after { transform: scaleY(1); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.chip {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 7px;
  padding: 3px 9px;
}
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }

.card h3 {
  margin: 0;
  font-size: 18.5px;
  line-height: 1.45;
  font-weight: 700;
  letter-spacing: -.01em;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}
.card-tags span {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 7px;
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 8px; }

/* ---------- 文章阅读页 ---------- */
.reader { max-width: 760px; margin: 0 auto; }

.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 60;
  transition: width .1s linear;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin: 4px 0 22px;
}
.backlink:hover { color: var(--accent-ink); text-decoration: none; }

.article-head { border-bottom: 1px solid var(--line); padding-bottom: 26px; margin-bottom: 32px; }
.article-head .card-top { margin-bottom: 14px; }
.article-head h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 4.4vw, 38px);
  line-height: 1.28;
  letter-spacing: -.02em;
  font-weight: 750;
}
.article-head .summary {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.prose { font-size: 16.5px; line-height: 1.95; color: var(--ink-soft); }
.prose h2 {
  position: relative;
  margin: 44px 0 14px;
  padding-left: 14px;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
}
.prose h2::before {
  content: "";
  position: absolute;
  left: 0; top: .32em; bottom: .32em;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.prose h3 { margin: 30px 0 10px; font-size: 17.5px; font-weight: 700; color: var(--ink); }
.prose p { margin: 0 0 18px; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 22px; }
.prose li { margin: 7px 0; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 12px 12px 0;
  color: var(--ink-soft);
  font-size: 15.5px;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 14.5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.prose th, .prose td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.prose th { background: var(--surface-2); font-weight: 700; color: var(--ink); font-size: 13.5px; }
.prose tr:last-child td { border-bottom: 0; }

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 56px 0 0;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.pager a, .pager div {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  background: var(--surface);
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.pager small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; margin-bottom: 4px; letter-spacing: .06em; }
.pager .next { text-align: right; }
.pager .placeholder { border-style: dashed; background: transparent; opacity: .5; }

/* ---------- 页脚 ---------- */
footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px 22px 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 26px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13.5px;
}
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--accent-ink); }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 30px 0 0;
  background: var(--surface-2);
}

/* ---------- 动画 ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.rise { animation: rise .42s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .topbar-inner { padding: 12px 16px; }
  .brand-text small { display: none; }
  .nav-links { display: none; }
  .hero { padding: 36px 16px 4px; }
  .hero p { font-size: 15.5px; }
  main { padding: 22px 16px 64px; }
  .toolbar { top: 61px; }
  .toolbar-inner { padding: 10px 16px; gap: 10px; }
  .search { flex: 1 1 100%; order: -1; }
  .search .kbd { display: none; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 18px; }
  .prose { font-size: 16px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
  .footer-inner { padding: 26px 16px 36px; }
}

@media (min-width: 980px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .card.feature { grid-column: span 2; }
}
