:root {
  --brand: #1f4e79;
  --bg: #eef1f5; --surface: #ffffff; --text: #1d2330; --muted: #5d6675; --line: #d5dbe3;
  --field: rgba(255, 214, 10, .28); --field-line: #c9a400; --done: rgba(46, 160, 67, .14); --other: rgba(120, 130, 145, .10);
  --danger: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1d2129; --text: #e7eaf0; --muted: #9aa3b2; --line: #333a46; color-scheme: dark;
  }
}
:root[data-theme="dark"] { --bg: #14171c; --surface: #1d2129; --text: #e7eaf0; --muted: #9aa3b2; --line: #333a46; color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
.bar { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 3px solid var(--brand); flex-wrap: wrap; }
.bar-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
.bar-title img { max-height: 32px; }
.bar-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.bar-title span { color: var(--muted); font-size: 13px; }
.bar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.progress { color: var(--muted); font-size: 13px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: 110%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); display: flex; flex-direction: column; min-width: 220px; z-index: 30; }
.menu-list button { border: 0; background: none; text-align: left; padding: 10px 14px; font: inherit; color: var(--text); cursor: pointer; }
.menu-list button:hover { background: var(--bg); }
.menu-list .danger { color: var(--danger); }
.banner { background: #fff4ce; color: #4d3b00; padding: 10px 16px; border-bottom: 1px solid #e8d48a; }
main { padding: 16px; max-width: 980px; margin: 0 auto; }
.center { text-align: center; padding: 60px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; max-width: 520px; margin: 40px auto; }
.card h1 { font-size: 20px; margin: 0 0 8px; }
.card p { color: var(--muted); }
.card input { width: 100%; }
.spinner { width: 28px; height: 28px; margin: auto; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { background: var(--surface); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; white-space: pre-wrap; }
.page { color-scheme: light; position: relative; margin: 0 auto 18px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.page canvas { display: block; width: 100%; height: auto; }
.pno { text-align: center; color: var(--muted); font-size: 12px; margin: -12px 0 14px; }
.f { position: absolute; display: flex; align-items: center; border-radius: 2px; }
.f.mine { background: var(--field); outline: 1px dashed var(--field-line); }
.f.mine.ok { background: var(--done); outline-color: #2ea043; }
.f.mine.req::after { content: "*"; position: absolute; top: -3px; right: -8px; color: var(--danger); font-weight: 700; font-size: 13px; }
.f.other { background: var(--other); }
.f.focus { box-shadow: 0 0 0 3px var(--brand); }
.f input[type=text], .f input[type=date], .f input:not([type]), .f select, .f .val {
  width: 100%; height: 100%; border: 0; background: transparent; padding: 0 2px; color: #102a5c; font-family: Helvetica, Arial, sans-serif; }
.f select { appearance: auto; }
.f input[type=checkbox], .f input[type=radio] { width: 100%; height: 100%; margin: 0; accent-color: var(--brand); }
.f .sigbtn { width: 100%; height: 100%; border: 0; background: transparent; color: #4d3b00; font-weight: 600; cursor: pointer; font-size: 12px; }
.f img { width: 100%; height: 100%; object-fit: contain; }
.f .lbl { color: #222; font-family: Helvetica, Arial, sans-serif; }
.f a { color: #0b4fd0; font-family: Helvetica, Arial, sans-serif; }
.f .ph { color: #6b7280; font-size: 10px; padding: 0 3px; white-space: nowrap; overflow: hidden; }
.f .file { font-size: 10px; cursor: pointer; width: 100%; height: 100%; display: flex; align-items: center; padding: 0 3px; color: #4d3b00; }
dialog { border: 0; border-radius: 12px; padding: 20px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 15, 25, .55); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog input, dialog textarea, .card input { display: block; width: 100%; margin: 8px 0; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; background: var(--bg); color: var(--text); }
.scroll { max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 13px; background: var(--bg); }
.check { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.check input, .typed input { display: inline-block; width: auto; margin: 0; flex: none; }
.row { display: flex; gap: 8px; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.fine { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 8px 12px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.pad { width: 100%; height: 160px; border: 1px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; display: block; }
.typed { display: grid; gap: 8px; }
.typed label { color-scheme: light; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; color: #111; }
.typed span { font-size: 30px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.dl { display: grid; gap: 10px; margin-top: 16px; }
.dl a { text-align: center; text-decoration: none; }
@media (max-width: 640px) {
  .bar { padding: 8px 12px; }
  .bar-title strong { max-width: 90vw; }
  .bar-actions { width: 100%; justify-content: space-between; }
  main { padding: 10px 8px; }
}
