/* Rédaction · Meliora 编辑部 —— 纸、墨、氧化棕;手机优先 */
:root {
  --paper: #f5f2ea; --paper-hi: #faf8f2; --paper-lo: #ece7da;
  --ink: #221f19; --soft: #6f6a5d; --oxide: #5a4634; --red: #8a2a1c;
  --line: rgba(34, 31, 25, .45); --line-soft: rgba(34, 31, 25, .16);
  --veil: rgba(245, 242, 234, .78);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --latin: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --nav-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1914; --paper-hi: #23201a; --paper-lo: #2c2821;
    --ink: #e9e3d6; --soft: #a39c8c; --oxide: #c9a27e; --red: #e0826f;
    --line: rgba(233, 227, 214, .42); --line-soft: rgba(233, 227, 214, .15);
    --veil: rgba(27, 25, 20, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 16px; line-height: 1.7;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
body.editing { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea {
  font: inherit; font-size: 16px; /* 小于 16px 手机会自动放大 */
  color: var(--ink); background: var(--paper-hi);
  border: 1px solid var(--line-soft); border-radius: 0;
  padding: 10px 12px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--oxide); }
textarea { resize: vertical; line-height: 1.75; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--oxide); }
a { color: var(--oxide); }

/* 刊头 */
.mast {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 9px 14px;
  background: var(--paper); border-bottom: 3px double var(--ink);
}
.mast-name { flex: 1; min-width: 0; }
.mast-t { font-family: var(--latin); font-size: 17px; letter-spacing: .34em; text-transform: uppercase; line-height: 1.25; }
.mast-s { font-size: 11px; color: var(--soft); letter-spacing: .22em; }
.pill {
  font-size: 12px; letter-spacing: .06em; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; color: var(--soft);
}
.pill.busy { color: var(--oxide); border-color: var(--oxide); }
.pill.busy::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; margin-right: 6px; vertical-align: 1px; animation: blink 1.2s infinite;
}
.pill.ok { color: var(--ink); }
.pill.bad { color: var(--red); border-color: var(--red); }
@keyframes blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .pill.busy::before { animation: none; } }
.gear { width: 40px; height: 40px; font-size: 19px; display: grid; place-items: center; color: var(--soft); }

.banner { background: var(--paper-lo); color: var(--oxide); font-size: 13px; text-align: center; padding: 7px 12px; border-bottom: 1px solid var(--line-soft); }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 28px; }

/* 底部栏目 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--paper); border-top: 1px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { height: var(--nav-h); font-size: 14px; letter-spacing: .1em; color: var(--soft); position: relative; }
.tabs button.on { color: var(--ink); font-weight: 700; }
.tabs button.on::after { content: ''; position: absolute; left: 26%; right: 26%; top: -1px; border-top: 3px solid var(--ink); }
body.editing .tabs { display: none; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 20px;
  background: var(--ink); color: var(--paper);
  font-size: 15px; letter-spacing: .22em; text-decoration: none;
}
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--red); border: 1px solid var(--red); }
.btn:disabled { opacity: .45; }
.bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.bar.wrap { flex-wrap: wrap; margin: 12px 0 0; }
.count { font-size: 13px; color: var(--soft); margin-left: auto; }

/* 列表 */
.list { list-style: none; }
.row {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "dt tags" "ttl ttl";
  gap: 2px 10px; width: 100%; text-align: left; padding: 12px 2px;
  border-bottom: 1px dotted var(--line-soft);
}
.row:active { background: var(--paper-lo); }
.row .dt { grid-area: dt; font-family: var(--latin); font-size: 12.5px; color: var(--soft); }
.row .tags { grid-area: tags; justify-self: end; display: flex; gap: 6px; align-items: center; }
.row .ttl { grid-area: ttl; font-size: 17px; font-weight: 700; line-height: 1.5; }
.row .ttl.note { font-weight: 400; font-size: 16px; }
.row .sub { display: block; font-weight: 400; font-size: 13px; color: var(--soft); margin-top: 2px; }
.rub { font-size: 12px; color: var(--oxide); letter-spacing: .15em; }
.tag { font-size: 11px; line-height: 1.6; border: 1px solid var(--line-soft); padding: 0 6px; color: var(--soft); }
.tag.wip { border-color: var(--oxide); color: var(--oxide); }
.muted { color: var(--soft); text-align: center; padding: 40px 0; font-size: 14px; }
.muted .btn { margin-top: 14px; }

