/* ダサスラ★メーカー — ツール本体 */
:root {
  --bg: #f1efe9; --pane: #ffffff; --line: #e3ddd0; --line2: #ddd6c6;
  --ink: #26221c; --mute: #8a8271;
  --pink: #e6007a; --pink-d: #b30061; --pink-l: #fdeef6;
  --yel: #ffe600; --shadow: #26221c;
  --danger: #c23a2b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  font-size: 13px; line-height: 1.6; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body.lock { overflow: hidden; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--pink); }
.eyebrow { font-size: 11px; font-weight: 700; color: var(--mute); letter-spacing: .08em; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.now { font-size: 11px; color: var(--mute); font-weight: 700; }
.note { font-size: 12px; color: var(--mute); line-height: 1.7; margin: 8px 0 0; }

/* ボタン：ちょっとダサい立体 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; font-size: 13px; padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 2px solid var(--ink); background: #fff; color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s, background .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--pink-l); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 3px 3px 0 var(--ink); }
.btn.key { background: var(--pink); border-color: var(--pink-d); color: #fff; box-shadow: 3px 3px 0 var(--pink-d); }
.btn.key:hover { background: var(--pink-d); }
.btn.key:active { box-shadow: 1px 1px 0 var(--pink-d); }
.btn.line { border-color: var(--pink); color: var(--pink); box-shadow: 3px 3px 0 var(--pink); }
.btn.line:active { box-shadow: 1px 1px 0 var(--pink); }
.btn.mini { font-size: 12px; padding: 6px 10px; border-width: 1px; box-shadow: 2px 2px 0 var(--ink); border-radius: 6px; }
.btn.mini:active { box-shadow: 0 0 0 var(--ink); }
.btn.mini:disabled { box-shadow: 2px 2px 0 var(--ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); box-shadow: 2px 2px 0 var(--danger); }
.btn.danger:hover { background: #fbeeec; }

/* レイアウト */
#app {
  display: grid; height: 100dvh; min-height: 480px;
  grid-template-columns: 176px 1fr 250px;
  grid-template-rows: 58px 1fr 110px;
  grid-template-areas: "top top top" "mats stage panel" "films films films";
}
#top {
  grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: var(--pane); border-bottom: 3px solid transparent;
  border-image: repeating-linear-gradient(-45deg, var(--yel) 0 12px, var(--ink) 12px 24px) 3;
}
.logo { margin: 0; font-family: 'DotGothic16', monospace; font-weight: 400; font-size: 23px; letter-spacing: .02em; white-space: nowrap; }
.logo span { color: var(--pink); display: inline-block; animation: logostar 1.6s ease-in-out infinite; }
@keyframes logostar { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.35) rotate(20deg); } }
.tagline { margin: 0; font-size: 12px; color: var(--mute); white-space: nowrap; }
.topacts { margin-left: auto; display: flex; gap: 8px; align-items: center; }

