/* HN 中文阅读 —— 阅读风：浅米白打底，橙色只做标记；深色可一键切。 */

:root {
  --bg: #fbfaf8;
  --bg-elev: #ffffff;
  --text: #1b1a18;
  --text-2: #56524d;
  --muted: #8b857e;
  --line: #eae6e0;
  --line-strong: #ddd8d1;
  --accent: #ff6600;
  --accent-soft: rgba(255, 102, 0, .09);
  --hover: rgba(0, 0, 0, .028);
  --shadow: 0 1px 2px rgba(28, 22, 16, .05), 0 8px 24px -12px rgba(28, 22, 16, .14);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: Georgia, "Songti SC", "Noto Serif SC", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --wrap: 820px;
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #131211;
  --bg-elev: #1a1917;
  --text: #e9e5df;
  --text-2: #b5afa6;
  --muted: #8a847c;
  --line: #2a2825;
  --line-strong: #383530;
  --accent: #ff7a1a;
  --accent-soft: rgba(255, 122, 26, .13);
  --hover: rgba(255, 255, 255, .045);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100dvh; }

::selection { background: var(--accent-soft); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ───────────────────────── 顶栏 ───────────────────────── */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.bar-in {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo { display: flex; align-items: center; gap: 9px; flex: none; }

.logo-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.logo-text { font-size: 15px; font-weight: 650; letter-spacing: .2px; }

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--hover); color: var(--text); }
.tab.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.bar-actions { display: flex; gap: 4px; flex: none; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }

html[data-theme="dark"] .icon-sun { display: none; }
html:not([data-theme="dark"]) .icon-moon { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* 顶部加载条 */
.progress {
  position: absolute;
  left: 0; bottom: -1px;
  height: 2px;
  width: 0;
  background: var(--accent);
  opacity: 0;
  transition: width .25s ease, opacity .25s;
}
.progress.on { opacity: 1; }

/* ───────────────────────── 列表 ───────────────────────── */

main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 8px 24px 120px;
}

.feed { list-style: none; margin: 0; padding: 0; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0 6px;
  padding: 17px 12px 17px 10px;
  margin: 0 -12px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line);
  transition: background .13s;
}
.feed .row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.row.read .t { color: var(--muted); }
.row.read .rank { color: var(--line-strong); }

.rank {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  padding-top: 4px;
  letter-spacing: -.02em;
  opacity: .85;
}

.t {
  font-size: 17px;
  line-height: 1.55;
  font-weight: 500;
  letter-spacing: .1px;
  color: var(--text);
  transition: color .15s;
}
.row:hover .t { color: var(--accent); }

.meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.meta .dot { opacity: .45; }
.meta .pts { color: var(--text-2); font-variant-numeric: tabular-nums; }
.meta .pts::before { content: "▲"; font-size: 9px; margin-right: 3px; opacity: .7; }
.meta .cmt-ico::before { content: "❑"; font-size: 9px; margin-right: 4px; opacity: .6; }

.badge-type {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--hover);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* 骨架屏 */
.sk { padding: 20px 10px; border-bottom: 1px solid var(--line); }
.sk i {
  display: block;
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, var(--hover) 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.sk i:nth-child(1) { width: 72%; height: 17px; margin-bottom: 12px; }
.sk i:nth-child(2) { width: 38%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* 底部状态 */
.feed-foot {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.link-btn {
  border: 0; background: none; padding: 4px 0;
  color: var(--text-2); font-size: 12.5px;
  border-bottom: 1px solid var(--line-strong);
}
.link-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ───────────────────────── 详情 ───────────────────────── */

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 18px 0 6px;
  padding: 6px 0;
  font-size: 13.5px;
  color: var(--muted);
}
.back:hover { color: var(--text); }

.story-head { padding: 10px 0 4px; }

h1.title-zh {
  margin: 12px 0 10px;
  font-size: 30px;
  line-height: 1.42;
  font-weight: 650;
  letter-spacing: -.2px;
  text-wrap: pretty;
}

.title-en {
  display: block;
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}
.title-en:hover { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }

.story-meta {
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.story-meta .strong { color: var(--text-2); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.busy::after {
  content: "";
  width: 11px; height: 11px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.done { border-color: var(--line); color: var(--muted); }

.section { margin-top: 34px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .3px;
  color: var(--text);
}
.section-head .count { font-size: 12.5px; color: var(--muted); }
.section-head .spacer { flex: 1; }

.note-card {
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.note-lead {
  margin: 0 0 14px;
  font-size: 16.5px;
  line-height: 1.8;
  color: var(--text);
  font-weight: 500;
  text-wrap: pretty;
}

.note-item {
  display: flex;
  gap: 9px;
  margin: 9px 0;
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--text-2);
  text-wrap: pretty;
}
.note-item::before {
  content: "·";
  color: var(--accent);
  font-weight: 700;
  flex: none;
}

.note-source {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.note-empty {
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

/* 评论 */
.comment {
  padding: 13px 0 13px 0;
  border-top: 1px solid var(--line);
}
.comment:first-of-type { border-top: 0; }
.comment .who {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}
.comment .who b { color: var(--text-2); font-weight: 600; }
.comment .body {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  transition: opacity .2s;
}
.comment .en-toggle {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px dotted var(--line-strong);
  cursor: pointer;
}
.comment .en {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--hover);
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
  white-space: pre-wrap;
}
.comment .en[hidden] { display: none; }

.comment.d1 { padding-left: 22px; }
.comment.d2 { padding-left: 44px; }
.comment.d3 { padding-left: 66px; }
.comment.d1 .body, .comment.d2 .body, .comment.d3 .body { font-size: 15px; }

.comment-translating { opacity: .45; }

#cmt-more { margin: 20px 0 4px; text-align: center; }

.more-btn {
  padding: 9px 22px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
}
.more-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.more-end { font-size: 12.5px; color: var(--muted); }

/* ───────────────────────── 登录 ───────────────────────── */

.login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.login[hidden] { display: none; }

.login-card {
  width: min(360px, 100%);
  padding: 34px 28px 28px;
  border-radius: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-mark {
  width: 44px; height: 44px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
}
.login-card h1 { margin: 0; font-size: 19px; font-weight: 650; }
.login-sub { margin: 7px 0 22px; font-size: 13.5px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-card button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  transition: filter .15s;
}
.login-card button:hover { filter: brightness(1.06); }
.login-err { min-height: 18px; margin: 12px 0 0; font-size: 12.5px; color: #d64545; }

/* ───────────────────────── 提示 ───────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 88vw;
  text-align: center;
}
.toast.on { opacity: .95; transform: translate(-50%, 0); }

/* ───────────────────────── 响应式 ───────────────────────── */

@media (max-width: 680px) {
  .bar-in { padding: 0 16px; height: 54px; gap: 10px; }
  .logo-text { display: none; }
  main { padding: 4px 16px 100px; }
  .row { grid-template-columns: 34px 1fr; padding: 15px 8px; margin: 0 -8px; }
  .t { font-size: 16px; }
  h1.title-zh { font-size: 23px; }
  .note-card { padding: 18px 16px; }
  .comment.d1 { padding-left: 14px; }
  .comment.d2 { padding-left: 28px; }
  .comment.d3 { padding-left: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
