:root {
  --ink: #13212f;
  --muted: #6b7884;
  --line: #dfe5e8;
  --line-strong: #cbd4d8;
  --paper: #ffffff;
  --canvas: #e8edef;
  --panel: #f9fbfb;
  --accent: #13a99a;
  --accent-dark: #0a7d73;
  --accent-soft: #dff6f2;
  --navy: #101d2a;
  --danger: #d25555;
  --shadow: 0 18px 50px rgba(20, 38, 51, .16);
  --topbar-h: 68px;
  font-family: "Yu Gothic UI", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--canvas); font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.credit-note { margin: 14px 0 0; color: var(--muted); font-size: 11.5px; }
.credit-note a { color: inherit; text-decoration: underline; }

.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 24px;
  padding: 0 20px; background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 195px; }
.brand-mark { width: 34px; height: 40px; display: block; position: relative; }
.brand-mark::before, .brand-mark::after, .brand-mark i, .brand-mark b {
  content: ""; position: absolute; width: 23px; height: 29px; border: 2px solid var(--navy); border-radius: 3px;
  background: white; transform: skewY(-4deg);
}
.brand-mark::before { left: 2px; top: 1px; opacity: .28; }
.brand-mark::after { left: 6px; top: 5px; opacity: .56; }
.brand-mark i { left: 10px; top: 9px; z-index: 2; border-color: var(--accent); }
.brand-mark b { width: 9px; height: 3px; left: 15px; top: 17px; z-index: 3; border: 0; border-radius: 2px; background: var(--accent); box-shadow: 0 6px 0 #b7c5c8; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-copy strong { font-size: 17px; letter-spacing: -.25px; }
.brand-copy small { margin-top: 6px; color: var(--accent-dark); font-size: 8px; font-weight: 800; letter-spacing: 2.2px; }

.document-chip { min-width: 0; max-width: 360px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: #f3f6f7; color: var(--muted); }
.document-chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #aeb9bd; }
.document-chip.open .status-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(19,169,154,.12); }
.document-chip.open { color: var(--ink); }
.toolbar { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.toolbar-divider { width: 1px; height: 24px; background: var(--line); margin: 0 4px; display: inline-block; }

.button, .icon-button, .mini-button, .zoom-readout, .tool-button, .more-button, .delete-button {
  border: 0; cursor: pointer; transition: background .16s, color .16s, border-color .16s, transform .1s, opacity .16s;
}
.button:active, .icon-button:active, .mini-button:active, .tool-button:active { transform: translateY(1px); }
.button:disabled, .icon-button:disabled { opacity: .35; cursor: default; }
.button { height: 38px; padding: 0 15px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.button.primary { background: var(--accent); color: white; box-shadow: 0 5px 14px rgba(19,169,154,.18); }
.button.primary:hover { background: #0e9689; }
.button.convert { color: var(--accent-dark); background: #e7f5f3; border: 1px solid #c8e8e4; }
.button.convert:hover { background: #d8f0ed; border-color: #9dd7d1; }
.button.overwrite { color: var(--accent-dark); background: white; border: 1px solid #a9d8d2; }
.button.overwrite:hover:not(:disabled) { color: white; background: var(--accent-dark); border-color: var(--accent-dark); }
.button.new-doc { color: var(--navy); background: white; border: 1px solid var(--line-strong); }
.button.new-doc:hover { color: var(--accent-dark); border-color: #9dd7d1; background: #f3fbfa; }
.button.save { color: white; background: var(--navy); }
.button.save:hover { background: #203344; }
.button.ghost { color: var(--muted); background: #edf2f3; }
.icon { font-size: 20px; line-height: 0; font-weight: 400; }
.icon.open-icon { font-size: 17px; font-weight: 800; }
.download-icon { font-size: 19px; font-weight: 400; border-bottom: 1px solid currentColor; line-height: 15px; }
.convert-icon { font-size: 18px; font-weight: 900; line-height: 1; }
.overwrite-icon { font-size: 17px; font-weight: 800; line-height: 1; }
.icon-button { width: 36px; height: 36px; border-radius: 8px; background: transparent; font-size: 23px; }
.icon-button:hover:not(:disabled) { background: #edf5f4; color: var(--accent-dark); }

.app-shell { height: calc(100% - var(--topbar-h)); display: grid; grid-template-columns: 218px minmax(480px, 1fr) 304px; }
.page-sidebar, .inspector { min-height: 0; background: var(--panel); display: flex; flex-direction: column; }
.page-sidebar { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); overflow: hidden; }
.panel-heading { min-height: 74px; padding: 18px 18px 12px; display: flex; align-items: flex-end; justify-content: space-between; }
.panel-heading h2 { margin: 3px 0 0; font-size: 16px; }
.eyebrow { color: var(--accent-dark); font-size: 8px; font-weight: 900; letter-spacing: 1.8px; }
.count-badge { min-width: 27px; padding: 4px 7px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; font-weight: 800; text-align: center; }

.thumbnail-list { position: relative; min-height: 0; overflow-y: auto; padding: 3px 16px 22px; scrollbar-width: thin; }
.thumbnail { position: relative; width: 100%; padding: 8px; margin-bottom: 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; }
.thumbnail:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumbnail.drag-source { opacity: .4; }
.thumbnail:hover { background: #eef4f4; }
.thumbnail.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px rgba(19,169,154,.08); }
.thumbnail-image { height: 168px; display: grid; place-items: center; overflow: hidden; border-radius: 3px; background: #dce3e5; box-shadow: 0 3px 10px rgba(17,31,43,.12); }
.thumbnail-sheet { --ratio: .707; position: relative; width: min(100%, calc(168px * var(--ratio))); aspect-ratio: var(--ratio); overflow: hidden; background: white; }
.thumbnail-base { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.thumbnail-picture { position: absolute; pointer-events: none; }
.thumbnail-picture img { position: absolute; display: block; max-width: none; transform-origin: center; }
.thumbnail-actions { position: absolute; top: 13px; right: 13px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; }
.thumbnail:hover .thumbnail-actions, .thumbnail:focus-within .thumbnail-actions { opacity: 1; }
.thumbnail-actions button { width: 24px; height: 24px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: rgba(255,255,255,.96); color: #52616b; cursor: pointer; font-size: 12px; font-weight: 800; line-height: 1; box-shadow: 0 2px 6px rgba(17,31,43,.14); }
.thumbnail-actions button:hover:not(:disabled) { color: var(--accent-dark); border-color: var(--accent); }
.thumbnail-actions button.danger:hover:not(:disabled) { color: white; background: var(--danger); border-color: var(--danger); }
.thumbnail-actions button:disabled { opacity: .35; cursor: default; }
.drop-line { position: absolute; left: 14px; right: 14px; z-index: 5; height: 3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 3px rgba(19,169,154,.18); pointer-events: none; }
.drop-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.thumbnail footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; color: var(--muted); font-size: 11px; }
.thumbnail footer b { color: var(--ink); }
.thumbnail .edit-count { color: var(--accent-dark); font-weight: 800; }
.page-actions { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 14px 14px; }
.page-action-row { display: grid; grid-template-columns: 1fr 1.4fr 32px; gap: 5px; }
.page-action-row button { height: 32px; padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 7px; background: white; color: #3f4f58; cursor: pointer; font-size: 10.5px; font-weight: 800; white-space: nowrap; }
.page-action-row button:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }
.page-action-row .settings-button { color: var(--muted); font-size: 15px; font-weight: 400; }
.page-actions p { margin: 9px 2px 0; color: #8b979d; font-size: 9.5px; line-height: 1.55; }

.workspace { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background-color: var(--canvas); background-image: radial-gradient(#d3dcde 1px, transparent 1px); background-size: 18px 18px; }
.workspace-toolbar { height: 54px; flex: 0 0 54px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; background: rgba(250,252,252,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); position: relative; z-index: 10; }
.tool-group, .workspace-actions { display: flex; align-items: center; gap: 5px; }
.tool-group { padding: 3px; border-radius: 8px; background: #e9eeee; }
.tool-button { height: 32px; padding: 0 11px; display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.tool-button span { font-weight: 900; }
.tool-button.active { color: var(--accent-dark); background: white; box-shadow: 0 2px 7px rgba(20,37,48,.1); }
.switch-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; }
.switch { width: 29px; height: 17px; border-radius: 10px; background: #bdc7ca; position: relative; transition: .16s; }
.switch::after { content: ""; position: absolute; width: 11px; height: 11px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .16s; }
.switch-label input:checked + .switch { background: var(--accent); }
.switch-label input:checked + .switch::after { transform: translateX(12px); }
.mini-button, .zoom-readout { height: 30px; min-width: 30px; padding: 0 8px; border-radius: 6px; background: transparent; }
.mini-button { font-size: 18px; }
.mini-button:hover, .zoom-readout:hover { background: #e7eeee; }
.zoom-readout { min-width: 54px; color: var(--muted); font-size: 11px; font-weight: 800; }
.page-readout { color: var(--muted); font-size: 11px; min-width: 48px; text-align: center; }
.page-readout b { color: var(--ink); }

.canvas-scroll { min-width: 0; min-height: 0; flex: 1; overflow: auto; position: relative; }
.drop-hint { position: absolute; top: 68px; left: 50%; z-index: 30; max-width: calc(100% - 32px); padding: 9px 16px; overflow: hidden; border-radius: 22px; background: var(--navy); color: white; box-shadow: 0 10px 28px rgba(11,28,40,.28); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; transform: translateX(-50%); pointer-events: none; }
.empty-state { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; }
.empty-state h1 { margin: 8px 0 10px; font-size: clamp(22px, 2.2vw, 32px); letter-spacing: -.8px; }
.empty-state > p { margin: 0 0 24px; color: var(--muted); line-height: 1.7; }
.empty-visual { width: 120px; height: 116px; position: relative; margin-bottom: 10px; }
.sheet { position: absolute; width: 68px; height: 88px; left: 27px; top: 9px; border: 2px solid var(--navy); border-radius: 5px; background: white; box-shadow: 0 7px 18px rgba(26,45,58,.12); }
.sheet.back { transform: rotate(-8deg) translate(-10px, 3px); background: #dfe9ea; opacity: .72; }
.sheet.front { transform: rotate(4deg); z-index: 2; display: flex; flex-direction: column; gap: 8px; padding: 24px 13px; }
.sheet.front i { height: 3px; border-radius: 3px; background: #bcc8cb; }
.sheet.front i:first-child { width: 60%; background: var(--accent); }
.edit-spark { position: absolute; right: 13px; top: 3px; z-index: 3; width: 33px; height: 33px; display: grid; place-items: center; color: white; border-radius: 50%; background: var(--accent); font-size: 18px; box-shadow: 0 6px 15px rgba(19,169,154,.28); }
.drop-zone { width: min(420px, 90%); min-height: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1.5px dashed #9ab2b4; border-radius: 12px; background: rgba(255,255,255,.72); cursor: pointer; transition: .2s; }
.drop-zone:hover, .drop-zone.dragging { transform: translateY(-2px); border-color: var(--accent); background: white; box-shadow: var(--shadow); }
.upload-circle { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 3px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 19px; font-weight: 800; }
.drop-zone strong { font-size: 14px; }
.drop-zone small { color: var(--muted); font-size: 11px; }
.drop-zone small.drop-zone-lead { color: var(--accent-dark); font-weight: 700; }
.image-settings-summary { width: min(420px, 90%); margin-top: 10px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.66); color: var(--muted); font-size: 10.5px; text-align: left; }
.summary-label { flex: 0 0 auto; padding: 3px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-dark); font-size: 8.5px; font-weight: 900; }
#imageSettingsSummary { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-settings-summary button { flex: 0 0 auto; padding: 2px 4px; border: 0; background: transparent; color: var(--accent-dark); cursor: pointer; font-size: 10.5px; font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.text-link { margin-top: 10px; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--accent-dark); cursor: pointer; font-size: 12px; font-weight: 800; }
.text-link:hover { background: rgba(19,169,154,.1); }
.privacy-note { display: flex; gap: 6px; margin-top: 15px; color: #829095; font-size: 10px; }
.privacy-note span { color: var(--accent-dark); }

.page-stage { min-width: min-content; padding: 42px 60px 52px; display: flex; flex-direction: column; align-items: center; }
.page-shadow { position: relative; flex: 0 0 auto; background: white; box-shadow: var(--shadow), 0 0 0 1px rgba(27,47,59,.08); user-select: none; }
.page-shadow > img { display: block; width: 100%; height: 100%; pointer-events: none; }
.page-overlay { position: absolute; inset: 0; overflow: hidden; }
.page-overlay.add-mode { cursor: crosshair; }
.page-shadow.drop-target { outline: 3px dashed var(--accent); outline-offset: 6px; }
.page-shadow.drop-target::after { content: ""; position: absolute; inset: 0; z-index: 8; background: rgba(19,169,154,.08); pointer-events: none; }
.text-hitbox { position: absolute; z-index: 2; min-width: 3px; min-height: 3px; border: 1px solid rgba(10,125,115,.27); cursor: grab; color: transparent; white-space: pre; line-height: 1.22; transform-origin: top left; }
.hide-areas .text-hitbox:not(.selected):not(.modified) { border-color: transparent; }
.text-hitbox:hover { border-color: rgba(10,125,115,.85) !important; background: rgba(19,169,154,.07); }
.text-hitbox.selected { border: 1.5px solid var(--accent); background: rgba(19,169,154,.06); box-shadow: 0 0 0 2px rgba(19,169,154,.11); cursor: move; }
.text-hitbox.modified { border-color: rgba(19,169,154,.45); color: var(--text-color, #111827); background: transparent; }
.text-hitbox.deleted { opacity: .45; border-color: var(--danger); background: repeating-linear-gradient(-45deg, rgba(210,85,85,.12), rgba(210,85,85,.12) 4px, transparent 4px, transparent 8px); }
.redaction-mask { position: absolute; z-index: 1; pointer-events: none; }
.text-hitbox.modified { z-index: 4; }
.image-item { position: absolute; z-index: 3; outline: 1px solid transparent; cursor: grab; }
.image-item img { position: absolute; display: block; max-width: none; transform-origin: center; pointer-events: none; user-select: none; }
.image-item:hover { outline-color: rgba(10,125,115,.85); }
.page-overlay.add-mode .image-item { cursor: crosshair; outline-color: transparent; }
.image-item.selected { outline: 1.5px solid var(--accent); box-shadow: 0 0 0 3px rgba(19,169,154,.18); cursor: move; }
.text-hitbox.selected, .image-item.selected { z-index: 6; }
.resize-handle { display: none; position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; border: 2px solid white; border-radius: 2px; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); cursor: nwse-resize; }
.text-hitbox.selected .resize-handle, .image-item.selected .resize-handle { display: block; }
.canvas-hint { margin: 18px 0 0; padding: 6px 11px; border-radius: 20px; background: rgba(248,251,251,.88); color: #77858b; font-size: 10px; box-shadow: 0 2px 8px rgba(20,39,50,.08); }

.inspector-heading { border-bottom: 1px solid var(--line); }
.more-button { width: 31px; height: 28px; border-radius: 6px; background: transparent; color: var(--muted); letter-spacing: 2px; }
.more-button:hover { background: #edf2f3; }
.inspector-empty { margin: auto; padding: 32px; text-align: center; color: var(--muted); }
.inspector-empty strong { display: block; color: var(--ink); font-size: 14px; }
.inspector-empty p { font-size: 11px; line-height: 1.65; }
.selection-icon { width: 52px; height: 52px; margin: 0 auto 16px; border: 1px dashed #9aabad; border-radius: 10px; display: grid; place-items: center; transform: rotate(4deg); }
.selection-icon span { width: 18px; height: 21px; border-left: 2px solid var(--accent); border-top: 2px solid var(--accent); transform: skew(-14deg) rotate(-5deg); }
.inspector-form { min-height: 0; overflow-y: auto; padding-bottom: 24px; scrollbar-width: thin; }
.selection-summary { display: flex; align-items: center; gap: 10px; padding: 13px 16px; background: #f1f6f6; border-bottom: 1px solid var(--line); }
.type-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; background: var(--navy); color: white; font: 700 16px Georgia, serif; }
.type-icon.image { background: var(--accent-dark); font: 700 15px "Yu Gothic UI", sans-serif; }
.selection-summary div { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.selection-summary small { color: var(--accent-dark); font-size: 9px; font-weight: 800; }
.selection-summary strong { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.delete-button { width: 31px; height: 31px; border-radius: 6px; color: var(--danger); background: transparent; font-size: 17px; }
.delete-button:hover { background: #f9eaea; }
.form-section { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.field-label { display: flex; justify-content: space-between; margin-bottom: 8px; color: #52616b; font-size: 10px; font-weight: 800; letter-spacing: .3px; }
.field-label span { color: #99a5aa; font-weight: 500; }
textarea, .compact-field, .position-grid label { border: 1px solid var(--line-strong); background: white; border-radius: 7px; }
textarea { width: 100%; padding: 9px 10px; resize: vertical; min-height: 88px; color: var(--ink); line-height: 1.55; outline: none; }
textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(19,169,154,.1); outline: none; }
.field-meta { display: flex; justify-content: space-between; margin-top: 5px; color: #9aa5aa; font-size: 9px; }
.font-row { display: grid; grid-template-columns: 1fr 93px; gap: 8px; }
.font-preview { height: 40px; display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: white; font-size: 18px; font-weight: 700; }
.font-preview span { color: var(--muted); font-size: 10px; font-weight: 500; }
.compact-field { height: 40px; display: flex; align-items: center; padding: 0 7px; }
.compact-field span { color: var(--muted); font-size: 9px; }
.compact-field input { min-width: 0; width: 45px; border: 0; padding: 0 2px; text-align: right; font-size: 11px; }
.compact-field em { color: #9aa5aa; font-size: 9px; font-style: normal; }
.weight-control { margin-top: 8px; display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 7px; }
.weight-control > span { color: var(--muted); font-size: 9px; font-weight: 700; }
.weight-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 7px; background: #e9eeee; }
.weight-segmented button { height: 27px; border: 0; border-radius: 5px; background: transparent; color: #6d7b82; cursor: pointer; font-size: 10px; }
.weight-segmented button.active { color: var(--accent-dark); background: white; box-shadow: 0 1px 5px rgba(17,36,48,.1); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-top: 8px; padding: 3px; border-radius: 7px; background: #e9eeee; }
.segmented button { height: 27px; border: 0; border-radius: 5px; background: transparent; color: #6d7b82; cursor: pointer; font-size: 16px; line-height: 0; }
.segmented button:nth-child(2) { text-align: center; }
.segmented button:nth-child(3) { text-align: right; padding-right: 19px; }
.segmented button.active { color: var(--accent-dark); background: white; box-shadow: 0 1px 5px rgba(17,36,48,.1); }
.color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.color-row > label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 9px; }
.color-control { height: 32px; display: flex; align-items: center; gap: 5px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 7px; background: white; }
.color-control input { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: transparent; }
.color-control code { font: 9px ui-monospace, monospace; color: #66757c; }
.position-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.position-grid label { height: 34px; display: flex; align-items: center; padding: 0 8px; }
.position-grid span { width: 18px; color: var(--accent-dark); font-size: 9px; font-weight: 900; }
.position-grid input { width: 100%; min-width: 0; border: 0; text-align: right; font-size: 11px; }
.page-align-tools { margin-top: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9f9; }
.page-align-title { margin-bottom: 7px; color: #52616b; font-size: 9px; font-weight: 800; }
.page-align-row { display: grid; grid-template-columns: 28px 1fr; gap: 6px; align-items: center; }
.page-align-row + .page-align-row { margin-top: 6px; }
.page-align-row > span { color: var(--muted); font-size: 8px; font-weight: 700; }
.page-align-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.page-align-buttons button { height: 27px; padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 5px; background: white; color: #52616b; cursor: pointer; font-size: 9px; font-weight: 700; }
.page-align-buttons button:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }
.page-align-buttons button:active { transform: translateY(1px); }
.nudge-row { display: flex; align-items: center; gap: 4px; margin-top: 9px; }
.nudge-row > span { margin-right: auto; color: var(--muted); font-size: 9px; }
.nudge-row button { width: 28px; height: 26px; border: 1px solid var(--line-strong); border-radius: 5px; background: white; cursor: pointer; font-size: 11px; }
.nudge-row button:hover { color: var(--accent-dark); border-color: var(--accent); }
.image-card { display: flex; align-items: center; gap: 10px; }
.image-preview-box { width: 64px; height: 64px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: repeating-conic-gradient(#eef2f3 0% 25%, white 0% 50%) 50% / 12px 12px; }
.image-preview-box img { display: block; max-width: 100%; max-height: 100%; transition: transform .15s; }
.image-card-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.image-card-meta strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.image-card-meta small { color: var(--muted); font-size: 9.5px; }
.image-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.image-tools button, .wide-tool { height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; background: white; color: #3f4f58; cursor: pointer; font-size: 10px; font-weight: 800; }
.image-tools button span { margin-right: 5px; color: var(--accent-dark); font-size: 13px; }
.image-tools button:hover, .wide-tool:hover { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }
.check-row { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: #52616b; cursor: pointer; font-size: 10px; font-weight: 700; }
.check-row input { accent-color: var(--accent); }
.wide-tool { width: 100%; margin-top: 9px; }
.inspector-tip { margin: 14px 16px 0; padding: 10px; display: flex; gap: 8px; border-radius: 8px; background: var(--accent-soft); }
.inspector-tip span { color: var(--accent-dark); font-size: 8px; font-weight: 900; letter-spacing: 1px; }
.inspector-tip p { margin: 0; color: #55716f; font-size: 9px; line-height: 1.55; }

.loading-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(12,28,39,.36); backdrop-filter: blur(3px); }
.loader-card { min-width: 270px; padding: 27px; display: flex; flex-direction: column; align-items: center; border-radius: 13px; background: white; box-shadow: 0 24px 70px rgba(11,27,39,.28); }
.loader-card strong { margin-top: 14px; }
.loader-card small { margin-top: 6px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #d9e8e7; border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 240px; max-width: 380px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; color: white; border-radius: 9px; background: var(--navy); box-shadow: 0 12px 30px rgba(11,28,40,.25); animation: toast-in .22s ease-out; }
.toast.success { background: #0b756c; }
.toast.error { background: #9e3f44; }
.toast span { font-weight: 900; }
.toast p { margin: 0; font-size: 11px; line-height: 1.5; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.save-dialog { width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 26px 80px rgba(12,28,39,.35); }
.save-dialog::backdrop { background: rgba(12,28,39,.46); backdrop-filter: blur(3px); }
.save-dialog form { padding: 26px; }
.dialog-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 24px; font-weight: 800; }
.save-dialog h2 { margin: 15px 0 6px; font-size: 20px; }
.save-dialog p { margin: 0 0 18px; color: var(--muted); font-size: 11px; }
.save-dialog label { display: flex; flex-direction: column; gap: 6px; color: #53616a; font-size: 10px; font-weight: 800; }
.save-dialog input { height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.new-dialog, .settings-dialog { width: min(460px, calc(100vw - 32px)); }
.new-grid { display: grid; grid-template-columns: 1fr 96px; gap: 10px; }
.settings-grid { display: grid; gap: 10px; }
.save-dialog select { height: 40px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: white; color: var(--ink); font-weight: 500; }
.save-dialog select:disabled { color: #a3adb2; background: #f3f6f6; }
.orientation-field { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; color: #53616a; font-size: 10px; font-weight: 800; }
.orientation-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 9px; background: #e9eeee; }
.orientation-toggle button { height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 6px; background: transparent; color: #6d7b82; cursor: pointer; font-size: 12px; font-weight: 800; }
.orientation-toggle button.active { color: var(--accent-dark); background: white; box-shadow: 0 1px 5px rgba(17,36,48,.1); }
.sheet-icon { display: inline-block; border: 1.5px solid currentColor; border-radius: 2px; background: white; }
.sheet-icon.portrait { width: 12px; height: 16px; }
.sheet-icon.landscape { width: 16px; height: 12px; }
.from-images { width: 100%; margin-top: 14px; display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 1.5px dashed #a5b8bb; border-radius: 10px; background: #fbfdfd; cursor: pointer; text-align: left; }
.from-images:hover { border-color: var(--accent); background: #f1fbf9; }
.from-images-mark { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 16px; }
.from-images > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.from-images strong { color: var(--ink); font-size: 12px; }
.from-images small { color: var(--muted); font-size: 9.5px; }
.settings-dialog .check-option { margin-top: 12px; display: grid; grid-template-columns: 19px 1fr; gap: 3px 8px; }
.settings-dialog .check-option input { height: auto; padding: 0; }
.settings-dialog .check-option small { font-weight: 500; }

.convert-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 16px; background: white; box-shadow: 0 28px 90px rgba(12,28,39,.38); overflow: hidden; }
.convert-dialog::backdrop { background: rgba(12,28,39,.48); backdrop-filter: blur(4px); }
.convert-card { max-height: calc(100vh - 32px); overflow-y: auto; }
.convert-header { min-height: 96px; display: flex; align-items: center; gap: 14px; padding: 19px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, #f8fbfb, #eef8f6); }
.convert-header > div:nth-child(2) { min-width: 0; flex: 1; }
.convert-header h2 { margin: 3px 0 3px; font-size: 20px; letter-spacing: -.4px; }
.convert-header p { margin: 0; color: var(--muted); font-size: 10px; }
.convert-heading-mark { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; background: var(--navy); color: #65dfd2; font-size: 24px; font-weight: 900; box-shadow: 0 8px 18px rgba(16,29,42,.17); }
.dialog-close { align-self: flex-start; width: 32px; height: 32px; border: 0; border-radius: 7px; background: transparent; color: #7e8c92; cursor: pointer; font-size: 24px; line-height: 1; }
.dialog-close:hover { color: var(--ink); background: #e5eeee; }
.convert-tabs { margin: 18px 22px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 10px; background: #e8eeee; }
.convert-tabs button { min-height: 43px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 8px; color: #76848a; background: transparent; cursor: pointer; font-size: 12px; }
.convert-tabs button span { color: #9aa8ad; font-size: 17px; }
.convert-tabs button.active { color: var(--accent-dark); background: white; box-shadow: 0 3px 10px rgba(18,37,49,.1); }
.convert-tabs button.active span { color: var(--accent); }
.convert-panel { padding: 19px 22px 22px; }
.conversion-intro { display: flex; align-items: center; gap: 12px; padding: 0 2px 13px; }
.conversion-intro > div { min-width: 0; }
.conversion-intro strong { font-size: 13px; }
.conversion-intro p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.format-badge { width: 43px; height: 43px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; font-size: 10px; font-weight: 900; letter-spacing: .5px; }
.format-badge.pdf { color: #a54146; background: #f9e9e9; border: 1px solid #f0cdcf; }
.format-badge.md { color: #315c83; background: #e9f1f8; border: 1px solid #cfdfed; }
.conversion-file-picker { width: 100%; min-height: 86px; padding: 13px 15px; display: flex; align-items: center; gap: 13px; border: 1.5px dashed #a5b8bb; border-radius: 10px; background: #fbfdfd; text-align: left; cursor: pointer; transition: .18s; }
.conversion-file-picker:hover, .conversion-file-picker.has-file { border-color: var(--accent); background: #f1fbf9; }
.conversion-file-picker > span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.conversion-file-picker strong { font-size: 12px; }
.conversion-file-picker small { max-width: 535px; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-icon { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 20px; font-weight: 900; }
.conversion-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.check-option { min-height: 58px; display: grid; grid-template-columns: 19px 1fr; grid-template-rows: auto auto; column-gap: 8px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: white; cursor: pointer; }
.check-option input { grid-row: 1 / 3; align-self: center; accent-color: var(--accent); }
.check-option span { color: #3f4f58; font-size: 10px; font-weight: 800; }
.check-option small { color: #8b979c; font-size: 8.5px; line-height: 1.4; }
.check-option code, .conversion-note code { font-family: ui-monospace, monospace; }
.conversion-note { margin-top: 11px; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 7px; background: #f2f6f6; }
.conversion-note > span { padding: 3px 6px; border-radius: 4px; color: var(--accent-dark); background: var(--accent-soft); font-size: 8px; font-weight: 900; }
.conversion-note p { margin: 0; color: #6f7d83; font-size: 9px; }
.convert-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.button.wide { min-width: 150px; }
.pdf-settings { display: grid; grid-template-columns: 1.1fr .9fr .9fr; gap: 9px; margin-top: 12px; }
.pdf-settings > label, .output-name-field { display: flex; flex-direction: column; gap: 6px; color: #5d6c74; font-size: 9px; font-weight: 800; }
.pdf-settings select, .unit-input, .output-name-field input { height: 38px; border: 1px solid var(--line-strong); border-radius: 7px; background: white; }
.pdf-settings select { padding: 0 9px; color: var(--ink); }
.unit-input { display: flex; align-items: center; padding: 0 8px; }
.unit-input input { width: 100%; min-width: 0; border: 0; }
.unit-input em { color: #97a3a8; font-size: 9px; font-style: normal; }
.output-name-field { margin-top: 11px; }
.output-name-field input { padding: 0 10px; color: var(--ink); }

@media (max-width: 1020px) {
  .app-shell { grid-template-columns: 170px minmax(430px, 1fr) 270px; }
  .brand { min-width: auto; }
  .brand-copy small, .document-chip { display: none; }
  .topbar { gap: 14px; }
  .page-stage { padding-left: 38px; padding-right: 38px; }
}

@media (max-width: 790px) {
  .app-shell { grid-template-columns: minmax(390px, 1fr) 260px; }
  .page-sidebar { display: none; }
  .toolbar .button span:not(.icon):not(.download-icon):not(.convert-icon):not(.overwrite-icon) { display: none; }
  .button { width: 38px; padding: 0; }
  .workspace-actions .switch-label, .workspace-actions > .toolbar-divider:first-of-type { display: none; }
}

/* スマホ（Web 版で追加）: 編集画面は1列。ページ一覧は下に横並び・プロパティは画像を選んだ時だけ下に出す */
@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .brand { min-width: 0; }
  .brand-copy { display: none; }
  .toolbar { gap: 4px; }
  .toolbar-divider { margin: 0 2px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; }
  .workspace, .page-sidebar, .inspector, .thumbnail-list { min-width: 0; }
  .workspace { grid-row: 1; }
  .workspace-toolbar { padding: 0 8px; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  #selectTool { display: none; }
  .tool-button { padding: 0 8px; white-space: nowrap; font-size: 11.5px; }
  .workspace-actions { gap: 2px; }
  .workspace-actions .toolbar-divider { display: none; }
  .page-stage { padding-left: 14px; padding-right: 14px; }
  .empty-state { padding: 22px 16px; }
  .page-sidebar { display: flex; grid-row: 2; border-right: 0; border-top: 1px solid var(--line); }
  .page-sidebar .panel-heading { min-height: 0; padding: 8px 12px 0; }
  .page-sidebar .panel-heading .eyebrow { display: none; }
  .thumbnail-list { display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden; padding: 6px 12px 8px; }
  .thumbnail { flex: 0 0 104px; width: 104px; margin-bottom: 0; }
  .thumbnail-image { height: 112px; }
  .thumbnail-sheet { width: min(100%, calc(112px * var(--ratio))); }
  .thumbnail-actions { opacity: 1; top: 10px; right: 10px; }
  .page-actions { padding: 6px 12px 8px; }
  .page-actions p { display: none; }
  .inspector { grid-row: 3; max-height: 42vh; overflow-y: auto; border-left: 0; border-top: 1px solid var(--line); }
  .inspector:has(#inspectorForm.hidden) { display: none; }
  .inspector-heading { display: none; }
}

@media (max-width: 560px) {
  .convert-header { padding: 16px; }
  .convert-tabs { margin-left: 16px; margin-right: 16px; }
  .convert-panel { padding: 16px; }
  .conversion-options, .pdf-settings { grid-template-columns: 1fr; }
  .convert-actions .button { width: auto; padding: 0 13px; }
}
