:root {
  --paper: #fcfdfb;
  --grid: #e3eee6;
  --rule: #2e7d4f;
  --rule-soft: #b9d6c2;
  --ink: #1b1e1c;
  --ink-2: #4a5a50;
  --pen: #d93a22;
  --pen-wash: rgba(217, 58, 34, .12);
  --bar: #2e7d4f;
  --cell: 22px;
  --size: 15px;
  --lh: 1.6;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1611;
    --grid: #17271d;
    --rule: #5fb784;
    --rule-soft: #2a4634;
    --ink: #e6eee8;
    --ink-2: #9db5a6;
    --pen: #ff6a4d;
    --pen-wash: rgba(255, 106, 77, .16);
    --bar: #4fa874;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); color: var(--ink); font-size: var(--size); line-height: var(--lh);
  -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body { margin: 0; min-height: 100vh;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px; }
::selection { background: var(--pen-wash); color: var(--ink); }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; border-radius: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--rule-soft) transparent; caret-color: var(--pen); }
a { color: inherit; text-decoration-color: var(--rule-soft); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--pen); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 刊头：一行，左名右状态与控件 */
.masthead { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 32px) 12px; background: var(--paper);
  border-bottom: 3px double var(--rule); }
.masthead h1 { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: .12em; color: var(--rule); }
.masthead h1 b { color: var(--pen); font-weight: 800; }
.health { display: flex; gap: 18px; flex-wrap: wrap; color: var(--ink-2); }
.health .warn { color: var(--pen); font-weight: 600; }
.mast-right { display: flex; align-items: baseline; gap: 10px 22px; flex-wrap: wrap; justify-content: flex-end; }
.controls { display: flex; align-items: baseline; gap: 16px; }

/* 文字按钮：稿纸上的批注字，不做成胶囊按钮 */
.link-btn { font: inherit; color: var(--rule); background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: var(--pen); }
.link-btn.danger { color: var(--pen); }
a.link-btn { display: inline; }

/* 语言切换：两个字并排，当前语言用红笔下划线 */
.lang { display: inline-flex; gap: 2px; }
.lang button { font: inherit; font-weight: 700; color: var(--ink-2); background: none; border: 0; padding: 0 4px; cursor: pointer;
  border-bottom: 2px solid transparent; }
.lang button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--pen); }
.who { color: var(--ink-2); }

/* 手机：领域切换 */
.tabs { display: none; position: sticky; top: 0; z-index: 2; background: var(--paper);
  border-bottom: 1px solid var(--rule); padding: 0 8px; }
.tabs button { flex: 1; font: inherit; font-weight: 600; color: var(--ink-2); background: none; border: 0;
  padding: 10px 4px 8px; border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--pen); }
.tabs .fresh { color: var(--pen); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* 稿纸 */
.desk { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 22px);
  padding: clamp(14px, 2vw, 24px) clamp(16px, 3vw, 32px) 40px; align-items: start; }
.sheet { background: var(--paper); border: 1px solid var(--rule); box-shadow: 0 1px 0 var(--rule-soft), 0 10px 24px -18px rgba(20, 60, 35, .35); }
.sheet > header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 10px 14px 8px; border-bottom: 3px double var(--rule); }
.sheet h2 { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: .2em; color: var(--rule); }
:lang(en) .sheet h2, :lang(en) .masthead h1 { letter-spacing: .04em; }
:lang(en) .form-sheet .switch button, :lang(en) .btn { letter-spacing: .02em; }
.sheet header span { color: var(--ink-2); }
.sheet header .fresh { color: var(--pen); font-weight: 600; }

/* 你不在时的头条：编辑贴在稿纸上方的红笔便签 */
.missed { margin: 10px 12px 6px; padding: 8px 10px 9px; border: 1px dashed var(--pen); }
.missed h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; color: var(--pen); }
.missed h3 span { color: var(--ink-2); font-weight: 400; margin-left: 6px; }
.missed ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.missed a { font-weight: 700; text-decoration: none; }
.missed a:hover { text-decoration: underline; text-decoration-color: var(--pen); }
.missed .when { display: block; color: var(--ink-2); font-variant-numeric: tabular-nums; }

ol.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 6px;
  padding: 11px 14px 12px 6px; border-top: 1px solid var(--rule-soft); }
.entry:first-child { border-top: 0; }

