:root {
    --main-bg: #cbd3da;
    --toolbar-bg: #343a40;
    --primary-blue: #007bff;
    --edit-green: #28a745;
    --danger-red: #dc3545;
    --panel-bg: #222;
    --panel-text: #00ff00; /* ターミナル風グリーン */
}

/* --- 全体レイアウト --- */
body {
    background: var(--main-bg);
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    margin: 0;
    padding: 0;
    /* フッターと被らないための余白 */
    padding-bottom: 50px; 
}

/* --- ヘッダー：横スクロール対応 --- */
.toolbar {
    background: var(--toolbar-bg);
    padding: 10px 15px;
    display: flex;
    flex-wrap: nowrap;      /* 折り返し禁止 */
    overflow-x: auto;       /* 横スクロール有効 */
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 2000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    align-items: center;
}

/* スクロールバーのデザイン（細く目立たせない） */
.toolbar::-webkit-scrollbar {
    height: 6px;
}
.toolbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.toolbar-group {
    display: flex;
    flex-shrink: 0;         /* グループが潰れないように固定 */
    background: #495057;
    border-radius: 4px;
    padding: 6px 10px;
    gap: 8px;
    align-items: center;
    color: white;
    font-size: 11px;
    border: 1px solid rgba(255,255,255,0.1);
}

.toolbar button {
    background: #2c3e50;
    border: 1px solid #5d6d7e;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: background 0.2s;
}

.toolbar button:hover {
    background: var(--primary-blue);
}

.toolbar input[type="number"], 
.toolbar select {
    background: #2c3e50;
    color: white;
    border: 1px solid #5d6d7e;
    border-radius: 3px;
    padding: 3px;
}

.canvas-container {
    padding: 60px 20px;
    display: flex;
    justify-content: center;
}

/* --- エディタ本体 (Canvas) --- */
#editor-workspace {
    padding: 50px;
    background: white;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

#visual-editor {
    width: 750px;
    min-height: 1100px;
    background: white;
    padding: 0 !important;
    outline: 2px solid var(--primary-blue);
    position: relative;
    line-height: 1.8;
    font-size: 16px;
    overflow: hidden;
    box-sizing: border-box;
    background-size: 20px 20px;
}

/* グリッド表示 */
#visual-editor.show-grid {
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
}

/* --- 移動可能オブジェクト (.movable) --- */
.movable {
    position: absolute !important;
    cursor: move;
    border: 1px solid transparent;
    user-select: none;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.movable.active {
    border: 1px dashed var(--primary-blue);
}

.movable.editing {
    border: 1px solid var(--edit-green);
    cursor: text;
}

/* テキストボックス自動リサイズ設定 */
.editable-area {
    width: 100%;
    height: 100%; /* 親の高さに追随 */
    min-height: 30px;
    outline: none;
    word-break: break-all;
    white-space: normal;
    overflow: hidden;
    padding: 5px;
}

.movable img, .movable iframe {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none; /* ドラッグを阻害しない */
}

/* リサイザー */
.resizer {
    width: 12px;
    height: 12px;
    background: var(--primary-blue);
    position: absolute;
    right: -6px;
    bottom: -6px;
    cursor: nwse-resize;
    z-index: 3000;
    border-radius: 50%;
    display: none;
}

.movable.active .resizer {
    display: block;
}

/* --- フッター：情報パネル固定 --- */
#object-info-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: var(--panel-bg);
    color: var(--panel-text);
    border-top: 2px solid #444;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    z-index: 10000;
    gap: 30px;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.3);
    box-sizing: border-box;
}

.info-item {
    display: inline-block;
    white-space: nowrap;
}

/* --- 右クリックメニュー --- */
#context-menu {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 5000;
    border-radius: 4px;
    padding: 5px 0;
    min-width: 150px;
}

#context-menu div {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
}

#context-menu div:hover {
    background: var(--primary-blue);
    color: white;
}

#custom-theme-input {
    margin-top: 10px;
    display: none;
    border-color: var(--primary-blue);
}

/* --- 投稿パネル --- */
.post-panel {
    max-width: 768px;
    margin: 40px auto 100px;
    padding: 25px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.post-field {
    margin-bottom: 15px;
}

.post-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.post-field input, .post-field select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

/* 追加のスタイル調整 */
.scg-site-card .card-link-box {
    display: block;
    text-decoration: none;
    color: #007bff;
    background: #f0f7ff;
    padding: 10px;
    border-radius: 4px;
    font-weight: bold;
    margin-top: 10px;
    pointer-events: auto; /* 編集モードでもクリック可能にする */
}

.scg-site-card .card-title {
    font-size: 20px;
    margin-bottom: 10px;
    color: #222;
}

/* カード全体の設定 */
.site-card-container {
    user-select: none; /* ドラッグ中のテキスト選択防止 */
}

/* --- スマホ表示用ズレ防止 (等倍縮小) --- */
@media screen and (max-width: 800px) {
    #editor-workspace {
        transform: scale(calc(100vw / 800));
        transform-origin: top center;
        margin: 10px auto;
    }
}