:root {
  --curtain: #1f1a2e;
  --panel: #282238;
  --panel-2: #332b47;
  --ink: #efe8d8;
  --muted: #b3aac6;
  --spot: #f0c35a;
  --spot-ink: #2b2110;
  --line: #463d61;
  --danger: #ff8a7a;
  --radius: 10px;
  --ui: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  --display: "Dela Gothic One", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--curtain); color: var(--ink); font-family: var(--ui); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--spot); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 1fr 360px; height: 100dvh; }

.stage-wrap {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; overflow: hidden;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
#stage { display: block; touch-action: none; border-radius: 6px; }

.panel {
  background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 18px 20px 40px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.brand { font-family: var(--display); font-weight: 400; font-size: 26px; letter-spacing: 0.04em; margin: 0; color: var(--spot); }
.close-panel { display: none; }

.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.hint, .status, .tips p { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.7; }
.error { font-size: 13px; color: var(--danger); margin: 4px 0 0; min-height: 0; }
.error:empty { display: none; }

textarea {
  width: 100%; resize: vertical; min-height: 120px;
  background: var(--curtain); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; font-size: 16px; line-height: 1.7;
}
select {
  width: 100%; background: var(--curtain); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 10px; font-size: 15px;
}

.row { display: flex; gap: 8px; margin-top: 10px; }
.row .btn { flex: 1; }
.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius);
  padding: 10px 12px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--spot); color: var(--spot-ink); border-color: var(--spot); }
.btn.small { font-size: 13px; padding: 8px 6px; font-weight: 500; }
.nav .row { margin-top: 0; }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button {
  flex: 1; background: transparent; border: 0; padding: 9px 4px; font-size: 14px; cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-checked="true"] { background: var(--spot); color: var(--spot-ink); font-weight: 700; }

.custom { display: none; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.custom.on { display: grid; }
.custom label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.custom select { font-size: 13px; padding: 7px 8px; }

.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-opt {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius); background: transparent;
  padding: 8px 10px; cursor: pointer; font-size: 14px;
}
.theme-opt[aria-checked="true"] { border-color: var(--spot); box-shadow: inset 0 0 0 1px var(--spot); }
.swatch { display: inline-flex; width: 34px; height: 22px; border-radius: 5px; overflow: hidden; flex: none; }
.swatch i { flex: 1; }

.float-btn, .exit-show {
  position: absolute; z-index: 5; border: 1px solid rgba(255,255,255,0.35); border-radius: 999px;
  background: rgba(20, 16, 30, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #fff; font-size: 14px; padding: 10px 16px; cursor: pointer;
}
.edit-btn { display: none; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.exit-show { display: none; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); opacity: 0.35; font-size: 12px; padding: 6px 12px; }
.exit-show:hover, .exit-show:focus-visible { opacity: 1; }

.toast {
  position: absolute; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  margin: 0; max-width: min(90%, 420px); padding: 10px 14px; border-radius: var(--radius);
  background: rgba(20, 16, 30, 0.85); color: #fff; font-size: 13px; line-height: 1.6;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.toast.on { opacity: 1; }

/* 本番表示: 設定をすべて隠して舞台だけにする */
.app.show { grid-template-columns: 1fr; }
.app.show .panel, .app.show .edit-btn { display: none; }
.app.show .exit-show { display: block; }

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .edit-btn { display: block; }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 82dvh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    transform: translateY(105%); transition: transform 0.28s ease;
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  }
  .panel.open { transform: translateY(0); }
  .close-panel { display: block; background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}
