:root {
  --bg: #0a0a12;
  --panel: #14141f;
  --panel2: #1c1c2b;
  --line: #2a2a40;
  --text: #e7e7f5;
  --dim: #9a9ab8;
  --accent: #ff2e88;
  --accent2: #14e0e0;
  --accent3: #a95bff;
  --ok: #35e08a;
  --err: #ff5d5d;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Meiryo", system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ===== ヘッダー ===== */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}
#topbar h1 {
  font-size: 17px; margin: 0; letter-spacing: 2px; white-space: nowrap;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#topbar h1 span { font-weight: 300; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ===== ボタン類 ===== */
.btn {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 12.5px;
}
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: linear-gradient(135deg, #ff2e88cc, #a95bffcc); border-color: transparent; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.15); }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.rec { border-color: var(--err); color: var(--err); }
.mini {
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 11.5px;
}
.mini:hover { border-color: var(--accent2); color: var(--text); }

/* ===== メイン3カラム ===== */
#mainarea { display: flex; flex: 1 1 auto; min-height: 0; }

/* --- 左ペイン --- */
#leftpane {
  width: 300px; flex: 0 0 auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--panel);
  min-height: 0;
}
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px; }
.pane-head h2 { font-size: 12px; margin: 0; color: var(--accent2); letter-spacing: 1px; text-transform: uppercase; }
.tapsync { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.tapsync-hint { color: var(--dim); font-size: 11px; margin: 4px 0; }
.tapsync-hint b { color: var(--accent2); }
.tapsync .offsetrow { color: var(--dim); font-size: 11.5px; display: flex; align-items: center; gap: 6px; }
.tapsync input[type=number] { width: 64px; }
.tapsync .btn.active { border-color: var(--err); color: var(--err); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.55; } }

#lineList { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1 1 auto; }
#lineList li {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; margin-bottom: 6px; cursor: pointer;
}
#lineList li.selected { border-color: var(--accent); box-shadow: 0 0 8px rgba(255,46,136,0.3); }
#lineList li.active-now { border-left: 3px solid var(--accent2); }
#lineList .lrow1 { display: flex; align-items: center; gap: 6px; }
#lineList .idx {
  min-width: 20px; height: 20px; border-radius: 5px; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent3); color: #fff; font-weight: 700; flex: 0 0 auto;
}
#lineList input.txt {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 13px; padding: 2px; min-width: 0;
}
#lineList input.txt:focus { outline: 1px solid var(--accent2); border-radius: 4px; }
#lineList .del { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 13px; }
#lineList .del:hover { color: var(--err); }
#lineList .lrow2 { display: flex; gap: 4px; margin-top: 4px; align-items: center; color: var(--dim); font-size: 11px; }
#lineList .lrow2 input[type=number] { width: 62px; }
.autodist { padding: 8px 10px; border-top: 1px solid var(--line); }

/* --- 中央ペイン --- */
#centerpane { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #06060c; }
#previewWrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin: 10px;
}
#checker, #refVideo, #preview, #overlay {
  position: absolute;
  max-width: 100%; max-height: 100%;
  aspect-ratio: 16 / 9;
}
#refVideo {
  width: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0.6;
}
#refVideo[hidden] { display: none; }
#checker {
  background:
    repeating-conic-gradient(#23232f 0% 25%, #191922 0% 50%) 0 0 / 24px 24px;
  width: 100%; height: 100%;
  max-width: calc(min(100%, (100vh) * 16 / 9));
  display: none;
}
#previewWrap.transparent #checker { display: block; }
#preview, #overlay { width: 100%; }
#overlay { pointer-events: auto; }

#transport {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 6px 12px; border-top: 1px solid var(--line); background: var(--panel);
  flex-wrap: wrap;
}
.timedisp { font-family: Consolas, monospace; color: var(--accent2); font-size: 14px; }
#transport label { color: var(--dim); display: flex; align-items: center; gap: 6px; }
.warn { color: #ffb547; font-size: 12px; }

#timelineWrap { flex: 0 0 auto; background: var(--panel); border-top: 1px solid var(--line); }
#tlResize {
  height: 8px; cursor: ns-resize; touch-action: none;
  background: linear-gradient(var(--panel2), var(--panel));
  border-bottom: 1px solid var(--line); position: relative;
}
#tlResize::after {
  content: ''; position: absolute; left: 50%; top: 3px; width: 44px; height: 2px;
  margin-left: -22px; border-radius: 2px; background: var(--dim);
}
#tlResize:hover::after { background: var(--accent2); }
#timeline { display: block; width: 100%; cursor: crosshair; }
.tl-controls { display: flex; padding: 3px 12px 6px; color: var(--dim); font-size: 11.5px; }
.tl-controls label { display: flex; align-items: center; gap: 8px; }
.tl-controls input[type=range] { width: 160px; accent-color: var(--accent2); }

/* --- 右ペイン --- */
#rightpane {
  width: 340px; flex: 0 0 auto; overflow-y: auto;
  border-left: 1px solid var(--line); background: var(--panel);
  padding: 8px;
}
.insp-section {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 12px;
}
.insp-section h3 {
  font-size: 14px; margin: 0 0 8px; color: var(--accent2);
  letter-spacing: 1px;
}
.insp-section.hiphop h3 { color: var(--accent); }
.insp-section .dim { color: var(--dim); font-weight: 400; }
.row { margin-bottom: 11px; }
.row:last-child { margin-bottom: 0; }
.row label { color: var(--dim); display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3fx { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.grid3fx label { flex-direction: column; align-items: stretch; gap: 3px; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; }
.sliderrow { width: 100%; }
.sliderrow input[type=range] { flex: 1; accent-color: var(--accent); min-width: 0; height: 26px; }
.val {
  min-width: 46px; text-align: center; font-weight: 700; font-size: 13px;
  color: var(--accent2); background: var(--panel);
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 4px;
}
input[type=number], input[type=text], select, textarea {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 14px; max-width: 100%;
}
input[type=number] { width: 86px; }
input[type=text] { width: 100%; }
select { cursor: pointer; }
#selFont { width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent2); }
input[type=color] {
  width: 50px; height: 32px; padding: 1px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); cursor: pointer;
}
.chk { display: flex; gap: 7px; align-items: center; cursor: pointer; }
.chk input { accent-color: var(--accent); width: 18px; height: 18px; }

.kernrow { align-items: center; }
.kernrow input[type=number] { width: 78px; }
.kernhint { font-size: 10.5px; margin-top: 3px; }

.dropzone {
  border: 2px dashed var(--line); border-radius: 8px; padding: 10px;
  text-align: center; color: var(--dim); font-size: 11.5px; transition: .15s;
}
.dropzone.over { border-color: var(--accent); background: rgba(255,46,136,0.07); color: var(--text); }

/* ===== モーダル ===== */
.modal {
  position: fixed; inset: 0; background: rgba(4,4,10,0.72);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px; width: min(560px, 92vw); max-height: 88vh; overflow-y: auto;
  box-shadow: 0 10px 60px rgba(0,0,0,0.6);
}
.modal-box h3 { margin: 0 0 10px; color: var(--accent2); }
.modal-box p { font-size: 12.5px; }
.modal-box p.dim, .modal-box .dim { color: var(--dim); }
.modal-box textarea { width: 100%; resize: vertical; font-family: inherit; line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.progressbar {
  height: 14px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin: 14px 0 8px;
}
#progressFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent3));
  transition: width .2s;
}