/* 表单 */
.form { border: 1px solid var(--ink); background: var(--paper-hi); padding: 16px 14px; margin-bottom: 16px; }
.form.center { text-align: center; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; letter-spacing: .28em; color: var(--oxide); margin-bottom: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.55; }
.check input { flex: none; margin-top: 1px; }
.hint { font-size: 12.5px; color: var(--soft); margin-top: 5px; line-height: 1.65; }
.hint.gap { margin: 4px 0 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status { font-size: 13px; color: var(--soft); margin-bottom: 12px; letter-spacing: .08em; }
.status b { color: var(--oxide); font-weight: 400; }
.err { color: var(--red); font-size: 14px; min-height: 1.5em; margin: -4px 0 10px; }

/* 编辑 */
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar button { min-height: 36px; padding: 4px 12px; font-size: 13px; letter-spacing: .1em; border: 1px solid var(--line-soft); background: var(--paper); }
.body-ta { min-height: 55vh; font-family: var(--mono); font-size: 15px; }
.note-ta { min-height: 120px; }
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--ink);
}
.actions .btn { flex: 1; padding: 10px 6px; letter-spacing: .16em; }
.actions .back { flex: 0 0 52px; letter-spacing: 0; font-size: 18px; }
.danger-zone { margin-top: 24px; padding-top: 14px; border-top: 1px dashed var(--line-soft); }

/* 插图 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line-soft); background: var(--paper-hi); padding: 6px; }
.card .thumb { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-lo); }
.card .nm { font-family: var(--mono); font-size: 10.5px; color: var(--soft); word-break: break-all; line-height: 1.45; margin-top: 5px; }
.card .ops { display: flex; justify-content: space-between; margin-top: 4px; }
.card .ops button { font-size: 13px; color: var(--oxide); padding: 6px 2px; }

/* 付印记录 */
.runs { list-style: none; }
.runs li { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 9px 0; border-bottom: 1px dotted var(--line-soft); }
.runs .rs { grid-row: span 2; font-size: 12px; border: 1px solid var(--line-soft); padding: 1px 7px; align-self: start; white-space: nowrap; }
.runs .rs.ok { border-color: var(--ink); }
.runs .rs.busy { color: var(--oxide); border-color: var(--oxide); }
.runs .rs.bad { color: var(--red); border-color: var(--red); }
.runs .rt { font-size: 14px; line-height: 1.5; word-break: break-word; }
.runs .rd { font-size: 12px; color: var(--soft); }

/* 提示条 / 遮罩 */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  max-width: 88vw; padding: 10px 18px;
  background: var(--ink); color: var(--paper); font-size: 14px; line-height: 1.5;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
}
body.editing .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--veil); font-size: 15px; letter-spacing: .3em; }

/* 首次设置 */
.setup { max-width: 520px; margin: 0 auto; padding: calc(32px + env(safe-area-inset-top)) 18px 48px; }
.setup-t { font-family: var(--latin); font-size: 30px; letter-spacing: .4em; text-transform: uppercase; text-align: center; }
.setup-s { text-align: center; font-size: 13px; color: var(--soft); letter-spacing: .3em; padding-bottom: 14px; margin-bottom: 20px; border-bottom: 3px double var(--ink); }
.setup > p { margin-bottom: 16px; font-size: 15px; }
.help { margin: 18px 0; border: 1px solid var(--line-soft); background: var(--paper-hi); padding: 10px 14px; }
.help summary { cursor: pointer; font-size: 14px; color: var(--oxide); }
.steps { padding-left: 1.3em; margin-top: 8px; font-size: 14px; line-height: 1.75; }
.steps li { margin-bottom: 6px; }

@media (min-width: 700px) {
  .tabs { left: 50%; right: auto; width: 760px; transform: translateX(-50%); border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
  .actions { left: 50%; right: auto; width: 760px; transform: translateX(-50%); }
}
