/* =============================================================
 * 席替えスタジオ — Stage × Neon
 * ============================================================= */
:root {
  --bg-0: #0b0d1a;
  --bg-1: #11142a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --stroke: rgba(255, 255, 255, 0.12);
  --stroke-strong: rgba(255, 255, 255, 0.22);
  --text: #eef1ff;
  --text-dim: #a3a9cc;
  --text-mute: #6f76a0;

  --accent: #7c5cff;
  --accent-2: #19d3da;
  --accent-3: #ff5da2;
  --warn: #ffcf5c;
  --danger: #ff6b6b;

  --grad-primary: linear-gradient(135deg, #7c5cff 0%, #19d3da 100%);
  --grad-stage: radial-gradient(120% 80% at 50% -10%, #2a2350 0%, #14172e 45%, #0b0d1a 100%);

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 18px 50px rgba(124, 92, 255, 0.35);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "M PLUS Rounded 1c", system-ui, sans-serif;
  --font-display: "Outfit", "M PLUS Rounded 1c", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  background-image:
    radial-gradient(900px 600px at 12% -8%, rgba(124, 92, 255, 0.25), transparent 60%),
    radial-gradient(800px 500px at 92% 0%, rgba(25, 211, 218, 0.18), transparent 55%),
    var(--bg-0);
  overflow-x: hidden;
}

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 32px) 40px;
}

/* ===== トップバー ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 30px;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--grad-primary);
  box-shadow: var(--shadow-pop);
  animation: floaty 5s var(--ease) infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-4deg);} 50% { transform: translateY(-5px) rotate(6deg);} }
.brand-text h1 { font-family: var(--font-display); font-size: 22px; margin: 0; letter-spacing: 0.3px; }
.brand-text p { margin: 2px 0 0; font-size: 11px; color: var(--text-mute); letter-spacing: 2px; }

.stats { display: flex; gap: 10px; margin-left: auto; }
.stat {
  min-width: 70px;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--stroke);
}
.stat-num { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1; }
.stat-num.warn { color: var(--warn); }
.stat-label { font-size: 11px; color: var(--text-dim); }

.actions { display: flex; gap: 10px; align-items: center; }

/* ===== ボタン ===== */
.btn {
  font-family: var(--font); font-weight: 700;
  border: 1px solid var(--stroke-strong);
  color: var(--text);
  background: var(--surface-2);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s, filter 0.2s;
}
.btn:hover { transform: translateY(-2px); background: var(--surface-2); filter: brightness(1.1); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  border: none;
  background: var(--grad-primary);
  box-shadow: var(--shadow-pop);
  font-size: 15px;
  padding: 13px 24px;
}
.btn-primary:hover { box-shadow: 0 22px 60px rgba(124, 92, 255, 0.5); }
.btn-ghost { background: transparent; }
.btn-mini { padding: 9px 14px; font-size: 13px; border-radius: 12px; }
.btn-mini.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.4); }

/* ===== レイアウト本体 ===== */
.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  margin-top: 18px;
}

