body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans CJK JP", "Yu Gothic", Meiryo, sans-serif;
    background-color: #f0f2f5; /* Light gray background */
    color: #333;
    margin: 0;
    padding: 0;
}

.controls-column h3 {
    color: #333;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 10px;
    margin-top: 30px;
}

#fileName-B, #status-B {
    color: #666;
}

/* --- スタート画面のスタイル --- */
#start-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

.start-container {
    max-width: 800px;
    width: 90%;
}

.start-container h1 {
    font-size: 2.5em;
    color: #005a9c;
    border: none;
}

.start-buttons {
    display: flex;
    gap: 30px;
    margin-top: 40px;
    justify-content: center;
}

.start-btn {
    width: 300px;
    padding: 25px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-align: left;
}

.start-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.start-btn h2 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: #007bff;
    border: none;
}

.start-btn p {
    margin: 0;
    font-size: 0.9em;
    color: #666;
}


/* --- A/B画面共通ヘッダー --- */
.header-bar {
    background-color: #fff;
    padding: 10px 40px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 38px;
    position: relative;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.header-bar:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    background-color: #fdfdfd;
}
.header-bar h1 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.5em;
    color: #333;
    font-weight: 700;
}
.back-btn {
    background-color: transparent;
    color: #007bff;
    border: 1px solid #007bff;
    font-weight: bold;
    border-radius: 6px;
    transition: all 0.2s;
}
.back-btn:hover {
    background-color: #e7f3ff;
    transform: translateY(-1px);
}
.back-btn:active {
    transform: translateY(1px);
}

/* --- ツールバーのスタイル --- */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
}
.toolbar-btn {
    background-color: #6c757d;
    padding: 8px 18px;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    color: white;
}
.toolbar-btn:hover:not(:disabled) {
    background-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.toolbar-btn:active:not(:disabled) {
    background-color: #4e555b;
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.toolbar-btn:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}
.toolbar-btn.active {
    background-color: #007bff;
    color: white;
    font-weight: bold;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
    transform: none;
}
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-container {
    position: relative;
    display: inline-block;
}
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #ffffff;
    min-width: 180px;
    box-shadow: 0px 8px 25px rgba(0,0,0,0.15);
    z-index: 1001;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-top: 8px;
    overflow: hidden;
}
.dropdown-content a {
    color: #444;
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    transition: all 0.2s;
}
.dropdown-content a:hover {
    background-color: #f0f7ff;
    color: #007bff;
    padding-left: 24px;
}
.dropdown-content.show {
    display: block;
    animation: fadeInDown 0.2s ease-out;
}
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* --- 2カラムレイアウトのスタイル --- */
.main-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    padding: 0 20px;
    max-width: 1600px;
    margin: 20px auto;
}

.controls-column {
    width: 450px;
    flex-shrink: 0;
}

.canvas-column {
    flex-grow: 1;
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#preview-B, #preview-A, #preview-container-B, #preview-container-A {
    width: 100%;
}


/* PDFをドラッグ＆ドロップしたときの背景色 */
body.dragover {
    background-color: #e0f0ff;
}

hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 30px 0;
}

.controls-column h3 {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
    margin-top: 30px;
}

/* --- 各セクションのスタイル --- */
.control-group {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    color: #333;
}

/* --- フォーム要素のスタイル --- */
input[type="file"],
select {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    margin-bottom: 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
input[type="text"] {
     width: calc(100% - 22px);
     padding: 10px;
     font-size: 16px;
     border-radius: 4px;
     border: 1px solid #ccc;
}

button {
    padding: 10px 18px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #0056b3;
}

/* モード切替ボタンのスタイル */
.mode-switch-btn {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    font-weight: bold;
    background-color: #28a745;
}
.mode-switch-btn:hover {
    background-color: #218838;
}


/* --- 値入力フォームのスタイル --- */
.value-input-item {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}
.value-input-item > label {
    flex: 0 0 150px;
    font-weight: bold;
    padding-right: 10px;
    text-align: right;
}
.radio-group-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    flex: 1;
}
.radio-group-container div {
    display: flex;
    align-items: center;
}
.radio-group-container label {
    flex: initial;
    font-weight: normal;
    text-align: left;
    margin-left: 5px;
}


/* --- キャンバスのスタイル --- */
#preview-B, #preview-A {
    text-align: center;
}

#pdfCanvas-B, #pdfCanvas-A {
    border: none;
    max-width: 100%;
    height: auto;
    background-color: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    display: block;
    margin: 0 auto;
}

