:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-sub: #475569;
    --accent-color: #10b981;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 0;
    margin: 0;
}

.container.wide { 
    max-width: 1200px; 
    margin: 0 auto; 
    width: 100%; 
}

header { 
    padding: 15px 20px; 
    background: white; 
    border-bottom: 1px solid #e2e8f0; 
    margin-bottom: 20px;
}
header h1 { font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }

.main-container {
    display: flex;
    gap: 20px;
    padding: 0 20px 20px 20px;
    align-items: flex-start; /* これが重要：中身の高さに合わせる */
}

.settings-sidebar {
    width: 380px;
    flex-shrink: 0;
}

.preview-content {
    flex: 1;
    position: sticky; /* スクロールに追従 */
    top: 20px; /* 画面上部からの距離 */
}

.sticky-preview {
    width: 100%;
}

.card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 15px;
}

h3 { font-size: 0.9rem; margin-bottom: 15px; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.05em; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 0.85rem; margin-bottom: 5px; font-weight: 500; }
textarea, select, input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
}

input[type="range"] { width: 100%; margin-top: 5px; }

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: normal;
    cursor: pointer;
}

.primary-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background 0.2s;
}
.primary-btn:hover { background: var(--primary-hover); }

.secondary-btn {
    width: 100%;
    background: #bbdefb;
    color: #1565c0;
    border: 1px solid #90caf9;
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.secondary-btn:hover { opacity: 0.8; }

#result-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    overflow: hidden;
}

#result-area svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05));
}

.info-card {
    background-color: #fffbeb;
    border: 1px solid #fef3c7;
}

.info-list {
    padding-left: 20px;
    margin: 0;
}

.info-list li {
    font-size: 0.85rem;
    color: #92400e;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* レイアウト構造 (PC版デフォルト) */
.main-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* 左側：設定エリア (PC版) */
.settings-sidebar {
    flex: 0 0 350px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding-right: 10px;
}

/* 右側：プレビューエリア (PC版) */
.preview-content {
    flex: 1;
    min-width: 0;
}

.sticky-preview {
    position: sticky;
    top: 20px;
}

.preview-card {
    margin-bottom: 20px;
    min-height: 450px;
    display: flex;
    flex-direction: column;
}

#result-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    overflow: hidden;
}

#result-area svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05));
}

.info-card {
    background-color: #fffbeb;
    border: 1px solid #fef3c7;
}

.info-list {
    padding-left: 20px;
    margin: 0;
}

.info-list li {
    font-size: 0.85rem;
    color: #92400e;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* --------------------------------------------------
   スマホ対応 (モバイル専用に上書き)
-------------------------------------------------- */
@media (max-width: 850px) {
    .main-container {
        flex-direction: column;
        gap: 0;
    }

    .settings-sidebar {
        flex: none;
        width: 100%;
        position: static;
        order: 3; /* 設定を一番下に */
        max-height: none;
        overflow-y: visible;
        padding: 20px 15px;
    }

    /* display: contentsにより、子要素が直接main-container直下にあるかのように振る舞う */
    .preview-content {
        display: contents;
    }

    .sticky-preview {
        position: sticky;
        top: 0;
        z-index: 2000;
        background: white;
        padding: 0;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    .preview-card {
        margin-bottom: 0;
        border-radius: 0;
        border: none;
        min-height: auto;
    }

    #result-area {
        min-height: 180px;
        border: none;
        border-radius: 0;
        padding: 10px;
    }

    .info-card {
        order: 2; /* お知らせをプレビューの直後に */
        margin: 15px;
        border-radius: 8px;
        position: relative;
        z-index: 10;
    }

    header {
        position: relative;
        z-index: 2001;
        background: white;
        border-bottom: 1px solid #e2e8f0;
    }

    .lang-switch-container {
        background: white;
        padding: 8px 15px;
        margin-bottom: 0;
        border-bottom: 1px solid #f1f5f9;
    }
}

/* 言語切り替えスイッチ (共通) */
.lang-switch-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 10px;
    padding-right: 5px;
}
.lang-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sub);
}
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 20px; }
.slider.round:before { border-radius: 50%; }

footer { text-align: center; margin-top: 20px; color: var(--text-sub); font-size: 0.8rem; padding: 10px; }

.hidden { display: none !important; }
