:root {
    --bg: #0f0f0f;
    --card: #1a1a1a;
    --accent: #007bff;
    --accent-hover: #0056b3;
    --text: #e0e0e0;
    --red: #ff4444;
    --border: #333;
}

body.dark-theme { background: var(--bg); color: var(--text); font-family: 'Segoe UI', Arial, sans-serif; margin: 0; overflow: hidden; }

/* パスワード保護画面 */
#password-gate { position: fixed; inset: 0; background: #000; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.gate-content { background: var(--card); padding: 40px; border-radius: 12px; text-align: center; border: 1px solid var(--border); }
.gate-content input { background: #000; border: 1px solid var(--accent); color: #0f0; padding: 12px; text-align: center; font-size: 1.2rem; margin-bottom: 20px; }

/* 🌟 レイアウト全体の調整 */
.main-layout { display: flex; height: 100vh; width: 100vw; }

/* 🌟 左パネルを少しスリムにして、右のプレビュー領域を広げました */
.controls-panel { flex: 0 0 350px; padding: 12px; overflow-y: auto; border-right: 2px solid var(--border); background: #151515; }

/* プレビューパネル全体の余白を削減 */
.preview-panel { 
    flex: 1; 
    padding: 8px; 
    background: #080808; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    height: 100vh; 
    box-sizing: border-box;
}

/* コントロールパネル内のカードデザイン */
.card { background: var(--card); border-radius: 8px; padding: 12px; margin-bottom: 15px; border-top: 4px solid var(--accent); }
.card h3 { margin-top: 0; font-size: 0.75rem; letter-spacing: 1px; color: #888; text-transform: uppercase; margin-bottom: 10px; }

/* 入力・ボタン */
.flex-column { display: flex; flex-direction: column; gap: 8px; }
.flex-row { display: flex; gap: 5px; align-items: center; }
.setting-row { display: flex; justify-content: space-between; align-items: center; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
input, select { background: #222; border: 1px solid var(--border); color: #fff; padding: 6px; border-radius: 4px; font-size: 0.85rem; }
button { background: var(--accent); color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 0.85rem; }
.btn-open { background: #28a745; }
.btn-folder { background: #444; }
.btn-black-add { background: #000; border: 1px solid #555; font-size: 0.65rem; padding: 4px; }
.btn-del { background: var(--red); padding: 2px 6px; font-size: 0.75rem; }

/* リスト・グリッド */
.sortable-list { list-style: none; padding: 0; margin: 0; }
.sortable-list li { background: #252525; padding: 6px; margin-bottom: 4px; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; cursor: grab; font-size: 0.85rem; border: 1px solid transparent; }
.sortable-list li:hover { border-color: var(--accent); }
.scene-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.scene-card-container { position: relative; }
.scene-card { background: #333; padding: 15px 5px; text-align: center; border-radius: 6px; cursor: pointer; border: 2px solid transparent; font-size: 0.85rem; font-weight: bold; }
.scene-card:hover { border-color: var(--accent); }
.scene-del-mini { position: absolute; top: 2px; right: 2px; background: rgba(255,0,0,0.7); border: none; color: white; border-radius: 50%; width: 16px; height: 16px; font-size: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* 🌟 プレビューブロックの最大化設定 */
.preview-block { 
    flex: 1; /* 上下のスペース（NEXTとLIVE）を均等に半分ずつ取る */
    background: #111; 
    padding: 8px; 
    border-radius: 8px; 
    border: 1px solid #333; 
    position: relative; 
    display: flex;
    flex-direction: column;
    min-height: 0; /* これがないと縮小できずにはみ出します */
}
.preview-block.live { border-color: var(--red); box-shadow: 0 0 10px rgba(255,0,0,0.2); }
.badge { position: absolute; top: -8px; left: 12px; background: #444; padding: 2px 8px; border-radius: 10px; font-size: 0.65rem; font-weight: bold; z-index: 10; }
.badge.red { background: var(--red); }

/* モニターを並べるコンテナ */
.preview-monitor-group { 
    flex: 1; 
    display: flex; 
    gap: 8px; 
    margin-top: 10px; /* バッジに被らないように少しだけ空ける */
    margin-bottom: 0;
    min-height: 0;
    align-items: center; /* 縦横比を保って中央に配置 */
    justify-content: center; 
}

/* 🌟 個別のモニター窓が「枠いっぱいに広がる」ための神設定 */
.mon-wrap { 
    width: 100%;
    max-width: calc(50% - 4px); /* 2つの画面が横に並ぶ限界の幅 */
    max-height: 100%; /* 親（枠）の高さを絶対に超えない */
    background: #000; 
    position: relative; 
    border: 1px solid #222; 
    overflow: hidden; 
    box-sizing: border-box;
    /* ※ここにJSから aspectRatio (16:9等) が付与されると、限界まで大きく表示されます */
}

/* ラベルとメーター */
.mon-label { position: absolute; top: 5px; left: 5px; font-size: 0.6rem; background: rgba(0,0,0,0.6); padding: 2px 4px; pointer-events: none; z-index: 5; border-radius: 3px; }
.meter-container { width: 100%; height: 4px; background: #222; position: absolute; bottom: 0; left: 0; z-index: 20; }
.meter-bar { height: 100%; width: 0%; background: #0f0; transition: width 0.1s ease; box-shadow: 0 0 5px #0f0; }
.red-meter { background: #f00; box-shadow: 0 0 5px #f00; }

.audio-monitor-ctrl { font-size: 0.8rem; margin-top: 5px; text-align: right; }
/* 🌟 修正：映像（iframe）を枠いっぱいに広げる */
.mon-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}
/* 🌟 TAKEボタンのスタイル */
.take-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5px 0;
    z-index: 50;
    position: relative;
}

.btn-take {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: white;
    font-size: 1.5rem;
    font-weight: 900;
    padding: 12px 60px;
    border-radius: 8px;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255,0,0,0.6);
    letter-spacing: 3px;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-take:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(255,0,0,0.6);
}

/* iframeを枠にフィットさせる（前回追加分） */
.mon-wrap iframe {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%; border: none;
}
/* 🌟 修正：映像（iframeとvideo）を枠いっぱいに広げる */
.mon-wrap iframe, .mon-wrap video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    object-fit: contain; /* 動画の縦横比を保って全体を表示します */
    background: #000;
}

/* 🌟 タイトルバーのデザイン */
.title-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: #222; padding: 6px 12px; border-radius: 6px;
    border-left: 4px solid var(--accent);
}
.title-bar.live-bar { border-left-color: var(--red); }
.title-bar .badge { position: static; font-size: 0.8rem; background: transparent; padding: 0; }
.title-bar .badge.red { background: transparent; color: var(--red); }
.title-bar .audio-select { width: 160px; padding: 4px; font-size: 0.75rem; }

/* 🌟 CUT / FADE ボタンのスタイル */
.take-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 5px 0;
    z-index: 50;
    position: relative;
}

.btn-take {
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 10px 40px;
    border-radius: 6px;
    border: 2px solid #fff;
    cursor: pointer;
    letter-spacing: 2px;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-take.cut {
    background: linear-gradient(135deg, #f0ad4e, #d58512);
    box-shadow: 0 4px 10px rgba(240,173,78,0.5);
}

.btn-take.fade {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    box-shadow: 0 4px 10px rgba(255,0,0,0.5);
}

.btn-take:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* 映像（iframeとvideo）を枠いっぱいに広げる */
.mon-wrap iframe, .mon-wrap video {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    border: none; object-fit: contain; background: #000;
}