/* 1. 外側のコンテナ：画面幅からはみ出さないようにガード */
.article-content-container {
    width: 100%;
    overflow: hidden; /* はみ出しをカット */
    background: #fff;
    position: relative;
}

/* 2. レイアウト本体：PCの基準幅（850px）で固定し、左上を軸にする */
.custom-layout {
    position: relative;
    width: 768px; /* ここをエディタの幅と必ず一致させる */
    min-height: 500px;
    transform-origin: 0 0; /* 左上を起点に縮小 */
    margin: 0;
    padding: 0;
}

.scg-custom-wrapper{
    overflow: auto;
}

/* サイト紹介カードのスタイル（カスタム記事専用） */
.site-card-container {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
    overflow: hidden;
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}

.scg-site-card {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
}

.card-image-box {
    width: 100%;
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 4px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}

.img-placeholder {
    color: #888;
    font-size: 12px;
}

.card-description {
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.card-link-box {
    font-size: 12px;
    background: #f1f3f5;
    padding: 8px;
    border-radius: 4px;
    color: #007bff;
    word-break: break-all;
}

/* 編集中の枠線を強調 */
.movable.active.site-card-container {
    outline: 2px solid #007bff;
}

/* 3. スマホ・タブレット用：画面が850pxより狭い時に発動 */
@media screen and (max-width: 850px) {
    .custom-layout {
        /* 「実際の画面幅 ÷ 850px」の比率で全体を等倍縮小 */
        transform: scale(calc(100vw / 750));
        
        /* scaleを使うと元の領域が残ってしまうため、高さを動的に補正 */
        /* コンテンツが途切れる場合は、ここを調整するかJSでの制御が必要です */
        margin-bottom: calc((750px - 100vw) * -1);
    }
}

/* --- 以下、要素のズレ防止設定 --- */
.custom-layout * {
    line-height: inherit !important;
    vertical-align: top;
    box-sizing: border-box;
}

.custom-layout p {
    margin: 0 !important;
    padding: 0 !important;
}

/* 画像と動画を枠に固定 */
.movable img, .movable iframe {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: contain;
}

.movable-line {
    width: 100%;
    height: 4px;
    background: #333;
    display: block;
}

/* 修正：height: auto !important を削除 */
.movable {
    position: absolute !important;
    min-width: 50px; /* 500pxは大きすぎる可能性があるため調整 */
    height: auto; 
    display: flex;
    flex-direction: column;
}

/* 編集エリアの設定 */
.editable-area {
    width: 100%;
    height: 100%; /* 親の高さに追随 */
    min-height: 30px;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden; /* 手動リサイズ時に文字がはみ出さないように */
}

/* 編集中のスタイル（安定化のため） */
.movable.editing {
    cursor: text;
}

/* 太字設定を強制的に有効化 */
.custom-layout b, 
.custom-layout strong,
.custom-layout [style*="font-weight: bold"],
.custom-layout [style*="font-weight:bold"] {
    font-weight: bold !important;
}

/* 既存の全指定(*)が邪魔をしている場合の対策 */
.custom-layout * {
    /* line-height: inherit !important; ← もしこれが原因で崩れる場合はここをコメントアウト */
    box-sizing: border-box;
}