:root {
  --bg: #0f1216;
  --panel: #191d24;
  --panel-2: #21262f;
  --line: #2c333d;
  --text: #e8ecf1;
  --muted: #93a0b0;
  --accent: #5dcaa5;
  --accent-2: #7aa2ff;
  --danger: #e06a6a;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --panel: #ffffff; --panel-2: #eef1f5; --line: #dde3ea;
    --text: #1b2027; --muted: #5c6673; --accent: #1d9e75; --accent-2: #3f6fe0;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent-2); }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar .spacer { flex: 1; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); padding: 8px 14px; border-radius: var(--radius);
  font-size: 14px; cursor: pointer; transition: filter .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--accent); color: #06231a; border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=range] { width: 100%; }
input[type=text], input[type=number] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.hint { color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }

/* ギャラリー */
.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }
.hero { text-align: center; padding: 28px 0 8px; }
.hero p { color: var(--muted); max-width: 560px; margin: 8px auto 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card .thumb { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--panel-2); display: block; }
.card .meta { padding: 10px; }
.card .meta .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta .acts { display: flex; gap: 6px; margin-top: 8px; }
.card .meta .acts a, .card .meta .acts button { flex: 1; text-align: center; font-size: 12px; padding: 6px 0; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); text-decoration: none; cursor: pointer; }

/* エディタ */
.editor { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 53px); }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; height: auto; } }
.stage { position: relative; background: repeating-conic-gradient(var(--panel-2) 0% 25%, var(--panel) 0% 50%) 50% / 24px 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 320px; }
.stage canvas { max-width: 100%; max-height: 100%; touch-action: none; }
.side { border-left: 1px solid var(--line); background: var(--panel); padding: 16px; overflow-y: auto; }
@media (max-width: 760px) { .side { border-left: none; border-top: 1px solid var(--line); } }
.steps { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.steps .step { font-size: 12px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.steps .step.active { background: var(--accent); color: #06231a; border-color: transparent; font-weight: 600; }
.panel-body { display: none; }
.panel-body.active { display: block; }
.panel-body .col { margin-bottom: 12px; }
.nav { display: flex; justify-content: space-between; margin-top: 18px; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }

/* ビューア/AR フルスクリーン */
.full { position: fixed; inset: 0; }
.overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; z-index: 10; }
.overlay-top { position: absolute; top: 0; left: 0; right: 0; padding: 12px 16px; display: flex; align-items: center; gap: 10px; z-index: 10; }
.badge { background: rgba(0,0,0,.5); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; backdrop-filter: blur(6px); }
.center-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 5; }
.center-msg .box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 340px; }
video.ar-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
