:root {
  --bg: #15171c;
  --bg-2: #1d2027;
  --bg-3: #262a33;
  --line: #333845;
  --text: #e6e8ee;
  --text-dim: #9aa1b1;
  --accent: #4f8cff;
  --accent-2: #7bb0ff;
  --video: #3b6ea8;
  --image: #3f8f6a;
  --audio: #8a6bc9;
  --text-clip: #c98a3b;
  --danger: #e05d5d;
  --radius: 8px;
  --header-h: 52px;
  --footer-h: 26px;
  --timeline-h: 300px;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic UI', Meiryo, system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); }
button, input, select { font: inherit; color: inherit; }

.app { display: flex; flex-direction: column; height: 100vh; }
.booting, .fatal { padding: 40px; text-align: center; color: var(--text-dim); }
.fatal { color: var(--danger); }

/* ---------- ヘッダー ---------- */
.header { height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--bg-2); border-bottom: 1px solid var(--line); flex: none; }
.header-left, .header-center, .header-right { display: flex; align-items: center; gap: 8px; }
.header-center { flex: 1; justify-content: center; }
.brand { display: flex; align-items: baseline; gap: 6px; margin-right: 8px; }
.brand-mark { color: var(--accent); font-size: 16px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { color: var(--text-dim); font-size: 11px; }
.aspect-label { display: flex; align-items: center; gap: 6px; color: var(--text-dim); }
.aspect-select, select { background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 240px; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.45); padding: 6px; z-index: 50; display: flex; flex-direction: column; gap: 2px; }
.header-left .menu { left: 0; right: auto; }
.menu-title { padding: 6px 10px; color: var(--text-dim); font-size: 12px; }
.menu-note { padding: 8px 10px 4px; color: var(--text-dim); font-size: 11px; line-height: 1.5; }
.btn.menu-item { justify-content: flex-start; width: 100%; background: transparent; border-color: transparent; }
.btn.menu-item:hover { background: var(--bg-2); }
.exporting { gap: 10px; }
.progress { width: 220px; height: 10px; background: var(--bg-3); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }
.progress-text { color: var(--text-dim); font-size: 12px; min-width: 200px; }

