/* ぱらぱら漫画メーカー - サイドバー形式 CSS v3.0.2 - 完全修正版 */

/* ベースリセット */
.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: 15px;
    border-radius: 12px;
    margin: 20px 0;
    max-height: 95vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
    display: block !important;
    width: 100% !important;
    clear: both !important;
    position: relative;
}

/* メインエリア */
.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: 600px;
    max-height: calc(95vh - 30px);
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* サイドバー */
.flipbook-sidebar {
    width: 280px !important;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-right: 2px solid #dee2e6;
    display: flex !important;
    flex-direction: column !important;
    padding: 20px;
    flex-shrink: 0 !important;
    overflow-y: auto;
    box-shadow: inset -2px 0 4px rgba(0,0,0,0.05);
    max-height: 100%;
}

.flipbook-sidebar::-webkit-scrollbar {
    width: 6px;
}

.flipbook-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.flipbook-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.flipbook-sidebar::-webkit-scrollbar-thumb:hover {
    background: #007bff;
}

/* サイドバーセクション */
.flipbook-sidebar-section {
    margin-bottom: 20px;
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.flipbook-sidebar-section h3 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 700;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #f8f9fa;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flipbook-sidebar-section h3::before {
    content: '';
    width: 4px;
    height: 16px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    border-radius: 2px;
}

/* 作品管理セクション */
.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);
}

/* アニメーションコントロール */
.flipbook-animation-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flipbook-animation-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: none;
}

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

#flipbook-play-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.3);
}

#flipbook-play-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

#flipbook-save-btn {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.3);
}

#flipbook-save-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

/* 描画ツール */
.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: 8px;
    padding: 16px 8px;
    background: #fafafa;
    position: relative;
    min-height: 400px;
}

/* キャンバス左右のツール列 */
.flipbook-side-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    width: 56px;
}

.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: 6px 15px 10px;
    flex-shrink: 0;
    height: 175px;
    display: flex;
    flex-direction: column;
}

.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: 18px 16px 8px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.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;
}

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

/* 現在フレーム: 大きく中央に */
.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);
}

.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;
}

.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: #1e3a5f;
    border-radius: 6px;
    padding: 4px 10px;
    margin-top: 4px;
    white-space: nowrap;
    cursor: pointer;
}
.flipbook-paste-hint:hover {
    background: #d4af37;
}

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