/* --- 質問ビルダーのスタイル --- */
#questionBuilder {
    background-color: #f8f9fa;
}
.question-block {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 15px;
    background-color: #fff;
    position: relative;
}
.delete-question-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-weight: bold;
    line-height: 25px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}
.form-group {
    margin-bottom: 10px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
}
.choice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.choice-item select {
    width: 150px;
    margin-bottom: 0;
}
.choice-item input {
    flex-grow: 1;
}
.add-choice-btn {
    font-size: 0.8em;
    padding: 5px 10px;
    background-color: #6c757d;
}


/* モーダル（ポップアップ）のスタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.1); /* 背景を暗くしすぎない */
    overflow: auto;
}
.modal-content {
    background-color: #fefefe;
    margin: 10vh auto;
    padding: 20px;
    border: 1px solid #ccc;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* 設定用モーダル（グループ化・自動判定）を左側に寄せる */
#groupingModal .modal-content,
#autoFillModal .modal-content {
    position: fixed;
    top: 80px;
    left: 20px; /* 右から左へ変更 */
    margin: 0;
    width: 420px;
    max-height: 85vh;
    overflow-y: auto;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-button:hover,
.close-button:focus {
    color: black;
}
/* グループ化モード中にボタンをアクティブに見せるスタイルは .toolbar-btn.active に統一 */

.floating-controls {
    position: absolute;
    z-index: 1000; /* Canvasより手前に */
    background: white;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 複製コントロール全体のコンテナ */
.quick-duplicate-controls {
    position: absolute;
    z-index: 1000;
    pointer-events: none; /* コンテナ自体はクリックを邪魔しない */
}

/* 矢印ボタン共通 */
.dup-btn {
    position: absolute;
    width: 24px;
    height: 24px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    color: #555;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    pointer-events: auto; /* ボタンはクリック可能に */
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: background-color 0.2s;
    padding: 0;
}

.dup-btn:hover {
    background-color: #e0f7fa; /* ホバー時は水色っぽく */
    color: #007bff;
    border-color: #007bff;
}

/* 各方向の位置調整 (JSでコンテナを中心に配置した後、ここ微調整) */
.dup-top    { top: -35px; left: 50%; transform: translateX(-50%); }
.dup-bottom { bottom: -35px; left: 50%; transform: translateX(-50%); }
.dup-left   { left: -35px; top: 50%; transform: translateY(-50%); }
.dup-right  { right: -35px; top: 50%; transform: translateY(-50%); }

.rule-row { display: flex; align-items: center; margin-bottom: 8px; gap: 5px; }
.rule-row input { flex: 1; padding: 5px; }
.rule-delete { cursor: pointer; color: red; font-weight: bold; }

/* style.css の末尾に追加 */

/* === Phase 1: スタート画面とオーバーレイ === */

/* スタート画面 */
.start-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    background-color: #f9f9f9;
    text-align: center;
    position: fixed; /* 画面固定 */
    top: 0;
    left: 0;
    z-index: 100;
}

.start-content h1.app-logo {
    font-size: 3rem;
    color: #333;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.start-content .app-desc {
    color: #666;
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

.primary-btn {
    background-color: #007bff;
    color: white;
    padding: 15px 40px;
    font-size: 1.2rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,123,255, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,123,255, 0.4);
    background-color: #0056b3;
}

.sub-text {
    margin-top: 1.5rem;
    color: #999;
    font-size: 0.9rem;
}

/* 全画面ドラッグオーバーレイ */
.drag-overlay {
    display: none; /* 通常非表示 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 123, 255, 0.9); /* 青色背景 */
    z-index: 9999; /* 最前面 */
    justify-content: center;
    align-items: center;
    color: white;
    pointer-events: none; /* ドロップイベントを下のwindowに通す */
}

.drag-overlay.active {
    display: flex;
}

.overlay-content {
    pointer-events: none;
    text-align: center;
}

/* style.css の一番下に追加 */

/* --- ツールチップ（説明吹き出し）のスタイル --- */
.tooltip {
    position: relative; /* 子要素の絶対配置の基準 */
}

/* 吹き出し本体と三角マークの共通設定（初期状態は非表示） */
.tooltip::after,
.tooltip::before {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    transition-delay: 0s; /* 消えるときは即座に */
    pointer-events: none;
    z-index: 1100;
}

/* ホバー時にディレイを置いて表示 */
.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.6s; /* 0.6秒待ってから表示 */
}

/* 吹き出し本体 */
.tooltip::after {
    content: attr(data-tooltip);
    top: 100%;
    margin-top: 12px;
    background-color: #333;
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    width: max-content;
    max-width: 280px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    text-align: left;
}

