:root {
  color-scheme: light;
  --navy: #1f2e55;
  --ink: #172239;
  --muted: #53617a;
  --line: #d8e0eb;
  --background: #f4f6fa;
  --gold: #b9870e;
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .46; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid #6490d3; outline-offset: 3px; }
.header { background: white; border-bottom: 1px solid var(--line); }
.header-inner { width: min(1320px, 100%); margin: auto; padding: 11px clamp(18px, 4vw, 52px); display: flex; align-items: center; gap: 15px; }
.brand { color: var(--navy); font-size: 1.45rem; font-weight: 800; letter-spacing: .045em; }
.header-title { padding-left: 15px; border-left: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
main { width: min(1320px, 100%); margin: auto; padding: 0 clamp(16px, 4vw, 52px) 32px; }
.welcome { max-width: 750px; margin: clamp(45px, 9vh, 97px) auto 0; text-align: center; }
.heading h1 { margin: 0; color: var(--navy); font-size: clamp(2.2rem, 6vw, 3.35rem); letter-spacing: .025em; line-height: 1.18; }
.heading p { margin: 10px 0 25px; color: var(--muted); }
.drop { padding: 40px 22px 29px; border: 2px dashed #a7b7d1; border-radius: 16px; color: var(--navy); background: white; }
.drop.is-dragging { border-color: var(--navy); background: #edf3ff; }
.drop h2 { margin: 10px 0 15px; font-size: clamp(1.08rem, 4vw, 1.35rem); }
.drop p { margin: 15px 0 0; font-size: .875rem; color: var(--muted); }
.sample-line { margin: 14px 0 0; }
.primary, .secondary { min-height: 41px; border: 1px solid transparent; border-radius: 8px; padding: 7px 15px; font-size: .9rem; font-weight: 700; text-align: center; }
.primary { background: var(--navy); color: white; }
.primary:hover:not(:disabled) { background: #304673; }
.secondary { border-color: #c4cfdf; background: white; color: var(--navy); }
.secondary:hover:not(:disabled) { background: #f0f4fb; }
.text-button { padding: 4px 0; border: 0; background: none; color: #234572; text-decoration: underline; text-underline-offset: 3px; font-size: .875rem; }
.status { margin: 10px auto 0; text-align: center; color: var(--navy); font-size: .875rem; }
.status:empty { display: none; }
.status.error { color: #a12323; }
.editor { margin-top: 22px; }
.file-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.file-label { min-width: 0; }
.file-label h1 { margin: 0; color: var(--navy); font-size: clamp(1.4rem, 4vw, 1.85rem); }
.file-label p { margin: 2px 0 0; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.file-bar button { flex-shrink: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.preview, .controls { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.preview-bar, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.preview-bar { padding: 9px 11px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.page-nav { display: flex; align-items: center; gap: 9px; font-size: .875rem; color: var(--muted); }
.page-nav button { min-height: 34px; padding: 1px 10px; font-size: 1.3rem; line-height: 1; }
.segmented { display: inline-flex; gap: 2px; border-radius: 8px; padding: 3px; background: #eaf0f8; }
.segmented button { padding: 6px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--navy); font-weight: 700; font-size: .875rem; }
.segmented button[aria-pressed="true"] { background: white; box-shadow: 0 1px 3px #16274920; }
.paper-wrap { display: flex; align-items: start; justify-content: center; background: #e8ecf3; padding: 14px; min-height: 290px; }
.paper { position: relative; width: min(100%, var(--paper-width, 650px)); box-shadow: 0 2px 12px #14274b2c; background: white; }
#page-canvas { display: block; width: 100%; height: auto; }
.overlay { position: absolute; cursor: move; touch-action: none; outline: 1px solid #3d6ec9; z-index: 1; }
.overlay.original { background: #2853a21c; outline: 1px dashed #3d6ec9; }
.overlay canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.overlay.original canvas { visibility: hidden; }
.handle { position: absolute; width: 12px; height: 12px; border: 1px solid #3566be; border-radius: 2px; background: white; }
.handle[data-corner="nw"] { top: 0; left: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.handle[data-corner="ne"] { top: 0; right: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.handle[data-corner="sw"] { bottom: 0; left: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.handle[data-corner="se"] { bottom: 0; right: 0; transform: translate(50%, 50%); cursor: nwse-resize; }
.controls section { padding: 14px; }
.controls section + section { border-top: 1px solid var(--line); }
.controls h2 { margin: 0 0 8px; color: var(--navy); font-size: 1rem; }
.section-head h2 { margin-bottom: 0; }
.controls label { display: grid; gap: 3px; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.controls label.check { display: flex; align-items: center; gap: 7px; font-size: .9rem; color: var(--ink); }
.check input { accent-color: var(--navy); }
.controls input:not([type="checkbox"]) { min-width: 0; width: 100%; padding: 6px 8px; min-height: 36px; border: 1px solid #c5d0df; border-radius: 7px; background: white; color: var(--ink); }
.hint { margin: 7px 0; color: var(--muted); font-size: .85rem; }
.badge { margin: 7px 0 0; color: #315a4e; font-weight: 700; font-size: .875rem; }
.badge.review { color: #8a570c; }
.numbers, .output-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#confirm-band { width: 100%; margin-top: 9px; }
.output { background: #f7f9fc; }
.output-buttons { margin-top: 10px; }
.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: .01; }
@media (max-width: 790px) {
  .workspace { grid-template-columns: 1fr; }
  .paper-wrap { min-height: 210px; }
}
@media (max-width: 410px) {
  .preview-bar { gap: 6px; }
  .primary, .secondary { padding-inline: 10px; }
}
