/* Theme base, inlined from the shared app-style.css. App pages load only
   their own stylesheet, so the variables and base rules must live here. */
:root {
  color-scheme: light;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  --canvas: #f5f5f7;
  --surface: #fff;
  --recessed: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #65656b;
  --line: rgb(0 0 0 / .06);
  --control-line: rgb(0 0 0 / .14);
  --selected: rgb(0 0 0 / .075);
  --accent: #0071e3;
  --accent-hover: #0065cc;
  --accent-ink: #fff;
  --motion: .2s cubic-bezier(.16, 1, .3, 1);
  color: var(--ink);
  background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #161618;
  --surface: #1e1e20;
  --recessed: #242426;
  --ink: #f5f5f7;
  --muted: #ababaf;
  --line: rgb(255 255 255 / .08);
  --control-line: rgb(255 255 255 / .19);
  --selected: rgb(255 255 255 / .10);
  --accent: #5aaaf9;
  --accent-hover: #7bbaff;
  --accent-ink: #101820;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; transition: background-color var(--motion), color var(--motion); }
main { width: min(896px, calc(100% - 32px)); margin: clamp(32px, 7vw, 80px) auto; padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
h1 { font-size: clamp(2.25rem, 5vw, 4rem); font-weight: 600; line-height: 1.12; letter-spacing: -.045em; margin: 16px 0 8px; }
p { color: var(--muted); margin: 0; }
a { color: var(--ink); text-underline-offset: .2em; }
.panel { display: grid; gap: 24px; margin-block-start: 32px; border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 4vw, 32px); background: var(--surface); }
label { min-width: 0; font-size: 14px; font-weight: 500; display: grid; gap: 8px; }
label:has(output) { grid-template-columns: 1fr auto; }
label input[type=range] { grid-column: 1 / -1; accent-color: var(--accent); }
input, select, textarea { min-width: 0; width: 100%; color: inherit; background: var(--recessed); border: 1px solid var(--control-line); border-radius: 8px; font: inherit; padding: 8px 12px; }
.of-url-note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
button, .button { display: inline-flex; justify-content: center; align-items: center; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 8px; min-height: 44px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; text-decoration: none; cursor: pointer; transition: background-color var(--motion), transform var(--motion); }
button:not(:disabled):hover, .button:hover { background: var(--accent-hover); }
button:not(:disabled):active, .button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: wait; }
.secondary { color: var(--ink); background: var(--recessed); }
.secondary:not(:disabled):hover, a.secondary:hover { background: var(--selected); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; gap: 4px; background: var(--recessed); border: 1px solid var(--control-line); border-radius: 10px; padding: 4px; }
.seg button { background: transparent; color: var(--ink); border: 0; min-height: 36px; border-radius: 7px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.brand-line { text-align: center; color: var(--muted); font-size: 12.5px; letter-spacing: .14em; padding: 20px 0 calc(28px + env(safe-area-inset-bottom, 0px)); margin: 0; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } :active { transform: none !important; } }




