:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1f1d1a; --muted: #6f6a62; --line: #e3ded4; --soft: #f0ece4;
  --accent: #c2410c; --accent-ink: #fff; --del: #fde2e1; --del-ink: #9f1d1d; --ins: #dcfce7; --ins-ink: #14532d; --warn: #fff7e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --panel: #201f1c; --ink: #ece8e1; --muted: #a39d93; --line: #34312c; --soft: #2a2825;
    --accent: #fb923c; --accent-ink: #1b1209; --del: #4a1d1d; --del-ink: #fecaca; --ins: #173823; --ins-ink: #bbf7d0; --warn: #2e2614;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 14px/1.6 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 4px 12px; touch-action: manipulation; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
input[type=password] { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 3px 8px; width: 9em; }
.hint { color: var(--muted); font-size: 12.5px; }
.grow { flex: 1; }
[hidden] { display: none !important; }

header { display: flex; align-items: center; gap: 6px 12px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header h1 { font-size: 17px; margin: 0; }
.pwd { margin-left: auto; white-space: nowrap; }

#views { display: none; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
section { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex-wrap: wrap; }
.actions { border-top: 1px solid var(--line); background: var(--panel); }

#src, .scroll { flex: 1; min-height: 0; overflow: auto; border: 0; border-top: 1px solid var(--line); background: var(--panel); }
#src, .out { padding: 10px 14px; font-size: 14.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
#src { resize: none; outline: none; }
.out:empty::before { content: "校对完，改好的全文显示在这里"; color: var(--muted); }
.notes { white-space: pre-wrap; background: var(--warn); padding: 10px 14px; font-size: 13px; border-top: 1px solid var(--line); }
.notes:empty { display: none; }
del { background: var(--del); color: var(--del-ink); }
ins { background: var(--ins); color: var(--ins-ink); text-decoration: none; }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: s 1s linear infinite; vertical-align: -1px; }
@keyframes s { to { transform: rotate(360deg); } }

/* 手机：一次看一个页签，按钮放大、固定在底部 */
@media (max-width: 760px) {
  body { font-size: 15px; }
  header { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  header .sub, .desk { display: none; }
  input[type=password] { font-size: 16px; padding: 6px 10px; width: 8.5em; } /* 16px 起 iOS 才不会自动放大 */
  button { min-height: 42px; padding: 8px 14px; font-size: 15px; }

  #views { display: flex; background: var(--panel); border-bottom: 1px solid var(--line); }
  #views button { flex: 1; border: 0; border-radius: 0; background: none; min-height: 44px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
  #views button.on { color: var(--accent); border-bottom-color: var(--accent); }
  #badge:not(:empty) { margin-left: 6px; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }

  main { display: flex; }
  section { flex: 1; border-right: 0; }
  body[data-view="src"] #paneOut, body[data-view="out"] #paneSrc { display: none; }

  .bar { padding: 8px 12px; }
  #src, .out { font-size: 16px; padding: 12px; }
  .actions { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .actions .primary { flex: 1; }
  #busy, #usage { font-size: 12px; }
}
