  :root {
    --bg: #eeeeee;
    --ink: #4d4d4d;
    --ink-soft: #777777;
    --line: #7a7a7a;
    --white: #ffffff;
    --accent: #4a5bd4;
    --accent-dark: #3b4bb8;
    --thumb-1: #fff4dc;
    --thumb-2: #dcfbec;
    --thumb-3: #f6dcff;
    --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", Meiryo, sans-serif;
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
  }
  button { font-family: inherit; cursor: pointer; }
  button:focus-visible, input:focus-visible {
    outline: 3px solid #8fa0ff;
    outline-offset: 2px;
  }
  svg { display: block; }

  .view[hidden] { display: none; }

  /* ---------- Home ---------- */
  #home { min-height: 100%; padding: 0 clamp(16px, 8.5vw, 163px) 56px; }

  .home-title {
    margin: 0;
    padding: 28px 0 0;
    text-align: center;
    font-size: clamp(32px, 4.4vw, 84px);
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--ink);
  }

  .new-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 clamp(20px, 2.4vw, 46px);
    height: clamp(44px, 4.5vw, 88px);
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: clamp(16px, 1.7vw, 32px);
    font-weight: 600;
    letter-spacing: 0.12em;
  }
  .new-page-btn svg { width: 1em; height: 1em; }
  .new-page-btn:hover { background: #333; }
  .new-page-btn.danger { background: #c93b3b; }
  .new-page-btn.danger:hover:not(:disabled) { background: #a92e2e; }
  .new-page-btn:disabled { opacity: 0.4; cursor: default; }
  .new-page-btn[hidden] { display: none; }

  .home-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: clamp(12px, 1.6vw, 28px) 0 clamp(14px, 1.8vw, 24px);
    padding: 0 clamp(0px, 2.6vw, 50px);
  }

  /* 選択モードのチェックボックス */
  .select-box {
    position: absolute;
    top: 10px; right: 10px;
    display: grid;
    place-items: center;
    width: clamp(32px, 2.6vw, 48px);
    height: clamp(32px, 2.6vw, 48px);
    padding: 0;
    border: 3px solid var(--ink);
    border-radius: 10px;
    background: var(--white);
    color: #fff;
  }
  .select-box svg { width: 70%; height: 70%; opacity: 0; }
  .select-box[aria-checked="true"] { background: var(--ink); }
  .select-box[aria-checked="true"] svg { opacity: 1; }
  .page-card.selectable { cursor: pointer; }
  .page-card.selected { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(74, 91, 212, 0.35); }

  .page-panel {
    min-height: min(60vh, 800px);
    padding: clamp(16px, 4.4vw, 84px) clamp(16px, 4.4vw, 84px);
    background: var(--white);
    border: 2px solid var(--line);
    border-radius: clamp(28px, 4.6vw, 88px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: clamp(16px, 3vw, 72px);
    margin: 0; padding: 0;
    list-style: none;
  }
  .card-grid > li { max-width: 428px; }
  .card-grid > li.empty { max-width: none; }

  .page-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--white);
    border: 2px solid var(--line);
    border-radius: clamp(20px, 2.1vw, 40px);
    overflow: hidden;
  }
  .page-card .thumb {
    position: relative;
    aspect-ratio: 428 / 262;
    border-bottom: 2px solid var(--line);
  }
  .page-card .edit-btn {
    position: absolute;
    top: 10px; right: 10px;
    padding: 6px 20px;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: clamp(13px, 1.2vw, 22px);
    font-weight: 600;
    letter-spacing: 0.14em;
  }
  .page-card .edit-btn:hover { background: #222; }
  .page-card .delete-btn {
    position: absolute;
    top: 10px; left: 10px;
    display: grid;
    place-items: center;
    width: clamp(32px, 2.6vw, 48px);
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
  }
  .page-card .delete-btn svg { width: 58%; height: 58%; }
  .page-card .delete-btn:hover { background: #b3261e; }
  .page-card .name {
    margin: 0;
    padding: clamp(10px, 1vw, 18px) clamp(14px, 1.6vw, 30px);
    font-size: clamp(14px, 1.25vw, 22px);
    font-weight: 400;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
  }

  .notice {
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(66%, 780px);
    height: clamp(44px, 3.5vw, 66px);
    margin: clamp(12px, 1.8vw, 28px) auto clamp(28px, 4vw, 64px);
    padding: 0 clamp(16px, 2vw, 32px);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  }
  .notice[hidden] { display: none; }
  .notice svg { flex: none; width: 26px; height: 26px; color: var(--ink); }
  .notice-sep { flex: none; width: 1px; height: 1.3em; background: var(--ink-soft); }
  .notice-link {
    min-width: 0;
    color: #3b82f6;
    font-size: clamp(14px, 1.2vw, 20px);
    text-decoration: underline;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  @media (max-width: 700px) { .notice { width: 100%; } }

  .page-card .thumb { background: #eee; }
  .thumb-page {
    position: absolute;
    top: 0; bottom: 0; left: 50%;
    transform: translateX(-50%);
    aspect-ratio: 3 / 4;
    overflow: hidden;
    pointer-events: none;
    background-repeat: no-repeat;
  }
  .thumb-inner { position: absolute; top: 0; left: 0; width: 686px; padding: 0; transform-origin: top left; }

  .empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 12vh 0;
    text-align: center;
    color: var(--ink-soft);
    font-size: clamp(15px, 1.4vw, 24px);
    line-height: 1.9;
  }

  /* ---------- Editor ---------- */
  #editor { height: 100%; display: flex; flex-direction: column; background: var(--white); }
  #editor[hidden] { display: none; }

  .topbar {
    flex: none;
    height: 68px;
    overflow: hidden;
    background: var(--white);
    border-bottom: 1px solid var(--line);
  }
  .topbar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 76px;
    width: 111.1112%;
    padding: 0 28px;
    transform: scale(0.9);
    transform-origin: top left;
  }
  .icon-btn {
    display: grid;
    place-items: center;
    width: 46px; height: 46px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--white);
    color: var(--ink);
  }
  .icon-btn svg { width: 25px; height: 25px; }
  .icon-btn:hover:not(:disabled) { background: #f0f0f0; }
  .icon-btn:disabled { opacity: 0.45; cursor: default; }

  .name-field {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-left: 22px;
    min-width: 0;
  }
  .name-field label { font-size: 21px; font-weight: 600; letter-spacing: 0.08em; white-space: nowrap; }
  .name-field input {
    width: min(340px, 26vw);
    padding: 3px 6px;
    border: 0;
    border-bottom: 2px solid var(--line);
    border-radius: 0;
    background: transparent;
    font: inherit;
    font-size: 23px;
    color: var(--ink);
  }
  .spacer { flex: 1; min-width: 48px; }
  .undo-redo { display: flex; gap: 12px; margin-right: 18px; }

  .preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    height: 46px;
    padding: 0 28px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--white);
    color: var(--ink);
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0.08em;
  }
  .preview-btn svg { width: 24px; height: 24px; flex: none; }
  .preview-btn:disabled { opacity: 0.45; cursor: default; }

  .save-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    margin-left: 20px;
    padding: 0 32px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0.16em;
  }
  .save-btn svg { width: 25px; height: 25px; }
  .save-btn:hover { background: var(--accent-dark); }

  .export-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    margin-left: 10px;
    padding: 0 26px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0.08em;
  }
  .export-btn svg { width: 24px; height: 24px; }
  .export-btn:disabled { cursor: default; }

  .workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(200px, 21.5%) 1fr minmax(200px, 21.5%);
  }
  #editor.preview-mode .workspace { grid-template-columns: 1fr; }
  #editor.preview-mode .side { display: none; }
  #editor.preview-mode .el { cursor: default; }
  #editor.preview-mode .el:hover,
  #editor.preview-mode .el.selected,
  #editor.preview-mode .canvas.drag-over { outline: none; }
  #editor.preview-mode .drop-line, #editor.preview-mode .sel-box { display: none; }
  .side {
    background: var(--white);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
  .side.left { border-right: 1px solid var(--line); }
  .side.right { border-left: 1px solid var(--line); }
  .stage {
    background: var(--bg);
    overflow: auto;
    scrollbar-gutter: stable both-edges;
    padding: 46px 32px 0;
    box-shadow: inset 0 6px 8px -6px rgba(0, 0, 0, 0.2);
  }
  .canvas {
    position: relative;
    width: 686px;
    max-width: none;
    min-height: 100%;
    margin: 0 auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-bottom: 0;
  }

  /* ---------- 左右パネル ---------- */
  .side-inner {
    width: 111.1112%;
    padding: 28px 24px;
    transform: scale(0.9);
    transform-origin: top left;
  }
  .side-h {
    margin: 0 0 16px;
    padding-left: 12px;
    border-left: 2px solid var(--ink);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    color: #222;
  }
  .side-h + .field-row, .side-h + textarea { margin-top: 4px; }
  .side-h:not(:first-child) { margin-top: 30px; }
  .field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
  .field-label { font-size: 19px; white-space: nowrap; color: #222; }
  .pill-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 130px;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--white);
    font-family: inherit;
    font-size: 17px;
    color: var(--ink);
  }
  .pill-field:focus-within { outline: 3px solid #8fa0ff; outline-offset: 2px; }
  .pill-field input[type="color"] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
  }
  .swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
  select.pill-field { cursor: pointer; }
  .palette { display: flex; flex-wrap: wrap; gap: 16px; }
  .palette-item {
    display: grid;
    place-items: center;
    width: 84px; height: 84px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--white);
    color: var(--ink);
    cursor: grab;
  }
  .palette-item svg { width: 44px; height: 44px; }
  .palette-item:hover:not(:disabled) { background: #f0f0f0; }
  .palette-item:disabled { opacity: 0.45; cursor: default; }
  .side-empty { margin: 0; font-size: 16px; line-height: 1.8; color: var(--ink-soft); }
  #propRich {
    width: 100%;
    min-height: 104px;
    max-height: 260px;
    overflow: auto;
    margin-bottom: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--ink);
  }
  #propRich:focus-visible { outline: 3px solid #8fa0ff; outline-offset: 2px; }
  .hint { margin: 0 0 14px; font-size: 13px; line-height: 1.6; color: var(--ink-soft); }
  .text-input {
    flex: 1; min-width: 120px; height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit; font-size: 16px;
    color: var(--ink);
  }
  .file-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 22px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--white);
    color: var(--ink);
    font-size: 17px; font-weight: 600; letter-spacing: 0.08em;
  }
  .file-btn svg { width: 22px; height: 22px; }
  #chIconRow { flex-wrap: nowrap; }
  #chIconPick { padding: 0 16px; letter-spacing: 0.04em; white-space: nowrap; }
  .file-btn:hover { background: #f0f0f0; }
  .color-history { display: flex; gap: 8px; flex-basis: 100%; }
  .color-history:empty { display: none; }
  .hist-swatch { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; }
  .hist-swatch:hover { outline: 2px solid var(--accent); outline-offset: 2px; }
  .img-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    height: 140px;
    border: 2px dashed #b5b5b5;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
    color: #888;
    font-size: 16px; line-height: 1.5;
  }
  .img-empty svg { width: 40px; height: 40px; }
  .el img { -webkit-user-drag: none; user-select: none; }
  .seg { display: inline-flex; gap: 8px; }
  .tool-btn {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--white);
    color: var(--ink);
  }
  .tool-btn svg { width: 22px; height: 22px; }
  .tool-btn:hover { background: #f0f0f0; }
  .tool-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
  /* キャンバス上の要素 */
  .canvas { padding: 0; }
  .canvas.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }
  .el {
    position: absolute;
    min-height: 1.2em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
    cursor: move;
    user-select: none;
  }
  .el:hover { outline: 1px dashed #9aa5ff; outline-offset: -1px; }
  .el.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
  .drop-line { height: 4px; margin: 0 24px; border-radius: 2px; background: var(--accent); pointer-events: none; }

  /* ---------- ページ一覧（編集画面・左） ---------- */
  .page-nav { margin-bottom: 0; }
  .page-list { list-style: none; margin: 0 0 6px; padding: 0; }
  .page-li { margin-bottom: 8px; }
  .page-li.dragging { opacity: 0.4; }
  .page-drop { height: 3px; margin: -2px 0 5px; border-radius: 2px; background: var(--accent); pointer-events: none; list-style: none; }
  .page-row {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: #f3f3f3;
  }
  .page-row.current { background: var(--white); border-color: var(--ink); }
  .page-grip {
    flex: none;
    display: grid; place-items: center;
    width: 22px; height: 34px;
    color: var(--ink-soft);
    cursor: grab;
    touch-action: none;
  }
  .page-grip.fixed { opacity: 0.3; cursor: default; }
  .page-grip svg { width: 18px; height: 18px; }
  .page-item {
    flex: 1; min-width: 0;
    padding: 6px 6px;
    border: 0; border-radius: 6px;
    background: transparent;
    font-family: inherit; font-size: 19px; font-weight: 600; letter-spacing: 0.04em;
    text-align: left;
    color: #555;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .page-rename {
    flex: 1; min-width: 0;
    padding: 5px 8px;
    border: 2px solid var(--accent); border-radius: 8px;
    font: inherit; font-size: 19px; font-weight: 600;
    color: var(--ink);
  }
  .page-del {
    flex: none;
    display: grid; place-items: center;
    width: 34px; height: 34px; padding: 0;
    border: 0; border-radius: 8px;
    background: transparent;
    color: #555;
  }
  .page-del svg { width: 20px; height: 20px; }
  .page-del:hover { background: #fdeeee; color: #c93b3b; }
  .page-dup {
    flex: none;
    display: grid; place-items: center;
    width: 34px; height: 34px; padding: 0;
    border: 0; border-radius: 8px;
    background: transparent;
    color: #555;
  }
  .page-dup svg { width: 20px; height: 20px; }
  .page-dup:hover { background: #ececec; color: #222; }
  .add-page-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; height: 48px;
    border: 0; border-radius: 999px;
    background: var(--ink); color: #fff;
    font-size: 19px; font-weight: 600; letter-spacing: 0.12em;
  }
  .add-page-btn svg { width: 20px; height: 20px; }
  .add-page-btn:hover { background: #333; }

  /* ---------- 左パネルを一回り小さく ---------- */
  .side.left .side-inner { padding: 20px 18px; }
  .side.left .side-h { margin-bottom: 12px; font-size: 20px; }
  .side.left .side-h:not(:first-child) { margin-top: 24px; }
  .side.left .field-label { font-size: 15px; }
  .side.left .field-row { margin-bottom: 10px; gap: 6px; }
  .side.left .pill-field { height: 34px; padding: 0 12px; border-radius: 12px; font-size: 15px; }
  .side.left .swatch { width: 18px; height: 18px; }
  .side.left .page-li { margin-bottom: 6px; }
  .side.left .page-row { padding: 2px 6px 2px 10px; border-radius: 12px; }
  .side.left .page-grip { width: 20px; height: 30px; }
  .side.left .page-item { padding: 5px 4px; font-size: 16px; }
  .side.left .page-del { width: 30px; height: 30px; }
  .side.left .page-del svg { width: 18px; height: 18px; }
  .side.left .page-dup { width: 30px; height: 30px; }
  .side.left .page-dup svg { width: 18px; height: 18px; }
  .side.left .add-page-btn { height: 40px; font-size: 16px; }
  .side.left .bg-box-btn { height: 92px; border-radius: 14px; }
  .side.left .palette { gap: 12px; }
  .side.left .palette-item { width: 64px; height: 64px; border-radius: 14px; }
  .side.left .palette-item svg { width: 34px; height: 34px; }
  .side.left .palette-wide { height: 52px; border-radius: 26px; font-size: 17px; }

  /* ---------- テンプレート選択ダイアログ ---------- */
  .modal-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; text-align: center; }
  .tpl-list { display: grid; gap: 10px; margin-bottom: 20px; }
  .tpl-card {
    display: flex; align-items: center; gap: 14px;
    width: 100%; padding: 12px 16px;
    border: 2px solid var(--line); border-radius: 16px;
    background: var(--white);
    font: inherit; text-align: left; color: var(--ink);
    cursor: pointer;
  }
  .tpl-card:hover { border-color: var(--ink); background: #f7f7f7; }
  .tpl-card svg { width: 48px; height: 48px; flex: none; }
  .tpl-card strong { display: block; font-size: 17px; }
  .tpl-card small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }

  /* ---------- キャラクター一覧（編集パネル） ---------- */
  .side.right .page-li { margin-bottom: 6px; }
  .side.right .page-row { padding: 2px 6px 2px 10px; border-radius: 12px; }
  .side.right .page-grip { width: 20px; height: 30px; }
  .side.right .page-item { padding: 5px 4px; font-size: 16px; }
  .side.right .page-del { width: 30px; height: 30px; }
  .side.right .page-del svg { width: 18px; height: 18px; }
  .ch-intro-label { display: block; margin-top: 14px; }
  .ch-tools { display: flex; gap: 6px; margin: 6px 0; }
  .ch-tools .tool-btn { width: 32px; height: 32px; }
  .ch-tools .tool-btn svg { width: 18px; height: 18px; }
  .rich-box {
    width: 100%; min-height: 96px; max-height: 240px; overflow: auto;
    margin: 0 0 6px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 12px;
    font-size: 15px; line-height: 1.6;
    white-space: pre-wrap; overflow-wrap: anywhere;
    color: var(--ink);
  }
  .rich-box:focus-visible { outline: 3px solid #8fa0ff; outline-offset: 2px; }
  .ch-prof { list-style: none; margin: 0 0 8px; padding: 0; }
  .ch-prow { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
  .ch-prow .text-input { flex: 1; min-width: 0; font-size: 14px; }
  .ch-prow .ch-flabel { flex: none; width: 88px; }
  .ch-flabel-fixed { display: flex; align-items: center; gap: 4px; font-size: 14px; color: #222; }
  .ch-flabel-fixed svg { width: 13px; height: 13px; flex: none; color: var(--ink-soft); }
  .ch-prow .tool-btn { width: 28px; height: 28px; border-radius: 8px; }
  .ch-prow .tool-btn svg { width: 15px; height: 15px; }
  .ch-vthumb { position: relative; flex: none; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #f3f3f3; overflow: hidden; cursor: pointer; }
  .ch-vthumb img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
  .ch-vrow.current .ch-vthumb { border: 2px solid var(--ink); }
  .ch-vrow.current .text-input { border-color: var(--ink); }

  .palette-wide {
    width: 100%;
    height: 64px;
    border: 1px solid var(--line);
    border-radius: 32px;
    background: var(--white);
    font-family: inherit; font-size: 20px; letter-spacing: 0.1em;
    color: #222;
    cursor: pointer;
  }
  .palette-wide:hover { background: #f0f0f0; }
  .sub-h { margin: 20px 0 8px; font-size: 16px; font-weight: 700; color: #222; }
  #geoProps { margin-bottom: 26px; padding-bottom: 8px; border-bottom: 1px solid #e3e3e3; }
  #geoProps .sub-h:first-child { margin-top: 0; }
  #charProps .sub-h { margin-top: 30px; padding-top: 22px; border-top: 1px solid #e3e3e3; }
  #charProps > .file-btn, #charProps > .ch-prof + .file-btn, #charProps > .ch-rows + .file-btn { margin-bottom: 4px; }
  #charProps .ch-rows, #charProps .ch-prof { margin-bottom: 12px; }
  .ch-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
  .ch-item {
    max-width: 100%;
    padding: 6px 14px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--white);
    font: inherit; font-size: 15px; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ch-item[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
  .ta {
    width: 100%; margin: 4px 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 12px;
    font: inherit; font-size: 15px; line-height: 1.6;
    resize: vertical; color: var(--ink);
  }
  .ch-val-label { flex: none; width: 5.2em; font-size: 15px; color: #222; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pf-list { list-style: none; margin: 0 0 10px; padding: 0; }
  .pf-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
  .pf-fixed { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: #f3f3f3; font-size: 15px; color: #555; }
  .pf-fixed svg { width: 16px; height: 16px; flex: none; }
  .tool-btn:disabled { opacity: 0.35; cursor: default; }
  .pf-row .tool-btn { width: 36px; height: 36px; }

  /* ---------- カラーピッカー ---------- */
  button.pill-field { cursor: pointer; text-align: left; }
  .field-row[hidden], .tool-btn[hidden] { display: none; }
  .bg-thumb {
    flex: none;
    width: 22px; height: 22px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background-size: cover;
    background-position: center;
  }
  .bg-thumb.empty { border-style: dashed; background: #fafafa; }
  .bg-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .bg-box { position: relative; }
  .bg-box-btn {
    display: grid; place-items: center;
    width: 100%; height: 110px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background-color: var(--white);
    background-repeat: no-repeat;
    background-position: center;
    overflow: hidden;
    cursor: pointer;
  }
  .bg-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 14px; color: #999; }
  .bg-empty[hidden] { display: none; }
  .bg-empty svg { width: 32px; height: 32px; }
  .bg-clear {
    position: absolute; top: 8px; right: 8px;
    display: grid; place-items: center;
    width: 30px; height: 30px; padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--white);
    color: var(--ink);
  }
  .bg-clear[hidden] { display: none; }
  .bg-clear svg { width: 16px; height: 16px; }
  .bg-clear:hover { background: #f0f0f0; }
  .color-pop {
    position: fixed;
    z-index: 5;
    width: 264px;
    padding: 14px;
    border: 1px solid #dcdcdc;
    border-radius: 18px;
    background: var(--white);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  }
  .cp-sv {
    position: relative;
    height: 150px;
    border-radius: 12px;
    cursor: crosshair;
    touch-action: none;
  }
  .cp-sv:focus-visible { outline: 3px solid #8fa0ff; outline-offset: 2px; }
  .cp-handle {
    position: absolute;
    width: 18px; height: 18px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #777, 0 1px 4px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
  }
  .cp-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; }
  .cp-preview { flex: none; width: 30px; height: 30px; border: 1px solid #ccc; border-radius: 50%; }
  .cp-hue {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 12px; margin: 0;
    border-radius: 6px;
    background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
    cursor: pointer;
  }
  .cp-hue::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border: 2px solid #fff; border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1px #777, 0 1px 4px rgba(0, 0, 0, 0.4);
  }
  .cp-hue::-moz-range-thumb {
    width: 14px; height: 14px;
    border: 2px solid #fff; border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1px #777, 0 1px 4px rgba(0, 0, 0, 0.4);
  }
  .cp-hex {
    width: 100%; height: 42px;
    border: 0; border-radius: 12px;
    background: #f3f3f3;
    font: inherit; font-size: 17px; font-weight: 600;
    text-align: center;
    color: var(--ink);
  }
  .cp-eye {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; height: 40px; margin-top: 8px;
    border: 0; border-radius: 12px;
    background: #f3f3f3;
    font-size: 15px; font-weight: 600;
    color: var(--ink);
  }
  .cp-eye[hidden] { display: none; }
  .cp-eye svg { width: 20px; height: 20px; }
  .cp-eye:hover, .cp-hex:hover { background: #ebebeb; }
  .cp-used { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e2e2e2; }
  .cp-used p { margin: 0 0 8px; font-size: 14px; color: var(--ink-soft); }
  .cp-swatches { display: flex; gap: 10px; min-height: 32px; align-items: center; }
  .cp-sw { width: 32px; height: 32px; padding: 0; border: 1px solid #ccc; border-radius: 8px; cursor: pointer; }
  .cp-sw:hover { outline: 2px solid var(--accent); outline-offset: 2px; }
  .cp-none { font-size: 13px; color: #999; }

  /* ---------- 確認ダイアログ ---------- */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.4);
  }
  .modal-backdrop[hidden] { display: none; }
  .modal-x {
    position: absolute; top: 14px; right: 14px;
    display: grid; place-items: center;
    width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: 50%;
    background: transparent; color: var(--ink); cursor: pointer;
  }
  .modal-x:hover { background: #f0f0f0; }
  .modal-x svg { width: 22px; height: 22px; }
  .modal.shape-modal { position: relative; width: min(760px, 100%); min-height: 360px; }
  .shape-grid { display: grid; grid-template-columns: repeat(auto-fill, 64px); gap: 10px; padding-top: 28px; }
  .shape-opt { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--white); color: var(--ink); cursor: pointer; }
  .shape-opt:hover { background: #f0f0f0; }
  .shape-opt svg { width: 32px; height: 32px; overflow: visible; }
  #shapeProps { margin-bottom: 8px; }
  #shapeProps .sub-h { margin-top: 26px; padding-top: 22px; border-top: 1px solid #e3e3e3; }
  #shapeProps .side-h + .sub-h { margin-top: 18px; padding-top: 0; border-top: 0; }
  .modal {
    width: min(480px, 100%);
    padding: 32px 32px 24px;
    border: 2px solid var(--line);
    border-radius: 28px;
    background: var(--white);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }
  .modal p {
    margin: 0 0 28px;
    font-size: 20px;
    line-height: 1.7;
    text-align: center;
    color: var(--ink);
    overflow-wrap: anywhere;
  }
  .modal-actions { display: flex; gap: 16px; justify-content: center; }
  .modal-actions button {
    min-width: 140px;
    height: 52px;
    padding: 0 24px;
    border-radius: 999px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.12em;
  }
  .modal-no { border: 2px solid var(--ink); background: var(--white); color: var(--ink); }
  .modal-no:hover { background: #f0f0f0; }
  .modal-yes { border: 0; background: var(--ink); color: #fff; }
  .modal-yes:hover { background: #222; }
  .modal-yes.danger { background: #c93b3b; }
  .modal-yes.danger:hover { background: #a92e2e; }

  /* ---------- Toast ---------- */
  .toast {
    position: fixed;
    z-index: 1000000;
    left: 50%; bottom: 28px;
    transform: translate(-50%, 16px);
    padding: 12px 28px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 18px;
    letter-spacing: 0.08em;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }

  /* ---------- Smaller screens (editor topbar) ---------- */
  @media (max-width: 1280px) {
    .topbar { height: 58px; }
    .topbar-inner { height: 64px; padding: 0 14px; gap: 8px; }
    .icon-btn { width: 40px; height: 40px; border-radius: 10px; }
    .icon-btn svg { width: 22px; height: 22px; }
    .name-field { margin-left: 10px; }
    .name-field label { font-size: 17px; }
    .name-field input { font-size: 18px; }
    .spacer { min-width: 24px; }
    .undo-redo { gap: 8px; margin-right: 8px; }
    .preview-btn { height: 40px; padding: 0 18px; font-size: 17px; }
    .preview-btn svg { width: 20px; height: 20px; }
    .save-btn { height: 40px; padding: 0 20px; font-size: 17px; margin-left: 8px; gap: 6px; }
    .save-btn svg { width: 22px; height: 22px; }
    .export-btn { height: 40px; padding: 0 16px; font-size: 17px; margin-left: 6px; gap: 6px; }
    .export-btn svg { width: 20px; height: 20px; }
  }
  @media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; }
    .side { display: none; }
    .name-field label { display: none; }
    .name-field input { width: 28vw; }
  }
  @media (prefers-reduced-motion: reduce) {
    .toast { transition: none; }
  }
  /* ---------- 自由配置：選択枠・拡大縮小・回転・数値入力・レイヤー ---------- */
  .num-input {
    width: 84px; height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit; font-size: 17px;
    color: var(--ink);
  }
  .num-input:disabled { background: #f3f3f3; color: #999; }
  .sel-box {
    position: absolute; z-index: 99999; box-sizing: border-box;
    border: 1px solid #4aa3df;
    pointer-events: none;
  }
  .sb-h {
    position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
    box-sizing: border-box; border: 1px solid #fff; border-radius: 50%;
    background: #4aa3df; pointer-events: auto;
  }
  .sb-line { position: absolute; left: 50%; top: -24px; width: 1px; height: 24px; background: #4aa3df; }
  .sb-rot {
    position: absolute; left: 50%; top: -30px; width: 12px; height: 12px; margin: -6px 0 0 -6px;
    box-sizing: border-box; border: 1.5px solid #4aa3df; border-radius: 50%;
    background: #fff; cursor: grab; pointer-events: auto;
  }
  .el.selected.boxed { outline: none; }
  .align-row { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
  .align-row .tool-btn { width: 38px; height: 38px; }
  .align-row .tool-btn svg { width: 22px; height: 22px; }
  .align-sep { width: 1px; height: 26px; margin: 0 6px; background: var(--line); }
  .layer-empty { list-style: none; padding: 4px 2px; font-size: 14px; color: var(--ink-soft); }
  .layer-ic { display: inline-block; width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; color: var(--ink-soft); }
  .layer-ic svg { display: block; width: 16px; height: 16px; }
  .page-row.current .layer-ic { color: inherit; }

/* CHARARY_CHARACTER_CSS_START */
.cl{position:relative;isolation:isolate;color:#333;font-size:15px;line-height:1.5;white-space:normal}
.cl-nm{padding:0 4px 8px;border-bottom:2px solid currentColor;font-size:34px;font-weight:700;line-height:1.3;font-family:inherit}
.cl-nm .cl-nodata{font-size:.6em}
.cl-stack{display:grid}
.cl-stack>*{grid-area:1/1;opacity:0;pointer-events:none;transition:opacity .5s ease-in-out}
.cl-stack>.is-on{opacity:1;pointer-events:auto}
.cl-stage{position:relative;width:68%;aspect-ratio:1/1;margin:30% auto 0}
.cl-frame{position:absolute;left:0;right:0;top:-16%;height:100%;z-index:0;box-sizing:border-box}
.cl-f-double{border:3px solid #fff}
.cl-f-double::after{content:"";position:absolute;inset:5%;border:3px solid #fff;background:rgba(255,255,255,.5)}
.cl-f-y2k{top:-22%;height:112%;border:3px solid #fff;border-radius:50% 50% 0 0 / 46% 46% 0 0}
.cl-f-y2k::after{content:"";position:absolute;inset:5%;border:3px solid #fff;border-radius:50% 50% 0 0 / 44% 44% 0 0;background:rgba(255,255,255,.5)}
.cl-f-circle{border:3px solid #fff;background:rgba(255,255,255,.5)}
.cl-f-image{left:calc(-23.5294% - 40px);right:calc(-23.5294% - 40px);top:40%;height:auto;aspect-ratio:1/1;transform:translateY(-50%) scale(.9);background-size:contain;background-repeat:no-repeat;background-position:center}
.cl-f-circle{border-radius:50%}
.cl-viewport{position:absolute;left:calc(-23.5294% - 40px);right:calc(-23.5294% - 40px);top:40%;aspect-ratio:1/1;transform:translateY(-50%);z-index:1;overflow:hidden;pointer-events:none}
.cl-track{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;transition:transform .95s cubic-bezier(.45,0,.15,1)} /* 出だしも終わりもなめらか（ぬるっと切り替える） */
.cl-slide{position:relative;flex:none;width:100%;height:100%}
.cl-slide img{position:absolute;left:0;top:0;width:100%;height:100%;max-width:none;object-fit:contain;object-position:center;-webkit-user-drag:none;user-select:none}
.cl-noimg{position:absolute;left:50%;top:50%;height:60%;width:auto;transform:translate(-50%,-50%);color:rgba(0,0,0,.16)}
.cl-v{position:absolute;left:0;top:0;width:100%;height:100%;opacity:0;transition:opacity .35s ease}
.cl-v.is-on{opacity:1}
.cl-chs{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;width:90%;margin:14px auto 0;padding-bottom:24px}
.cl-ci{position:relative;flex:none;box-sizing:border-box;width:calc((100% - 24px) / 5 - .5px);aspect-ratio:155/112;padding:0;border:0;border-radius:12px;background:#fff;color:inherit;overflow:hidden;cursor:pointer}
.cl-ci:not(.is-on) img,.cl-ci:not(.is-on) .cl-noimg{opacity:.55}
.cl-ci:not(.is-on):hover img{opacity:.85}
.cl-ci-slant{transform:skewX(-22deg);border-radius:10px}
.cl-cin{position:absolute;left:-14.6%;top:0;width:129.2%;height:100%;transform:skewX(22deg)} /* ななめ枠の外接の幅まで広げ、枠の左右の端まで画像で埋める */
.cl-chs[data-shape="circle"]{gap:10px}
.cl-ci-circle{width:88px;aspect-ratio:1/1;border-radius:50%}
.cl-shift{position:absolute;left:0;top:0;width:100%;height:100%;z-index:1;transition:transform .45s ease}
.cl-vstack{position:absolute;top:40%;right:calc(-16.1765% - 38px);transform:translateY(-50%);z-index:3}
.cl-vw{display:flex;flex-direction:column;align-items:center;justify-content:center}
.cl-vs{display:flex;flex-direction:column;align-items:center;gap:15px}
.cl-vi{position:relative;flex:none;box-sizing:border-box;width:88px;height:88px;padding:0;border:2px solid currentColor;border-radius:18px;background:#fff;color:inherit;overflow:hidden;cursor:pointer;transition:border-color .2s ease}
.cl-vi-circle{border-radius:50%}
.cl-vi:not(.is-on){border-color:transparent}
.cl-ci img,.cl-vi img{position:absolute;left:0;top:0;width:100%;height:100%;max-width:none;object-fit:cover;object-position:50% 0;transform:scale(1.9);transform-origin:50% 5%;-webkit-user-drag:none;user-select:none;pointer-events:none}
.cl-ci .cl-noimg,.cl-vi .cl-noimg{height:70%}
.cl-info{position:relative;z-index:2;width:84%;margin:10px auto 0;padding:12px 14px 14px;background:var(--cl-panel,rgba(255,255,255,.62));font-size:17px;font-family:var(--cl-prof-font,inherit);color:#333}
.cl-prof{display:grid;grid-auto-flow:column;grid-template-columns:1fr 1fr;gap:4px 16px;margin:0;padding:10px 0}
.cl-prof>div{display:flex;gap:6px;min-width:0}
.cl-prof dt{font-weight:700;white-space:nowrap}
.cl-prof dt::after{content:" :"}
.cl-prof dd{min-width:0;margin:0;overflow-wrap:anywhere}
.cl-intro{padding-top:10px;border-top:2px solid currentColor;white-space:pre-wrap;overflow-wrap:anywhere}
.cl-nodata{font-weight:400;opacity:.45}
.cl-cards .cc-row{display:flex;gap:10px;height:380px}
.cl-cards[data-open="1"] .cc-row{display:none}
.cc-s{position:relative;flex:1 1 0;min-width:0;box-sizing:border-box;padding:0;border:0;border-radius:0;background:#fff;overflow:hidden;cursor:pointer;transition:opacity .2s ease}
.cl-cards[data-cbg="black"] .cc-s{background:#000}
.cl-cards[data-cbg="black"] .cc-s img{filter:grayscale(1) contrast(.5) brightness(1.3) drop-shadow(0 0 1px #fff) drop-shadow(0 0 3px rgba(255,255,255,.6))}
.cl-cards[data-cbg="black"] .cc-s .cl-noimg{color:rgba(255,255,255,.3)}
.cc-s:hover{opacity:.85}
.cc-s img{position:absolute;left:0;top:0;width:100%;height:100%;max-width:none;object-fit:cover;object-position:50% 0;transform:scale(1.35);transform-origin:50% 0;filter:grayscale(1);-webkit-user-drag:none;user-select:none;pointer-events:none}
.cc-s .cl-noimg{height:55%;filter:grayscale(1)}
.cc-card{display:none;position:relative;box-sizing:border-box;padding:14px;background:var(--cc-bg,#ffd9d9)}
.cl-cards[data-open="1"] .cc-card{display:block}
.cl-cards.cc-run .cc-card{position:absolute;left:0;right:0;top:0}
.cl-cards.cc-run[data-open="1"] .cc-row{display:flex}
.cc-x{position:absolute;left:14px;top:14px;z-index:4;display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border:2px solid #666;background:#f4f4f4;color:#333;cursor:pointer}
.cc-x:hover{background:#e6e6e6}
.cc-x svg{width:18px;height:18px}
.cc-pic{position:relative;height:560px}
.cc-pic .cl-slide{position:absolute;left:0;top:0;opacity:0;pointer-events:none;transition:opacity .35s ease,transform .45s ease}
.cc-pic .cl-slide.is-on{opacity:1}
.cl-cards .cl-vstack{top:50%;right:4px}
.cl-cards .cl-info{width:auto;margin:-64px 0 0;padding:0;background:none}
.cl-cards .cl-nm{width:fit-content;min-width:55%;max-width:100%;box-sizing:border-box;margin-bottom:12px;padding:8px 14px;border-bottom:0;background:var(--cl-panel)}
.cl-cards .cl-pbox{padding:12px 14px 14px;background:var(--cl-panel)}
.cl-ci img.cl-own,.cc-s img.cl-own{transform:none;object-position:50% 50%}
.cl-ci-slant img{transform:scale(1.4)}
/* CHARARY_CHARACTER_CSS_END */
