/* ぱらぱら漫画メーカー - サイドバー形式 CSS v3.9.0 - Blank Page全画面対応 */

/* Blank Pageテンプレート用：ページ全体の余分なスクロールを止める
   （このアプリが置かれたページにのみ適用） */
html:has(.flipbook-maker-container),
body:has(.flipbook-maker-container) {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* ベースリセット */
.flipbook-maker-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* メインコンテナ（画面いっぱいに固定） */
.flipbook-maker-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    font-size: 14px;
    line-height: 1.4;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 8px;
    border-radius: 0;
    margin: 0;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    box-shadow: none;
    border: none;
    display: block !important;
    width: 100% !important;
    clear: both !important;
    position: relative;
}

/* WordPress管理者バー分を差し引く（ログイン時のはみ出し防止） */
body.admin-bar .flipbook-maker-container {
    height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
    body.admin-bar .flipbook-maker-container {
        height: calc(100dvh - 46px);
    }
}

/* メインエリア（上限を設けず、コンテナの高さをすべて使う） */
.flipbook-main-area {
    background: white;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    height: 100%;
    display: flex !important;
    flex-direction: row !important;
    min-height: 0;
    max-height: none;
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* ===== 右下フロートボタン（資料箱・再生・保存／常時表示） ===== */
.flipbook-fab-stack {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    z-index: 2147482000;
}

.flipbook-fab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.flipbook-fab-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #1e3a5f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.flipbook-fab-item:hover .flipbook-fab-icon {
    background: #1e3a5f;
    color: #fff;
}

.flipbook-fab-item.open .flipbook-fab-icon {
    background: #1e3a5f;
    color: #fff;
}

@media (max-width: 600px) {
    .flipbook-fab-stack { right: 12px; bottom: 12px; gap: 10px; }
    .flipbook-fab-icon { width: 48px; height: 48px; font-size: 20px; }
}

