/*
 * デザイントークン。見た目を変えたいときはまずここだけ触る。
 * 白を基調にしたシンプルなデザイン（細い線・影なし・モノトーン＋差し色は最小限）
 */
:root {
  --font: 'Inter', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;

  --bg: #ffffff;
  --bg-soft: #f5f5f6;
  --surface: #ffffff;
  --ink: #18181b;
  --ink-soft: #71717a;
  --line: #e4e4e7;
  --line-soft: #ededf0;

  --primary: #18181b;
  --primary-ink: #ffffff;
  --accent: #f4f4f5;
  --sun: #f4f4f5;
  --sky: #f4f4f5;
  --danger: #dc2626;
  --focus: #2563eb;

  --radius: 12px;
  --radius-sm: 8px;
  --border: 1px solid var(--line);
  --shadow: none;
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.06);

  --header-h: 60px;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- layout ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.app.fullscreen { height: 100%; }
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page.narrow { max-width: 460px; }
.center { display: grid; place-items: center; padding: 48px 16px; color: var(--ink-soft); }

/* ---------- header ---------- */
.header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: var(--border);
  position: sticky; top: 0; z-index: 20;
  flex-shrink: 0;
}
.logo { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo img { width: 32px; height: 32px; flex: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 500; color: var(--ink-soft); white-space: nowrap; }
.nav a:hover { background: var(--bg-soft); color: var(--ink); }
.nav a.active { background: var(--bg-soft); color: var(--ink); font-weight: 600; }
.header .user { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 500; font-size: 14px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg-soft); }
.btn:active:not(:disabled) { opacity: .8; }
.btn[hidden] { display: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { background: #3f3f46; border-color: #3f3f46; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn.danger:hover:not(:disabled) { background: #fef2f2; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--bg-soft); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; }
.input, textarea.input, select.input {
  width: 100%; padding: 9px 12px; border: var(--border); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
textarea.input { resize: vertical; min-height: 84px; }

.error { color: var(--danger); font-weight: 500; margin: 8px 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.note { color: var(--ink-soft); font-size: 13px; }
.tabs { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--bg-soft); gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 6px; font-weight: 500; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-soft); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: var(--shadow-soft); }
.badge.private { background: var(--ink); color: #fff; }

.card { background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 460px; }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

/* ---------- hero / gallery ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  aspect-ratio: 16 / 9;
  display: flex; flex-direction: column; justify-content: flex-start;
  border-radius: var(--radius);
  background: #fdf1e1;
  padding: 48px 40px; margin-bottom: 28px;
}
.hero-media { position: absolute; inset: 0; z-index: -1; }
.hero-media img, .hero-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* 空の明るい部分に文字を載せるので、左上だけ薄く白で覆って読みやすくする */
.hero-media::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, rgba(255, 250, 242, .92) 0%, rgba(255, 250, 242, .7) 35%, rgba(255, 250, 242, 0) 62%);
}
@media (max-width: 600px) {
  .hero { aspect-ratio: 4 / 5; padding: 28px 20px; }
  .hero-media::after {
    background: linear-gradient(180deg, rgba(255, 250, 242, .92) 0%, rgba(255, 250, 242, .7) 38%, rgba(255, 250, 242, 0) 60%);
  }
}
.hero h1 { font-size: clamp(26px, 5vw, 40px); margin-bottom: 10px; }
.hero p { margin: 0 0 24px; max-width: 34em; color: var(--ink-soft); line-height: 1.7; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.work-card { display: block; background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .1s; }
.work-card { transition: border-color .12s, box-shadow .12s; }
.work-card:hover { border-color: #d4d4d8; box-shadow: 0 4px 16px rgba(0, 0, 0, .06); }
.work-card .thumb { aspect-ratio: 4 / 3; background: var(--bg-soft); display: grid; place-items: center; font-size: 44px; border-bottom: var(--border); position: relative; }
.work-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.work-card .thumb .badge { position: absolute; left: 8px; top: 8px; z-index: 2; pointer-events: none; }
.work-card .thumb .badge.private { left: auto; right: 8px; }
.work-card .meta { display: block; padding: 12px 14px 14px; }
.work-card .thumb-link { display: grid; place-items: center; width: 100%; height: 100%; }
/* ワールドのカード: エリアのサムネイルを3秒ずつクロスフェード */
.work-card .slides { display: grid; width: 100%; height: 100%; }
.work-card .slides img { grid-area: 1 / 1; opacity: 0; }
.work-card .slides img:first-child { opacity: 1; }
.work-card .slides.n2 img { animation: slides2 6s infinite; }
.work-card .slides.n3 img { animation: slides3 9s infinite; }
.work-card .slides img:nth-child(2) { animation-delay: 3s; }
.work-card .slides img:nth-child(3) { animation-delay: 6s; }
@keyframes slides2 { 0% { opacity: 0; } 7.5%, 50% { opacity: 1; } 57.5%, 100% { opacity: 0; } }
@keyframes slides3 { 0% { opacity: 0; } 5%, 33.3% { opacity: 1; } 38.3%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .work-card .slides img { animation: none; } }
.work-card .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-card .sub { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.detail > * { min-width: 0; }
.detail h1, .detail .desc p, .credits li { overflow-wrap: anywhere; }
.viewer { aspect-ratio: 4 / 3; min-height: 240px; max-width: 100%; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; background: var(--bg-soft); }
.detail .side { display: grid; gap: 14px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.credits { margin: 0; padding-left: 18px; font-size: 14px; }
pre.json { max-height: 240px; overflow: auto; background: var(--bg-soft); border: var(--border); border-radius: var(--radius-sm); padding: 10px; font-size: 12px; }

/* ---------- editors ---------- */
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr) ; }
.editor.three { grid-template-columns: 280px minmax(0, 1fr) 300px; }
@media (max-width: 900px) {
  /* スマホ: 3Dビューを上に固定し、パネルは潰さずに縦に並べてエディタ全体をスクロールさせる */
  .editor, .editor.three { display: flex; flex-direction: column; overflow-y: auto; }
  .editor .canvas { order: -1; flex: none; height: 45vh; min-height: 240px; position: sticky; top: 0; z-index: 5; border-bottom: var(--border); }
  .editor .panel { flex: none; overflow: visible; border-right: 0 !important; border-left: 0 !important; border-top: var(--border); }
  .editor .panel:first-of-type { border-top: 0; }
  /* 選んだ素材の位置・回転・大きさを素材一覧より先に出す */
  .editor.props-first .panel.right { order: 0; border-top: 0; }
  .editor.props-first .panel:not(.right) { order: 1; border-top: var(--border); }
  /* 指で押しやすい大きさに。16px 未満だと iOS が入力時に勝手にズームする */
  .editor .num-grid input, .editor .select-field, .editor .input { font-size: 16px; padding: 10px; }
  .editor .tabs button { padding: 10px 14px; }
}
.panel { background: var(--surface); border-right: var(--border); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.panel.right { border-right: 0; border-left: var(--border); }
.panel h3 { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: .04em; text-transform: uppercase; }
.canvas { position: relative; min-height: 0; background: var(--bg-soft); }
.canvas > div:not(.hud) { position: absolute !important; inset: 0; }
.canvas .hud { position: absolute; left: 12px; bottom: 12px; z-index: 2; font-size: 12px; font-weight: 500; background: rgba(255,255,255,.92); border: var(--border); border-radius: 6px; padding: 4px 10px; pointer-events: none; }
.canvas .canvas-light { position: absolute; right: 12px; top: 12px; z-index: 2; display: flex; align-items: center; gap: 8px; }
.canvas .canvas-light input[type=range] { width: 110px; }
.canvas .canvas-light select { padding: 6px 8px; border: var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.subbar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; background: var(--surface); border-bottom: var(--border); flex-wrap: wrap; flex-shrink: 0; }
.subbar .sp { flex: 1; }
.more-menu { position: relative; }
.more-menu > .btn { min-width: 34px; padding-left: 8px; padding-right: 8px; font-weight: 700; letter-spacing: .05em; }
.more-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 200px;
  display: grid; padding: 4px; background: var(--surface); border: var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
}
.more-menu-list button { border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 6px; font-size: 14px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.more-menu-list button:hover:not(:disabled) { background: var(--bg-soft); }
.more-menu-list button:disabled { opacity: .45; cursor: not-allowed; }
.more-menu-list button.danger { color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  cursor: pointer; animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@media (max-width: 900px) {
  /* スマホ: ツールバーを詰めて1行に収める */
  .subbar { padding: 8px 12px; gap: 6px; }
  .subbar .tabs button, .subbar .tabs .tabs-link { padding: 6px 10px; font-size: 13px; }
  .subbar .btn.sm { padding: 5px 9px; }
}

.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 6px; border: var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-weight: 500; font-size: 13px; cursor: pointer; text-align: center;
}
.chip:hover { background: var(--bg-soft); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch { aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px solid rgba(0, 0, 0, .1); cursor: pointer; padding: 0; }
.swatch.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.color-input { width: 100%; height: 40px; border: var(--border); border-radius: var(--radius-sm); padding: 2px; background: var(--surface); cursor: pointer; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; text-align: left; width: 100%;
}
.list-item:hover { background: var(--bg-soft); }
.list-item.on { background: var(--bg-soft); border-color: var(--ink); }
.list-item img, .list-item .ph { width: 44px; height: 33px; border-radius: 8px; object-fit: cover; background: var(--bg-soft); flex-shrink: 0; display: grid; place-items: center; }
.list-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-item .n { font-size: 12px; color: var(--ink-soft); }

.num-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.num-grid label { display: grid; gap: 2px; font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.num-grid input { width: 100%; padding: 6px 8px; border: var(--border); border-radius: 6px; color: var(--ink); }

.select-field { width: 100%; padding: 8px 10px; border: var(--border); border-radius: var(--radius-sm); background: var(--surface); }

.anim-card { border: var(--border); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; background: var(--surface); }
.anim-card header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.slider { display: grid; gap: 2px; font-size: 13px; font-weight: 500; }
.slider .lab { display: flex; justify-content: space-between; }
.slider input[type=range] { width: 100%; accent-color: var(--ink); }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-sm); background: var(--bg-soft); }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; font-weight: 500; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.seg.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; box-sizing: border-box; }
.seg.grid3 button { padding: 4px 6px; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-soft); }
.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.preset { display: grid; gap: 2px; padding: 10px; border: var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; text-align: left; }
.preset:hover:not(:disabled) { background: var(--bg-soft); }
.preset:disabled { opacity: .4; cursor: not-allowed; }
.preset.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.preset b { font-size: 14px; font-weight: 600; }
.preset small { color: var(--ink-soft); font-size: 11px; }
.empty { padding: 16px; text-align: center; color: var(--ink-soft); border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: 14px; }

/* ================= PHPページ用の追加スタイル ================= */
#root { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabs a { padding: 6px 14px; border-radius: 6px; font-weight: 500; font-size: 14px; color: var(--ink-soft); }
.tabs a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-soft); }
.header form { margin: 0; }
.flash { padding: 10px 16px; text-align: center; font-weight: 500; font-size: 14px; background: #f0fdf4; color: #166534; border-bottom: 1px solid #bbf7d0; }
.flash.error { background: #fef2f2; color: var(--danger); border-bottom-color: #fecaca; }
.footer { margin-top: auto; padding: 28px 16px; text-align: center; border-top: var(--border); background: var(--surface); display: grid; gap: 8px; color: var(--ink-soft); font-size: 14px; }
.footer a:hover { color: var(--ink); }
.prose-page { max-width: 780px; }
.prose h1 { margin-bottom: 4px; }
.prose h2 { font-size: 19px; margin: 28px 0 10px; }
.prose h3 { font-size: 15px; margin: 18px 0 6px; }
.prose p, .prose li { line-height: 1.7; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 22px; }
.prose a { color: var(--focus); text-decoration: underline; }
.prose code { font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--bg-soft); }
.breadcrumb { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.breadcrumb a { text-decoration: underline; }
.section { margin-bottom: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 20px; }
.section-head .more { font-weight: 500; font-size: 14px; color: var(--ink-soft); }
.section-head .more:hover { color: var(--ink); }
.search { display: flex; gap: 8px; align-items: center; }
.search .input { width: 220px; padding: 7px 12px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.pagination a { min-width: 38px; padding: 7px 12px; text-align: center; border: var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 500; font-size: 14px; }
.pagination a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.work-card .thumb .ph { font-size: 44px; }
.work-card .title { font-size: 16px; margin: 0; }
.viewer { position: relative; }
.viewer .poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer .poster.ph { display: grid; place-items: center; font-size: 72px; aspect-ratio: 4 / 3; }
.viewer .viewer-canvas { position: absolute; inset: 0; }
.viewer .viewer-hint { position: absolute; left: 12px; bottom: 12px; font-size: 12px; font-weight: 500; background: rgba(255,255,255,.92); border: var(--border); border-radius: 6px; padding: 3px 10px; pointer-events: none; }
.viewer.ready .poster { visibility: hidden; }
.viewer.error .viewer-hint { display: none; }
.detail { margin-bottom: 40px; }
.detail .desc { margin-top: 20px; }
.detail .desc h2 { font-size: 18px; margin-bottom: 8px; }
.detail .desc p { margin: 0; line-height: 1.8; }
.detail h1 { font-size: 24px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 16px; font-size: 14px; }
.facts dt { color: var(--ink-soft); font-weight: 400; }
.facts dd { margin: 0; font-weight: 500; }
.license { margin: -6px 0 16px; line-height: 1.6; }
.license a { text-decoration: underline; }
.stack { display: grid; gap: 10px; }
.stack .btn { width: 100%; }

/* ---------- スマホ幅: ヘッダーのナビを2段目に折り返す ---------- */
@media (max-width: 720px) {
  .header { height: auto; flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .header .logo { font-size: 19px; }
  .header .user { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; }
  .nav a { padding: 6px 12px; font-size: 14px; }
  .toolbar h1 { font-size: 22px; }
  .search .input { width: 100%; }
  .search { width: 100%; }
}

/* 一覧カードの再生ボタン(JSが読み込まれるまで隠す)。押すと .mix-modal のポップアップで再生する */
.work-card .play { display: none; position: absolute; right: 8px; bottom: 8px; z-index: 3; width: 44px; height: 44px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .95); color: var(--ink); font: inherit; font-size: 14px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.cards-ready .work-card .play { display: grid; }
.work-card .play::before { content: '▶'; padding-left: 2px; }
.work-card .play.night { background: #0b1330; }
.work-card .play.night::before { content: '🌙'; padding-left: 0; font-size: 18px; }
.work-card .play[data-state="loading"]::before { content: '…'; padding-left: 0; }
.work-card .play[data-state="loading"] { cursor: progress; }

/* ---------- Mix 再生ポップアップ ---------- */
.mix-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); }
.mix-modal .dialog { display: flex; flex-direction: column; width: min(960px, 100%); height: min(720px, 100%); background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, .2); overflow: hidden; }
.mix-modal header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: var(--border); }
.mix-modal h2 { flex: 1; min-width: 0; margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-modal .stage { position: relative; flex: 1; min-height: 0; background: var(--bg-soft); }
.mix-modal .stage > div:first-child { opacity: 0; transition: opacity .25s; }
.mix-modal .stage.ready > div:first-child { opacity: 1; }
.mix-modal .stage-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-soft); pointer-events: none; }
.mix-modal .toolbar { margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 10px 14px; border-top: var(--border); }
.mix-modal .group { display: flex; flex-wrap: wrap; gap: 6px; }
.mix-modal .darkness { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.mix-modal .darkness input { width: 110px; }
@media (max-width: 600px) { .mix-modal { padding: 0; } .mix-modal .dialog { border-radius: 0; border-width: 0; height: 100%; } }

/* 自動録画ダイアログ（SNS用の動画）。.frame の比率は JS が指定する */
.reel-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); }
.reel-modal .dialog { display: flex; flex-direction: column; gap: 12px; width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.reel-modal header { display: flex; align-items: center; gap: 8px; }
.reel-modal h2 { flex: 1; margin: 0; font-size: 16px; }
.reel-modal .frame { position: relative; margin: 0 auto; background: var(--bg-soft); border: var(--border); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.reel-modal .frame > div:first-child, .reel-modal .frame > video { position: absolute !important; inset: 0; width: 100%; height: 100%; }
.reel-modal .frame > video { object-fit: contain; background: #000; }
.reel-modal .frame > canvas.cap { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.reel-modal .check,
.anim-card .check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
.reel-modal .stage-msg { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .6); font-weight: 600; }
.reel-modal .rec { position: absolute; left: 10px; top: 10px; padding: 2px 10px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; }
.reel-modal .angle-drag { position: absolute; inset: 0; cursor: grab; touch-action: none; }
.reel-modal .angle-drag:active { cursor: grabbing; }
.reel-modal .bar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; flex-shrink: 0; }
.reel-modal .bar i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); }
.reel-modal .dialog > * { flex-shrink: 0; }
.reel-modal .seg { align-self: flex-start; }
.reel-modal .seg button:disabled { opacity: .5; cursor: not-allowed; }
.reel-modal .note, .reel-modal .error { margin: 0; }
.reel-modal .music-row { align-items: flex-end; }
.reel-modal .music-row .note, .reel-modal .music-row .error { padding-bottom: 8px; }
.reel-modal .zoom-row { flex-wrap: nowrap; }
.reel-modal .duration-row { align-items: center; }
.reel-modal .custom-len { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.reel-modal .custom-len input { width: 72px; }
.reel-modal .builders { display: grid; gap: 8px; }
.reel-modal .assembly { display: grid; gap: 6px; }
.reel-modal .colors { align-items: center; gap: 12px; flex-wrap: wrap; }
.reel-modal .colors > label:not(.check) { display: flex; align-items: center; gap: 6px; }
.reel-modal .colors input[type="color"] { width: 40px; height: 30px; border: var(--border); border-radius: var(--radius-sm); padding: 2px; background: var(--surface); cursor: pointer; }
.reel-modal .colors input[type="color"]:disabled { opacity: .4; cursor: not-allowed; }
.reel-modal .assembly .seg { align-self: stretch; }
.reel-modal .builders .row { align-items: center; }
.reel-modal .builders .chip { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--bg-soft); border: var(--border); }
.reel-modal .builders .chip img { width: 100%; height: 100%; object-fit: contain; }
.reel-modal .builders .chip i { font-style: normal; }
.reel-modal .builders .chip button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 10px; line-height: 18px; cursor: pointer; }
.reel-modal .builder-pick { display: grid; gap: 8px; padding: 10px; border: var(--border); border-radius: var(--radius-sm); }
.reel-modal .builder-pick input[type="search"] { flex: 1; min-width: 120px; }
.reel-modal .builder-pick .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.reel-modal .builder-pick .grid button { display: grid; gap: 2px; padding: 4px; border: var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font: inherit; font-size: 11px; }
.reel-modal .builder-pick .grid button:hover { border-color: var(--ink); }
.reel-modal .builder-pick .grid button:disabled { opacity: .5; cursor: wait; }
.reel-modal .builder-pick .grid img, .reel-modal .builder-pick .grid i { width: 100%; aspect-ratio: 1; object-fit: contain; display: grid; place-items: center; font-style: normal; background: var(--bg-soft); border-radius: 6px; }
.reel-modal .builder-pick .grid span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-modal .zoom-row .note { flex-shrink: 0; }
.reel-modal .zoom-row input[type="range"] { flex: 1; min-width: 100px; }
.reel-modal .dialog.play { width: min(1100px, 100%); }
.reel-modal .frame > img.shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.reel-modal .focus-mark { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border: 2px solid #ffd43b; border-radius: 6px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); pointer-events: none; animation: focus-tap .5s ease-out; }
@keyframes focus-tap { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.reel-modal .photo-sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 2px; border-radius: var(--radius-sm); background: var(--bg-soft); }
.reel-modal .photo-sizes button { display: grid; gap: 1px; min-width: 0; padding: 6px 4px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer; font: inherit; text-align: center; }
.reel-modal .photo-sizes button b { font-size: 13px; }
.reel-modal .photo-sizes button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.reel-modal .photo-sizes button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); }
.reel-modal .photo-sizes button.custom { grid-column: 1 / -1; }
.reel-modal .custom-size { align-items: center; gap: 6px; }
.reel-modal .custom-size label { display: flex; align-items: center; gap: 4px; }
.reel-modal .custom-size input { width: 80px; }
@media (max-width: 600px) { .reel-modal .photo-sizes { grid-template-columns: repeat(2, 1fr); } }
.reel-modal .play .frame.live { width: min(100%, calc((100vh - 200px) * 16 / 9)); aspect-ratio: 16 / 9; }
.reel-modal .play .stick { position: absolute; left: 20px; bottom: 20px; width: 112px; height: 112px; border-radius: 50%; background: rgba(255, 255, 255, .35); border: 2px solid rgba(255, 255, 255, .7); display: grid; place-items: center; touch-action: none; }
.reel-modal .play .find-banner { position: absolute; top: 32%; left: 50%; transform: translateX(-50%); display: grid; gap: 2px; width: max-content; max-width: calc(100% - 24px); padding: 8px 16px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .94); box-shadow: 0 4px 16px rgba(0, 0, 0, .15); text-align: center; font-size: 14px; pointer-events: none; }
.reel-modal .play .find-banner span { font-size: 13px; color: var(--ink-soft); }
.reel-modal .play .hunt { position: absolute; top: 12px; right: 12px; display: grid; gap: 6px; max-width: min(260px, calc(100% - 24px)); padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .92); box-shadow: 0 4px 16px rgba(0, 0, 0, .12); font-size: 13px; pointer-events: none; }
.reel-modal .play .hunt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-modal .play .hunt .icons { display: flex; flex-wrap: wrap; gap: 6px; }
.reel-modal .play .hunt .icons span { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; background: var(--bg-soft); }
.reel-modal .play .hunt .icons img { width: 100%; height: 100%; object-fit: contain; }
.reel-modal .play .hunt .icons i { font-style: normal; font-weight: 800; color: var(--ink-soft); }
.reel-modal .play .hunt .icons .got img { opacity: .5; }
.reel-modal .play .hunt .icons .got::after { content: '✓'; position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; background: #2f9e44; color: #fff; font-size: 12px; font-weight: 800; line-height: 18px; text-align: center; }
.reel-modal .play .lift { position: absolute; right: 20px; bottom: 20px; display: grid; gap: 10px; }
.reel-modal .play .lift button { width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, .35); border: 2px solid rgba(255, 255, 255, .7); color: #fff; font-size: 20px; touch-action: manipulation; }
.reel-modal .play .stick i { width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, .9); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); pointer-events: none; }
@media (max-width: 600px) { .reel-modal .play .frame.live { width: 100%; aspect-ratio: auto; flex: 1; min-height: 240px; } }
@media (max-width: 600px) { .reel-modal { padding: 0; } .reel-modal .dialog { border-radius: 0; border-width: 0; height: 100%; } }