#mats { grid-area: mats; background: var(--pane); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
#matlist { display: flex; flex-direction: column; gap: 6px; }
.mat {
  display: flex; align-items: center; gap: 9px; text-align: left; width: 100%;
  font-weight: 700; font-size: 12.5px; padding: 6px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line2); background: #fff; color: var(--ink); transition: border-color .15s, background .15s, transform .08s;
}
.mat:hover { border-color: var(--pink); background: #fdf7fa; }
.mat:active { transform: scale(.97); }
.mat .chip { width: 48px; height: 32px; flex: none; border-radius: 5px; background: #f6f3ec; border: 1px solid var(--line); }
.mat .chip.img { background: linear-gradient(135deg, #8fd3ff 60%, #2e8b2e 60%); }
.pickbtn { border-style: dashed; border-color: #b7ae98; background: #fbfaf6; margin-top: 4px; }

#stagewrap { grid-area: stage; position: relative; display: flex; align-items: center; justify-content: center; background: #dcd8cc; overflow: hidden;
  background-image: radial-gradient(#cfc9ba 1px, transparent 1px); background-size: 16px 16px; }
#stagewrap.over::after { content: '画像をドロップして追加'; position: absolute; inset: 12px; border: 3px dashed var(--pink); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--pink); background: rgba(253, 238, 246, .8); pointer-events: none; }
#stage { display: block; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); touch-action: none; background: #fff; }
#elanimrow { margin-top: 12px; }
#freeze { position: absolute; top: 10px; right: 12px; display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--ink); background: rgba(255, 255, 255, .85); border: 1px solid var(--line2); border-radius: 6px; padding: 4px 8px; cursor: pointer; user-select: none; white-space: nowrap; z-index: 2; }
#freeze input { accent-color: var(--pink); margin: 0; }

#panel { grid-area: panel; background: var(--pane); border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.grp { border-top: 1px solid #eee8da; padding-top: 12px; }
.grp:first-child { border-top: 0; padding-top: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.seg button { font-size: 11.5px; font-weight: 700; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line2); background: #fff; cursor: pointer; }
.seg button:hover { border-color: var(--pink); }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.colr { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.colr input[type=color] { width: 32px; height: 26px; padding: 1px 2px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.sw { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .25); cursor: pointer; padding: 0; }
.sw:hover { outline: 2px solid var(--pink); outline-offset: 1px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.chk input { accent-color: var(--pink); }
.sel { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.sel select { font-weight: 500; padding: 6px 8px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; width: 100%; max-width: 100%; min-width: 0; }
.sel.inline { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.txt { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.txt input { font-weight: 500; padding: 7px 8px; border: 1px solid var(--line2); border-radius: 6px; width: 100%; min-width: 0; }
.rng { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.rng span { color: var(--pink); }
.rng input[type=range] { width: 100%; accent-color: var(--pink); margin: 0; }
#eltext { width: 100%; padding: 8px; border: 1px solid var(--line2); border-radius: 8px; resize: vertical; margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
.acts4 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }
.acts .btn { flex: 1 1 auto; }
.about { display: flex; width: 100%; margin: 24px 0 10px; }
.flinks { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; }
.flinks a { color: var(--mute); text-decoration: none; }
.flinks a:hover { color: var(--pink); text-decoration: underline; }

/* ダサブースト：普段は閉じたボタン。開くと注意の縞 */
.boostbox { border: 0; padding: 0; margin-top: 2px; background: none; }
.boostbox summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none;
  font-size: 12.5px; font-weight: 700; letter-spacing: .04em; color: var(--yel);
  background: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 8px 12px;
  box-shadow: 3px 3px 0 var(--danger); transition: transform .08s, box-shadow .08s, background .15s;
}
.boostbox summary::-webkit-details-marker { display: none; }
.boostbox summary .lbl { flex: 1; }
.boostbox summary .tag { font-size: 10px; letter-spacing: .1em; color: #fff; background: var(--danger); padding: 1px 7px; border-radius: 4px; }
.boostbox summary::after { content: '▸'; color: var(--yel); font-size: 13px; transition: transform .15s; }
.boostbox[open] summary::after { transform: rotate(90deg); }
.boostbox summary:hover { background: #3a3428; }
.boostbox summary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--danger); }
.boostbox .body { margin-top: 8px; border: 2px dashed var(--danger); border-radius: 8px; padding: 10px;
  background: repeating-linear-gradient(-45deg, #fff5b8 0 10px, #ffffff 10px 20px); }
.boostbox .note { margin: 0 0 8px; color: #6b4a1e; }
.boostbox .acts1 { display: grid; gap: 6px; margin: 6px 0 10px; }
.boostbox, .boostbox .body { min-width: 0; }
.boostbox .btn { white-space: normal; min-width: 0; padding-left: 6px; padding-right: 6px; }

.chk.vloop { align-self: end; margin-bottom: 12px; }
.save-preview video { max-width: 100%; max-height: 60vh; border: 1px solid var(--line); background: #000; }
#films { grid-area: films; background: var(--pane); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
#thumbs { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; padding: 4px; }
.thumb { position: relative; flex: none; padding: 0; border: 2px solid #cfc7b4; border-radius: 6px; background: #fff; cursor: pointer; overflow: hidden; line-height: 0; }
.thumb.on { border-color: var(--pink); box-shadow: 0 0 0 2px var(--pink-l); }
.thumb canvas { display: block; }
.thumb span { position: absolute; left: 4px; top: 3px; font-size: 11px; font-weight: 700; line-height: 1; padding: 2px 5px; background: rgba(255, 255, 255, .85); border-radius: 4px; }
.filmacts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: none; max-width: 300px; }

/* 再生 */
#playerWrap { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
#pstage { flex: 1; min-height: 0; position: relative; }
#pcv { display: block; cursor: pointer; }
#pbar { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #1a1a1a; color: #ddd; }
#pbar .now { color: #ddd; }
#pbar .sp { flex: 1; }
#pbar .btn { background: #2a2a2a; color: #fff; border-color: #555; box-shadow: 2px 2px 0 #000; }
#pbar .sel select { background: #2a2a2a; color: #fff; border-color: #555; }

/* モーダル */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(38, 34, 28, .6); overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); opacity: 0; transition: opacity .2s; }
.modal.is-open { opacity: 1; }
/* 収まるときは上下中央、はみ出すときは上寄せでオーバーレイがスクロールする */
.modal.center { display: flex; flex-direction: column; }
.modal.center .card { margin: auto; width: 100%; }
.modal .card { background: #fff; border-radius: 14px; max-width: 520px; margin: 0 auto; padding: 16px 18px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); border: 3px solid var(--ink); transform: translateY(10px); transition: transform .25s; display: flex; flex-direction: column; }
.modal.is-open .card { transform: none; }
.mhead { display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.modal section { border-top: 1px solid #eee8da; padding: 12px 0 4px; }
.modal h3 { margin: 0 0 8px; font-size: 13px; color: var(--pink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.save-preview { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; background: #f1efe9; border-radius: 8px; padding: 8px; margin: 6px 0; }
.save-preview img { max-width: 100%; max-height: 60vh; width: auto; height: auto; object-fit: contain; -webkit-touch-callout: default; border: 1px solid var(--line); }
#saveModal .acts { flex-shrink: 0; margin-top: 10px; }
.modal .acts { margin-top: 14px; }              /* 説明文とボタンの間を空ける */
.modal h3 + .acts { margin-top: 4px; }          /* 見出し直下のボタンは詰める */
.pcChk { margin-top: 14px; }

/* PC推奨モーダル：ぽよんと出る */
.modal .card.poyon { transform: scale(.6); opacity: 0; transition: none; }
.modal.is-open .card.poyon { animation: poyon .55s cubic-bezier(.34, 1.56, .64, 1) forwards; }
@keyframes poyon { from { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } to { transform: scale(1); opacity: 1; } }
.pcLead { margin: 6px 0 8px; font-size: 13px; }
.pcWhy { margin: 0 0 6px; padding-left: 1.2em; font-size: 12.5px; line-height: 1.7; }
.pcWhy li { margin-bottom: 6px; }
.pcWhy b { display: block; color: var(--pink); }
.pcChk { justify-content: center; margin: 12px 0 0; font-weight: 500; color: var(--mute); }
#err { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--danger); color: #fff; font-weight: 700; padding: 10px 16px; border-radius: 8px; z-index: 70; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }

@media (prefers-reduced-motion: reduce) { .logo span { animation: none; } .modal, .modal .card { transition: none; } }

/* 中幅：素材を細く */
@media (max-width: 1080px) {
  #app { grid-template-columns: 150px 1fr 230px; }
  .tagline { display: none; }
}

/* スマホ：縦積み。スライドを上部に固定し、その下の設定をスクロールして編集する */
@media (max-width: 760px) {
  body { font-size: 14px; }
  input, select, textarea { font-size: 16px; } /* iOS のフォーカス時ズームを防ぐ */
  #app { height: auto; min-height: 100dvh; display: flex; flex-direction: column; }
  #top { order: 0; position: sticky; top: 0; z-index: 12; flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 6px 10px; }
  .logo { font-size: 19px; }
  .tagline { display: none; }
  .topacts { width: 100%; margin: 0; display: flex; gap: 5px; }
  .topacts .btn { flex: 1 1 auto; padding: 8px 4px; font-size: 12px; border-radius: 6px; box-shadow: 2px 2px 0 var(--ink); }
  .topacts .btn.key { box-shadow: 2px 2px 0 var(--pink-d); }
  .topacts .btn.line { box-shadow: 2px 2px 0 var(--pink); }
  #undo, #redo { flex: 0 0 auto; }
  #stagewrap { order: 1; position: sticky; top: var(--toph, 84px); z-index: 11; height: auto; padding: 8px 6px 8px; box-shadow: 0 6px 12px -8px rgba(0, 0, 0, .35); }
  #stage { max-width: 100%; }
  #freeze { top: 12px; right: 10px; font-size: 11px; padding: 3px 7px; }
  #mats { order: 2; border-right: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 10px; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; -webkit-overflow-scrolling: touch; }
  #mats .eyebrow { display: none; }
  #matlist { flex-direction: row; gap: 6px; }
  .mat { flex-direction: column; width: 70px; padding: 6px 4px; gap: 4px; font-size: 11px; text-align: center; }
  .mat .chip { width: 54px; height: 34px; }
  .pickbtn { margin: 0; }
  #panel { order: 3; border-left: 0; padding: 12px 12px 20px; }
  #selgrp { order: -1; border-top: 0; padding-top: 0; }
  .grp { padding-top: 12px; }
  .acts4 .btn { padding: 9px 8px; }
  #films { order: 4; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px 18px; }
  #thumbs { width: 100%; }
  .filmacts { max-width: none; }
  .filmacts .btn { padding: 9px 10px; }
  .row2 { grid-template-columns: 1fr; }
  #pbar { flex-wrap: wrap; gap: 8px; }
}
