:root {
  --bg: #f6f5f4;
  --card: #ffffff;
  --ink: #1d232b;
  --muted: #5d6772;
  --line: #dde1e6;
  --accent: #a8322a;
  --accent-soft: #fbeceb;
  --good: #1d7a46;
  --bad: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 4px 16px rgba(20, 30, 45, 0.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic UI', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }

/* ---- ヘッダー・フッター ---- */
.site-head { position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, 0.95); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(6px); }
.site-head .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; text-decoration: none; white-space: nowrap; }
.logo img { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px 16px; margin-left: auto; overflow-x: auto; font-size: 14px; white-space: nowrap; scrollbar-width: none; }
.nav a { padding: 6px 2px; color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--accent); }
.lang-switch { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); font-size: 13px; text-decoration: none; white-space: nowrap; }
@media (max-width: 760px) {
  .site-head .wrap { flex-wrap: wrap; gap: 0 12px; padding-top: 6px; }
  .nav { order: 3; width: 100%; margin-left: 0; padding-bottom: 4px; }
  .lang-switch { margin-left: auto; }
}
.site-foot { margin-top: 64px; padding: 32px 0 40px; border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 14px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.site-foot a { color: var(--muted); }

/* ---- 本文 ---- */
main { display: block; }
.hero { padding: 28px 0 4px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(23px, 4vw, 34px); line-height: 1.3; }
.hero p { margin: 0; color: var(--muted); max-width: 860px; }
.crumbs { margin: 16px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: '›'; margin: 0 6px 0 2px; }
section.block { margin-top: 36px; }
h2 { margin: 0 0 16px; font-size: 22px; line-height: 1.4; }
h3 { margin: 0 0 8px; font-size: 17px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.note { color: var(--muted); font-size: 14px; }
.prose { max-width: 780px; }
.prose h2 { margin-top: 36px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.links a { display: inline-block; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 14px; text-decoration: none; }
.links a:hover { border-color: var(--accent); color: var(--accent); }
.faq details { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.faq details + details { margin-top: 8px; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { margin: 10px 0 0; }
.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 15px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { background: var(--accent-soft); font-size: 13px; color: var(--muted); }
.prose table.data th { white-space: nowrap; }

/* ---- ツール一覧のカード ---- */
.tool-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.tool-cards a { display: grid; grid-template-columns: 40px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; height: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); text-decoration: none; }
.tool-cards a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tool-cards i { grid-row: 1 / 3; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-style: normal; font-size: 20px; font-weight: 700; }
.tool-cards b { font-size: 16px; line-height: 1.4; }
.tool-cards small { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---- ボタン・入力 ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 22px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer; font: inherit; font-weight: 700; text-decoration: none; text-align: center; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn.secondary { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 14px; font-weight: 600; }
.btn small { font-weight: 400; opacity: 0.9; }
.icon { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-size: 16px; line-height: 1; }
.icon:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.icon:disabled { opacity: 0.35; cursor: default; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field { display: block; min-width: 0; margin: 0; padding: 0; border: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.field select, .field input[type='text'], .field input[type='number'], .range, .sign-nav select {
  width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid #c9cfd6; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
.field input[type='range'] { width: 100%; accent-color: var(--accent); }
.radios { display: flex; flex-wrap: wrap; gap: 8px; }
.radios label { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-size: 14px; }
.radios label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.radios input { accent-color: var(--accent); }
.check-line { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 14px; line-height: 1.5; cursor: pointer; }
.check-line input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

/* ---- ツールの画面 ---- */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 150px; padding: 24px 16px; border: 2px dashed #c9a5a1; border-radius: 12px; background: #fdf8f7; cursor: pointer; text-align: center; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop b { font-size: 18px; color: var(--accent); }
.drop small { color: var(--muted); font-size: 13px; }
.drop .count { font-size: 13px; font-weight: 700; }
.privacy-badge { margin: 10px 0 0; font-size: 13px; color: var(--good); font-weight: 700; }
.privacy-badge::before { content: '🔒 '; }
form.opts { margin-top: 16px; }
form.opts:empty { display: none; }
form.opts > .field + .field, form.opts > .fieldset + .field { margin-top: 12px; }
form.opts .note { margin: 0; }
.split-sum { margin: 12px 0 0; font-size: 14px; font-weight: 700; }
.split-sum.bad, .status.bad { color: var(--bad); }
.status { margin: 14px 0 0; padding: 10px 14px; border-radius: 8px; background: #fff; border: 1px solid var(--line); font-size: 14px; }
.status.good { color: var(--good); }
.work { margin-top: 16px; }
.work:empty { display: none; }
.work-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.work-head > span { margin-right: auto; overflow-wrap: anywhere; }
.work-head .hint { width: 100%; }
.run-row { margin: 16px 0 0; }
.run-row .btn { width: 100%; max-width: 420px; font-size: 17px; }

.file-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.file-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.file-row .thumb { width: 64px; height: 64px; object-fit: contain; background: #eef0f2; border-radius: 4px; }
.file-info b { display: block; font-size: 15px; overflow-wrap: anywhere; line-height: 1.4; }
.file-info small { color: var(--muted); font-size: 13px; }
.file-info .range { margin-top: 6px; max-width: 320px; min-height: 34px; font-size: 14px; }
.row-btns { display: flex; gap: 4px; }
@media (max-width: 520px) {
  .file-row { grid-template-columns: 48px minmax(0, 1fr); }
  .file-row .thumb { width: 48px; height: 48px; }
  .row-btns { grid-column: 1 / -1; justify-content: flex-end; }
}

.page-grid { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 520px) { .page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.page-card { position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.page-grid:not(.sortable) .page-card { cursor: pointer; }
.page-card .pg { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1; overflow: hidden; }
.page-card .thumb { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); background: #fff; transition: transform 0.15s; }
.page-card .pg-no { margin-top: 4px; font-size: 13px; font-weight: 700; text-align: center; line-height: 1.3; }
.page-card .pg-no small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.pg-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 6px; }
.pg-btns .icon { min-width: 28px; height: 30px; padding: 0 4px; font-size: 14px; }
.page-card.del .pg { opacity: 0.25; }
.page-card.del .pg-no { text-decoration: line-through; color: var(--muted); }
.page-card.dragging { opacity: 0.4; }
.page-card.target { border-color: var(--accent); border-style: dashed; }
.page-card.sel { border-color: var(--accent); background: var(--accent-soft); }
.page-card.sel::after { content: '✓'; position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; line-height: 22px; text-align: center; }
.page-card[data-g='1'].sel { border-color: #1f63b6; background: #e8f0fb; }
.page-card[data-g='1'].sel::after { background: #1f63b6; }
.page-card[data-g='2'].sel { border-color: #1d7a46; background: #e7f4ec; }
.page-card[data-g='2'].sel::after { background: #1d7a46; }
.page-card[data-g='3'].sel { border-color: #8a4fb0; background: #f3ebf8; }
.page-card[data-g='3'].sel::after { background: #8a4fb0; }
.page-card[data-g='4'].sel { border-color: #b07a00; background: #fbf3e0; }
.page-card[data-g='4'].sel::after { background: #b07a00; }
.page-card[data-g='5'].sel { border-color: #127c87; background: #e4f4f5; }
.page-card[data-g='5'].sel::after { background: #127c87; }

/* ---- 署名 ---- */
.sign-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.sign-nav { display: flex; align-items: center; gap: 4px; }
.sign-nav select { width: auto; min-height: 34px; font-size: 14px; }
.sign-adds { display: flex; flex-wrap: wrap; gap: 6px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sign-pad, .sign-text { margin-bottom: 12px; padding: 14px; }
.sign-pad canvas { display: block; width: 100%; max-width: 900px; aspect-ratio: 3 / 1; border: 1px dashed #b9bfc6; border-radius: 8px; background: repeating-linear-gradient(0deg, transparent 0 74%, #eef0f2 74% 75%, transparent 75% 100%) #fff; touch-action: none; cursor: crosshair; }
.sign-pad .note { margin: 0 0 8px; }
.pad-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; }
.pad-opts select { min-height: 34px; border: 1px solid #c9cfd6; border-radius: 8px; font: inherit; font-size: 14px; }
.sign-stage { position: relative; max-width: 900px; margin: 0 auto; background: #e7eaee; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.sign-page { display: block; width: 100%; height: auto; background: #fff; }
.sign-layer { position: absolute; inset: 0; }
.sign-item { position: absolute; cursor: move; touch-action: none; outline: 1px dashed rgba(168, 50, 42, 0.5); }
.sign-item.on { outline: 2px solid var(--accent); background: rgba(168, 50, 42, 0.06); }
.sign-item img { display: block; width: 100%; height: auto; pointer-events: none; user-select: none; }
.sign-selected { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; max-width: 900px; margin: 10px auto 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; }
.sign-selected label { display: flex; align-items: center; gap: 8px; flex: 1 1 200px; }
.sign-selected input[type='range'] { flex: 1; accent-color: var(--accent); }
.sign-count { max-width: 900px; margin: 8px auto 0; }

/* ---- 結果 ---- */
.results { margin-top: 16px; }
.result h3 { color: var(--good); }
.result .actions { margin: 8px 0; }
.result .actions .btn { flex-direction: column; gap: 0; max-width: 100%; overflow-wrap: anywhere; }
.out-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.out-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }
.out-list img { width: 44px; height: 44px; object-fit: contain; background: #eef0f2; flex: none; }
.out-link { font-size: 13px; overflow-wrap: anywhere; min-width: 0; }
.out-link small { display: block; color: var(--muted); }
.out-preview { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 12px; }
.out-preview .thumb { width: 120px; height: auto; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); background: #fff; }
.more-pages { font-size: 13px; color: var(--muted); }
.out-img { display: block; max-height: 360px; width: auto; margin-top: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }

@media (max-width: 760px) {
  .logo { white-space: normal; line-height: 1.3; min-width: 0; }
  .card { padding: 14px; }
}
