* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0a0b0f;
  --panel: #16181f;
  --panel2: #1c1f28;
  --line: #2a2e3a;
  --text: #eef1f8;
  --muted: #8b93a7;
  --pika-pink: #ff2d78;
  --pika-blue: #00a3ff;
  --lcd: #7dffa8;
}
html, body {
  margin: 0; height: 100%;
  background:
    radial-gradient(1200px 500px at 50% -200px, #171a24 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", system-ui, sans-serif;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; /* ダブルタップズーム無効(誤タップ対策) */
}
button { touch-action: manipulation; }
body { display: flex; flex-direction: column; height: 100dvh; }

/* ===== ヘッダー ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(#20242f, #14161d);
  border-bottom: 2px solid #000;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
}
.logo { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.logo img { height: 40px; display: none; }
.logo.has-img img { display: block; }
.logo.has-img .logo-text { display: none; }
.logo-text {
  font-weight: 900; font-size: 24px; letter-spacing: .02em;
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
  -webkit-text-stroke: 1px #000;
}
.logo-text .lh { color: #fff; }
.logo-text .lp { color: var(--pika-pink); }
.logo-text .lt { color: var(--pika-blue); }
.logo-sub {
  font-size: 10px; font-weight: 700; letter-spacing: .28em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px;
}
.btn {
  border: none; border-radius: 10px; padding: 10px 14px;
  font-size: 14px; font-weight: 700; color: var(--text);
  background: linear-gradient(#2a2f3d, #20242f);
  box-shadow: 0 2px 0 #000, inset 0 1px 0 rgba(255,255,255,.08);
  cursor: pointer;
}
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #000; }
.btn.primary { background: linear-gradient(#ff4f8d, #e01e63); }
.btn.danger { background: linear-gradient(#3a1d24, #301219); color: #ff8a8a; }
.btn.ghost.editing { background: linear-gradient(#ff4f8d, #e01e63); }

/* ===== デッキ全体 ===== */
.deck { flex: 1; display: flex; min-height: 0; gap: 10px; padding: 10px; }

/* ===== ボード（左：セクション行） ===== */
.board { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex; align-items: stretch;
  background: linear-gradient(#181b23, #14161d);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04);
  overflow: hidden;
}
/* ジャンル帯（左の縦ラベル） */
.row-label {
  width: 46px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(90deg, #10121a, #161923);
  border-right: 1px solid var(--line);
  border-left: 4px solid var(--rl, var(--pika-pink));
  cursor: default;
}
.rl-name {
  writing-mode: vertical-rl; text-orientation: upright;
  font-weight: 800; font-size: 14px; letter-spacing: .18em; color: var(--text);
}
.rl-mode {
  writing-mode: vertical-rl;
  font-size: 9px; font-weight: 700; letter-spacing: .2em; color: var(--rl, var(--muted));
}
body.edit .row-label { cursor: pointer; }
body.edit .row-label::after { content: "⚙"; font-size: 12px; opacity: .7; }

.row-pads {
  flex: 1; display: grid; gap: 10px; padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  align-content: start;
}

/* ===== パッド ===== */
.pad {
  position: relative; overflow: hidden;
  border: none; border-radius: 14px; min-height: 96px;
  color: #fff; font-size: 15px; font-weight: 800; text-align: center;
  padding: 12px 10px; cursor: pointer;
  background:
    radial-gradient(circle at 30% 22%, rgba(255,255,255,.18), transparent 55%),
    var(--pad-color, #333);
  box-shadow: 0 5px 14px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.2), inset 0 -3px 6px rgba(0,0,0,.35);
  transition: transform .07s ease, filter .15s ease;
  filter: saturate(.8) brightness(.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  touch-action: none;
}
.pad:active { transform: scale(.97); }
.pad.playing {
  filter: saturate(1.25) brightness(1.12);
  box-shadow: 0 0 0 3px rgba(255,255,255,.4), 0 0 22px var(--pad-color), 0 6px 20px rgba(0,0,0,.5);
}
.pad .kind { font-size: 9px; font-weight: 700; opacity: .85; letter-spacing: .14em; }
.pad .label { line-height: 1.2; word-break: break-word; }
.pad .progress { position: absolute; left: 0; bottom: 0; height: 4px; width: 0%; background: rgba(255,255,255,.9); }
.pad .live {
  position: absolute; top: 9px; right: 11px; width: 8px; height: 8px; border-radius: 50%;
  background: #fff; opacity: 0; box-shadow: 0 0 8px #fff;
}
.pad.playing .live { opacity: 1; animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

body.edit .pad { filter: saturate(.6) brightness(.8); outline: 2px dashed rgba(255,255,255,.35); outline-offset: -6px; }
.pad.drag-src { opacity: .3; }
body.edit .row-pads.drop-hint { box-shadow: inset 0 0 0 2px var(--pika-pink); background: rgba(255,45,120,.06); }
.pad.drag-ghost {
  position: fixed; z-index: 99; pointer-events: none; opacity: .9;
  transform: scale(1.05) rotate(2deg); margin: 0;
}

/* 追加タイル・セクション追加（編集モードのみ表示） */
.add-tile, .add-sec { display: none; }
body.edit .add-tile {
  display: flex; align-items: center; justify-content: center;
  min-height: 96px; border-radius: 14px; cursor: pointer;
  border: 2px dashed #3a4152; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 700;
}
body.edit .add-sec {
  display: block; margin: 2px auto 8px; padding: 12px 22px;
  border: 2px dashed #3a4152; border-radius: 12px; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer;
}

/* ===== ミキサー（右ストリップ） ===== */
.mixer {
  width: 108px; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 14px 10px;
  background: linear-gradient(#1d2029, #14161d);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
  position: relative;
}
/* ネジ */
.mixer::before, .mixer::after {
  content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555, #1a1a1a);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.8);
}
.mixer::before { top: 6px; left: 8px; }
.mixer::after { top: 6px; right: 8px; }

.mx-btn {
  width: 100%; border: none; border-radius: 10px; padding: 10px 4px;
  font-size: 13px; font-weight: 900; letter-spacing: .08em; color: var(--text);
  background: linear-gradient(#2a2f3d, #1e222c);
  box-shadow: 0 3px 0 #000, inset 0 1px 0 rgba(255,255,255,.08);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.mx-btn small { font-size: 8px; font-weight: 700; color: var(--muted); letter-spacing: .05em; }
.mx-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.mx-btn .led {
  width: 8px; height: 8px; border-radius: 50%; background: #333;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.7); margin-bottom: 2px;
}
.mx-btn.talk.on { background: linear-gradient(#00b4ff, #0077cc); }
.mx-btn.talk.on .led { background: #aef; box-shadow: 0 0 8px #7df; }
.mx-btn.cut { background: linear-gradient(#e6353f, #a8121b); }
.mx-btn.stop { background: linear-gradient(#e09a1a, #b06f06); }

.fader-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 0; width: 100%; }
.fader-readout {
  font-family: ui-monospace, monospace; font-size: 15px; font-weight: 700;
  color: var(--lcd); background: #060a07; border: 1px solid #1d2b20;
  border-radius: 5px; padding: 2px 10px; text-shadow: 0 0 6px rgba(125,255,168,.7);
}
.fader {
  flex: 1; width: 100%; position: relative; min-height: 120px;
  touch-action: none; cursor: pointer;
  /* 目盛り */
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(10% - 1px), #333947 calc(10% - 1px), #333947 10%)
    center / 44px calc(100% - 34px) no-repeat;
}
.fader::before {
  /* センターの溝 */
  content: ""; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 6px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #05060a, #101521, #05060a);
  border-radius: 3px; box-shadow: inset 0 1px 3px #000;
}
.fader-cap {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 62px; height: 34px; border-radius: 6px;
  background: linear-gradient(#3a3f4d 0%, #23262f 45%, #15171e 50%, #2c303c 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.15);
}
.fader-cap::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px;
  transform: translateY(-50%); background: var(--pika-pink); box-shadow: 0 0 6px var(--pika-pink);
}
.fader-label { font-size: 10px; font-weight: 800; letter-spacing: .22em; color: var(--muted); }

/* ===== ステータス（LCD風） ===== */
.status {
  margin: 0 10px; margin-bottom: calc(8px + env(safe-area-inset-bottom));
  padding: 7px 14px; border-radius: 8px;
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--lcd); background: #060a07; border: 1px solid #1d2b20;
  text-shadow: 0 0 6px rgba(125,255,168,.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ===== モーダル ===== */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal.hidden, .sheet.hidden { display: none; }
.sheet {
  width: min(440px, 100%); max-height: 85dvh; overflow-y: auto;
  background: linear-gradient(#1e222c, #171a22);
  border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h3 { margin: 0; font-size: 17px; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.sheet label.chk { flex-direction: row; align-items: center; font-size: 14px; color: var(--text); }
.sheet input[type="text"], .sheet select {
  font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #10131a; color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.sheet input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--pika-pink); }
.field-name { font-size: 12px; font-weight: 700; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; border: none;
  box-shadow: inset 0 -3px 5px rgba(0,0,0,.3);
}
.swatch.sel { outline: 3px solid #fff; outline-offset: 2px; }
.sheet-row { display: flex; gap: 10px; }
.sheet-row .btn { flex: 1; }

/* 狭い画面 */
@media (max-width: 640px) {
  .mixer { width: 88px; }
  .row-pads { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
}