/* ===== ステージ ===== */
.stage {
  position: relative;
  padding: 18px clamp(14px, 2.5vw, 34px) 30px;
  border-radius: var(--r-lg);
  background: var(--grad-stage);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.stage::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(124, 92, 255, 0.18), transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 38px, rgba(255, 255, 255, 0.02) 39px, transparent 40px);
  pointer-events: none;
}
.stage-top {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.mode-hint { margin: 0; font-size: 13px; color: var(--text-dim); }

.seg {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--stroke);
}
.seg-btn {
  border: none; background: transparent; color: var(--text-dim);
  font-family: var(--font); font-weight: 700; font-size: 13px;
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  transition: color 0.2s, background 0.3s var(--ease);
}
.seg-btn.is-on { color: #fff; background: var(--grad-primary); box-shadow: 0 6px 18px rgba(124, 92, 255, 0.4); }

.board {
  position: relative;
  height: 46px;
  margin: 6px auto 26px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c3a2e, #14271f);
  border: 3px solid #5a3d24;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(0, 0, 0, 0.4);
  color: #cfeede; letter-spacing: 8px; font-weight: 700; font-size: 15px;
}

.stage-wrap { position: relative; }

/* ===== 座席グリッド ===== */
.seat-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(8px, 1.1vw, 16px);
  z-index: 2;
}
.seat {
  position: relative;
  aspect-ratio: 4 / 3;
  min-height: 56px;
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--stroke);
  transition: transform 0.18s var(--ease), box-shadow 0.2s, border-color 0.2s, background 0.3s;
}
.seat.is-occupied {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    color-mix(in oklab, var(--seat-color, #7c5cff) 22%, transparent);
  border-color: color-mix(in oklab, var(--seat-color, #7c5cff) 55%, var(--stroke));
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 22px -8px color-mix(in oklab, var(--seat-color, #7c5cff) 70%, transparent);
}
.seat.is-occupied:hover { transform: translateY(-3px) scale(1.02); }
.seat.is-locked { outline: 2px solid var(--warn); outline-offset: -2px; }
.seat.seat--aisle {
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02) 6px, transparent 6px, transparent 12px);
  border-style: dashed;
  opacity: 0.6;
}
.seat.drop-target {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2), 0 0 24px rgba(25, 211, 218, 0.5);
  transform: scale(1.03);
}
.seat-num {
  position: absolute; top: 5px; left: 7px;
  font-size: 11px; font-weight: 700; color: var(--text-mute);
  font-family: var(--font-display);
}
.seat-name {
  font-weight: 700;
  font-size: clamp(11px, 1.05vw, 15px);
  text-align: center;
  line-height: 1.25;
  padding: 0 4px;
  cursor: grab;
  word-break: break-word;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.seat-name:active { cursor: grabbing; }
.seat-empty { font-size: 12px; color: var(--text-mute); }
.seat-aisle-label { font-size: 11px; color: var(--text-mute); letter-spacing: 2px; }
.seat-lock {
  position: absolute; top: 3px; right: 3px;
  width: 24px; height: 24px;
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; opacity: 0; border-radius: 8px;
  transition: opacity 0.2s, background 0.2s;
}
.seat:hover .seat-lock { opacity: 0.7; }
.seat-lock:hover { background: rgba(255, 255, 255, 0.12); opacity: 1; }
.seat-lock.on { opacity: 1; }
/* 配置編集モードでは席を掴めるように */
body[data-mode="layout"] .seat { cursor: pointer; }
body[data-mode="layout"] .seat[data-type="seat"] { cursor: grab; }

/* ===== 飛び込みチップ ===== */
.fly-layer {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 5;
}
.fly-chip {
  position: absolute; top: 0; left: 0;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 800; font-size: 15px; white-space: nowrap;
  color: #0b0d1a;
  background: var(--c, #fff);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 26px color-mix(in oklab, var(--c, #fff) 60%, transparent);
  will-change: transform, opacity, filter;
}

/* ===== サイドパネル ===== */
.panel {
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  padding: 12px;
  height: fit-content;
  position: sticky; top: 16px;
}
.tabs { display: flex; gap: 6px; padding: 4px; background: rgba(0, 0, 0, 0.25); border-radius: 14px; }
.tab {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  font-family: var(--font); font-weight: 700; font-size: 13px;
  padding: 9px; border-radius: 10px; cursor: pointer; transition: 0.2s;
}
.tab.is-on { background: var(--surface-2); color: #fff; box-shadow: inset 0 0 0 1px var(--stroke); }
.tabpanel { display: none; padding: 14px 6px 6px; animation: fadeIn 0.25s var(--ease); }
.tabpanel.is-on { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-head h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.pill {
  font-family: var(--font-display); font-size: 12px; font-weight: 800;
  background: var(--grad-primary); color: #fff;
  padding: 2px 9px; border-radius: 999px;
}
.hint { font-size: 12px; color: var(--text-mute); margin: 16px 0 8px; line-height: 1.5; }
.credit { font-size: 11px; color: var(--text-mute); margin-top: 16px; line-height: 1.6; }

/* フィールド */
.field {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font); font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
.field.area { resize: vertical; margin-top: 8px; }
.field.num { text-align: center; width: 64px; }

.add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.add-row .field { flex: 1; }

/* 名簿リスト */
.roster {
  list-style: none; margin: 0; padding: 0;
  max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  scrollbar-width: thin; scrollbar-color: var(--accent) transparent;
}
.roster::-webkit-scrollbar { width: 8px; }
.roster::-webkit-scrollbar-thumb { background: var(--stroke-strong); border-radius: 8px; }
.roster-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 10px;
  background: var(--surface);
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.roster-item:hover { border-color: var(--stroke); background: var(--surface-2); }
.roster-no { font-family: var(--font-display); font-size: 12px; color: var(--text-mute); width: 22px; text-align: right; }
.roster-swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; box-shadow: 0 0 8px -2px currentColor; }
.roster-name {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  padding: 4px; border-radius: 6px;
}
.roster-name:focus { outline: none; background: rgba(0, 0, 0, 0.3); }
.roster-del {
  border: none; background: transparent; color: var(--text-mute);
  cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; transition: 0.2s;
}
.roster-del:hover { color: var(--danger); background: rgba(255, 107, 107, 0.12); }

.bulk { margin-top: 14px; }
.bulk summary { cursor: pointer; font-size: 13px; color: var(--text-dim); padding: 6px 0; }
.bulk-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ステッパー */
.stepper-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stepper-row > label { font-size: 14px; color: var(--text-dim); }
.stepper { display: flex; align-items: center; gap: 6px; }
.step {
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--stroke-strong); background: var(--surface-2);
  color: var(--text); font-size: 18px; cursor: pointer; transition: 0.15s;
}
.step:hover { background: var(--accent); border-color: var(--accent); }

.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.chip-btn {
  border: 1px solid var(--stroke-strong); background: var(--surface);
  color: var(--text); font-family: var(--font-display); font-weight: 700;
  padding: 10px; border-radius: 12px; cursor: pointer; transition: 0.15s;
}
.chip-btn:hover { background: var(--surface-2); border-color: var(--accent-2); transform: translateY(-2px); }

.layout-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 設定 */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.set-row > label { font-size: 14px; color: var(--text-dim); white-space: nowrap; }
.set-row .field { width: auto; }
input[type="range"] { accent-color: var(--accent); flex: 1; }
.switch {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; cursor: pointer; font-size: 14px; color: var(--text-dim);
}
.switch input { width: 42px; height: 24px; appearance: none; border-radius: 999px; background: rgba(0, 0, 0, 0.4); position: relative; cursor: pointer; transition: background 0.25s; border: 1px solid var(--stroke); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.25s var(--ease); }
.switch input:checked { background: var(--grad-primary); }
.switch input:checked::after { transform: translateX(18px); }

/* ===== トースト ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 30px);
  padding: 13px 22px; border-radius: 14px;
  font-weight: 700; color: #fff;
  background: rgba(20, 23, 46, 0.92);
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; z-index: 100;
  transition: transform 0.35s var(--ease), opacity 0.3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(25, 211, 218, 0.5); }
.toast.warn { border-color: var(--warn); color: var(--warn); }

/* シャッフル中はパネル操作を軽く抑制 */
body.is-shuffling .panel { filter: saturate(0.8) brightness(0.92); }

/* ===== レスポンシブ ===== */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .stats { order: 3; width: 100%; justify-content: space-between; }
  .actions { order: 2; }
}
@media (max-width: 560px) {
  .brand-text p { display: none; }
  .actions { width: 100%; }
  .actions .btn-primary { flex: 1; }
  .stat { min-width: 0; flex: 1; }
}

/* ===== 印刷 ===== */
@media print {
  body { background: #fff; color: #000; }
  .topbar .actions, .panel, .stage-top, #fx, .toast, .fly-layer { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .stage { background: #fff; border: none; box-shadow: none; }
  .seat { border: 1px solid #999; background: #fff !important; }
  .seat-name { color: #000; text-shadow: none; }
  .board { background: #ddd; color: #000; }
}

/* ===== モーション軽減 ===== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.05ms !important; }
}
