* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: #f7f8fa;
  color: #22262b;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
:root {
  --accent: #e63329;
  --accent-dark: #c22318;
  --ink: #22262b;
  --dim: #626b76;
  --line: #e3e7ec;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(20, 30, 50, .07);
  --shadow-hover: 0 8px 24px rgba(20, 30, 50, .13);
}

/* ---------- トップ ---------- */
.site-header {
  background: #ffffff;
  padding: 26px 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 900; font-size: 1.05rem; color: var(--accent); letter-spacing: .02em; }
.hero-title { margin: 8px 0 6px; font-size: 2rem; font-weight: 900; line-height: 1.25; }
.hero-sub { margin: 0 auto 12px; color: var(--dim); font-size: .98rem; max-width: 640px; }
.badges {
  list-style: none; margin: 0 0 12px; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.badges li {
  background: #fdecea; color: var(--accent-dark); border: 1px solid #f5c6c1;
  border-radius: 999px; padding: 2px 11px; font-size: .8rem; font-weight: 700;
}
.privacy-note {
  display: inline-block; margin: 0; background: #e9f7ee; color: #17693a;
  border: 1px solid #a9dcc0; border-radius: 10px; padding: 7px 13px;
  font-size: .88rem; font-weight: 700; max-width: 100%;
}
.container { max-width: 1020px; margin: 0 auto; padding: 16px 12px; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tool-card {
  appearance: none; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  font-family: inherit; color: var(--ink);
  transition: box-shadow .15s ease, transform .15s ease;
}
.tool-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.tool-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
}
.tile-red { background: #fdecea; } .tile-orange { background: #fff1e2; }
.tile-green { background: #e7f6ec; } .tile-teal { background: #e2f5f3; }
.tile-indigo { background: #e8eafc; } .tile-blue { background: #e3f0fd; }
.tile-purple { background: #f1e8fd; } .tile-pink { background: #fde8f1; }
.tile-cyan { background: #e0f6fa; } .tile-amber { background: #fdf3d8; }
.tile-slate { background: #e9edf1; }
.tool-name { font-size: 1.08rem; font-weight: 800; }
.tool-desc { font-size: .86rem; color: var(--dim); }

/* ---------- ツール画面 ---------- */
.tool-header {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 14px 16px 12px; text-align: center;
}
.tool-header h2 { margin: 8px 0 2px; font-size: 1.45rem; font-weight: 900; }
.tool-desc-head { margin: 0; color: var(--dim); font-size: .92rem; }
#backBtn { display: block; margin: 0 auto; }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 1.12rem; font-weight: 800; }
.card h4 { margin: 18px 0 6px; font-size: 1rem; font-weight: 800; }
.hint { color: var(--dim); font-size: .85rem; margin: 4px 0; }
.hint.indent { margin-left: 1.6em; }
.honest {
  background: #fff8e1; border: 1px solid #ffe082; border-radius: 10px;
  padding: 8px 11px; font-size: .88rem; margin: 0 0 10px;
}
.free-note { color: #17693a; font-weight: 700; font-size: .92rem; margin: 8px 0 0; }
.status { min-height: 1.4em; font-size: .9rem; color: var(--accent-dark); margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }
.status.error { color: #c62828; }
.doc-info { font-size: .9rem; font-weight: 700; margin: 6px 0 0; }

.drop-zone {
  border: 2px dashed #b9c2cc; border-radius: var(--radius); padding: 26px 12px;
  text-align: center; background: #fbfcfd; cursor: pointer;
}
.drop-zone.dragover { border-color: var(--accent); background: #fdecea; }
.dz-main { font-size: 1.05rem; font-weight: 800; margin: 0 0 2px; }
.dz-sub { color: var(--dim); font-size: .85rem; margin: 5px 0; }
.btn-big-inline { font-size: 1.05rem; padding: 12px 26px; }

.btn {
  appearance: none; border: 1px solid #b9c2cc; background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 15px; font-size: .95rem; cursor: pointer; min-height: 42px;
  font-family: inherit;
}
.btn:hover { background: #f0f3f6; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 800; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { border-color: #cfd6dd; color: #546e7a; }
.btn-big { flex: 1; font-size: 1.05rem; min-height: 54px; border-radius: 12px; }
.btn.armed { background: #c62828; border-color: #c62828; color: #fff; font-weight: 800; }

.source-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: .9rem; }
.source-list li { padding: 3px 0; border-bottom: 1px dotted var(--line); word-break: break-all; }
.source-list li:last-child { border-bottom: none; }

.pages-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px; margin-top: 10px;
}
.page-card {
  border: 2px solid var(--line); border-radius: 12px; padding: 6px;
  text-align: center; background: #fff; cursor: pointer;
}
.page-card.selected { border-color: var(--accent); background: #fdecea; }
.page-card canvas { max-width: 100%; height: auto; display: block; margin: 0 auto; background: #fff; }
.page-num { font-size: .8rem; font-weight: 700; margin: 4px 0; }
.page-btns { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.page-btns button {
  border: 1px solid #b9c2cc; background: #fff; border-radius: 7px;
  width: 34px; height: 34px; font-size: .95rem; cursor: pointer; padding: 0;
}
.page-btns button:hover { background: #f0f3f6; }
.row-actions { margin-top: 12px; text-align: right; }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 9px 0; }
.form-row.col { flex-direction: column; align-items: flex-start; gap: 2px; }
.form-row label { display: inline-flex; align-items: center; gap: 6px; font-size: .92rem; }
label.grow-label { flex: 1 1 260px; }
.text-input {
  border: 1px solid #b9c2cc; border-radius: 10px; padding: 10px 11px;
  font-size: 1rem; min-height: 44px; max-width: 100%; font-family: inherit;
}
.grow { flex: 1 1 200px; }
.num-input { width: 78px; border: 1px solid #b9c2cc; border-radius: 10px; padding: 9px; font-size: 1rem; }
select { border: 1px solid #b9c2cc; border-radius: 10px; padding: 9px; font-size: .95rem; background: #fff; max-width: 100%; font-family: inherit; }
input[type="range"] { max-width: 130px; }
input[type="checkbox"], input[type="radio"] { width: 19px; height: 19px; }

.pager-row { justify-content: center; }
.page-indicator { font-weight: 800; font-size: .95rem; min-width: 110px; text-align: center; }

.preview-wrap {
  position: relative; max-width: 760px; margin: 0 auto; background: #eceff1;
  border: 1px solid #cfd8dc; border-radius: 10px; overflow: hidden;
}
.preview-wrap canvas { display: block; width: 100%; height: auto; }
.overlay-layer { position: absolute; inset: 0; }
.overlay-item { position: absolute; pointer-events: none; }
.overlay-text {
  font-weight: 700; white-space: nowrap; line-height: 1;
  text-shadow: 0 0 3px rgba(255,255,255,.9), 0 0 3px rgba(255,255,255,.9);
}
.overlay-img { display: block; opacity: .92; outline: 1px dashed rgba(230,51,41,.7); }
.overlay-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .92rem; }
.overlay-list li { padding: 5px 0; border-bottom: 1px dotted var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.overlay-list button {
  border: 1px solid #b9c2cc; background: #fff; border-radius: 7px;
  height: 32px; padding: 0 11px; cursor: pointer; font-family: inherit;
}

.sign-wrap {
  border: 2px solid #b9c2cc; border-radius: 12px; background: #fff;
  max-width: 640px; overflow: hidden; touch-action: none;
}
.sign-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
#signSection.flash { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 12px; }

.action-bar {
  position: sticky; bottom: 0; background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line); padding: 10px 12px;
  display: flex; gap: 10px; z-index: 20;
}
.action-bar[hidden] { display: none; }

.img-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 10px 0; }
.img-item { border: 1px solid var(--line); border-radius: 12px; padding: 8px; text-align: center; background: #fff; }
.img-item img { max-width: 100%; height: auto; display: block; margin: 0 auto 6px; background: #fff; border: 1px solid #eef1f4; }
.img-item a { font-size: .88rem; font-weight: 700; color: var(--accent-dark); }

.extract-area {
  width: 100%; border: 1px solid #b9c2cc; border-radius: 10px; padding: 10px;
  font-size: .92rem; font-family: inherit; resize: vertical; background: #fbfcfd;
}

/* ---------- 第2弾ツールの追加スタイル ---------- */
.progress-track {
  height: 9px; background: #eef1f4; border-radius: 99px; overflow: hidden; margin: 6px 0 10px;
}
.progress-bar {
  height: 100%; width: 0; background: var(--accent); border-radius: 99px;
  transition: width .25s ease;
}
.drag-wrap { touch-action: none; cursor: crosshair; }
.select-rect {
  position: absolute; border: 2px dashed var(--accent);
  background: rgba(230, 51, 41, .12); z-index: 3; pointer-events: none;
}

/* ---------- 第3弾ツールの追加スタイル ---------- */
.big-result { font-size: 1.25rem; font-weight: 800; margin: 10px 0 2px; word-break: break-word; }
.hol-table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.hol-table td { padding: 4px 8px; border-bottom: 1px dotted var(--line); }
.hol-table td:first-child { white-space: nowrap; width: 9.5em; color: var(--dim); font-weight: 700; }
.zip-block { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
input[type="date"] { border: 1px solid #b9c2cc; border-radius: 10px; padding: 9px; font-size: .95rem; background: #fff; font-family: inherit; max-width: 100%; }

.meta-list { margin: 0 0 6px; font-size: .92rem; }
.meta-list div { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.meta-list dt { font-weight: 700; min-width: 92px; color: var(--dim); }
.meta-list dd { margin: 0; word-break: break-all; }

.site-footer { background: #fff; border-top: 1px solid var(--line); margin-top: 8px; padding-bottom: 26px; }
.site-footer h2 { font-size: 1.05rem; margin: 14px 0 6px; }
.howto, .limits { margin: 0; padding-left: 1.3em; font-size: .92rem; }
.foot-note { color: var(--dim); font-size: .85rem; }
.print-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 4px; }
.print-btn { display: inline-block; border: 1.5px solid #d92b2b; color: #d92b2b; font-weight: 700; padding: 9px 18px; border-radius: 10px; text-decoration: none; font-size: .95rem; background: #fff; }
.print-btn:hover { background: #fdecec; }
.print-note { color: var(--dim); font-size: .8rem; margin: 4px 0 10px; }

@media (max-width: 560px) {
  .hero-title { font-size: 1.55rem; }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
  .tool-card { padding: 14px 12px; }
  .tool-icon { width: 44px; height: 44px; font-size: 1.35rem; }
  .card { padding: 13px; }
  .pages-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .btn-big { font-size: .98rem; }
}

/* ---------- 結果画面（保存・印刷の前に表示するモーダル） ---------- */
.result-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.result-modal[hidden] { display: none; }
.result-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.result-modal-card { position: relative; background: #fff; color: #222; border-radius: 16px; padding: 28px 22px 20px; width: calc(100% - 32px); max-width: 430px; max-height: calc(100vh - 48px); overflow-y: auto; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.result-modal-x { position: absolute; top: 8px; right: 12px; border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: #666; padding: 6px; }
.result-modal-icon { font-size: 40px; }
.result-modal-card h2 { margin: 8px 0 4px; font-size: 22px; }
.result-file { color: #555; font-size: 14px; margin: 0 0 14px; word-break: break-all; }
.result-ad { min-height: 120px; background: #f4f6f8; border-radius: 10px; margin: 0 0 16px; overflow: hidden; }
.result-ad .adsbygoogle { min-height: 120px; }
.result-action { width: 100%; }
.result-done { color: #2e7d32; font-size: 14px; margin: 10px 0 0; }
.result-close-btn { width: 100%; margin-top: 10px; }
.result-note { color: #888; font-size: 12px; margin: 12px 0 0; }
