:root {
  --bg-1: #eef2fb;
  --bg-2: #f6f1fb;
  --panel: #ffffff;
  --border: #dde3ee;
  --border-strong: #c7cee0;
  --text: #1e2837;
  --muted: #6b7585;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-dark: #3a31b8;
  --tint: #eef0ff;
  --danger: #e11d48;
  --ok: #15a34a;
  --sel: #4f46e5;
  --shadow-sm: 0 1px 2px rgba(30,40,60,.06);
  --shadow-md: 0 6px 16px rgba(30,40,60,.09);
  --shadow-lg: 0 20px 44px rgba(50,40,90,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background:
    radial-gradient(1200px 600px at 12% -8%, #ece8ff 0%, transparent 55%),
    radial-gradient(1000px 560px at 100% 0%, #f1e9ff 0%, transparent 50%),
    linear-gradient(180deg, #e8e4fb, #efe8fc);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* 薄紫の下地の上に、色を抜いた(グレースケール)車を少し透過で重ねる */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: url("assets/car-bg.jpg") center center / cover no-repeat fixed;
  filter: grayscale(1);
  opacity: .14;
}
header, .toolbar, main, .statusbar, .editor-back, .modal-back { position: relative; z-index: 1; }

/* ===== Header ===== */
header.app-header {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 13px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.app-header h1 {
  font-size: 19px; margin: 0; display: flex; align-items: center; gap: 8px;
  font-weight: 800; letter-spacing: .2px;
}
.app-header h1 .accent {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.app-header .logo { font-size: 22px; }
.privacy-badge {
  font-size: 12px; color: #0f7a39; background: #e7f9ef; border: 1px solid #b6ecc9;
  padding: 4px 11px; white-space: nowrap; font-weight: 600;
}
.app-header .spacer { flex: 1; }
.app-header .counter {
  font-size: 13px; color: var(--brand-dark); font-weight: 700;
  background: var(--tint); border: 1px solid #d5d9f7; padding: 4px 11px;
}

/* ===== Toolbar ===== */
.toolbar {
  position: sticky; top: 53px; z-index: 30;
  background: rgba(255,255,255,.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 11px 22px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.toolbar .group {
  display: flex; gap: 7px; align-items: center;
  padding: 4px 13px 4px 8px; border-right: 1px solid var(--border);
}
.toolbar .group:last-child { border-right: none; }
.toolbar .group-label { font-size: 11px; color: var(--muted); margin-right: 2px; font-weight: 700; }

/* ===== Buttons ===== */
button.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  padding: 8px 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
  white-space: nowrap;
}
button.btn:hover:not(:disabled) {
  background: var(--tint); border-color: var(--brand); color: var(--brand-dark);
}
button.btn:active:not(:disabled) { transform: translateY(1px); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
button.btn.primary {
  background: var(--brand);
  border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 3px rgba(79,70,229,.25);
}
button.btn.primary:hover:not(:disabled) {
  background: var(--brand-dark); border-color: var(--brand-dark); color: #fff;
}
/* メインCTA：最も目立つ・大きめ・自然なホバーアニメーション */
button.btn.big {
  padding: 17px 40px; font-size: 16px; font-weight: 700; letter-spacing: .3px;
  transition: transform .22s cubic-bezier(.2,.7,.2,1), box-shadow .22s ease, background .18s ease;
}
button.btn.big.primary { box-shadow: 0 8px 24px rgba(79,70,229,.4); }
button.btn.big.primary:hover:not(:disabled) {
  transform: translateY(-3px); box-shadow: 0 16px 34px rgba(79,70,229,.5);
  background: var(--brand);
}
button.btn.big.primary:active:not(:disabled) { transform: translateY(-1px); }
button.btn.danger { color: var(--danger); border-color: #f0c4ce; }
button.btn.danger:hover:not(:disabled) { background: #fff1f3; border-color: var(--danger); color: var(--danger); }

/* ===== Main ===== */
main { padding: 30px 22px 44px; flex: 1 1 auto; }

/* ===== Hero (empty state) ===== */
.hero { max-width: 920px; margin: 26px auto 0; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.hero-card {
  width: 100%; background: transparent;
  border: 2px dashed rgba(79,70,229,.5);
  padding: 60px 28px 54px; text-align: center;
  box-shadow: none;
  transition: border-color .18s, background .18s;
}
.hero.drag .hero-card {
  border-color: var(--brand); background: rgba(79,70,229,.06);
}
.hero-icon {
  width: 80px; height: 80px; margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand); background: var(--tint);
}
.hero h2 { font-size: 30px; margin: 0 0 12px; font-weight: 800; letter-spacing: .4px; color: var(--text); }
.hero-sub { color: #3f4654; margin: 0 0 28px; font-size: 15px; line-height: 1.7; }
.hero-sub strong { color: var(--brand); font-weight: 700; }
.hero-privacy { color: var(--ok); font-size: 12.5px; margin: 22px 0 0; font-weight: 600; }

/* steps */
.steps { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.step {
  flex: 1; min-width: 190px;
  background: #ffffff; border: 1px solid var(--border);
  padding: 18px 20px; display: flex; align-items: center; gap: 15px;
}
.step .num {
  flex: none; width: 30px; height: 30px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.step div { display: flex; flex-direction: column; line-height: 1.45; }
.step b { font-size: 14px; }
.step div span { color: var(--muted); font-size: 12px; }
.step-arrow { display: flex; align-items: center; color: #c0c5d8; font-size: 18px; font-weight: 700; }

/* ===== feature list (bordered grid) ===== */
.features {
  width: 100%;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
}
.feat {
  background: #ffffff; padding: 18px 20px; display: flex; align-items: center; gap: 15px;
  transition: background .12s;
}
.feat:hover { background: #f7f8fc; }
.feat .ico {
  flex: none; width: 40px; height: 40px; background: var(--tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.feat .txt { display: flex; flex-direction: column; gap: 2px; line-height: 1.4; }
.feat .txt b { font-size: 14px; font-weight: 700; }
.feat .txt small { color: var(--muted); font-size: 11.5px; }

/* ===== Page grid ===== */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 16px; max-width: 1400px; margin: 0 auto;
}
.page-card {
  background: #fff; border: 1px solid var(--border);
  overflow: hidden; position: relative; box-shadow: var(--shadow-sm);
  user-select: none; transition: border-color .12s, box-shadow .12s, transform .08s;
}
.page-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.page-card.selected { border-color: var(--sel); box-shadow: 0 0 0 2px var(--sel), var(--shadow-md); }
.page-card.dragging { opacity: .4; }
.page-card.drag-over { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

.thumb-wrap {
  height: 182px; display: flex; align-items: center; justify-content: center;
  background: #eff1f7; overflow: hidden; cursor: pointer; position: relative;
}
.thumb-wrap canvas, .thumb-wrap img {
  max-width: 90%; max-height: 90%; box-shadow: 0 2px 8px rgba(20,25,40,.18); background: #fff; transition: transform .15s;
}
.thumb-wrap .loading { position: absolute; font-size: 12px; color: var(--muted); }
.page-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 9px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); background: #fbfcfe;
}
.page-meta .pno { font-weight: 700; color: #fff; background: var(--brand); min-width: 20px; text-align: center; padding: 1px 6px; }
.page-meta .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 92px; }

.page-actions { position: absolute; top: 7px; right: 7px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.page-card:hover .page-actions { opacity: 1; }
.page-actions button {
  width: 27px; height: 27px; border: none; background: rgba(30,40,55,.82); color: #fff;
  cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; padding: 0;
}
.page-actions button:hover { background: rgba(30,40,55,1); }
.page-actions button.del:hover { background: var(--danger); }

.sel-check {
  position: absolute; top: 7px; left: 7px; width: 22px; height: 22px;
  border: 2px solid #fff; background: rgba(255,255,255,.75); box-shadow: 0 1px 4px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; font-size: 14px; font-weight: 700;
}
.page-card.selected .sel-check { background: var(--sel); border-color: var(--sel); }

.drag-handle {
  position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%);
  background: rgba(30,40,55,.62); color: #fff; font-size: 10px; padding: 2px 9px; opacity: 0; cursor: grab;
}
.page-card:hover .drag-handle { opacity: 1; }

/* ===== Status bar ===== */
.statusbar {
  flex: none;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 14px rgba(20,22,45,.12);
  padding: 11px 22px; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 12px;
}
.status-dot { width: 8px; height: 8px; background: var(--ok); box-shadow: 0 0 0 3px #d8f3e1; flex: none; }
.statusbar .bar { flex: 1; height: 7px; background: #e9ecf6; overflow: hidden; display: none; }
.statusbar .bar.show { display: block; }
.statusbar .bar > i { display: block; height: 100%; width: 0%; background: var(--brand); transition: width .2s; }

/* ===== Modal ===== */
.modal-back {
  position: fixed; inset: 0; background: rgba(20,25,45,.5); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-back.show { display: flex; }
.modal { background: #fff; padding: 24px; width: 440px; max-width: 92vw; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal h3 { margin: 0 0 16px; font-size: 17px; font-weight: 800; }
.modal .row { margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; margin-bottom: 6px; font-weight: 700; }
.modal .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.modal input[type=range] { width: 100%; accent-color: var(--brand); }
.modal input[type=number], .modal input[type=text], .modal select {
  width: 100%; padding: 9px; border: 1px solid var(--border-strong); font: inherit;
}
.modal .radios { display: flex; gap: 9px; flex-wrap: wrap; }
.modal .radios label {
  flex: 1; min-width: 130px; border: 1.5px solid var(--border); padding: 12px;
  cursor: pointer; font-weight: 400; display: flex; gap: 9px; align-items: flex-start;
  transition: border-color .12s, background .12s;
}
.modal .radios label.sel { border-color: var(--brand); background: var(--tint); }
.modal .radios .t { font-weight: 700; font-size: 13px; }
.modal .radios .d { font-size: 11px; color: var(--muted); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.hidden { display: none !important; }

/* ===== brand logo ===== */
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; transition: opacity .12s; }
.brand:hover .brand-logo { opacity: .78; }

/* ===== removed (greyed-out) page ===== */
.page-card.removed .thumb-wrap canvas, .page-card.removed .thumb-wrap img { filter: grayscale(1); opacity: .35; }
.page-card.removed { box-shadow: var(--shadow-sm); border-style: dashed; }
.page-card.removed .page-actions, .page-card.removed .sel-check, .page-card.removed .drag-handle { display: none; }
.page-card.removed .pno { background: #9aa3b2; }
.removed-overlay {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 8px;
  background: rgba(245,247,250,.55); cursor: pointer; text-align: center;
}
.page-card.removed .removed-overlay { display: flex; }
.removed-overlay .rtxt { font-size: 12px; color: var(--muted); font-weight: 700; }
.removed-overlay .rbtn {
  background: var(--brand); color: #fff; border: none; padding: 7px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.removed-overlay .rbtn:hover { background: var(--brand-dark); }

/* ===== Editor ===== */
.editor-back {
  position: fixed; inset: 0; background: rgba(15,18,32,.72); backdrop-filter: blur(3px);
  display: none; z-index: 60; padding: 18px;
}
.editor-back.show { display: flex; }
.editor {
  margin: auto; background: #f4f6fb; width: 100%; max-width: 1100px; height: 100%;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); border: 1px solid #2a2e44;
}
.editor-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--border);
}
.editor-bar .eb-group { display: flex; gap: 7px; align-items: center; padding-right: 10px; border-right: 1px solid var(--border); }
.editor-bar .eb-group:last-child, .editor-bar .eb-group.spacer { border-right: none; }
.editor-bar .spacer { flex: 1; border: none; }
.editor-bar .group-label { font-size: 11px; color: var(--muted); font-weight: 700; }
.editor-bar label { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.editor-bar input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--border-strong); cursor: pointer; background: #fff; }
.editor-bar input[type=range] { width: 120px; accent-color: var(--brand); }
.editor-bar input[type=number] { width: 64px; padding: 5px 6px; border: 1px solid var(--border-strong); font: inherit; }
.editor-bar select { padding: 5px 6px; border: 1px solid var(--border-strong); font: inherit; background: #fff; cursor: pointer; }
.editor-bar .eb-allpages { background: #f3f1ff; border: 1px solid #d8d3fb; padding: 4px 8px; cursor: pointer; }
.editor-bar #edPageNum.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.editor-bar #edZoomLabel { min-width: 46px; text-align: center; font-weight: 700; font-size: 13px; color: var(--brand-dark); }
.ed-pagenum-preview {
  position: absolute; pointer-events: none; line-height: 1.1; white-space: nowrap;
  opacity: .92; text-shadow: 0 0 3px rgba(255,255,255,.9);
}
#edObjControls { opacity: .4; pointer-events: none; }
#edObjControls.active { opacity: 1; pointer-events: auto; }
.editor-stage {
  flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: safe center;
  padding: 24px; background:
    repeating-conic-gradient(#eceef4 0% 25%, #f6f7fb 0% 50%) 50% / 22px 22px;
}
.editor-page { position: relative; box-shadow: var(--shadow-lg); background: #fff; }
.editor-page canvas { display: block; }
/* 複数ページ表示 */
#edPages { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.doc-page { position: relative; background: #fff; box-shadow: var(--shadow-lg); }
.doc-page.current { outline: 3px solid var(--brand); outline-offset: 3px; }
.doc-page .ed-bg { display: block; }
.doc-page .doc-pageno {
  position: absolute; top: -22px; left: 0; font-size: 11px; font-weight: 700;
  color: #fff; background: rgba(20,22,40,.7); padding: 2px 9px; pointer-events: none;
}
.ed-search-hit { position: absolute; background: rgba(255,214,0,.4); pointer-events: none; mix-blend-mode: multiply; }
.ed-search-hit.active { background: rgba(255,138,0,.55); outline: 1px solid #ff7a00; }
.editor-bar #edSearch { width: 150px; padding: 6px 9px; border: 1px solid var(--border-strong); font: inherit; }
.editor-bar #edModeSingle.on, .editor-bar #edModeAll.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.editor-bar #edPickText.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.editor-bar #edFlatten.on { background: var(--danger); color: #fff; border-color: var(--danger); }
.editor-hint { padding: 8px 14px; background: #fff; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); text-align: center; }

/* editor objects */
.eo {
  position: absolute; box-sizing: border-box; cursor: move;
  outline: 1px dashed transparent;
}
.eo.sel { outline: 1.5px solid var(--brand); }
.eo-text {
  min-width: 24px; min-height: 1em; padding: 2px 3px; line-height: 1.25;
  white-space: pre-wrap; word-break: break-word; outline-offset: 1px;
}
.eo-text:focus { outline: 1.5px solid var(--brand); cursor: text; background: rgba(79,70,229,.04); }
.eo-rect { background: #ffffff; border: 1px solid rgba(0,0,0,.06); }
.eo-image img { width: 100%; height: 100%; display: block; pointer-events: none; }
.eo-ghost {
  pointer-events: none; opacity: .6;
  outline: 1px dashed rgba(79,70,229,.5); outline-offset: 0;
}
.eo .handle {
  position: absolute; right: -6px; bottom: -6px; width: 13px; height: 13px;
  background: var(--brand); border: 2px solid #fff; cursor: nwse-resize; display: none;
}
.eo.sel .handle { display: block; }

@media (max-width: 600px) {
  .step-arrow { display: none; }
  .hero h2 { font-size: 21px; }
  body::before { opacity: .04; }
}