.banner { background: #4a3b1a; color: #ffe2a8; padding: 8px 16px; border-bottom: 1px solid #6b5425; font-size: 12px; }
.banner ul { margin: 4px 0; padding-left: 18px; }

/* ---------- ボタン ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-3); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; user-select: none; }
.btn:hover { background: #2f3440; border-color: #434a5a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #3f7df0; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.is-disabled { opacity: .45; cursor: not-allowed; }
.btn.is-disabled:hover { background: var(--bg-3); border-color: var(--line); }
.btn.is-active { background: #2a4a85; border-color: var(--accent); }
.btn.icon { padding: 6px 9px; min-width: 32px; }
.btn.icon.tiny { padding: 2px 5px; min-width: 24px; font-size: 11px; }
.btn.play { font-size: 15px; min-width: 44px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.tab { border-radius: 0; border: none; border-bottom: 2px solid transparent; background: transparent; padding: 8px 12px; color: var(--text-dim); }
.btn.tab.is-active { color: var(--text); border-bottom-color: var(--accent); background: transparent; }

/* ---------- メイン 3 カラム ---------- */
.main { flex: 1; display: grid; grid-template-columns: 280px 1fr 280px; min-height: 0; }
.left-panel, .right-panel { background: var(--bg-2); overflow: auto; display: flex; flex-direction: column; min-height: 0; }
.left-panel { border-right: 1px solid var(--line); }
.right-panel { border-left: 1px solid var(--line); padding: 12px; gap: 8px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.panel-title { font-size: 13px; margin: 0 0 6px; color: var(--text-dim); font-weight: 600; }
.section-title { font-size: 12px; margin: 12px 0 4px; color: var(--text-dim); font-weight: 600; text-transform: none; }
.empty-note { padding: 14px; color: var(--text-dim); line-height: 1.6; }
.empty-note.small { padding: 6px 0; font-size: 12px; }

.dropzone { margin: 10px; padding: 18px 12px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: border-color .12s, background .12s; }
.dropzone.compact { padding: 10px; flex-direction: row; justify-content: space-between; }
.dropzone.compact .dropzone-icon { display: none; }
.dropzone.over { border-color: var(--accent); background: rgba(79,140,255,.08); }
.dropzone-icon { font-size: 28px; color: var(--text-dim); }
.dropzone-text { color: var(--text-dim); }
.loading { color: var(--accent-2); font-size: 12px; }
.howto { margin: 6px 14px; padding-left: 20px; color: var(--text-dim); line-height: 1.7; }
.asset-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 10px 12px; }
.asset-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; padding: 6px; border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--line); cursor: grab; }
.asset-card:hover { border-color: #4a5366; }
.asset-card.dragging { opacity: .5; }
.thumb { width: 64px; height: 40px; border-radius: 4px; background: #0d0f13 center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 18px; }
.thumb-audio { background: #2b2440; color: #c9b8ff; }
.asset-info { min-width: 0; }
.asset-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.asset-meta { color: var(--text-dim); font-size: 11px; }
.asset-warn { color: #ffc46b; font-size: 11px; }
.asset-actions { display: flex; flex-direction: column; gap: 4px; }

/* ---------- プレビュー ---------- */
.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0f1115; }
.stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; }
.preview-canvas { background: #000; box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(0,0,0,.5); }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-dim); pointer-events: none; gap: 10px; line-height: 1.8; background: rgba(15,17,21,.6); }
.stage-empty-title { font-size: 15px; color: var(--text); }
.transport { height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; border-top: 1px solid var(--line); background: var(--bg-2); }
.time { margin-left: 12px; font-variant-numeric: tabular-nums; color: var(--text-dim); font-family: ui-monospace, Consolas, monospace; }

/* ---------- インスペクター ---------- */
.clip-head { display: flex; align-items: center; gap: 8px; }
.clip-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.kind-badge { font-size: 11px; padding: 2px 6px; border-radius: 4px; color: #fff; flex: none; }
.kind-badge.kind-video { background: var(--video); }
.kind-badge.kind-image { background: var(--image); }
.kind-badge.kind-audio { background: var(--audio); }
.kind-badge.kind-text { background: var(--text-clip); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; color: var(--text-dim); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kv span:nth-child(even) { color: var(--text); }
.row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.row-label { width: 76px; flex: none; color: var(--text-dim); font-size: 12px; }
.row select { flex: 1; }
.slider-row input[type=range] { flex: 1; min-width: 0; }
.slider-value { width: 48px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.check-row { gap: 8px; }

/* ---------- タイムライン ---------- */
.timeline { height: var(--timeline-h); flex: none; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: var(--bg-2); }
.tl-toolbar { height: 40px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-bottom: 1px solid var(--line); flex: none; }
.tl-toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.tl-toolbar .spacer { flex: 1; }
.zoom { display: flex; align-items: center; gap: 4px; color: var(--text-dim); }
.zoom input { width: 110px; }
.tl-scroll { flex: 1; overflow: auto; position: relative; }
.tl-grid { display: grid; grid-template-columns: 150px 1fr; position: relative; }
.tl-corner { position: sticky; top: 0; left: 0; z-index: 6; background: var(--bg-2); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); display: flex; align-items: center; padding: 0 10px; font-family: ui-monospace, Consolas, monospace; color: var(--accent-2); font-size: 12px; }
.tl-ruler { position: sticky; top: 0; z-index: 5; background: var(--bg-2); border-bottom: 1px solid var(--line); cursor: text; }
.tick { position: absolute; bottom: 0; width: 1px; height: 6px; background: #4a5162; }
.tick.major { height: 12px; background: #6b7384; }
.tick-label { position: absolute; top: 2px; font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.tl-header { position: sticky; left: 0; z-index: 4; background: var(--bg-2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 8px; gap: 4px; }
.tl-track-name { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-header-actions { display: flex; gap: 2px; }
.tl-lane { position: relative; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(90deg, transparent 0 59px, rgba(255,255,255,.03) 59px 60px); }
.tl-lane.kind-audio { background-color: rgba(138,107,201,.05); }
.tl-lane.muted { opacity: .5; }
.tl-lane.drop-target { background-color: rgba(79,140,255,.12); }
.drop-ghost { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; }
.tl-empty { grid-column: 1 / -1; padding: 20px; color: var(--text-dim); text-align: center; }

.clip { position: absolute; top: 4px; bottom: 4px; border-radius: 6px; background: var(--video); border: 1px solid rgba(255,255,255,.15); overflow: hidden; cursor: grab; user-select: none; display: flex; }
.clip.kind-image { background: var(--image); }
.clip.kind-audio { background: var(--audio); }
.clip.kind-text { background: var(--text-clip); }
.clip.selected { outline: 2px solid #fff; outline-offset: -1px; box-shadow: 0 0 0 3px rgba(79,140,255,.5); }
.clip.dragging { opacity: .85; cursor: grabbing; }
.clip-body { flex: 1; min-width: 0; padding: 4px 6px; font-size: 11px; display: flex; align-items: flex-start; }
.clip-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.clip-handle { width: 8px; flex: none; cursor: ew-resize; background: rgba(255,255,255,.12); }
.clip-handle:hover, .clip.selected .clip-handle { background: rgba(255,255,255,.35); }
.clip.linked::after { content: '🔗'; position: absolute; right: 10px; bottom: 2px; font-size: 9px; opacity: .7; }

.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff5a5a; z-index: 7; pointer-events: none; }
.tl-playhead-head { position: absolute; top: 0; left: -6px; width: 14px; height: 14px; background: #ff5a5a; clip-path: polygon(0 0, 100% 0, 50% 100%); }

/* ---------- フッター・トースト・ツールチップ ---------- */
.footer { height: var(--footer-h); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 11px; color: var(--text-dim); background: var(--bg-2); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; flex: none; gap: 12px; }
.footer span:first-child { overflow: hidden; text-overflow: ellipsis; }
.toast-host { position: fixed; left: 50%; bottom: calc(var(--timeline-h) + var(--footer-h) + 60px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 100; pointer-events: none; }
.toast { padding: 9px 14px; border-radius: 8px; background: #2b303b; color: var(--text); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.4); opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; max-width: 70vw; font-size: 12.5px; }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-color: #3f8f6a; }
.toast-error { border-color: var(--danger); background: #3a2426; }
.tooltip { position: fixed; z-index: 200; background: #0d0f13; color: var(--text); border: 1px solid var(--line); padding: 6px 9px; border-radius: 6px; font-size: 11.5px; max-width: 320px; white-space: pre-line; pointer-events: none; opacity: 0; transition: opacity .1s; line-height: 1.5; }
.tooltip.show { opacity: 1; }

@media (max-width: 1100px) {
  .main { grid-template-columns: 220px 1fr 240px; }
}

/* ---------- 段階2 ---------- */
.clip-wave { position: absolute; left: 0; top: 5px; pointer-events: none; }
.clip.kind-audio .clip-body { position: relative; }
.clip-transition { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 3px, transparent 3px 7px); border-right: 1px dashed rgba(255,255,255,.7); pointer-events: auto; }
.clip-fx { position: absolute; right: 12px; top: 2px; font-size: 10px; color: #fff; text-shadow: 0 0 3px #000; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }
.preset-grid .btn { justify-content: flex-start; }
.panel-section { padding: 6px 10px; color: var(--text-dim); font-size: 12px; font-weight: 600; }
.text-area { width: 100%; min-height: 64px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; padding: 6px; resize: vertical; }
.color-row input[type=color] { width: 36px; height: 24px; padding: 0; border: 1px solid var(--line); background: none; border-radius: 4px; }
.fx-list { display: flex; flex-direction: column; gap: 2px; }
.help-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 150; display: flex; align-items: center; justify-content: center; }
.help-panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; width: min(720px, 92vw); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.help-panel h2 { margin: 0 0 10px; font-size: 16px; }
.help-panel h3 { margin: 14px 0 6px; font-size: 13px; color: var(--text-dim); }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; }
.help-grid kbd { background: var(--bg-3); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.help-panel ol { margin: 4px 0; padding-left: 20px; line-height: 1.7; }
.saved-indicator { color: var(--text-dim); }
.name-input { background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; width: 180px; }

.brand-home { margin-left: 10px; font-size: 11px; color: var(--text-dim); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; }
.brand-home:hover { color: var(--text); border-color: var(--accent); }
