:root {
  --bg: #eef3fa; --card: #fff; --ink: #162033; --muted: #5d6a7e; --line: #cfd9e8;
  --accent: #1554b7; --accent-ink: #fff; --ok: #1f7a4d; --err: #b3261e; --warn: #8a5a00; --warn-bg: #fff4d6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1626; --card: #18223a; --ink: #e8eefb; --muted: #9fb0cc; --line: #2c3a58; --accent: #2a6ad6; --accent-ink: #fff; --ok: #58c08b; --err: #ff8a80; --warn: #ffd27a; --warn-bg: #3a2f12; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--accent); color: var(--ink); font: 16px/1.5 system-ui, "Hiragino Sans", "Yu Gothic UI", "Microsoft YaHei", sans-serif; }
header { background: var(--accent); color: var(--accent-ink); padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
h1 { margin: 0; font-size: 18px; }
h1 small, h2 small { font-weight: normal; opacity: .8; font-size: 13px; margin-left: 6px; }
nav { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.tab { border: 0; border-radius: 999px; padding: 6px 14px; font-size: 15px; background: transparent; color: inherit; }
.tab.on { background: var(--accent-ink); color: var(--accent); font-weight: 600; }
main { flex: 1; background: var(--bg); padding: 12px max(16px, calc((100% - 608px) / 2)) 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card.ok { border-color: var(--ok); }
h2 { margin: 0 0 10px; font-size: 16px; }
label, .field { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
input:not([type=checkbox]), textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .btn:focus-within, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; margin-bottom: 8px; }
.check input { width: 20px; height: 20px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn, button.primary { display: inline-flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 16px; text-decoration: none; cursor: pointer; flex: 1; }
.primary { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink) !important; font-weight: 600; }
.big { width: 100%; min-height: 52px; font-size: 17px; }
button:disabled { opacity: .5; }
.textlink { border: 0; background: none; color: var(--accent); text-decoration: underline; font-size: 14px; padding: 6px 4px; cursor: pointer; }
.center { text-align: center; }
.strong { margin: 0 0 8px; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; user-select: all; }
.error { color: var(--err); margin: 6px 0; min-height: 0; font-size: 14px; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; white-space: pre-line; }
.warn { color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 6px 0 0; }
.code { display: inline-block; min-width: 3.2em; margin-right: 8px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
a.btn.off { opacity: .5; pointer-events: none; }
.range label { flex: 1; min-width: 140px; }
.topgap { margin-top: 16px; }
.alert { margin: 0 0 12px; font-size: 14px; border: 1px solid var(--warn); }
.pw-toggle { display: block; margin-left: auto; }
.mybox { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; }
.mybox .check { margin-bottom: 0; }
.preview { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.preview p, #done-name { margin: 0; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin-bottom: 10px; }
.page { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.page img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.page .no { position: absolute; top: 4px; left: 4px; background: rgba(0, 0, 0, .65); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 13px; }
.badge { position: absolute; top: 4px; right: 4px; border-radius: 999px; padding: 0 8px; font-size: 12px; color: #fff; }
.badge.ok { background: #1f7a4d; }
.badge.todo { background: #b3261e; }
.page .tools { display: flex; }
.page .tools button { flex: 1; border: 0; border-top: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 6px 0; font-size: 15px; min-height: 36px; }
.page .tools button + button { border-left: 1px solid var(--line); }
.page .tools button.wide { font-size: 13px; }
.page .tools button.on { background: var(--accent); color: var(--accent-ink); }
.records { list-style: none; margin: 10px 0 0; padding: 0; }
.records li { border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.records li.pending .rec { border-left: 4px solid var(--warn); padding-left: 8px; }
.records li.off { opacity: .55; }
.records .rec { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; padding: 10px 2px; color: var(--ink); overflow-wrap: anywhere; cursor: pointer; }
.records small { display: block; color: var(--muted); font-size: 12px; }
.records.small li { padding: 8px 2px; font-size: 14px; }
.grow { flex: 1; overflow-wrap: anywhere; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.table th, .table td { border-top: 1px solid var(--line); padding: 8px 4px; text-align: left; overflow-wrap: anywhere; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 12px; }
.table tfoot th { border-top: 2px solid var(--line); }

/* 日期框在 iPhone 上不要撑出卡片 */
input[type=date], input[type=month] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; min-height: 46px; text-align: left; }
input[type=date]::-webkit-date-and-time-value, input[type=month]::-webkit-date-and-time-value { text-align: left; }
/* 输入框下面的候选列表 */
.suggest { margin-top: 4px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); -webkit-overflow-scrolling: touch; }
.suggest button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font-size: 16px; padding: 11px 12px; }
.suggest button:last-child { border-bottom: 0; }
.suggest .none { padding: 10px 12px; color: var(--muted); font-size: 14px; }

/* 盖在页面上面的窗口：看 PDF、涂黑 */
body.noscroll { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: rgba(10, 16, 30, .96); }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--accent); color: var(--accent-ink); }
.viewer-bar p { flex: 1; margin: 0; font-size: 13px; line-height: 1.35; max-height: 2.7em; overflow: hidden; overflow-wrap: anywhere; }
.viewer-close { flex: none; min-height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--accent-ink); color: var(--accent); font-size: 16px; font-weight: 600; }
.viewer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 10px 10px max(16px, env(safe-area-inset-bottom)); }
.viewer-body figure { margin: 0 auto 14px; max-width: 900px; }
.viewer-body img { display: block; width: 100%; background: #fff; border-radius: 4px; }
.viewer-body figcaption, .viewer-body p { color: #dfe7f5; text-align: center; font-size: 13px; margin: 4px 0 0; }
.viewer-body p { font-size: 15px; margin: 40px 0 16px; }
.mask-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.mask-stage canvas { max-width: 100%; max-height: 100%; background: #fff; touch-action: none; cursor: crosshair; }
.mask-tools { display: flex; gap: 8px; padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }

/* 记录的详细：从下面升起来的卡片 */
.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(10, 16, 30, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; margin: 0; border-radius: 16px 16px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* 从主屏幕图标打开时：把标题往下挪一点，避开状态栏下面的模糊 */
@media (display-mode: standalone) {
  header { padding-top: calc(env(safe-area-inset-top) + 36px); }
  .viewer-bar { padding-top: calc(env(safe-area-inset-top) + 36px); }
}
