:root {
  --bg: #fbf6f3; --ink: #3d302c; --sub: #7b6a64; --line: #ead9d2; --pink: #e0578a; --pink-d: #c63f72; --card: #fff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button:disabled { opacity: .35; cursor: default; }
.hidden { display: none !important; }

.screen { display: none; }
.screen.on { display: block; }

/* ---- 入口・診断・結果（縦に読む画面） ---- */
#landing, #diag, #result { max-width: 480px; margin: 0 auto; padding: calc(18px + var(--safe-t)) 18px calc(28px + var(--safe-b)); text-align: center; }
h1 { font-size: 24px; margin: 6px 0 4px; letter-spacing: .02em; }
h2 { font-size: 20px; margin: 4px 0 12px; }
.lead { margin: 0 0 14px; color: var(--sub); font-size: 15px; }
.privacy { font-size: 13px; color: var(--sub); margin: 12px 0 0; }
.status { min-height: 1em; font-size: 14px; color: #b23a3a; margin: 10px 0 0; }
.foot { margin-top: 26px; font-size: 11px; color: #a8958e; }

.bigbtn { display: block; width: 100%; border: 0; border-radius: 999px; background: var(--pink); color: #fff; font-weight: 700; font-size: 18px; padding: 16px 20px; margin: 16px 0 0; box-shadow: 0 6px 18px rgba(224,87,138,.28); text-align: center; }
.bigbtn:active { background: var(--pink-d); }
.bigbtn.small { width: auto; padding: 10px 22px; font-size: 15px; margin: 0; box-shadow: none; }
.bigbtn.danger, .danger { background: #c94b4b; color: #fff; }
.textbtn { border: 0; background: none; color: var(--pink-d); font-size: 15px; padding: 12px; margin-top: 4px; text-decoration: underline; text-underline-offset: 3px; }

/* ビフォア／アフター */
.ba { --p: 50%; position: relative; width: 100%; aspect-ratio: 4 / 5; border-radius: 18px; overflow: hidden; background: #eee; box-shadow: 0 6px 22px rgba(80,40,30,.12); user-select: none; }
.ba img, .ba canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ba-after-wrap { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--p)); }
.ba-line { position: absolute; top: 0; bottom: 0; left: var(--p); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.3); pointer-events: none; }
.ba-line::after { content: "‹ ›"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: var(--ink); border-radius: 999px; font-size: 14px; font-weight: 700; padding: 6px 9px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.ba-tag { position: absolute; top: 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: #fff; background: rgba(0,0,0,.35); border-radius: 999px; padding: 3px 9px; pointer-events: none; }
.ba-tag.l { left: 10px; } .ba-tag.r { right: 10px; }
.ba-range { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; touch-action: pan-y; }

/* 診断 */
.diag-top { display: flex; align-items: center; gap: 6px; }
.diag-top h2 { margin: 0; flex: 1; text-align: left; }
.thumb { width: 120px; height: auto; border-radius: 14px; margin: 10px auto 6px; display: block; box-shadow: 0 4px 14px rgba(80,40,30,.12); }
.answer { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 12px 0 0; text-align: left; }
.answer small { display: block; color: var(--sub); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.answer b { display: block; font-size: 26px; margin: 2px 0 4px; color: var(--pink-d); }
.answer p { margin: 0; font-size: 14px; line-height: 1.6; }
.answer ul { margin: 8px 0 0; padding-left: 1.2em; font-size: 14px; line-height: 1.6; }
.sw-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.sw-dot { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.sw-cap { font-size: 12px; color: var(--sub); margin-left: 4px; }
.note { font-size: 12px; color: var(--sub); margin: 12px 0 0; }
details.more { margin-top: 18px; text-align: left; font-size: 13px; color: var(--sub); }
details.more summary { cursor: pointer; text-align: center; color: var(--pink-d); font-size: 14px; padding: 6px; }
details.more p { line-height: 1.6; margin: 8px 0; }
.mono { font-variant-numeric: tabular-nums; }

/* ---- 編集画面（全画面） ---- */
body[data-screen="editor"] { overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; }
#editor.on { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#editor { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.topbar { display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-t)) 6px 6px; background: #fff; border-bottom: 1px solid var(--line); flex: none; }
.iconbtn { width: 38px; height: 38px; border: 0; background: none; font-size: 22px; border-radius: 10px; flex: none; }
.iconbtn:active { background: #f3e6e0; }
.tbtn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; flex: none; }
.tbtn[aria-pressed="true"] { background: #fde7ef; border-color: #f0a9c3; color: var(--pink-d); }
.tbtn.on { background: var(--ink); color: #fff; }
.tbtn.primary { background: var(--pink); color: #fff; border-color: var(--pink); margin-left: auto; }
#cmpBtn { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }

.stage { position: relative; flex: 1 1 auto; min-height: 120px; overflow: hidden; background: radial-gradient(circle at 50% 40%, #f6ece7, #e9dbd5); touch-action: none; user-select: none; -webkit-user-select: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#c3d { display: none; }
body.is3d #c3d { display: block; }
.zoomchips { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; background: rgba(255,255,255,.88); padding: 4px; border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.zoomchips button { white-space: nowrap; border: 0; background: none; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--sub); }
.zoomchips button.on { background: var(--ink); color: #fff; }
.yawbar { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: none; align-items: center; gap: 6px; background: rgba(255,255,255,.92); padding: 5px 8px; border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.1); width: min(94%, 380px); }
body.is3d .yawbar { display: flex; }
.yawbar button { border: 0; background: #f3e6e0; border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 600; flex: none; }
.yawbar input { flex: 1; min-width: 60px; accent-color: var(--pink); }
.toast { position: absolute; left: 50%; top: 54px; z-index: 3; transform: translate(-50%, -6px); max-width: 92%; background: rgba(40,28,26,.86); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 12px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.scorecard { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(255,255,255,.96); border-radius: 14px; padding: 10px 34px 10px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: 13px; line-height: 1.5; display: flex; flex-direction: column; gap: 2px; }
.scorecard b { font-size: 16px; color: var(--pink-d); }
.scorecard .dim { color: var(--sub); }
.scorecard .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 3px 0 8px; vertical-align: -1px; }
.scorecard .legend i:first-child { margin-left: 0; }
.legend .g { background: rgb(70,185,100); } .legend .o { background: rgb(255,150,20); } .legend .r { background: rgb(230,50,60); }
.scorecard .x { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 20px; color: var(--sub); }

.panel { flex: none; background: #fff; border-top: 1px solid var(--line); padding: 6px 10px 2px; max-height: 42vh; overflow-y: auto; }
.row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.row.chips, .row.pal { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.row.chips::-webkit-scrollbar, .row.pal::-webkit-scrollbar, .tray::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; white-space: nowrap; flex: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.sep { width: 1px; height: 20px; background: var(--line); flex: none; margin: 0 2px; }
.sw { position: relative; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); flex: none; }
.sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.sw.rec::after { content: "★"; position: absolute; top: -6px; right: -5px; font-size: 12px; color: #f0a500; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }
.cname { font-size: 12px; color: var(--sub); white-space: nowrap; margin-left: 4px; }
.row.sls { gap: 10px; flex-wrap: wrap; }
.sl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); flex: 1 1 30%; min-width: 96px; }
.sl span { flex: none; }
.sl input { flex: 1; min-width: 50px; accent-color: var(--pink); }
.row.acts { flex-wrap: wrap; }
.act { border: 0; background: #fde7ef; color: var(--pink-d); font-weight: 700; border-radius: 999px; padding: 7px 14px; font-size: 13px; }
.act.primary { background: var(--pink); color: #fff; }
.hint { font-size: 12px; color: var(--sub); margin: 2px 0; }
details.adj { font-size: 13px; margin: 2px 0 4px; }
details.adj summary { color: var(--pink-d); cursor: pointer; padding: 2px 0; }

.tray { flex: none; display: flex; gap: 2px; overflow-x: auto; background: #fff; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--safe-b)); scrollbar-width: none; }
.tool { flex: none; width: 62px; border: 0; background: none; border-radius: 12px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--sub); }
.tool i { font-style: normal; font-size: 20px; line-height: 26px; width: 36px; height: 28px; border-radius: 10px; }
.tool span { font-size: 11px; white-space: nowrap; }
.tool.on { color: var(--pink-d); }
.tool.on i { background: #fde7ef; }
.tool.auto span, .tool.course span { font-weight: 700; }
.tool i { display: flex; align-items: center; justify-content: center; }
.tool i svg { width: 30px; height: 22px; }
.tool.course { color: var(--pink-d); }
/* 道具（実物の形のアイコン付き） */
.row.tools { gap: 5px; }
.tchip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px 3px 6px; }
.tchip svg { width: 26px; height: 20px; flex: none; }
.real { font-size: 12px; line-height: 1.5; color: var(--ink); background: #fbf3ef; border-radius: 10px; padding: 5px 9px; margin: 2px 0 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.real span { color: var(--sub); }
.real svg { width: 26px; height: 20px; color: var(--pink-d); }
/* ガイドのひと言 */
.guidetip { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0 auto; max-width: 420px; background: rgba(255,255,255,.95); border-left: 4px solid var(--pink); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; line-height: 1.5; box-shadow: 0 2px 10px rgba(0,0,0,.1); display: none; pointer-events: none; }
.guidetip.on { display: block; }
.guidetip b { display: block; color: var(--pink-d); font-size: 12px; }
body.is3d .guidetip { display: none; }
.guidetip.compact { pointer-events: auto; cursor: pointer; }
.guidetip.compact:not(.open) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; padding-bottom: 0; border-bottom: 6px solid rgba(255,255,255,.95); } /* 下の余白に 3 行目がのぞかないように、余白を枠線で作る */
.guidetip.compact:not(.open) b { display: inline; margin-right: .4em; }
.guidetip.compact small { font-weight: normal; color: var(--sub); font-size: 11px; margin-left: .3em; }
.guidetip.compact.open small { display: none; }
body.is3d .guidetip.compact { display: none; }
.d3status { position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%); display: none; background: rgba(40,28,26,.8); color: #fff; font-size: 12px; padding: 5px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap; }
.d3status.on { display: block; }
.d3status::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; vertical-align: -1px; animation: spin .9s linear infinite; }
/* 練習コース */
.course { background: #fde7ef; border-radius: 12px; padding: 6px 8px; margin: 2px 0 4px; }
.course .ctop { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--pink-d); }
.course .dots { display: flex; gap: 4px; }
.course .dots i { width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px #f0a9c3; }
.course .dots i.done { background: #f0a9c3; }
.course .dots i.cur { background: var(--pink); box-shadow: none; }
.course .cbtns { display: flex; gap: 5px; margin-top: 5px; }
.course .cbtns button { border: 0; background: #fff; border-radius: 999px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.course .cbtns button.primary { background: var(--pink); color: #fff; flex: 1; }
.course .cbtns button:disabled { opacity: .4; }
.course .cbtns button.quit { color: var(--sub); background: none; padding: 6px 4px; }
.course-sub { font-size: 12px; color: var(--sub); margin: 6px 0 0; }
#diag #startCourse { margin-top: 14px; }
#diag .thumb { width: 96px; margin: 6px auto 2px; }
.ftype-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.ftype-chips span { font-size: 12px; color: var(--sub); }
.ftype-chips .chip.on { background: var(--pink-d); border-color: var(--pink-d); }
.ftype-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.ftype-list button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 6px; font-size: 15px; font-weight: 700; }
.ftype-list button small { display: block; font-size: 11px; color: var(--sub); font-weight: 400; margin-top: 2px; }
.ftype-list button.on { border-color: var(--pink); background: #fde7ef; color: var(--pink-d); }
/* できあがり */
.bigbtn.sub { background: #fff; color: var(--pink-d); border: 2px solid var(--pink); box-shadow: none; margin-top: 10px; padding: 13px 20px; }
.next { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 14px 0 0; text-align: left; font-size: 14px; line-height: 1.6; }
.next b { color: var(--pink-d); }
.next p { margin: 0; }
.used { text-align: left; font-size: 12.5px; line-height: 1.55; margin: 16px 0 0; background: #fbf3ef; border-radius: 12px; padding: 10px 12px; }
.used h4 { margin: 0 0 4px; font-size: 13px; }
.used ul { margin: 0; padding-left: 1.1em; }
.used li span { color: var(--sub); }
#result #saveBtn { margin-top: 10px; }
.practice-top .act.primary { padding: 9px 18px; font-size: 14px; }
/* 道具と実物の一覧 */
.tools-body { max-height: 86vh; overflow-y: auto; }
.toollist { list-style: none; padding: 0; margin: 8px 0 12px; }
.toollist li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.toollist li i { flex: none; width: 38px; height: 30px; display: flex; align-items: center; justify-content: center; background: #fde7ef; border-radius: 9px; color: var(--pink-d); }
.toollist li div { display: flex; flex-direction: column; font-size: 13px; line-height: 1.4; }
.toollist small { color: var(--sub); font-size: 11px; }
.toollist span { font-size: 12px; }

/* メニュー・モーダル */
.sheet, .modal, .busy { position: fixed; inset: 0; display: none; z-index: 20; }
.sheet.on, .modal.on, .busy.on { display: flex; }
.sheet { background: rgba(0,0,0,.35); align-items: flex-end; }
.sheet-body { background: #fff; width: 100%; max-width: 520px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 10px 14px calc(14px + var(--safe-b)); }
.sheet-body button { display: block; width: 100%; border: 0; background: none; text-align: left; font-size: 16px; padding: 14px 6px; border-bottom: 1px solid var(--line); }
.sheet-body button.danger { color: #c94b4b; background: none; }
.sheet-body button.close { text-align: center; color: var(--sub); border: 0; }
.sheet-note { font-size: 12px; color: var(--sub); line-height: 1.6; margin: 10px 4px 0; }
.modal { background: rgba(0,0,0,.4); align-items: center; justify-content: center; padding: 18px; }
.modal-body { background: #fff; border-radius: 18px; padding: 18px; max-width: 400px; width: 100%; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; } /* 説明が長くても閉じるボタンまでスクロールできる */
.modal-body h3 { margin: 0 0 8px; font-size: 19px; text-align: center; }
.howto { padding-left: 1.3em; margin: 0; font-size: 15px; line-height: 1.6; }
.howto li { margin: 6px 0; }
.small { font-size: 12px; color: var(--sub); }
.confirm-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; }
.busy { background: rgba(251,246,243,.92); flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 15px; color: var(--sub); padding: 24px; text-align: center; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid #f3d3df; border-top-color: var(--pink); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  #editor.on { max-width: 760px; margin: 0 auto; box-shadow: 0 0 30px rgba(0,0,0,.08); }
}
