/* 声で動かす（2026-10-21〜、試験運用。chibi/pngtuber/page.php） */
* { box-sizing: border-box; }
/* hidden の付いたものは、display を決めた箱（.demo-bar・.row など）でも出さない */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #f6f1ec; color: #3a2e2a;
}
button, select, input { font: inherit; }
/* CHARAT の共通ヘッダー（common/header.php、上に固定・高さ 50px）の下（CHOCO 広場と同じ） */
.voice-app { margin-top: 50px; }

/* 大きすぎないように（ユーザー判断 2026-10-21）: 画面の幅は 1060px まで、キャラは作ったときのそのままの大きさ（--natural）まで */
.main { display: flex; justify-content: center; align-items: flex-start; gap: 18px; padding: 18px; width: 100%; max-width: 1060px; margin: 0 auto; }
.stage-wrap { flex: 0 1 660px; display: flex; flex-direction: column; min-width: 0; }
.stage { position: relative; height: clamp(320px, calc(100dvh - 260px), 520px); border-radius: 16px; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; }
.holder { position: relative; height: min(92%, var(--natural, 520px)); aspect-ratio: var(--ratio, 0.6); margin-bottom: 2%; will-change: transform; }
.holder img, .holder canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom center; }
.loading { position: absolute; inset: 0; margin: auto; height: 1.5em; text-align: center; color: rgba(0,0,0,.55); }
.status { margin: 6px 4px 0; font-size: 13px; color: #b0413e; min-height: 1em; }

.bg-green { background: #00ff00; }
.bg-blue { background: #0000ff; }
.bg-magenta { background: #ff00ff; }
.bg-white { background: #fff; }

/* 見本のキャラのとき（キャラが無い・同意していない人）: 作る画面へのボタン */
.demo-bar { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin: 0 0 10px; padding: 9px 12px; background: #fff; border: 1px solid #ece3db; border-radius: 14px; }
.demo-bar p { margin: 0; flex: 1; min-width: 180px; font-size: 13px; line-height: 1.6; }
.demo-bar .btn { text-decoration: none; white-space: nowrap; }

/* キャラの下の1列: マイク・背景・出し方 */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px solid #ece3db; border-radius: 14px; }
.tb-mic { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; flex: 1 1 280px; min-width: 0; }
.tb-level { flex: 1 1 140px; min-width: 120px; }
.tb-out { display: flex; gap: 6px; }
.meter { position: relative; height: 8px; margin: 2px 0 5px; border-radius: 4px; background: #eee6df; overflow: hidden; }
.meter-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #b9a89c; transition: width .05s linear; }
.meter-bar.loud { background: #5ea8a7; }
.meter-thr { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #2fbf4a; }
.slider { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #7a6a62; }
.slider input { flex: 1; min-width: 0; }
select { max-width: 100%; border: 1px solid #d9cdc2; border-radius: 8px; padding: 5px 6px; background: #fff; font-size: 13px; }

.btn { border: 1px solid #d9cdc2; background: #fff; color: #3a2e2a; border-radius: 20px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f6f1ec; }
.btn.primary { background: #5ea8a7; border-color: #5ea8a7; color: #fff; font-weight: bold; }
.btn.primary:hover { background: #4d9594; }
.btn.small { font-size: 12px; padding: 5px 10px; }
.btn.on { background: #00293c; border-color: #00293c; color: #fff; }

.swatches { display: flex; gap: 6px; align-items: center; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d9cdc2; cursor: pointer; padding: 0; position: relative; overflow: hidden; }
.sw.on { box-shadow: 0 0 0 2px #00293c; }
.sw-green { background: #00ff00; } .sw-blue { background: #0000ff; } .sw-magenta { background: #ff00ff; } .sw-white { background: #fff; }
.sw-custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.sw-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* 右: 見出し（小さく）・キャラの一覧・開いたときだけの 顔（口と目）・動き */
.panel { width: 320px; flex: 0 0 320px; display: flex; flex-direction: column; gap: 10px; }
.panel-head { padding: 2px 4px 0; }
.panel-head .back { color: #5ea8a7; text-decoration: none; font-size: 12px; font-weight: bold; }
.panel-head h1 { margin: 4px 0 0; font-size: 16px; color: #00293c; line-height: 1.5; }
.panel-head h1 .trial { font-size: 10px; font-weight: normal; padding: 0 6px; border: 1px solid #5ea8a7; color: #5ea8a7; border-radius: 9px; vertical-align: 2px; white-space: nowrap; }
.panel-head h1 .sub { display: block; font-size: 12px; font-weight: normal; color: #7a6a62; }
.card { background: #fff; border: 1px solid #ece3db; border-radius: 14px; padding: 10px 12px; }
details.more summary { cursor: pointer; font-size: 13px; font-weight: bold; color: #00293c; list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: ''; width: 6px; height: 6px; border-right: 2px solid #5ea8a7; border-bottom: 2px solid #5ea8a7; transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
details.more[open] summary::before { transform: rotate(45deg); }
details.more[open] summary { margin-bottom: 8px; }
.others { margin: 2px 4px 0; font-size: 12px; }
.others a { color: #5ea8a7; text-decoration: none; font-weight: bold; }
.others a:hover { text-decoration: underline; }
.note { margin: 0 4px; font-size: 11px; line-height: 1.7; color: #9a8a80; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 4px 0; }

.chara-group + .chara-group { margin-top: 10px; }
.chara-group h3 { margin: 0 0 6px; font-size: 12px; font-weight: normal; color: #7a6a62; }
details.chara-group summary { cursor: pointer; font-size: 12px; color: #7a6a62; list-style: none; display: flex; align-items: center; gap: 6px; }
details.chara-group summary::-webkit-details-marker { display: none; }
details.chara-group summary::before { content: ''; width: 5px; height: 5px; border-right: 2px solid #5ea8a7; border-bottom: 2px solid #5ea8a7; transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
details.chara-group[open] summary::before { transform: rotate(45deg); }
details.chara-group[open] summary { margin-bottom: 6px; }
.chara-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chara { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px 3px; border: 1px solid #ece3db; border-radius: 10px; background: #f6f1ec; cursor: pointer; min-width: 0; }
.chara img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.chara span { font-size: 10.5px; color: #6b5a52; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chara.on { box-shadow: 0 0 0 2px #5ea8a7; border-color: #5ea8a7; background: #fff; }
.chara-new { border: 1.5px dashed #b9cfcf; background: transparent; text-decoration: none; }
.chara-new:hover { border-color: #5ea8a7; background: #fff; }
.chara-new b { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.chara-new b::before { content: '+'; font-size: 26px; font-weight: normal; line-height: 1; color: #5ea8a7; }
.chara-new span { color: #5ea8a7; font-weight: bold; }

.faces { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.faces figure { margin: 0; text-align: center; background: #f6f1ec; border-radius: 10px; padding: 4px 2px; }
.faces img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.faces figure.now { box-shadow: 0 0 0 2px #5ea8a7; }
.faces figcaption { font-size: 11px; color: #6b5a52; }
#pickBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#pickBtns .btn { width: 100%; }
.picker { margin-top: 10px; }
.picker-title { margin: 0 0 6px; font-size: 12px; color: #6b5a52; }
.picker-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.picker-list button { padding: 0; border: 1px solid #ece3db; border-radius: 10px; background: #f6f1ec; cursor: pointer; aspect-ratio: 1; overflow: hidden; }
.picker-list button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-list button.on { box-shadow: 0 0 0 2px #5ea8a7; border-color: #5ea8a7; }
.picker-list button.wait { opacity: .35; }

/* 小窓（Document Picture-in-Picture）に出したとき */
body.pip .stage { position: fixed; inset: 0; height: auto; border-radius: 0; }
.stage-away { align-items: center; color: #9a8a80; background: repeating-linear-gradient(45deg, #efe7e0 0 12px, #f6f1ec 12px 24px); }

/* 指で触る端末（スマホ・タブレット）には、「小窓で出す」を出さない（ユーザー判断 2026-10-21。voice.js も、使えないブラウザでは隠す） */
@media (hover: none) and (pointer: coarse) { .tb-out { display: none; } }

/* スマホ: キャラ → すぐ下にマイク・背景・出し方 → キャラの一覧（横に流す1列）→ 顔・動き（開いたときだけ） */
@media (max-width: 800px) {
  .main { flex-direction: column; align-items: stretch; padding: 10px; gap: 10px; }
  .stage-wrap { flex: none; }
  .stage { height: min(50vh, 440px); }
  .toolbar { gap: 8px 12px; }
  .tb-mic { flex-basis: 100%; }
  .tb-out { margin-left: auto; }
  .panel { width: auto; flex: none; }
  .panel-head { order: -1; }
  .chara-list { display: flex; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
  .chara { flex: 0 0 60px; }
}

/* 使い方・よくある質問（キャラの下。PC は2列、スマホは1列。幅は上のキャラ＋右の列（660＋18＋320）にそろえる） */
.guide { width: 100%; max-width: 1034px; margin: 6px auto 40px; padding: 0 18px; display: flex; flex-direction: column; gap: 16px; }
.guide-intro { margin: 0; padding: 0 4px; font-size: 13.5px; line-height: 1.9; color: #5a4a42; }
.guide-card { background: #fff; border: 1px solid #ece3db; border-radius: 14px; padding: 16px 20px; }
.guide h2 { margin: 0 0 12px; font-size: 16px; color: #00293c; }
.guide h3 { margin: 0; font-size: 14px; color: #3a2e2a; }
.guide p, .guide ul, .guide ol.steps { margin: 0; font-size: 13px; line-height: 1.8; color: #5a4a42; }
.guide a { color: #5ea8a7; }
.howto { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.howto > li { counter-increment: step; position: relative; padding-left: 34px; }
.howto > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: #00293c; color: #fff; font-size: 13px; font-weight: bold; display: flex; align-items: center; justify-content: center; }
.howto h3 { margin: 2px 0 4px; }
.guide-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.qa { border-top: 1px solid #f1ebe5; }
.qa:first-of-type { border-top: 0; }
.qa summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 2px; }
.qa summary::-webkit-details-marker { display: none; }
.qa summary h3 { flex: 1; }
.qa summary::after { content: ''; flex: none; width: 7px; height: 7px; border-right: 2px solid #b9a89c; border-bottom: 2px solid #b9a89c; transform: rotate(45deg); margin: -4px 4px 0; transition: transform .15s; }
.qa[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.qa.faq summary h3::before { content: 'Q. '; color: #5ea8a7; }
.qa-body { padding: 0 2px 12px; display: flex; flex-direction: column; gap: 6px; }
.guide ol.steps { padding-left: 1.4em; }
.guide ol.steps li, .qa-body ul li { margin: 2px 0; }
.qa-body ul { padding-left: 1.2em; }
@media (max-width: 800px) { .guide { padding: 0 10px; gap: 10px; } .howto, .guide-cols { grid-template-columns: 1fr; gap: 10px; } .howto { gap: 12px; } }