/* ---- paper-format-check （规矩） ---- */
main h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
main h3 { font-size: 1rem; font-weight: 600; margin: 8px 0 0; }
.panel > p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--recessed); font-size: 13px; color: var(--muted); }
.stat-num { font-size: 1.6rem; font-weight: 600; color: var(--ink); line-height: 1.1; }
.stat-bad .stat-num { color: #c81e1e; }
.stat-warn .stat-num { color: #b45309; }
.stat-good .stat-num { color: #15803d; }
:root[data-theme="dark"] .stat-bad .stat-num { color: #f87171; }
:root[data-theme="dark"] .stat-warn .stat-num { color: #fbbf24; }
:root[data-theme="dark"] .stat-good .stat-num { color: #4ade80; }
.plain-list { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.plain-list li { margin: 4px 0; }
.plain-list .muted { list-style: none; margin-left: -20px; }
.field-hint { grid-column: 1 / -1; font-size: 13px; color: var(--muted); font-weight: 400; }
label.wide { grid-column: 1 / -1; }
#status.error { color: #c81e1e; font-weight: 600; }
:root[data-theme="dark"] #status.error { color: #f87171; }
.med-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.med-list .empty { color: var(--muted); }
.med-row { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--recessed); }
.med-row.status-expired, .med-row.status-invalid { border-color: rgb(200 30 30 / .45); }
.med-row.status-soon { border-color: rgb(180 83 9 / .45); }
.med-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.med-head strong { font-size: 15px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--selected); color: var(--ink); }
.badge-expired, .badge-invalid { background: #fee2e2; color: #991b1b; }
.badge-soon { background: #fef3c7; color: #92400e; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-no-date { background: var(--selected); color: var(--muted); }
.badge-low { background: #ede9fe; color: #5b21b6; }
:root[data-theme="dark"] .badge-expired, :root[data-theme="dark"] .badge-invalid { background: rgb(248 113 113 / .2); color: #fca5a5; }
:root[data-theme="dark"] .badge-soon { background: rgb(251 191 36 / .18); color: #fcd34d; }
:root[data-theme="dark"] .badge-ok { background: rgb(74 222 128 / .16); color: #86efac; }
:root[data-theme="dark"] .badge-low { background: rgb(167 139 250 / .18); color: #c4b5fd; }
.med-meta, .med-exp, .med-note { font-size: 13px; color: var(--muted); }
.med-exp { color: var(--ink); }
.med-warn { font-size: 13px; color: #991b1b; font-weight: 600; }
:root[data-theme="dark"] .med-warn { color: #fca5a5; }
.med-row .small { justify-self: start; min-height: 36px; padding: 4px 12px; }
button.small { font-size: 13px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print {
  body { background: #fff; }
  #back, #add-form, .buttons, #backup-h, #why-h, .brand-line { display: none !important; }
  main { width: 100%; margin: 0; }
  .panel { break-inside: avoid; border: 1px solid #ccc; }
}

/* ---- paper-format-check （规矩） ---- */
main h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
main h3 { font-size: 1rem; font-weight: 600; margin: 8px 0 0; }
.panel > p { margin: 0; }
.panel > label { display: grid; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--recessed); font-size: 13px; color: var(--muted); }
.stat-num { font-size: 1.6rem; font-weight: 600; color: var(--ink); line-height: 1.1; }
.stat-bad .stat-num { color: #c81e1e; }
.stat-warn .stat-num { color: #b45309; }
.stat-good .stat-num { color: #15803d; }
:root[data-theme="dark"] .stat-bad .stat-num { color: #f87171; }
:root[data-theme="dark"] .stat-warn .stat-num { color: #fbbf24; }
:root[data-theme="dark"] .stat-good .stat-num { color: #4ade80; }
.field-hint { font-size: 13px; color: var(--muted); font-weight: 400; }
#status.error { color: #c81e1e; font-weight: 600; }
:root[data-theme="dark"] #status.error { color: #f87171; }
textarea { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; line-height: 1.6; resize: vertical; }
.med-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.med-list .empty { color: var(--muted); }
.med-row { display: grid; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--recessed); }
.med-row.status-error { border-color: rgb(200 30 30 / .45); }
.med-row.status-warn { border-color: rgb(180 83 9 / .45); }
.med-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.med-head strong { font-size: 15px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--selected); color: var(--ink); }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-pass { background: #dcfce7; color: #166534; }
:root[data-theme="dark"] .badge-error { background: rgb(248 113 113 / .2); color: #fca5a5; }
:root[data-theme="dark"] .badge-warn { background: rgb(251 191 36 / .18); color: #fcd34d; }
:root[data-theme="dark"] .badge-pass { background: rgb(74 222 128 / .16); color: #86efac; }
.med-meta { font-size: 13px; color: var(--muted); word-break: break-word; }
.med-note { font-size: 13px; color: var(--muted); }
.issue-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.issue-list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 13px; }
.issue-error { color: #991b1b; font-weight: 600; }
.issue-warn { color: #92400e; }
:root[data-theme="dark"] .issue-error { color: #fca5a5; }
:root[data-theme="dark"] .issue-warn { color: #fcd34d; }
.issue-mark { font-weight: 700; }
.basis-tag { font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: var(--selected); color: var(--muted); }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print {
  body { background: #fff; }
  #back, #input-h, .buttons, #report-h, #why-h, .brand-line { display: none !important; }
  main { width: 100%; margin: 0; }
  .panel { break-inside: avoid; border: 1px solid #ccc; }
}