/* 名次：靠字重和红笔，不靠字号 */
.rank { position: relative; width: 44px; height: 38px; display: grid; place-items: center; align-self: start;
  font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.rank svg { position: absolute; inset: 0; width: 44px; height: 38px; overflow: visible; pointer-events: none; }
.rank path { fill: none; stroke: var(--pen); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.rank.is-new { color: var(--pen); }
.rank s { position: absolute; top: -4px; right: 1px; color: var(--pen); font-weight: 600; text-decoration: none; padding: 0 2px; }
.rank s::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 2px; background: var(--pen);
  border-radius: 2px; transform: rotate(-28deg); }
.draw path { stroke-dasharray: 150; stroke-dashoffset: 150; animation: ink .7s cubic-bezier(.16, 1, .3, 1) forwards; animation-delay: var(--d, 0ms); }
@keyframes ink { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .draw path { animation: none; stroke-dashoffset: 0; } }

.title { display: block; font-weight: 700; text-decoration: none; text-wrap: pretty; }
.title:hover { text-decoration: underline; text-decoration-color: var(--pen); }
.summary { margin: 2px 0 0; color: var(--ink); text-wrap: pretty; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; margin-top: 6px; color: var(--ink-2); }
.meta a { text-decoration: none; }
.meta a:hover { color: var(--ink); }
.meta .age.hot { color: var(--pen); font-weight: 600; }
.stat { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.icon { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

details.more { margin-top: 6px; }
details.more summary { color: var(--rule); cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary .icon { transition: transform .2s cubic-bezier(.16, 1, .3, 1); }
details.more[open] summary .icon { transform: rotate(90deg); }
.original { margin: 8px 0 0; padding: 8px 10px; border: 1px dashed var(--rule-soft); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.original .quoted { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--rule-soft); color: var(--ink-2); }
.original img { display: block; max-width: 100%; height: auto; margin-top: 8px; border: 1px solid var(--rule-soft); }
.related { margin: 8px 0 0; padding: 0; list-style: none; color: var(--ink-2); }
.related li { overflow-wrap: anywhere; }

.empty { padding: 28px 16px; color: var(--ink-2); }
.notice { margin: 24px clamp(16px, 3vw, 32px); padding: 14px 16px; border: 1px solid var(--pen); color: var(--ink); background: var(--paper); }
.notice strong { color: var(--pen); }

@media (max-width: 1180px) { .desk { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .tabs { display: flex; }
  .desk { grid-template-columns: minmax(0, 1fr); padding-top: 12px; }
  .sheet[hidden-mobile] { display: none; }
  .desk .sheet > header { display: none; }
  .masthead { padding-bottom: 10px; }
}

/* ---- 表单（登录 / 注册 / 管理后台） ---- */
.form-sheet { width: min(420px, calc(100% - 32px)); margin: clamp(24px, 8vh, 80px) auto 40px; }
.form-sheet .switch { display: flex; border-bottom: 3px double var(--rule); }
.form-sheet .switch button { flex: 1; font: inherit; font-weight: 800; letter-spacing: .1em; color: var(--ink-2); background: none;
  border: 0; padding: 12px 8px 10px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.form-sheet .switch button[aria-selected="true"] { color: var(--rule); border-bottom-color: var(--pen); }
.form-body { padding: 18px 20px 22px; display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 700; }
.field .hint { color: var(--ink-2); }
input[type=text], input[type=password], input[type=number], select {
  font: inherit; color: var(--ink); background: var(--paper); border: 0; border-bottom: 1px solid var(--rule);
  padding: 6px 2px; border-radius: 0; width: 100%; }
input:focus-visible, select:focus-visible { outline: none; border-bottom: 2px solid var(--pen); padding-bottom: 5px; }
.btn { font: inherit; font-weight: 800; letter-spacing: .1em; color: var(--paper); background: var(--rule); border: 1px solid var(--rule);
  padding: 9px 18px; cursor: pointer; border-radius: 2px; }
.btn:hover { background: var(--ink); border-color: var(--ink); }
.btn:disabled { opacity: .55; cursor: progress; }
.error { color: var(--pen); font-weight: 600; min-height: 1.6em; margin: 0; }

/* ---- 管理后台 ---- */
.admin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 22px);
  padding: clamp(14px, 2vw, 24px) clamp(16px, 3vw, 32px) 48px; align-items: start; }
.admin .wide { grid-column: 1 / -1; }
.admin .sheet .body { padding: 14px 16px 16px; }
.figures { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0; }
.figures div { border-left: 1px solid var(--rule-soft); padding-left: 10px; }
.figures div:first-child { border-left: 0; padding-left: 0; }
.figures dt { color: var(--ink-2); }
.figures dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.chart { margin-top: 14px; }
.chart svg { display: block; width: 100%; height: 90px; overflow: visible; margin-top: 4px; }
.chart .bar { fill: var(--bar); }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .bar-hit:hover + .bar, .chart .bar-hit:focus + .bar { fill: var(--pen); }
.chart .axis { stroke: var(--rule-soft); stroke-width: 1; }
.chart .chart-head, .chart .chart-axis { display: flex; justify-content: space-between; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart .chart-axis { margin-top: 4px; }
.chart .tip { position: absolute; pointer-events: none; background: var(--paper); border: 1px solid var(--rule); padding: 2px 8px;
  white-space: nowrap; transform: translate(-50%, -110%); }
.status-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.status-list dt { color: var(--ink-2); }
.status-list dd { margin: 0; font-variant-numeric: tabular-nums; }
.status-list .warn { color: var(--pen); font-weight: 600; }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.grid th { text-align: left; font-weight: 700; color: var(--ink-2); border-bottom: 1px solid var(--rule); padding: 6px 10px 6px 0; white-space: nowrap; }
table.grid td { border-bottom: 1px solid var(--rule-soft); padding: 7px 14px 7px 0; vertical-align: top; white-space: nowrap; }
table.grid tr.off td { color: var(--ink-2); }
table.grid .tag { color: var(--pen); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.invite-form { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; margin-bottom: 14px; }
.invite-form .field { min-width: 110px; }
.invite-form .field.note { flex: 1; min-width: 160px; }
.codes { margin: 0 0 12px; padding: 10px 12px; border: 1px dashed var(--pen); }
.codes code { font-weight: 700; user-select: all; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

@media (max-width: 900px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 12px; }
  .figures div:nth-child(4) { border-left: 0; padding-left: 0; }
}