/* 三角マーク */
.tooltip::before {
    content: "";
    top: 100%;
    margin-top: 0px;
    border: 6px solid transparent;
    border-bottom-color: #333;
}

/* ホバー時に少し浮き上がるアニメーションを追加 */
.tooltip:hover::after {
    transform: translateX(-50%) translateY(4px);
}
.tooltip:hover::before {
    transform: translateX(-50%) translateY(4px);
}

/* --- ヘッダー用保存ボタンのスタイル --- */
.save-header-btn {
    background-color: #5295d0; 
    color: white;
    padding: 8px 22px;
    font-size: 14px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 8px; /* アイコンと文字の間隔 */
    transition: all 0.2s ease;
}

.save-header-btn:hover {
    background-color: #4184be; /* ホバー時は少し明るく */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.save-header-btn:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    filter: brightness(0.9);
}

/* --- セットアップウィザード用スタイル --- */
.wizard-container {
    max-width: 900px;
    width: 95%;
    height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

/* ヘッダー */
.wizard-header {
    background: #fff;
    padding: 20px;
    border-bottom: 1px solid #eee;
    text-align: center;
    flex-shrink: 0; /* 縮ませない */
}
.wizard-header h2 { margin: 0; font-size: 1.5rem; color: #333; }

/* ステップインジケーター */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #ccc;
}
.step-indicator .step { font-weight: bold; }
.step-indicator .step.active { color: #007bff; }
.step-indicator .line {
    width: 30px; height: 2px; background: #eee; margin: 0 10px;
}

/* コンテンツエリア (ここが重要) */
.wizard-step {
    flex: 1; /* 残りの高さを一杯に使う */
    display: none; /* 初期は非表示、JSでflexに切り替え */
    flex-direction: column;
    overflow: hidden; /* コンテナ自体はスクロールさせない */
}
/* JSで表示するときは display: flex になるようにする */
.wizard-step.active-step {
    display: flex !important;
}

/* スクロールする中身 */
.step-scroll-content {
    flex: 1;
    overflow-y: auto; /* ここだけスクロール */
    padding: 30px;
    background: #f9f9f9;
}

.wizard-step h3 { margin-top: 0; border-bottom: 2px solid #007bff; display: inline-block; padding-bottom: 5px; margin-bottom: 20px; }

/* フッターボタンエリア (固定) */
.wizard-buttons {
    padding: 20px 30px;
    background: #fff;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    flex-shrink: 0; /* 固定 */
    z-index: 10;
}

/* 要素の上に来た時（掴めるよ、という合図） */
.cursor-grab {
    cursor: grab !important;
    cursor: -webkit-grab !important; /* 古いブラウザ用 */
}

/* 実際に掴んで動かしている時 */
.cursor-grabbing {
    cursor: grabbing !important;
    cursor: -webkit-grabbing !important; /* 古いブラウザ用 */
}

/* その他パーツ (変更なし) */
.file-list { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); list-style: none; }
.file-list li { padding: 10px; border-bottom: 1px solid #eee; font-size: 1.1rem; }
.form-group label { font-weight: bold; color: #555; }
.form-group input[type="text"] { width: 100%; padding: 12px; margin-top: 5px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.tabs { display: flex; gap: 5px; margin-bottom: 0; border-bottom: 1px solid #ccc; }
.tab-btn { padding: 10px 20px; background: #e0e0e0; border: none; border-radius: 5px 5px 0 0; cursor: pointer; font-weight: bold; color: #666; }
.tab-btn.active { background: #333; color: #fff; }
.code-area { position: relative; background: #333; padding: 0; border-radius: 0 0 5px 5px; }
.code-block { display: none; }
.code-block.active { display: block; }
textarea { width: 100%; height: 350px; background: #1e1e1e; color: #d4d4d4; border: none; padding: 15px; font-family: 'Consolas', monospace; font-size: 13px; line-height: 1.5; resize: none; box-sizing: border-box; }
.copy-btn { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.3); padding: 5px 12px; border-radius: 4px; cursor: pointer; }
.img-box { margin-top: 10px; border: 1px solid #ddd; padding: 5px; background: #fff; display: inline-block; max-width: 100%; }
.img-box img { max-width: 100%; height: auto; display: block; }
.primary-btn { background: #007bff; color: white; border: none; padding: 12px 30px; border-radius: 5px; cursor: pointer; font-size: 1rem; }
.secondary-btn { background: #6c757d; color: white; border: none; padding: 12px 30px; border-radius: 5px; cursor: pointer; font-size: 1rem; }