/* 制作中だけ、画面全体をキャンバスの作業場所にする。 */
#studio { display: flex; flex-direction: column; }
#studio[hidden] { display: none; }
.studio-heading { order: -1; }
.editor-dock { display: none; }
body.editing { overflow: hidden; overscroll-behavior: none; background: #e9f0f2; }
body.editing:has(#studio:not([hidden])) main { width: 100%; max-width: none; margin: 0; padding: 0; }
body.editing main>header, body.editing .intro, body.editing .archive, body.editing .about, body.editing footer { display: none; }
body.editing #studio { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0,1fr) auto auto; }
.editor-topbar { display: flex; align-items: center; gap: 10px; padding: max(7px,env(safe-area-inset-top)) 16px 7px; border-bottom: 1px solid #d6e2e6; background: #fbfdfcf5; z-index: 1; }
.editor-home { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; color: #5f7c88; }
.editor-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; white-space: nowrap; }
.editor-name span { display: block; margin-top: 3px; color: #82999f; font-size: 9px; font-weight: 400; }
.editor-topbar .studio-actions { flex: none; align-items: center; gap: 12px; margin: 0; }
.editor-topbar .history-controls { flex: none; gap: 2px; }
.editor-topbar .history-controls button { flex: none; min-width: 44px; min-height: 44px; padding: 7px; border: 0; background: transparent; }
.editor-topbar .history-controls span { display: none; }
.editor-topbar #finish-art { min-height: 40px; padding: 8px 13px; font-size: 11px; border-radius: 10px; box-shadow: none; }
.editor-topbar #finish-art .ui-icon { display: none; }
body.editing .studio-layout { display: block; min-height: 0; padding: 0; }
body.editing .canvas-area { position: relative; top: auto; display: grid; place-items: center; width: 100%; height: 100%; min-height: 0; container-type: size; background-image: radial-gradient(#7896a320 .7px,transparent .7px); background-size: 14px 14px; }
body.editing .art-frame { width: min(calc(100cqw - 24px),calc((100cqh - 24px) * 33 / 38)); min-width: 0; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 2px; box-shadow: 0 5px 24px #304c6419,0 0 0 1px #476b7d18; }
body.editing #art { width: 100%; height: auto; }
body.editing .art-frame figcaption, body.editing #event { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.editing .studio-panel { display: none; }
body.editing .studio-heading { order: initial; display: block; margin: 0; min-height: 32px; padding: 5px 18px 7px; }
body.editing .studio-heading .section-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
body.editing .instruction { max-width: none; margin: 0; font-size: 10px; line-height: 1.5; color: #64808c; text-align: center; }
body.editing .canvas-invitation { font-size: 11px; padding: 10px 17px; border-color: #ffffffb0; background: #fffefaad; }
body.editing .editor-dock { display: block; padding: 0 14px max(12px,env(safe-area-inset-bottom)); }
.editor-toolbar { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); width: min(100%,440px); margin: auto; padding: 5px; border: 1px solid #d1e0e3; border-radius: 20px; background: #fffefaf5; box-shadow: 0 4px 20px #214c650b,inset 0 1px 0 white; }
.editor-toolbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; min-height: 60px; border: 0; border-radius: 14px; background: transparent; font-size: 10px; color: #597583; padding: 6px 3px; }
.editor-toolbar button[aria-expanded=true] { background: #e7f2f6; color: #176486; }
.editor-toolbar .ui-icon { width: 25px; height: 25px; }
.toolbar-color { display: block; width: 24px; height: 24px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #a9bdc5; }
.toolbar-canvas { display: block; width: 22px; height: 25px; border: 2px solid #fff; border-radius: 3px; box-shadow: 0 0 0 1px #a9bdc5; }
#auto-playback { width: min(100%,440px); margin: 0 auto 8px; padding: 0 6px; }
body.editing #status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); }
body.editing #error:not([hidden]) { position: fixed; z-index: 5; inset: 65px 12px auto; background: #eff8ff; }

/* 色・道具は必要なときに開く。キャンバスの大きさは変えない。 */
#editor-settings { position: fixed; inset: auto 20px 104px auto; width: min(380px,calc(100% - 24px)); max-height: min(620px,calc(100dvh - 150px)); margin: 0; padding: 17px; border: 1px solid #d1e0e4; border-radius: 22px; background: #fffefb; color: #193f55; box-shadow: 0 16px 60px #1d435a24; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
#editor-settings::backdrop { background: #2646570d; }
.editor-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -6px -5px 10px 0; }
.editor-panel-heading h2 { margin: 0; font-size: 15px; font-weight: 500; }
#editor-panel-close { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 0; padding: 8px; border-radius: 50%; background: #eef4f3; color: #6a828d; }
#editor-panel-close .ui-icon { width: 20px; height: 20px; }
#editor-settings .tools, #editor-settings #play-tools { grid-template-columns: repeat(3,minmax(0,1fr)); }
#editor-settings .tools button { min-height: 68px; font-size: 11px; }
#editor-settings .tools .ui-icon { width: 28px; height: 28px; }
#editor-settings .mode-switch { margin-bottom: 10px; }
#editor-settings .tool-sample { margin-top: 12px; padding: 8px; }
#editor-settings #tool-hint { font-size: 10px; }
#editor-settings .revealed-colors { margin: 6px 2px 16px; }
#editor-settings .extra-swatches { gap: 8px; }
#editor-settings .panel-caption { margin: 8px 0; color: #6a828d; font-size: 10px; }
#editor-settings .settings-row { display: block; }
#editor-settings .brush-label { min-height: 52px; font-size: 12px; }
#editor-settings .density-setting { border-top: 1px solid #e0e8e8; margin-top: 8px; padding-top: 8px; }
#editor-settings #drawing-help { display: block; }
#editor-settings .canvas-options>label { margin-top: 18px; }
@media (min-width:761px) {
  .editor-topbar { padding-inline: 24px; }
  .editor-name { font-size: 14px; }
  body.editing .art-frame { width: min(calc(100cqw - 72px),calc((100cqh - 36px) * 33 / 38)); }
  body.editing .instruction { font-size: 11px; }
  #editor-settings { right: max(20px,calc((100vw - 1000px) / 2)); }
}
@media (max-width:760px) {
  .editor-topbar { gap: 5px; padding-inline: 8px; }
  .editor-topbar .studio-actions { gap: 3px; }
  .editor-name { font-size: 12px; }
  body.editing .art-frame { width: min(calc(100cqw - 12px),calc((100cqh - 16px) * 33 / 38)); }
  #editor-settings { inset: auto 12px max(102px,calc(90px + env(safe-area-inset-bottom))) 12px; margin-inline: auto; padding: 14px; border-radius: 22px; }
}
@media (max-height:500px) and (orientation:landscape) {
  body.editing #studio { grid-template-columns: minmax(0,1fr) 90px; grid-template-rows: auto minmax(0,1fr) auto; }
  .editor-topbar { grid-column: 1/-1; }
  body.editing .studio-layout { grid-area: 2 / 1; }
  body.editing .studio-heading { grid-area: 3 / 1; }
  body.editing .editor-dock { grid-area: 2 / 2 / 4; padding: 6px 10px; }
  .editor-toolbar { grid-template-columns: 1fr; }
  .editor-toolbar button { min-height: 50px; }
  #editor-settings { inset: auto 100px 12px auto; max-height: calc(100dvh - 76px); }
}
