/* CHOCO 作成画面のモック（操作部分は HTML、キャラは SVG）
 * ボタンはキャラの上に浮かせて、行を取らない。スマホのパーツは下から出るシート（つまみで広げる） */
:root {
  --accent: #ff6f96;
  --accent-2: #ff9a6b;
  --accent-mid: #ff8582;   /* グラデーションの真ん中（線の絵の「帯の色」に使う） */
  --accent-soft: #ffe9ef;
  --ink: #2b2530;
  --sub: #8c8390;
  --line: rgba(43, 37, 48, .08);
  --tile: #f6f1f4;
  --glass: rgba(255, 255, 255, .72);
  --glass-line: rgba(255, 255, 255, .9);
  --shadow-sm: 0 6px 20px -8px rgba(90, 40, 70, .3);
  --shadow-lg: 0 30px 70px -30px rgba(110, 50, 80, .38);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: "Hiragino Maru Gothic ProN", "M PLUS Rounded 1c", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}
/* 名前とコピーライトの書体（本物の CHOCO と同じ Makinas-Scrap-5） */
@font-face { font-family: "Makinas5"; src: url("/common/font/Makinas-Scrap-5.woff") format("woff"), url("/common/font/Makinas-Scrap-5.otf") format("opentype"); font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  background:
    radial-gradient(900px 520px at 8% -8%, #ffdbe6 0%, transparent 62%),
    radial-gradient(760px 520px at 62% 4%, #e8e4ff 0%, transparent 58%),
    radial-gradient(820px 620px at 30% 112%, #ffeedd 0%, transparent 62%),
    #fbf7f9;
}
button { font: inherit; color: inherit; -webkit-user-select: none; user-select: none; }
button:focus-visible { outline: 3px solid rgba(255, 111, 150, .55); outline-offset: 2px; }
svg { display: block; }
.ico, .glass svg, .cta svg, .brand svg, .tool svg, .pad svg, .grad-swap svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.glass svg .dot { fill: currentColor; stroke: none; }

.app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) clamp(380px, 36vw, 520px); }
/* ページの枠（PC だけ。本物の CHOCO と同じく共通のヘッダー（高さ 50px・上に固定）・おすすめ・フッター。index.php の $hasFrame）。
   作る画面はヘッダーの下の高さいっぱいに、おすすめ・フッターはその下（ページをスクロールして見る） */
html.has-frame, html.has-frame body { height: auto; overflow: visible; }
/* 高さ: 画面が高ければ、おすすめ・フッター（--page-below、app.js の fitPageFrame が測る）まで画面に収める。
   ただし作る画面は FRAME_MIN（720px）より低くしない（その間はフッターの一部が下にはみ出す）。画面がそれより低ければ今までどおり画面いっぱい */
/* var() を含む行は、dvh が使えないブラウザでは「あとで無効」になって前の行（vh）まで消すので、@supports で分ける */
html.has-frame .app { height: min(calc(100vh - 50px), max(720px, calc(100vh - 50px - var(--page-below, 300px)))); margin-top: 50px; }
@supports (height: 1dvh) { html.has-frame .app { height: min(calc(100dvh - 50px), max(720px, calc(100dvh - 50px - var(--page-below, 300px)))); } }
/* パーツ・カテゴリの一覧を端までスクロールしても、ページごと動かない（フッターへは一覧の外でスクロール） */
html.has-frame .parts, html.has-frame .cats { overscroll-behavior: contain; }
/* 共通のヘッダー（z-index 9999）・予告の帯（9998）は、ダイアログ・完成画面・使い方・読み込み中の画面の下に */
html.has-frame .charat-header { z-index: 15 !important; }
html.has-frame .charat-notice { z-index: 14 !important; }

/* ---- キャラ ---- */
.stage-area { position: relative; min-width: 0; min-height: 0; container-type: size; display: flex; align-items: center; justify-content: center; padding: 84px 32px 32px; }
.stage-box { position: relative; width: min(100cqw, 100cqh); aspect-ratio: 1; flex: none; }
.stage { position: absolute; inset: 0; border-radius: 34px; overflow: hidden; background: #fff; box-shadow: var(--shadow-lg), 0 2px 6px rgba(120, 50, 90, .05); }
.stage svg { width: 100%; height: 100%; }
/* 表示の拡大（transform は setViewTo が付ける。動きの transition は付けない。左上を基準に拡大して、見せたい範囲を左上へ寄せる） */
.view { position: absolute; inset: 0; transform-origin: 0 0; }
/* 指やホイールで動かしている間だけ合成レイヤーにして GPU に拡大縮小させる（終わったら外して、その倍率でくっきり描き直す） */
.view.gesturing { will-change: transform; }
/* キャラの上のピンチ・ドラッグはページではなくキャラの表示に使う */
.stage { touch-action: none; }
.stage.zoomed { cursor: grab; }
.stage.panning { cursor: grabbing; }
.stage.pop svg { animation: pop .28s var(--ease); }
@keyframes pop { 40% { transform: scale(1.014); } }
/* 移動中: キャラの上をドラッグで動かせる */
.stage.moving { touch-action: none; }
/* 選んでいるパーツの枠（app.js の updateBox）。移動中は枠の中をドラッグ、四隅のつまみで大きさ。押して選んだときは少し出して消える */
.part-box { position: absolute; z-index: 7; border: 2px dashed rgba(255, 111, 150, .9); border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .8), inset 0 0 0 1px rgba(255, 255, 255, .8); pointer-events: none; }
.part-box[hidden] { display: none; }
.part-box.flash { animation: box-flash .9s ease forwards; }
@keyframes box-flash { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
.part-box .h { position: absolute; display: none; width: 18px; height: 18px; margin: -9px; border: 2px solid var(--accent); border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); pointer-events: auto; touch-action: none; }
.part-box .h::before { content: ""; position: absolute; inset: -12px; } /* 指でもつかめる広さ */
.part-box.scalable .h:not(.rot), .part-box.rotatable .rot { display: block; }
/* 回すつまみ: 枠の上のまん中（上に余白が無ければ枠の中）。回している間は角度を出す */
.part-box .rot { left: 50%; top: -26px; cursor: grab; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12a7 7 0 1 1-2.1-5M19 4v4h-4'/%3E%3C/svg%3E") center / 12px no-repeat; border-color: #fff; }
.part-box .rot::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 9px; margin-left: -1px; background: var(--accent); }
.part-box.rot-in .rot { top: 12px; }
.part-box.rot-in .rot::after { display: none; }
.part-box.rotating .rot { cursor: grabbing; }
.part-box.rotating::after { content: attr(data-angle); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 3px 9px; border-radius: 99px; background: rgba(43, 37, 48, .82); color: #fff; font-size: 12px; font-weight: 800; }
.part-box .tl { left: 0; top: 0; cursor: nwse-resize; }
.part-box .tr { left: 100%; top: 0; cursor: nesw-resize; }
.part-box .bl { left: 0; top: 100%; cursor: nesw-resize; }
.part-box .br { left: 100%; top: 100%; cursor: nwse-resize; }
@media (prefers-reduced-motion: reduce) { .part-box.flash { animation-duration: 1.2s; } }
.stage.dragging { cursor: grabbing; }
/* 拡大しているときだけ出す「全身」 */
.view-btn {
  position: absolute; left: 14px; top: 14px; z-index: 3; height: 40px; padding: 0 15px 0 11px; border: 0; border-radius: 99px; display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; box-shadow: var(--shadow-sm); font-size: 13px; font-weight: 800; cursor: pointer; transition: transform .12s var(--ease);
  animation: rise .2s var(--ease);
}
.view-btn[hidden] { display: none; }
.view-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.view-btn:active { transform: scale(.94); }
/* 元に戻す・やり直す（左下。移動中は十字キーの右へ） */
.history { position: absolute; left: 14px; bottom: 14px; z-index: 3; display: flex; gap: 2px; padding: 4px; border-radius: 99px; background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow-sm); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.history .hist { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; transition: transform .12s var(--ease), background .15s; }
.history .hist:hover:not(:disabled) { background: #fff; }
.history .hist:active:not(:disabled) { transform: scale(.92); }
.history .hist:disabled { color: rgba(43, 37, 48, .22); cursor: default; }
.history svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.stage.moving ~ .history { left: calc(14px + 132px + 12px); }
/* 名前: 画像の名前の位置（上から 93〜97%）に重ねる。拡大中・移動中は出さない */
.name-chip {
  position: absolute; left: 50%; top: 95.1%; z-index: 2; transform: translate(-50%, -50%); min-height: 28px; height: 5.4%; padding: 0 13px;
  display: inline-flex; align-items: center; justify-content: center; border: 1.5px dashed rgba(43, 37, 48, .28); border-radius: 99px;
  background: rgba(255, 255, 255, .78); color: var(--sub); font-size: 12px; font-weight: 800; white-space: nowrap; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.name-chip:hover { border-color: var(--accent); color: var(--accent); }
.name-chip.has-name { padding: 0; border-color: transparent; background: transparent; border-radius: 10px; }
.name-chip.has-name span { display: none; }
.name-chip.has-name:hover { border-color: rgba(255, 111, 150, .7); background: rgba(255, 111, 150, .06); }
.stage.zoomed ~ .name-chip, .stage.moving ~ .name-chip { display: none; }

/* すりガラスのボタン */
.glass, .brand, .pad {
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--ink);
  -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .12s var(--ease), background .15s;
}
.glass:hover, .brand:hover, .pad:hover { background: rgba(255, 255, 255, .92); }
.glass:active, .brand:active, .pad:active, .cta:active, .tool:active, .part:active, .cat:active, .sw:active { transform: scale(.94); }

.float { position: absolute; top: 18px; z-index: 6; display: flex; align-items: center; gap: 8px; }
.float.tl { left: 20px; }
.float.tr { right: 20px; }
.glass { height: 46px; min-width: 46px; padding: 0 16px 0 13px; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 14px; font-weight: 700; }
.glass svg { width: 21px; height: 21px; }
.cta {
  height: 46px; padding: 0 20px 0 15px; border: 0; border-radius: 99px; display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .04em;
  box-shadow: 0 10px 24px -10px rgba(255, 90, 130, .9), inset 0 1px 0 rgba(255, 255, 255, .35); cursor: pointer;
  transition: transform .12s var(--ease), filter .15s;
}
.cta:hover { filter: brightness(1.05) saturate(1.1); }
/* ランダム: サイコロ（実行）と ▾（設定）を1つのすりガラスに */
.glass.split { padding: 0; gap: 0; }
.split-main, .split-more { height: 100%; border: 0; background: transparent; display: inline-flex; align-items: center; gap: 7px; font-weight: 700; cursor: pointer; transition: background .15s; }
.split-main { padding: 0 10px 0 13px; border-radius: 99px 0 0 99px; }
.split-more { position: relative; padding: 0 10px 0 6px; border-left: 1px solid var(--line); border-radius: 0 99px 99px 0; }
.split-main:hover, .split-more:hover { background: rgba(255, 255, 255, .7); }
.glass .split-more svg { width: 16px; height: 16px; color: var(--sub); }
.split-badge { position: absolute; top: -5px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--ink); color: #fff; font: 800 10px/18px var(--font); font-style: normal; text-align: center; box-shadow: 0 0 0 2px #fff; }
.split-badge[hidden] { display: none; }
.cta svg { width: 22px; height: 22px; }

/* 左上のロゴ（モックの確認用メニュー） */
.brand { height: 46px; padding: 0 10px 0 16px; border-radius: 99px; display: inline-flex; align-items: center; gap: 8px; }
.brand svg { width: 18px; height: 18px; color: var(--sub); }
.brand-logo { display: block; height: 17px; width: auto; }
/* ロゴのメニュー: TOP・使い方・言語・お問い合わせ・SNS（下にモックの確認用をたたんで） */
.menu .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 12px; background: none; color: var(--ink); font-size: 14px; font-weight: 700; text-decoration: none; text-align: left; cursor: pointer; }
.menu .menu-item:hover { background: var(--tile); }
.menu .menu-item > svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--sub); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-lang select { margin-left: auto; min-width: 0; max-width: 10em; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; }
.menu-sns { display: flex; gap: 6px; padding: 6px 10px 8px; }
.menu-sns a { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--tile); color: var(--ink); }
.menu-sns a:hover { background: #efe7eb; }
.menu-sns svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.menu-sns svg .fill, .menu-sns svg .dot { fill: currentColor; stroke: none; }
.menu { position: absolute; top: calc(100% + 8px); left: 0; width: 270px; padding: 8px; border-radius: 20px; background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid var(--glass-line); box-shadow: var(--shadow-lg); animation: rise .2s var(--ease); }
.menu[hidden] { display: none; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.menu button:hover { background: var(--tile); }

/* 選んだカテゴリの調整: キャラの右下に縦に並べる（使えるものだけ。上は右上のボタンが来るので空けておく） */
.rail {
  position: absolute; right: 12px; bottom: 14px; z-index: 3;
  display: flex; flex-direction: column; gap: 2px; padding: 5px; border-radius: 28px;
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); box-shadow: var(--shadow-sm);
}
.rail[hidden], .tool[hidden] { display: none; }
.tool { width: 50px; height: 50px; padding: 0; border: 0; border-radius: 22px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; transition: transform .12s var(--ease), background .15s, opacity .15s; }
.tool svg { width: 22px; height: 22px; }
.tool span { font-size: 10px; font-weight: 800; color: var(--sub); line-height: 1; }
.tool:hover { background: rgba(43, 37, 48, .06); }
.tool.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.tool.on span { color: #fff; }
.tool.idle { opacity: .38; }
.tool { position: relative; }
.tool svg .fill { fill: currentColor; stroke: none; }
.tool.set::after { content: ''; position: absolute; top: 7px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.tool.on.set::after { background: #fff; }

/* うすさのつまみ（調整の列の左） */
.opa {
  position: absolute; z-index: 4; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
}
.opa[hidden] { display: none; }
.opa input { width: 150px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.opa-end { font-size: 11px; font-weight: 800; color: var(--sub); white-space: nowrap; }
.opa output { min-width: 3.2em; font-size: 12px; font-weight: 800; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

/* 移動の十字キー */
.dpad { position: absolute; left: 14px; bottom: 14px; z-index: 3; display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(3, 42px); gap: 3px; }
.dpad[hidden] { display: none; }
.pad { width: 42px; height: 42px; padding: 0; border-radius: 50%; display: grid; place-items: center; touch-action: none; }
.pad svg { width: 22px; height: 22px; stroke-width: 2.4; }
.pad.up { grid-area: 1 / 2; } .pad.left { grid-area: 2 / 1; } .pad.done { grid-area: 2 / 2; } .pad.right { grid-area: 2 / 3; } .pad.down { grid-area: 3 / 2; }
.pad.done { background: var(--ink); color: #fff; border-color: var(--ink); }
.dpad.vertical .pad.left, .dpad.vertical .pad.right { visibility: hidden; }
.dpad-hint { position: absolute; left: 0; bottom: calc(100% + 8px); margin: 0; white-space: nowrap; padding: 5px 11px; border-radius: 99px; background: rgba(43, 37, 48, .82); color: #fff; font-size: 11px; font-weight: 700; pointer-events: none; animation: hint 3.2s forwards; }
@keyframes hint { 0%, 82% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* お知らせ（「元に戻す」付き） */
.toast {
  position: absolute; left: 50%; bottom: 22px; z-index: 8; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 24px);
  padding: 6px 6px 6px 18px; border-radius: 99px; background: rgba(43, 37, 48, .92); color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 14px 30px -12px rgba(40, 20, 30, .6); transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast span { overflow: hidden; text-overflow: ellipsis; padding: 6px 4px 6px 0; }
.toast button { flex: none; border: 0; border-radius: 99px; padding: 7px 14px; background: rgba(255, 255, 255, .14); color: #ffb3c6; font-weight: 800; font-size: 13px; cursor: pointer; }
.toast button:hover { background: rgba(255, 255, 255, .22); }
.toast button[hidden] { display: none; }

/* ---- パーツ（PC は右に浮かせたカード: 左にカテゴリの縦の列） ---- */
.panel {
  min-height: 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); margin: 14px 14px 14px 0; border-radius: 30px; overflow: hidden;
  background: rgba(255, 255, 255, .9); border: 1px solid var(--glass-line); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); box-shadow: var(--shadow-lg);
}
.grip { display: none; }
.cats { position: relative; min-height: 0; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
/* カテゴリの絵は暗い帯用の白い線。白 → 文字の色（currentColor）、黒（帯の色だったところ）→ --icon-bg に置き換えて使う */
.cat {
  --icon-bg: #fff; position: relative; z-index: 1; flex: none; width: 100%; border: 0; border-radius: 20px; padding: 7px 2px 7px; background: transparent; color: rgba(43, 37, 48, .8);
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; transition: background .18s, color .18s, transform .12s var(--ease);
}
.cat svg { width: 46px; height: 46px; fill: var(--icon-bg); }
.cat-label { max-width: 100%; padding: 0 3px; font-size: 10.5px; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat:not(.sel):hover { background: var(--tile); --icon-bg: var(--tile); }
/* 選んだカテゴリ: 後ろの印（.cat-ind）がすべって来るので、ボタン自体は透明。白くなるのは印が来るのに合わせて少し遅らせる */
.cat.sel { color: #fff; --icon-bg: var(--accent-mid); transition: background .18s, color .2s .1s, transform .12s var(--ease); }
.cat.sel svg { animation: icon-pop .5s var(--ease); }
@keyframes icon-pop { 30% { transform: scale(1.18) rotate(-7deg); } 62% { transform: scale(.97) rotate(3deg); } }
.cat-ind {
  position: absolute; left: 0; top: 0; z-index: 0; border-radius: 20px; pointer-events: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 20px -10px rgba(255, 90, 130, .8);
  transition: transform .3s var(--ease), width .3s var(--ease), height .3s var(--ease);
}
.cat-ind.instant { transition: none; }
/* ランダムで変えないカテゴリ（鍵の印） */
.cat.locked::after { content: ""; position: absolute; top: 3px; right: 8px; z-index: 2; width: 18px; height: 18px; border-radius: 50%; background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='2.5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5'/%3E%3C/svg%3E") center / 11px no-repeat; box-shadow: 0 0 0 2px #fff; pointer-events: none; }

.editor { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.editor-head { display: flex; align-items: center; gap: 10px; padding: 20px 20px 8px; }
.cat-name { font-size: 21px; font-weight: 900; letter-spacing: .02em; }
.lock-btn { margin-left: auto; height: 32px; padding: 0 13px 0 10px; border: 0; border-radius: 99px; background: var(--tile); color: var(--sub); display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; cursor: pointer; transition: background .15s, color .15s, transform .12s var(--ease); }
.lock-btn:hover { color: var(--ink); }
.lock-btn:active { transform: scale(.94); }
.lock-btn[hidden] { display: none; }
.lock-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lock-btn .sh-closed, .lock-btn.on .sh-open { display: none; }
.lock-btn.on .sh-closed { display: inline; }
.lock-btn.on { background: var(--ink); color: #fff; }
.cat-count { font-size: 11px; font-weight: 800; color: var(--sub); background: var(--tile); padding: 4px 10px; border-radius: 99px; }

/* 段の出し入れ（高さ 0 ↔ 中身の高さを動かす） */
.fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .26s var(--ease); }
.fold.open { grid-template-rows: 1fr; }
.fold-in { min-height: 0; overflow: hidden; }

/* グラデーション: 横長のバーに「上」「下」のつまみ（押して選ぶ・動かして混ざり方を変える） */
.grad { padding: 6px 20px 6px; }
.grad-swap { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--tile); display: grid; place-items: center; cursor: pointer; }
.grad-swap svg { width: 19px; height: 19px; }
.grad-hint { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--sub); }

.colors { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 20px 14px; max-height: 152px; overflow-y: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.colors:empty { display: none; }
/* 左右の色（め）: どこに色を付けるか。丸はそれぞれの今の色 */
.lr { flex: none; display: inline-flex; gap: 2px; padding: 3px; border-radius: 99px; background: var(--tile); }
.lr button { height: 24px; padding: 0 10px 0 7px; border: 0; border-radius: 99px; background: transparent; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; color: var(--sub); cursor: pointer; transition: background .15s, color .15s; }
.lr button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
/* 置き場所の切りかえ（1つ目・2つ目 / 左手・右手）。丸はパーツが入っているか */
.layer-pick { display: flex; align-items: center; gap: 8px; padding: 0 20px 8px; }
.layer-pick[hidden] { display: none; }
.layer-pick .lr i { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.layer-pick .lr i.has { background: var(--accent); box-shadow: none; }
.layer-swap { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 11px 0 8px; border: 0; border-radius: 99px; background: var(--tile); color: var(--sub); font-size: 12px; font-weight: 800; cursor: pointer; }
.layer-swap:hover:not(:disabled) { color: var(--ink); }
.layer-swap:disabled { opacity: .45; cursor: default; }
.layer-swap svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lr i { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.sw { flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); cursor: pointer; transition: transform .12s var(--ease); }
.sw:hover { transform: scale(1.1); }
.sw.sel { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1), 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
/* 色の段の先頭（app.js の buildColors）: 色の設定のボタン（今のパレットの名前・連動の数）と自由な色 */
.pal-chip { flex: none; align-self: center; display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px 0 8px; border: 0; border-radius: 99px; background: var(--tile); color: var(--ink); font-size: 12px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.pal-chip:hover { background: #efe7eb; }
.pal-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pal-chip svg .dot { fill: currentColor; stroke: none; }
.pal-chip .caret { width: 14px; height: 14px; color: var(--sub); }
.ptn-swap.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.pal-link { display: inline-flex; align-items: center; gap: 1px; margin-left: 2px; padding: 0 5px 0 3px; height: 18px; border-radius: 99px; background: var(--ink); color: #fff; font-style: normal; font-size: 10.5px; }
.pal-link svg { width: 12px; height: 12px; }
.pal-empty { align-self: center; font-size: 12px; font-weight: 700; color: var(--sub); }
.sw.custom { position: relative; overflow: hidden; background: conic-gradient(#ff5d5d, #ffd25d, #8ef06b, #5de0ff, #7a6bff, #ff6bd8, #ff5d5d); }
.sw.custom::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); pointer-events: none; }
/* 自由な色（自前の色選び。app.js の openColorPicker）: 上の四角であざやかさ・明るさ、下の帯で色合い、色の番号 */
.cpick { width: min(340px, 100%); margin: 0 auto; }
.cpick h2 { margin: 0 0 12px; }
.cpick-sv { position: relative; height: 190px; border-radius: 16px; background-image: linear-gradient(to top, #000, rgba(0, 0, 0, 0)), linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); touch-action: none; cursor: crosshair; }
.cpick-dot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .3); pointer-events: none; }
.cpick-hue { position: relative; height: 30px; margin: 18px 6px 0; border-radius: 99px; background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); touch-action: none; cursor: pointer; }
.cpick-knob { position: absolute; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .3); pointer-events: none; }
.cpick-sv:focus-visible, .cpick-hue:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cpick-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.cpick-prev { flex: none; width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.cpick-hex { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cpick-hex:focus { outline: none; border-color: var(--accent); }
/* PC はキャラが見えるよう右に寄せる（スマホは下から出る） */
@media (min-width: 761px) and (min-aspect-ratio: 4/5) { .modal.picker { justify-items: end; padding-right: 40px; } .modal.picker .sheet { width: min(400px, 100%); } }
/* 色の設定のダイアログ: パレットの選びかた（見本の丸つき） */
.pal-options { display: grid; gap: 6px; margin-top: 8px; }
.pal-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 14px; background: var(--tile); color: var(--ink); text-align: left; cursor: pointer; }
.pal-opt.on { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
.pal-name { flex: none; min-width: 7em; font-size: 13px; font-weight: 800; }
.pal-dots { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; font-size: 11.5px; font-weight: 700; color: var(--sub); }
/* 連動の一覧: 選んでいる印は鍵ではなくチェック（.lock-cat の形を借りている） */
.colorset .lock-cat.on { --icon-bg: var(--accent-soft); background: var(--accent-soft); color: var(--ink); }
.colorset .lock-cat.on::after { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4 9-9'/%3E%3C/svg%3E") center / 11px no-repeat; }
.pal-dots i { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
/* 柄の一覧（app.js の buildPatterns）。「色・柄」の切りかえは左右の色と同じ形（丸の印なし） */
.ctabs button { padding: 0 11px; }
.sw.ptn { background-color: #fff; background-size: cover; background-position: center; }
.ptn-wait { align-self: center; font-size: 12px; font-weight: 700; color: var(--sub); }
.sw.reset { position: relative; background: conic-gradient(from 45deg, #fff 0 25%, #e6e0e3 0 50%, #fff 0 75%, #e6e0e3 0); }
.sw.reset::after { content: ""; position: absolute; inset: 13.5px 4px; background: var(--accent); transform: rotate(-45deg); border-radius: 2px; }

.parts { --slide-x: 0px; --slide-y: 22px; flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 20px; scrollbar-width: thin; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; align-content: start; }
/* 一覧が入ってくる動き。PC はカテゴリが縦の列なので縦に、スマホは横の帯なので横に（--dir: 後ろのカテゴリなら 1、前なら -1） */
.grid.enter { animation: grid-in .28s var(--ease) both; }
@keyframes grid-in { from { opacity: 0; transform: translate(calc(var(--dir, 0) * var(--slide-x)), calc(var(--dir, 0) * var(--slide-y))); } }
/* 正方形は幅 100% の下余白で作る（グリッドの中の button では aspect-ratio が段の高さに効かず、段が重なった） */
.part { position: relative; height: 0; padding: 0 0 100%; border: 0; border-radius: 22px; background: var(--tile); cursor: pointer; overflow: hidden; transition: transform .12s var(--ease), background .15s, box-shadow .15s; }
.part svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.part:hover { background: #fff; box-shadow: var(--shadow-sm); }
.part.sel { background: #fff; }
.part.sel::before { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; box-shadow: inset 0 0 0 3px var(--accent); pointer-events: none; }
.part.sel::after { content: ""; position: absolute; top: 7px; right: 7px; z-index: 2; width: 20px; height: 20px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 12.5l4 4 9-9'/%3E%3C/svg%3E") center / 13px no-repeat; box-shadow: 0 2px 6px rgba(255, 90, 130, .5); }
/* 重ね付け: もう一方の置き場所に入っているパーツ（印は 1・2・左・右。選んでいるパーツの印のほうが前） */
.part.other::before { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; box-shadow: inset 0 0 0 2px rgba(43, 37, 48, .28); pointer-events: none; }
.part.other:not(.sel)::after { content: attr(data-mark); position: absolute; top: 7px; right: 7px; z-index: 2; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 900; line-height: 20px; text-align: center; }
/* 中身の無いパーツ（押すと外す）: 「なし」 */
.part .none-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 800; color: var(--sub); }
.part .no { position: absolute; left: 9px; bottom: 6px; z-index: 1; font-size: 9.5px; font-weight: 700; color: rgba(43, 37, 48, .32); font-variant-numeric: tabular-nums; }
.part .label { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 14px 6px 6px; font-size: 10px; font-weight: 800; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(transparent, rgba(255, 255, 255, .95) 45%); }

/* ---- ダイアログ ---- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(43, 37, 48, .32); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s; }
.modal[hidden] { display: none; }
/* 後ろのキャラを見ながら変えるダイアログ（名前など） */
.modal.light { background: rgba(43, 37, 48, .14); -webkit-backdrop-filter: none; backdrop-filter: none; }
/* 1手順だけの照らし（同意のあとの「使い方はここから」）: 何手順目か・点・スキップは出さない */
.tour.single .tour-step, .tour.single .tour-dots, .tour.single #tourSkip { display: none; }
.tour.single .tour-foot { justify-content: flex-end; }
/* はじめて開いたとき（利用ガイドライン・利用規約への同意） */
.modal.first { z-index: 30; }
.first-sheet { width: min(440px, 100%); text-align: center; }
.first-sheet .sheet-body { padding: 26px 24px 8px; }
.first-logo { display: block; width: 150px; height: auto; margin: 2px auto 16px; }
.first-logo path { fill: #6b4330 !important; } /* ロゴの SVG は白（読み込み画面ではチョコ色の上）なので、ここではチョコ色に */
.first-sheet h2 { font-size: 18px; }
.first-terms { padding: 12px 14px; border-radius: 14px; background: var(--tile); font-size: 13px !important; }
.first-terms a { color: var(--accent); font-weight: 800; }
.first-foot { flex-direction: column-reverse; align-items: stretch; gap: 8px; padding: 12px 24px 22px; }
.first-foot .cta, .first-foot .pill { width: 100%; height: 46px; justify-content: center; font-size: 15px; }
.sheet { width: min(560px, 100%); max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column; background: #fff; border-radius: 30px; overflow: hidden; box-shadow: var(--shadow-lg); animation: rise .3s var(--ease); }
.sheet-body { overflow: auto; padding: 22px; }
.sheet-body h2 { margin: 0 0 10px; font-size: 17px; }
.sheet-body p { margin: 0 0 8px; font-size: 14px; line-height: 1.6; }
.sheet-body .note { font-size: 12px; color: var(--sub); }
.sheet-body img { display: block; width: 100%; height: auto; margin-bottom: 10px; border-radius: 20px; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.sheet-body textarea { width: 100%; height: 260px; border: 0; border-radius: 14px; padding: 12px; background: var(--tile); font: 12px/1.5 ui-monospace, Consolas, monospace; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
.pill { border: 0; border-radius: 99px; padding: 11px 22px; background: var(--tile); font-weight: 800; cursor: pointer; }
.pill:hover { background: #eee6ea; }
.sheet-foot .cta { height: 44px; }

/* セーブ・ロード（9 スロット） */
.slots-tabs { display: inline-grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 16px; background: var(--tile); }
.slots-tabs button { min-width: 0; padding: 9px 16px; white-space: nowrap; border: 0; border-radius: 12px; background: transparent; font-size: 14px; font-weight: 800; color: var(--sub); cursor: pointer; transition: background .15s, color .15s; }
.slots-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.slots p.slots-lead { margin: 0 0 10px; font-weight: 800; }
.slots-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
/* テンプレート（3つ目のタブ） */
@media (max-width: 760px), (max-aspect-ratio: 4/5) { .slots-tabs button { padding: 9px 6px; font-size: 13px; } }
.slots-grid.presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.slot.preset { aspect-ratio: 1; padding: 0; border: 0; border-radius: 16px; background: var(--tile); cursor: pointer; overflow: hidden; transition: transform .12s var(--ease), box-shadow .15s; }
.slot.preset:hover { box-shadow: 0 0 0 2px var(--accent) inset; }
.slot.preset svg { width: 100%; height: 100%; display: block; }
/* グラデーション: 上の色・下の色の切りかえとおすすめの2色 */
.grad-row { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.grad-seg { align-items: center; }
.grad-seg .grad-swap { margin-left: 2px; }
.grad-pairs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.grad-pairs-label { font-size: 11px; font-weight: 800; color: var(--sub); margin-right: 2px; }
.sw.pair { border: 1px solid rgba(43, 37, 48, .12); }
.slot { position: relative; border-radius: 18px; background: var(--tile); }
.slot.filled { background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); }
/* 縦長のカード（正方形と同じく下余白で高さを作る） */
.slot-main { position: relative; display: block; width: 100%; height: 0; padding: 0 0 118%; border: 0; border-radius: 18px; background: transparent; cursor: pointer; overflow: hidden; transition: background .15s; }
/* PC はダイアログが横に広いぶん、カードを少し低く（下のお知らせ・注意書きまで入るように） */
@media (min-width: 761px) and (min-aspect-ratio: 4/5) { .slot-main { padding-bottom: 96%; } }
.slot-main:hover:not(:disabled) { background: rgba(255, 111, 150, .06); }
.slot-main:disabled { cursor: default; }
/* 完成の画面の img の飾り（白い角丸・ふち）は付けない */
.slots .slot-main img { position: absolute; left: 10%; top: 14%; width: 80%; height: 66%; margin: 0; border-radius: 0; background: none; box-shadow: none; object-fit: contain; object-position: 50% 100%; }
.slot-no { position: absolute; left: 11px; top: 8px; font-size: 12px; font-weight: 800; color: var(--sub); }
.slot-date { position: absolute; left: 0; right: 0; bottom: 8px; font-size: 10.5px; font-weight: 700; color: var(--sub); text-align: center; }
.slot-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 6px; font-size: 12px; font-weight: 800; color: rgba(43, 37, 48, .38); }
.slot-del { position: absolute; top: 6px; right: 6px; z-index: 1; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: rgba(43, 37, 48, .5); color: #fff; display: grid; place-items: center; cursor: pointer; }
.slot-del:hover { background: rgba(43, 37, 48, .7); }
/* スロットの名前: 日時の上に1行、右上の × の左に「名前を付ける」 */
.slot-label { position: absolute; left: 6px; right: 6px; bottom: 23px; font-size: 12px; font-weight: 800; color: var(--ink); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slots .slot.named .slot-main img { top: 12%; height: 58%; }
.slot-ren { position: absolute; top: 6px; right: 36px; z-index: 1; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--line), 0 1px 4px rgba(43, 37, 48, .12); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.slot-ren:hover { background: var(--tile); }
.slot-ren svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slot-rename { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: 16px; background: var(--accent-soft); }
.slots .slot-rename p { flex: 1 0 100%; margin: 0; font-size: 12.5px; font-weight: 800; }
.slot-rename input { flex: 1 1 140px; min-width: 0; height: 36px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font: inherit; font-size: 14px; font-weight: 700; }
.slot-rename input:focus { outline: none; border-color: var(--accent); }
.slot-rename div { display: flex; gap: 6px; margin-left: auto; }
.slot-rename .pill, .slot-rename .cta { height: 36px; padding: 0 14px; font-size: 13px; }
.slot.renaming { box-shadow: 0 0 0 2.5px var(--accent); }
.slot-del svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; }
/* カードの上で確かめる（上書き・消す） */
.slot-ask { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 10px; border-radius: 18px; background: rgba(255, 255, 255, .96); box-shadow: inset 0 0 0 2px var(--accent); text-align: center; animation: fade .15s; }
.slots .slot-ask p { margin: 0; font-size: 12.5px; font-weight: 800; line-height: 1.5; }
.slot-ask div { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.slot-ask .pill, .slot-ask .cta { height: 32px; padding: 0 12px; font-size: 12px; }
/* 画像から読み込む（ロードのタブの先頭。app.js の restoreButton） */
.slot-restore { grid-column: 1 / -1; position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px dashed rgba(43, 37, 48, .22); border-radius: 16px; background: #fff; cursor: pointer; }
.slot-restore:hover { border-color: var(--accent); }
.slot-restore svg { flex: none; width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slot-restore span { display: grid; gap: 2px; text-align: left; }
.slot-restore b { font-size: 14px; font-weight: 800; }
.slot-restore small { font-size: 11.5px; font-weight: 700; color: var(--sub); }
.slot-restore input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.slots.drop { outline: 3px dashed var(--accent); outline-offset: 6px; border-radius: 20px; }
.slot-last { grid-column: 1 / -1; height: 52px; border: 0; border-radius: 16px; background: linear-gradient(135deg, var(--accent-soft), #fff1e6); font-size: 14px; font-weight: 800; cursor: pointer; transition: filter .15s; }
.slot-last:hover { filter: brightness(.98); }
.slots p.slots-msg { min-height: 1.5em; margin: 10px 2px 0; font-size: 13px; font-weight: 800; color: var(--accent); }
.slots p.slots-none { grid-column: 1 / -1; margin: 24px 0; text-align: center; color: var(--sub); }

/* 名前の欄 */
.name-field { position: relative; }
.name-field input { width: 100%; height: 48px; padding: 0 48px 0 16px; border: 2px solid var(--line); border-radius: 14px; background: var(--tile); font: 800 18px var(--font); color: var(--ink); outline: none; transition: border-color .15s, background .15s; }
.name-field input:focus { border-color: var(--accent); background: #fff; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.name-ed h3 { margin: 18px 0 8px; font-size: 14px; }
/* 欄の右の × で名前を消す */
.name-clear { position: absolute; right: 8px; top: 50%; width: 32px; height: 32px; margin-top: -16px; padding: 0; border: 0; border-radius: 50%; background: rgba(43, 37, 48, .1); color: var(--sub); display: grid; place-items: center; cursor: pointer; }
.name-clear[hidden] { display: none; }
.name-clear svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.name-clear:hover { background: rgba(43, 37, 48, .16); color: var(--ink); }
/* 色はたくさんあるので3段ほどで、あとは中でスクロール */
.name-colors { display: flex; flex-wrap: wrap; gap: 8px; max-height: 122px; overflow-y: auto; padding: 5px; margin: -5px; scrollbar-width: thin; }

/* ランダムの設定 */
.rnd h3 { display: flex; align-items: center; gap: 8px; margin: 20px 0 8px; font-size: 14px; }
.rnd h3 .lock-n { font-size: 12px; color: var(--accent); }
.text-btn { margin-left: auto; padding: 4px 2px; border: 0; background: none; color: var(--sub); font-size: 12px; font-weight: 700; text-decoration: underline; cursor: pointer; }
.text-btn[hidden] { display: none; }
.rnd .note { margin: 8px 2px 0; font-size: 12px; line-height: 1.5; color: var(--sub); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 16px; background: var(--tile); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 10px 4px; border-radius: 12px; font-size: 13px; font-weight: 800; text-align: center; color: var(--sub); transition: background .15s, color .15s, box-shadow .15s; }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 3px solid rgba(255, 111, 150, .55); }
.lock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; margin-top: 10px; }
.lock-cat { --icon-bg: var(--tile); position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; border: 0; border-radius: 16px; background: var(--tile); color: rgba(43, 37, 48, .75); cursor: pointer; transition: background .15s, color .15s, transform .12s var(--ease); }
.lock-cat:active { transform: scale(.94); }
.lock-cat svg { width: 38px; height: 38px; fill: var(--icon-bg); }
.lock-cat span { max-width: 100%; padding: 0 2px; font-size: 10px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock-cat span.tight { padding: 0; font-size: 9px; letter-spacing: -.02em; }
.lock-cat.now { box-shadow: inset 0 0 0 2px rgba(255, 111, 150, .55); }
.lock-cat.on { --icon-bg: var(--ink); background: var(--ink); color: #fff; }
.lock-cat.on::after { content: ""; position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='10.5' width='14' height='10' rx='2.5'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5'/%3E%3C/svg%3E") center / 11px no-repeat; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---- 完成画面 ---- */
.finish { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: rgba(43, 37, 48, .38); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: fade .2s; }
.finish[hidden] { display: none; }
.finish-card { width: min(940px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 32px; background: #fff; box-shadow: var(--shadow-lg); animation: rise .3s var(--ease); }
.finish-head { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 14px 16px 10px; background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.finish-head h2 { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: .06em; white-space: nowrap; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.finish-back, .finish-home { display: inline-flex; align-items: center; gap: 5px; height: 40px; border-radius: 99px; font-size: 13px; font-weight: 800; cursor: pointer; transition: background .15s, transform .12s var(--ease); }
.finish-back { justify-self: start; padding: 0 15px 0 9px; border: 0; background: var(--tile); color: var(--ink); }
.finish-home { justify-self: end; padding: 0 12px; color: var(--sub); text-decoration: none; }
.finish-back:hover { background: #eee6ea; }
.finish-home:hover { background: var(--tile); }
.finish-back:active, .finish-home:active, .fa:active { transform: scale(.95); }
.finish-back svg, .finish-home svg, .fa svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.finish-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; gap: 26px; padding: 6px 26px 28px; }
.finish-figure { text-align: center; }
/* 完成の画像（押すとホロ。.card_holo は本物の chibi.css） */
.finish #chaMakeResultImage { position: relative; overflow: hidden; border-radius: 26px; background: #fff; box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm); cursor: pointer; transition: transform .2s; }
.finish #chaMakeResultImage img { display: block; width: 100%; height: auto; }
.finish-tip { margin: 10px 0 0; font-size: 12px; color: var(--sub); }
.finish-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fa { min-height: 86px; padding: 12px 8px; border: 0; border-radius: 22px; background: var(--tile); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; font: 800 13px/1.35 var(--font); text-align: center; cursor: pointer; transition: background .15s, transform .12s var(--ease), opacity .2s; }
.fa svg { width: 26px; height: 26px; }
.fa:hover { background: #efe7eb; }
.fa-main { grid-column: 1 / -1; min-height: 58px; flex-direction: row; gap: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 15px; box-shadow: 0 12px 26px -12px rgba(255, 90, 130, .9); }
.fa-main:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.05); }
.fa.done { opacity: .45; pointer-events: none; }
/* 本物の完成画面のボタン（result.css の .link-btn）の見た目は打ち消す。.link-btn は「販売していない地域ではボタンを隠す」の目印に使う */
.finish .fa.link-btn { position: static; width: auto; min-width: 0; margin: 0; padding: 12px 8px; overflow: visible; text-transform: none; color: var(--ink); background: var(--tile); font-size: 13px; }
.finish .fa.link-btn::after { display: none; }
.finish .fa.link-btn:hover { color: var(--ink); background: #efe7eb; }
.finish-error { grid-column: 1 / -1; min-height: 1.3em; margin: 0; font-size: 12.5px; font-weight: 700; color: #c2334d; text-align: center; }
.finish .ohirome-rx-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 12px; padding: 11px 14px; border-radius: 16px; background: var(--accent-soft); color: #c2334d; font-size: 13px; font-weight: 800; text-decoration: none; }
/* 高画質DL の説明と決済（本物の result.css のまま、角と字だけ合わせる） */
.finish .paypal-modal { background: rgba(43, 37, 48, .45); }
.finish .paypal-modal .modal-content { width: min(560px, calc(100vw - 24px)); padding: 22px; border-radius: 26px; font-size: 14px; line-height: 1.6; }
.finish .paypal-modal .modal-content h3 { margin: 0 0 8px; font-size: 17px; }
.finish .paypal-modal .modal-content ul { margin: 0 0 14px; padding-left: 1.2em; font-size: 13px; color: #444; }
.finish #sns-share { border-radius: 26px; }
/* お披露目のあとの SNS のアイコン: result.css は幅 2rem＋余白 1rem の作りなので、この画面の border-box だと絵の幅が 0 になる */
.finish #sns-share .sharewrap img { box-sizing: content-box; }
/* 完成画面のアニメ（ui/emote.js）: 完成の画像の上に重ねる canvas（同じ箱の中なのでホロの傾き・きらきらも一緒に掛かる）と、
   動いている間にダウンロードを押したときの「静止画か GIF か」 */
.finish #chaMakeResultImage .emote-stage { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.emote-dl { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(43, 37, 48, .3); animation: fade .2s; }
.emote-dl[hidden] { display: none; }
.emote-dl-card { width: min(340px, 100%); padding: 20px; border-radius: 26px; background: #fff; box-shadow: var(--shadow-lg); display: grid; gap: 10px; animation: rise .25s var(--ease); }
.emote-dl-card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 900; text-align: center; }
.emote-dl-opt { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; border: 0; border-radius: 18px; background: var(--tile); color: var(--ink); font: 800 14px/1.35 var(--font); text-align: left; cursor: pointer; transition: background .15s, transform .12s var(--ease), opacity .2s; }
.emote-dl-opt:hover { background: #efe7eb; }
.emote-dl-opt:active { transform: scale(.97); }
.emote-dl-opt svg { flex-shrink: 0; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.emote-dl-opt.busy { opacity: .5; pointer-events: none; }
.emote-dl-close { justify-self: center; padding: 8px 16px; border: 0; background: none; color: var(--sub); font: 700 13px var(--font); cursor: pointer; }
/* 完成したときの動き（app.js の flash） */
.stage-flash { position: absolute; inset: 0; z-index: 5; border-radius: inherit; background: #fff; opacity: 0; pointer-events: none; }

/* ---- はじめての人への使い方（まわりを暗くして、1つずつ照らす） ---- */
.tour { position: fixed; inset: 0; z-index: 30; }
.tour[hidden] { display: none; }
/* 照らす枠。まわりは大きな影で暗くする（枠は次の手順へすべって移る） */
.tour-hole {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0; border-radius: 22px; pointer-events: none;
  box-shadow: 0 0 0 4px rgba(255, 111, 150, .55), 0 0 0 200vmax rgba(24, 14, 22, .62);
  transition: left .4s var(--ease), top .4s var(--ease), width .4s var(--ease), height .4s var(--ease);
}
.tour-hole.instant, .tour-hole.instant + .tour-tip { transition: none; }
.tour-tip {
  position: absolute; left: 16px; top: 16px; width: min(330px, calc(100vw - 32px)); padding: 18px 18px 14px; border-radius: 22px; background: #fff; box-shadow: var(--shadow-lg);
  transition: left .4s var(--ease), top .4s var(--ease); animation: rise .3s var(--ease);
}
.tour-step { margin: 0 0 4px; font-size: 11px; font-weight: 800; color: var(--accent); }
.tour-tip h3 { margin: 0 0 6px; font-size: 16px; }
.tour-text { margin: 0; font-size: 13.5px; line-height: 1.7; }
.tour-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.tour-foot .text-btn { margin-left: 0; }
.tour-foot .cta { height: 40px; padding: 0 18px; font-size: 14px; }
.tour-dots { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 4px; overflow: hidden; } /* 手順が多くても、ボタンを外へ押し出さない */
.tour-dots i { flex: none; }
.tour-foot .cta, .tour-foot .text-btn { flex: none; white-space: nowrap; }
.tour-dots i { width: 6px; height: 6px; border-radius: 99px; background: rgba(43, 37, 48, .15); transition: width .25s var(--ease), background .25s; }
.tour-dots i.on { width: 16px; background: var(--accent); }

/* ---- スマホ（とタブレットの縦向き）: 上にキャラ（画面の幅いっぱい）、下にパーツのシート ---- */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  /* キャラの段の高さ。ふだんは幅いっぱいの正方形が入る高さ（縦に短い画面では 50%）、広げると 38% */
  /* --stage-h は使う所で中身が決まるので、dvh が使えないブラウザでは @supports で vh に（そのままだと段の高さが消える） */
  .app { --stage-h: min(100vw, 50vh); grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--stage-h) minmax(0, 1fr); }
  .app.expanded { --stage-h: 38vh; }
  @supports (height: 1dvh) {
    .app { --stage-h: min(100vw, 50dvh); }
    .app.expanded { --stage-h: 38dvh; }
  }
  .app:not(.dragging) { transition: grid-template-rows .32s var(--ease); }

  .stage-area { padding: calc(6px + env(safe-area-inset-top)) 8px 10px; }
  .stage { border-radius: 28px; }
  /* 左上のロゴの下に */
  .view-btn { top: 56px; left: 10px; height: 36px; padding: 0 13px 0 10px; font-size: 12px; }
  .float { top: calc(14px + env(safe-area-inset-top)); gap: 6px; }
  .float.tl { left: 16px; }
  .float.tr { right: 16px; }
  .glass:not(.split) { width: 42px; height: 42px; min-width: 0; padding: 0; }
  .glass span { display: none; }
  .glass.split { height: 42px; }
  .split-main { padding: 0 5px 0 10px; }
  .split-more { padding: 0 8px 0 4px; }
  .cat.locked::after { top: 0; right: 0; width: 16px; height: 16px; background-size: 10px; }
  .brand { height: 42px; padding: 0 8px 0 14px; gap: 6px; }
  .brand-logo { height: 15px; }
  .cta { height: 42px; padding: 0 16px 0 13px; font-size: 14px; }
  .rail { right: 10px; bottom: 10px; }
  .tool { width: 46px; height: 46px; }
  .opa { padding: 7px 12px; gap: 6px; }
  .opa input { width: 120px; }
  .tool.set::after { top: 6px; right: 8px; }
  .dpad { left: 10px; bottom: 10px; grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(3, 38px); gap: 2px; }
  .pad { width: 38px; height: 38px; }
  .toast { bottom: 64px; } /* 左下の元に戻す・やり直すと重ならないように */
  .history { left: 10px; bottom: 10px; padding: 3px; }
  .history .hist { width: 36px; height: 36px; }
  .stage.moving ~ .history { left: calc(10px + 118px + 10px); }

  .panel { margin: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); border: 0; border-radius: 30px 30px 0 0; background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 -14px 40px -18px rgba(110, 50, 80, .32); }
  .grip { display: grid; place-items: center; height: 22px; padding: 0; border: 0; background: none; cursor: grab; touch-action: none; }
  .grip::before { content: ""; width: 42px; height: 5px; border-radius: 99px; background: rgba(43, 37, 48, .16); transition: background .15s, width .2s var(--ease); }
  .grip:hover::before, .app.dragging .grip::before { background: rgba(43, 37, 48, .3); width: 54px; }
  /* カテゴリ: 横の帯。選んだものだけ名前を出す */
  .cats { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 12px 8px; gap: 2px; border-right: 0; }
  .cat { width: auto; flex-direction: row; gap: 0; padding: 4px; border-radius: 99px; }
  .cat-ind { border-radius: 99px; }
  .cat svg { width: 42px; height: 42px; }
  .cat-label { max-width: 0; padding: 0; opacity: 0; font-size: 13px; transition: max-width .3s var(--ease), padding .3s var(--ease), opacity .2s; }
  .cat.sel .cat-label { max-width: 9em; padding: 0 12px 0 2px; opacity: 1; }
  /* 色の設定は絵だけに */
  .pal-chip.icon span, .pal-chip.icon .caret { display: none; }
  .pal-chip.icon { padding: 0 8px; }
  .editor-head { display: none; }
  .layer-pick { padding: 0 14px 6px; }
  .grad { padding: 0 14px 0; }
  .grad-hint { display: none; }
  .colors { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 6px 14px 10px; scrollbar-width: none; }
  .colors::-webkit-scrollbar { display: none; }
  /* おすすめの2色は横に流す（色の段と同じ） */
  .grad-pairs { flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
  .grad-pairs::-webkit-scrollbar { display: none; }
  .grad-pairs .sw { flex: none; }
  .grad-pairs-label { flex: none; }
  .grad-seg { position: static; box-shadow: none; }
  .sw { width: 32px; height: 32px; }
  /* 横に流れる色の段では、左右の切りかえは左に止めておく */
  /* 後ろを流れる色が上下・左の余白からのぞかないように、白い影で囲む */
  .lr { position: sticky; left: 0; z-index: 1; align-self: center; box-shadow: 0 0 0 7px #fff, -16px 0 0 7px #fff, 16px 0 12px -2px #fff; }
  /* 色の段の左に固定するもの（色・柄の切りかえ・左右の色・色の設定。app.js の buildColors） */
  /* 右のぼかしが隣の「元の色」の選択の輪にかからないよう、間を少しあけてぼかしを短く */
  .colors-fixed { position: sticky; left: 0; z-index: 2; flex: none; align-self: center; display: flex; align-items: center; gap: 8px; margin-right: 10px; background: #fff; box-shadow: 0 0 0 7px #fff, -16px 0 0 7px #fff, 8px 0 8px -4px #fff; }
  .colors-fixed .lr { position: static; box-shadow: none; }
  .sw.reset::after { inset: 14.5px 4px; }
  .sw:hover { transform: none; }
  .parts { --slide-x: 34px; --slide-y: 0px; padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
  .part { border-radius: 20px; }

  .modal { place-items: end center; padding: 0; }
  .finish { padding: 0; place-items: stretch; }
  .finish-card { width: 100%; max-height: none; height: 100vh; height: 100dvh; border-radius: 0; animation: rise .3s var(--ease); }
  .finish-head { padding: calc(10px + env(safe-area-inset-top)) 12px 8px; }
  .finish-head h2 { font-size: 16px; }
  .finish-home span { display: none; }
  .finish-body { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 2px 16px calc(24px + env(safe-area-inset-bottom)); }
  .finish-figure { width: min(100%, 52vh); width: min(100%, 52dvh); margin: 0 auto; }
  .fa { min-height: 76px; border-radius: 20px; }
  .sheet { width: 100%; max-height: 88vh; max-height: 88dvh; border-radius: 30px 30px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* キャラの段が少し低いとき（iPhone SE など）は、調整の列のボタンを低くする（6 つ並ぶと上のボタンにかかるので） */
@container (max-height: 400px) {
  .tool { height: 42px; }
  .tool.set::after { top: 4px; }
}

/* キャラの段が低いとき（縦に短い画面・シートを広げたとき）は、調整の列と十字キーを詰める（.stage-area の高さで決める） */
@container (max-height: 330px) {
  .tool { width: 40px; height: 36px; border-radius: 16px; }
  .tool.set::after { top: 3px; right: 6px; }
  .tool span { display: none; }
  .dpad { grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); }
  .pad { width: 34px; height: 34px; }
  .pad svg { width: 20px; height: 20px; }
}

/* キャラの段が狭いとき（スマホの横向きなど）は、右上のボタンの名前を消す（左上のロゴと重ならないように） */
@container (max-width: 620px) {
  .glass:not(.split) { width: auto; min-width: 0; aspect-ratio: 1; padding: 0; }
  .glass span { display: none; }
}

/* コンテナクエリが使えないブラウザ（iOS 15・Chrome 104 以下）: 上の3つと同じものを、app.js が .stage-area に付けるクラスで */
.no-cq .stage-area.cq-h400 .tool { height: 42px; }
.no-cq .stage-area.cq-h400 .tool.set::after { top: 4px; }
.no-cq .stage-area.cq-h330 .tool { width: 40px; height: 36px; border-radius: 16px; }
.no-cq .stage-area.cq-h330 .tool.set::after { top: 3px; right: 6px; }
.no-cq .stage-area.cq-h330 .tool span { display: none; }
.no-cq .stage-area.cq-h330 .dpad { grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); }
.no-cq .stage-area.cq-h330 .pad { width: 34px; height: 34px; }
.no-cq .stage-area.cq-h330 .pad svg { width: 20px; height: 20px; }
.no-cq .stage-area.cq-w620 .glass:not(.split) { width: auto; min-width: 0; aspect-ratio: 1; padding: 0; }
.no-cq .stage-area.cq-w620 .glass span { display: none; }

/* 動きを止める（メニューの「カテゴリを選んだときの動き」を外したとき・端末の「視差効果を減らす」） */
.no-anim .cat-ind, .no-anim .fold, .no-anim .cat-label { transition: none !important; }
.no-anim .cat.sel svg, .no-anim .grid.enter { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .cat-ind, .fold, .cat-label, .tour-hole, .tour-tip { transition: none !important; }
  .cat.sel svg, .grid.enter, .stage.pop svg { animation: none !important; }
}
/* 幅の狭いスマホ: 左上のロゴ（メニュー）と右上のボタンが重ならないよう、ロゴを小さく・間を詰める（2026-10-12。375px 以下でランダムが「∨」に重なっていた） */
@media (max-width: 400px) {
  .float { gap: 5px; }
  .float.tl { left: 12px; }
  .float.tr { right: 12px; }
  .brand { padding: 0 6px 0 11px; gap: 3px; }
  .brand-logo { height: 11px; }
  .cta { padding: 0 13px 0 11px; gap: 5px; }
}
@media (max-width: 350px) {
  .brand-logo { height: 9px; }
  .split-main { padding: 0 3px 0 8px; }
  .split-more { padding: 0 6px 0 2px; }
  .glass:not(.split) { width: 38px; }
  .cta { padding: 0 10px 0 9px; font-size: 13px; }
}