/* ---------- world map (worlds/:id) ---------- */
.world-map { display: grid; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.world-map .cell { aspect-ratio: 1; min-width: 96px; border-radius: var(--radius-sm); }
.world-map .cell.area { display: block; position: relative; overflow: hidden; border: var(--border); background: var(--bg-soft); }
.world-map .cell.area img { width: 100%; height: 100%; object-fit: cover; display: block; }
.world-map .cell.area .ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 32px; }
.world-map .cell.area .label { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 12px; font-weight: 500; background: rgba(255, 255, 255, .9); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-map .cell.empty { border: 1px dashed var(--line); }

/* ---------- world grid (editor: world page / minimap) ---------- */
.wgrid { --wcell: 120px; display: grid; gap: 6px; overflow: auto; max-width: 100%; }
.wgrid.compact { --wcell: 26px; gap: 3px; }
.wcell { width: var(--wcell); aspect-ratio: 1; border-radius: var(--radius-sm); padding: 0; position: relative; overflow: hidden; }
.wgrid.compact .wcell { border-radius: 6px; }
.wcell.area { border: var(--border); background: var(--bg-soft); cursor: pointer; }
.wcell.area:disabled { cursor: default; }
.wcell.area.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.wcell.area.swap:hover:not(:disabled) { outline: 2px dashed var(--ink-soft); outline-offset: 1px; }
.wgrid.compact .wcell.area.on { background: var(--ink); }
.wgrid.compact .wcell.area.on .label { color: #fff; }
.wcell.area img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wcell.area .ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 28px; }
.wcell.area .label { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 12px; font-weight: 500; background: rgba(255, 255, 255, .9); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wgrid.compact .wcell.area .label { inset: 0; display: grid; place-items: center; padding: 0; background: none; font-size: 10px; color: var(--ink); }
.wcell.add { border: 1px dashed #d4d4d8; background: transparent; font-size: 22px; font-weight: 400; color: var(--ink-soft); cursor: pointer; }
.wgrid.compact .wcell.add { font-size: 14px; }
.wcell.add:hover:not(:disabled) { background: var(--bg-soft); border-color: var(--ink-soft); color: var(--ink); }
.wcell.blank { display: block; }
.canvas .minimap { position: absolute; right: 12px; top: 12px; z-index: 2; width: 230px; background: rgba(255, 255, 255, .95); border: var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-soft); padding: 8px; display: grid; gap: 6px; max-width: 60%; }
.canvas .minimap .note { font-size: 11px; font-weight: 500; }
.canvas .inside-view { position: absolute; left: 12px; top: 12px; z-index: 2; width: 190px; max-width: 40%; display: grid; gap: 6px; justify-items: start; }
.canvas .inside-view .slider, .canvas .inside-view .note { width: 100%; box-sizing: border-box; background: rgba(255, 255, 255, .92); border: var(--border); border-radius: 6px; padding: 4px 8px; }
.canvas .inside-view .note { font-size: 11px; font-weight: 500; margin: 0; }
.area-tag { white-space: nowrap; font-size: 12px; font-weight: 500; padding: 3px 10px; border: var(--border); border-radius: 6px; background: rgba(255, 255, 255, .95); cursor: pointer; }
.area-tag:hover { background: var(--bg-soft); }
.my-tabs { flex-wrap: wrap; }
.reel-modal .photo-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.reel-modal .photo-strip button { flex: 0 0 auto; padding: 0; border: 2px solid transparent; border-radius: 6px; background: var(--bg-soft); cursor: pointer; overflow: hidden; }
.reel-modal .photo-strip button.on { border-color: var(--ink); }
.reel-modal .photo-strip img { display: block; height: 56px; width: auto; }
.reel-modal .photo-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 13px; color: var(--ink); }
.reel-modal .photo-meta time { font-weight: 600; font-variant-numeric: tabular-nums; }
.reel-modal .photo-meta span { color: var(--ink-soft); }
.reel-modal .post-text { display: grid; gap: 8px; padding: 12px; border: var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); }
.reel-modal .post-field { display: grid; gap: 4px; }
.reel-modal .post-field .row { flex-wrap: nowrap; align-items: flex-start; }
.reel-modal .post-field .input { flex: 1; min-width: 0; }
.reel-modal .post-field textarea.input { min-height: 0; }