/* 資料箱FABの上に並ぶ登録素材サムネイル */
.flipbook-fab-stickers {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.flipbook-fab-sticker {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: 2px solid #1e3a5f;
    background: #fff;
    padding: 3px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.15s;
}

.flipbook-fab-sticker:hover {
    transform: scale(1.08);
    border-color: #d4af37;
}

.flipbook-fab-sticker img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

@media (max-width: 600px) {
    .flipbook-fab-sticker { width: 42px; height: 42px; }
}

/* ===== 保存モーダル（作品管理＋動画保存） ===== */
.flipbook-work-modal {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147482001;
}

.flipbook-work-modal.hidden {
    display: none !important;
}

.flipbook-work-modal-inner {
    width: 300px;
    max-width: 90%;
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.flipbook-work-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f2f5;
}

.flipbook-work-modal-close {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 4px;
}

.flipbook-work-modal-close:hover {
    color: #1e3a5f;
}

.flipbook-work-btn-primary {
    background: linear-gradient(135deg, #1e3a5f 0%, #274a75 100%);
    box-shadow: 0 3px 10px rgba(30, 58, 95, 0.35);
    font-size: 14px;
    padding: 12px;
}

.flipbook-work-btn-primary:hover {
    box-shadow: 0 5px 16px rgba(30, 58, 95, 0.45);
}

/* 作品管理セクション */
.flipbook-work-name {
    background: white;
    padding: 10px 12px;
    border-radius: 8px;
    border: 2px solid #007bff;
    font-weight: 600;
    color: #495057;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.flipbook-work-name:hover {
    background: #f8f9ff;
    border-color: #0056b3;
    transform: translateY(-1px);
}

.flipbook-work-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flipbook-work-btn {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-transform: none;
    background: linear-gradient(135deg, #98d98e 0%, #7bc96f 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(123, 201, 111, 0.3);
}

.flipbook-work-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(123, 201, 111, 0.4);
}

#flipbook-new-work-btn {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

#flipbook-new-work-btn:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* 再生ボタンはFABアイコン(.flipbook-fab-item)として.flipbook-fab-stackセクションで統一スタイル適用 */
#flipbook-play-btn:disabled .flipbook-fab-icon {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 保存ボタン(モーダル内プライマリボタン)の無効化スタイル */
#flipbook-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#flipbook-save-btn:disabled:hover {
    box-shadow: 0 3px 10px rgba(30, 58, 95, 0.35);
}

/* 描画ツール */
.flipbook-drawing-tools {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flipbook-tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.flipbook-tool-btn {
    padding: 12px 8px;
    border: 2px solid #e9ecef;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #495057;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.flipbook-tool-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0,123,255,0.1) 0%, rgba(0,123,255,0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.flipbook-tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #007bff;
}

.flipbook-tool-btn:hover::before {
    opacity: 1;
}

.flipbook-tool-btn.active {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.flipbook-tool-btn.active::before {
    opacity: 0;
}

/* 色選択セクション */
.flipbook-color-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flipbook-basic-colors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
    justify-items: center;
}

.flipbook-color-item {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 2px solid transparent;
}

.flipbook-color-item:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.flipbook-color-item.selected {
    border-color: #007bff;
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.3);
}

.flipbook-more-colors-btn {
    padding: 10px 12px;
    border: 2px solid #007bff;
    background: linear-gradient(135deg, #f8f9ff 0%, #e7f3ff 100%);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    color: #007bff;
    text-align: center;
}

.flipbook-more-colors-btn:hover {
    background: linear-gradient(135deg, #e7f3ff 0%, #cce7ff 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,123,255,0.2);
}

/* スライダー */
.flipbook-sliders {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flipbook-slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255,255,255,0.5);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #f0f0f0;
}

.flipbook-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flipbook-slider-label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.flipbook-slider-value {
    font-size: 12px;
    font-weight: 700;
    color: #007bff;
    background: linear-gradient(135deg, #e7f3ff 0%, #cce7ff 100%);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid #b3d9ff;
    min-width: 45px;
    text-align: center;
}

.flipbook-slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #e9ecef 0%, #dee2e6 100%);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.flipbook-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
    transition: all 0.3s ease;
}

.flipbook-slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 10px rgba(0,123,255,0.4);
}

.flipbook-slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

/* フレーム操作 */
.flipbook-frame-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flipbook-frame-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.flipbook-frame-btn {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    color: #495057;
    text-align: center;
}

.flipbook-frame-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.flipbook-frame-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.flipbook-clear-btn {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-color: #c82333;
    grid-column: 1 / -1;
}

.flipbook-clear-btn:hover:not(:disabled) {
    box-shadow: 0 3px 8px rgba(220, 53, 69, 0.3);
}

/* 履歴操作 */
.flipbook-history-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.flipbook-history-btn {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
    color: #495057;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flipbook-history-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.flipbook-history-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* メインコンテンツエリア */
.flipbook-content-area {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0;
    min-width: 0;
}

/* キャンバスエリア（前・現在・次を同サイズで横並び） */
.flipbook-canvas-area {
    flex: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px;
    padding: 14px 10px;
    background: #fafafa;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* 前・現在・次の幅配分：前後はメインの約42%（半分以下） */
.flipbook-canvas-wrap,
.flipbook-nav-panel {
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flipbook-canvas-wrap { flex: 1 1 0; max-width: 820px; z-index: 10; }
.flipbook-nav-panel   { flex: 0.42 0.42 0; max-width: 344px; }

/* 前後コマの内側1/3をメイン画面の後ろに潜り込ませる
   （z-indexは指定しない：スタッキングコンテキストを作らないことで矢印を最前面に出せる） */
.flipbook-nav-prev { margin-right: -7.5%; }
.flipbook-nav-next { margin-left: -7.5%; }

/* 表示順：前のコマ → 左ツール → キャンバス → 右ツール → 次のコマ */
.flipbook-nav-prev    { order: 1; }
.flipbook-side-left   { order: 2; }
.flipbook-canvas-wrap { order: 3; }
.flipbook-side-right  { order: 4; }
.flipbook-nav-next    { order: 5; }

#flipbook-canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* キャンバス左右のツール列（高さは中身のまま。キャンバスがこの高さに合わせる） */
.flipbook-side-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 0 0 auto;
    width: 56px;
    z-index: 20;
    background: rgba(255,255,255,0.92);
    border-radius: 14px;
    padding: 6px 2px;
    box-shadow: 0 3px 14px rgba(0,0,0,0.12);
    box-sizing: border-box;
}

.flipbook-side-tools > * { flex-shrink: 0; }

/* ===== 前後コマ（メインと同サイズ・半透明） ===== */
.flipbook-nav-panel {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.flipbook-nav-panel:hover { opacity: 0.8; }

.flipbook-nav-panel.flipbook-nav-empty { opacity: 0.12; }

.flipbook-nav-preview {
    position: relative;
    width: 100%;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flipbook-nav-canvas {
    display: block;
    width: 100%;
    height: auto;
}

.flipbook-nav-label {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #1e3a5f;
    background: rgba(255,255,255,0.85);
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 700;
    z-index: 3;
    pointer-events: none;
}

.flipbook-nav-num {
    position: absolute;
    bottom: 5px;
    right: 6px;
    font-size: 11px;
    background: rgba(255,255,255,0.9);
    color: #495057;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 700;
    z-index: 3;
}

/* 矢印：ツール列のさらに外側（前後コマ側） */
.flipbook-nav-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid #1e3a5f;
    background: rgba(255,255,255,0.97);
    color: #1e3a5f;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    transition: all 0.15s;
    z-index: 25;
    opacity: 1;
}

/* 矢印は前後コマ画面の上下左右中央（.flipbook-nav-arrow で一括指定） */

.flipbook-nav-arrow:hover { background: #1e3a5f; color: #fff; }
.flipbook-nav-arrow:disabled { opacity: 0.3; cursor: not-allowed; }

/* 半透明パネル内でも矢印だけは常にはっきり見せる */
.flipbook-nav-panel { position: relative; }

/* ===== 下部ドットインジケーター ===== */
.flipbook-dots-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.flipbook-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s;
}

.flipbook-dots:hover { background: #eef2f7; }

.flipbook-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c3ccd6;
    transition: all 0.15s;
    flex-shrink: 0;
}

.flipbook-dot.active {
    background: #1e3a5f;
    width: 22px;
    border-radius: 4px;
}

/* ホバー/タップでフロート表示されるコマ一覧 */
.flipbook-frames-flyout {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    width: min(92vw, 760px);
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 2147481500;
}

.flipbook-dots-bar:hover .flipbook-frames-flyout,
.flipbook-dots-bar.flipbook-flyout-open .flipbook-frames-flyout {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* 狭い画面：前後コマを隠して描画面を確保（矢印は残す） */
@media (max-width: 1100px) {
    .flipbook-canvas-area { gap: 4px; }
    .flipbook-nav-panel {
        flex: 0 0 46px;
        opacity: 1;
    }
    .flipbook-nav-prev { margin-right: 0; }
    .flipbook-nav-next { margin-left: 0; }
    .flipbook-nav-preview,
    .flipbook-nav-label { display: none; }
    .flipbook-nav-prev .flipbook-nav-arrow,
    .flipbook-nav-next .flipbook-nav-arrow {
        position: static;
        transform: none;
        left: auto;
        right: auto;
    }
}

@media (max-width: 700px) {
    .flipbook-canvas-area { padding: 10px 4px; }
    .flipbook-side-tools { width: 48px; }
    .flipbook-st-btn { width: 44px; height: 44px; }
    .flipbook-nav-panel { flex: 0 0 38px; }
    .flipbook-nav-arrow { width: 38px; height: 38px; font-size: 22px; }
}

.flipbook-st-btn {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    gap: 2px;
    padding: 0;
    transition: all 0.15s;
}

.flipbook-st-btn.active {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}

.flipbook-st-btn.flipbook-st-danger {
    color: #e24b4a;
    border-color: #e24b4a;
}

.flipbook-st-btn.flipbook-st-add {
    border-color: #1e3a5f;
    color: #1e3a5f;
    background: #f0f5ff;
}
.flipbook-st-btn.flipbook-st-add:hover {
    background: #1e3a5f;
    color: #fff;
}

.flipbook-st-btn:hover:not(.active) {
    background: #f0f5ff;
    border-color: #1e3a5f;
}

.flipbook-st-icon {
    font-size: 22px;
    line-height: 1;
}

/* SVGアイコン共通サイズ */
.flipbook-st-svg {
    width: 26px;
    height: 26px;
    display: block;
    object-fit: contain;
}

/* サイドバー内SVG（再生ボタン） */
.flipbook-sidebar-svg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 2px;
}

/* dangerボタンのSVGは赤っぽくフィルター */
.flipbook-st-danger .flipbook-st-svg {
    filter: invert(30%) sepia(80%) saturate(500%) hue-rotate(320deg);
}

.flipbook-st-label {
    font-size: 10px;
    line-height: 1;
    color: inherit;
}

.flipbook-st-div {
    width: 32px;
    height: 1px;
    background: #ddd;
    margin: 2px 0;
}

/* 常時表示3色 */
.flipbook-quick-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s;
    flex-shrink: 0;
}
.flipbook-quick-color:hover { transform: scale(1.15); }
.flipbook-quick-color.selected {
    outline: 2.5px solid #1e3a5f;
    outline-offset: 2px;
}

/* 現在色ボタン */
.flipbook-current-color-btn {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    gap: 3px;
    transition: all 0.15s;
}
.flipbook-current-color-btn:hover { border-color: #1e3a5f; background: #f0f5ff; }
.flipbook-current-color-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.15);
}

/* 縦スライダー */
.flipbook-vslider-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.flipbook-vslider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 28px;
    height: 80px;
    cursor: pointer;
    accent-color: #1e3a5f;
}

/* カラーPOPUP */
.flipbook-color-popup {
    position: absolute;
    right: 68px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    background: #fff;
    border: 1.5px solid #1e3a5f;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 12px;
}
.flipbook-color-popup.hidden { display: none !important; }

.flipbook-color-popup-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.flipbook-color-popup .flipbook-basic-colors {
    display: grid;
    grid-template-columns: repeat(5, 28px);
    gap: 6px;
}

.flipbook-color-popup .flipbook-color-item {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}
.flipbook-color-popup .flipbook-color-item:hover { transform: scale(1.15); }
.flipbook-color-popup .flipbook-color-item.selected {
    outline: 2px solid #1e3a5f;
    outline-offset: 2px;
}

#flipbook-color-picker {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

.flipbook-canvas-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 48, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(0, 182, 122, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

#flipbook-canvas {
    border: 3px solid #007bff !important;
    border-radius: 8px;
    background: white !important;
    cursor: crosshair;
    box-shadow: 
        0 8px 25px rgba(0,123,255,0.15),
        inset 0 1px 0 rgba(255,255,255,0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 100%;
    max-height: 100%;
    position: relative;
    z-index: 1;
    display: block !important;
}

#flipbook-canvas:hover {
    box-shadow: 
        0 12px 35px rgba(0,123,255,0.2),
        inset 0 1px 0 rgba(255,255,255,0.5);
    transform: scale(1.02);
}

/* フレーム一覧エリア */
.flipbook-frames-area {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    padding: 4px 15px;
    flex-shrink: 0;
    height: 46px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.flipbook-frame-count {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
    color: #1e3a5f;
    background: rgba(231,243,255,0.92);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 700;
    border: 1px solid #b3d9ff;
    z-index: 5;
    pointer-events: none;
}

.flipbook-thumbnails {
    display: flex !important;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 16px 10px 10px;
    background: transparent;
    border-radius: 6px;
    border: none;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    scroll-snap-type: x proximity;
}

.flipbook-thumbnails::-webkit-scrollbar { height: 5px; }
.flipbook-thumbnails::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.flipbook-thumbnails::-webkit-scrollbar-thumb { background: #aaa; border-radius: 3px; }

.flipbook-thumbnail-item {
    position: relative;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: visible;
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    opacity: 0.55; /* 非選択フレームは薄く表示（フロート一覧内なので判別可能な濃さに） */
}

.flipbook-thumbnail-item:hover {
    border-color: #1e3a5f;
    opacity: 0.75;
}

/* 現在フレーム: 大きく中央に・不透明 */
.flipbook-thumbnail-item.flipbook-thumb-active {
    width: 80px;
    height: 80px;
    border: 3px solid #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30,58,95,0.2), 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-4px);
    opacity: 1;
}

.flipbook-add-frame-btn {
    border: 2px dashed #1e3a5f;
    border-radius: 6px;
    cursor: pointer;
    background: #f0f5ff;
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #1e3a5f;
    font-weight: bold;
    transition: all 0.2s;
    scroll-snap-align: center;
}

.flipbook-add-frame-btn:hover { background: #dceeff; }

.flipbook-thumbnail-canvas {
    display: block;
    border-radius: 4px;
    overflow: hidden;
}

.flipbook-frame-number {
    position: absolute;
    bottom: 2px;
    right: 3px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 1px 3px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
}

/* サムネイル×削除ボタン */
.flipbook-thumb-del {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e24b4a;
    color: #fff;
    border: none;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 10;
    font-weight: 700;
}

.flipbook-thumbnail-item:hover .flipbook-thumb-del {
    display: flex;
}

.flipbook-empty-message {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
    font-size: 13px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flipbook-loading {
    display: none;
    text-align: center;
    color: #1e3a5f;
    font-size: 13px;
    font-weight: 700;
    margin: 4px 0;
    padding: 6px;
    background: #e7f3ff;
    border-radius: 6px;
    border: 1px solid #b3d9ff;
    flex-shrink: 0;
}
.flipbook-loading.show { display: block; }

/* フォーカス状態 */
.flipbook-tool-btn:focus,
.flipbook-color-item:focus,
.flipbook-animation-btn:focus,
.flipbook-frame-btn:focus {
    outline: 3px solid rgba(0,123,255,0.3);
    outline-offset: 2px;
}

/* レスポンシブ対応 */
@media (max-width: 1024px) {
    .flipbook-sidebar {
        width: 250px;
        padding: 15px;
    }
    
    .flipbook-sidebar-section {
        padding: 12px;
        margin-bottom: 20px;
    }
}

@media (max-width: 900px) {
    .flipbook-main-area {
        flex-direction: column !important;
    }
    
    .flipbook-sidebar {
        width: 100% !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
        padding: 15px !important;
        max-height: 200px !important;
        border-right: none !important;
        border-bottom: 2px solid #dee2e6 !important;
    }
    
    .flipbook-sidebar-section {
        flex: 1;
        min-width: 200px;
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    .flipbook-maker-container {
        padding: 10px;
    }
    
    .flipbook-sidebar {
        flex-direction: column !important;
        max-height: none !important;
        gap: 10px !important;
    }
    
    .flipbook-sidebar-section {
        min-width: auto;
        padding: 10px;
    }
    
    .flipbook-tool-buttons {
        grid-template-columns: 1fr 1fr;
    }
    
    .flipbook-canvas-area {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .flipbook-sidebar {
        padding: 10px;
    }
    
    .flipbook-sidebar-section h3 {
        font-size: 12px;
    }
    
    .flipbook-tool-buttons {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .flipbook-animation-controls {
        gap: 8px;
    }
    
    .flipbook-animation-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .flipbook-maker-container {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: #4a5568;
    }
    
    .flipbook-main-area {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .flipbook-sidebar,
    
    .flipbook-sidebar-section {
        background: #374151;
        border-color: #4a5568;
    }
    
    .flipbook-canvas-area {
        background: #1a202c;
    }
}
/* ===== サイドバー資料箱サムネ ===== */
.flipbook-sticker-sidebar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0;
}
.flipbook-sticker-sidebar-list .flipbook-sticker-empty {
    font-size: 11px;
    color: #999;
    text-align: center;
    width: 100%;
    padding: 4px 0;
}
.flipbook-sticker-sidebar-list .flipbook-sticker-item {
    width: 52px;
    height: 52px;
}

/* ===== 資料箱タブボタン ===== */
.flipbook-sticker-tab-btn {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid #1e3a5f;
    border-radius: 8px;
    background: #f0f5ff;
    color: #1e3a5f;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
}
.flipbook-sticker-tab-btn:hover,
.flipbook-sticker-tab-btn.open {
    background: #1e3a5f;
    color: #fff;
}

/* ===== 資料箱ドロワー（フロート） ===== */
.flipbook-sticker-drawer {
    position: fixed;
    top: 50%;
    left: 300px;
    transform: translateY(-50%);
    width: 700px;
    max-height: 92vh;
    background: #fff;
    border: 2px solid #1e3a5f;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 8px;
    overflow-y: auto;
}
.flipbook-sticker-drawer.hidden {
    display: none !important;
}

.flipbook-sticker-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 700;
    color: #1e3a5f;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.flipbook-sticker-drawer-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flipbook-sticker-drawer-close:hover { background: #e24b4a; color: #fff; }

.flipbook-sticker-canvas-wrap {
    border: 2px solid #1e3a5f;
    border-radius: 6px;
    overflow: hidden;
    background-image: linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    cursor: crosshair;
    flex-shrink: 0;
}

#flipbook-sticker-canvas {
    display: block;
    width: 100%;
    height: auto;
}

.flipbook-sticker-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.flipbook-sticker-btn {
    flex: 1;
    padding: 5px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid #1e3a5f;
    background: #f0f5ff;
    color: #1e3a5f;
    cursor: pointer;
    font-weight: 600;
}
.flipbook-sticker-btn:hover { background: #1e3a5f; color: #fff; }

.flipbook-sticker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    max-height: 160px;
    overflow-y: auto;
    padding: 8px;
}

.flipbook-sticker-empty {
    font-size: 11px;
    color: #999;
    text-align: center;
    width: 100%;
    padding: 8px 0;
}

.flipbook-sticker-item {
    width: 64px;
    height: 64px;
    border: 2px solid #ccc;
    border-radius: 6px;
    overflow: visible;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s;
    position: relative;
    flex-shrink: 0;
}

.flipbook-sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}
.flipbook-sticker-item:hover { border-color: #1e3a5f; }
.flipbook-sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.flipbook-sticker-item-del {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e24b4a;
    color: #fff;
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 5;
    font-weight: 700;
}
.flipbook-sticker-item:hover .flipbook-sticker-item-del { display: flex; }

/* 貼り付けオーバーレイ */
.flipbook-paste-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 50;
    user-select: none;
}
.flipbook-paste-overlay.active {
    pointer-events: auto;
    cursor: move;
}
.flipbook-paste-overlay.hidden { display: none !important; }

#flipbook-paste-img {
    display: block;
    border: 2px dashed #1e3a5f;
    border-radius: 4px;
    opacity: 0.85;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;  /* クリックはoverlayで受ける */
}

.flipbook-paste-hint {
    text-align: center;
    font-size: 11px;
    color: #fff;
    font-weight: 700;
    background: rgba(30, 58, 95, 0.75);
    border-radius: 6px;
    padding: 4px 10px;
    margin-top: 4px;
    white-space: nowrap;
    pointer-events: none;
}

/* 貼り付け確定ボタン */
.flipbook-paste-confirm {
    display: block;
    margin: 6px auto 0;
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    background: #d4af37;
    color: #1e3a5f;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    transition: all 0.15s;
}

.flipbook-paste-confirm:hover {
    background: #1e3a5f;
    color: #fff;
}

/* ===== サムネイルD&D ===== */
.flipbook-thumbnail-item.flipbook-drag-over {
    border-color: #d4af37 !important;
    background: #fffbe6 !important;
}
.flipbook-thumbnail-item.flipbook-dragging {
    opacity: 0.4;
}
