/* -------------------------------------------------------------
 * WebP Converter Pro - デザインシステム ＆ スタイルシート
 * ------------------------------------------------------------- */

/* 基本設定とカラー変数 */
:root {
    --bg-main: #0b0f19;          /* メイン背景: 超深紺 */
    --bg-card: rgba(22, 31, 48, 0.75); /* カード背景: 半透明の濃紺（グラスモフィズム用） */
    --border-color: rgba(255, 255, 255, 0.08); /* 通常ボーダー */
    --border-focus: #6366f1;     /* フォーカス時のインディゴ色 */
    
    /* テキストカラー */
    --text-primary: #f3f4f6;     /* プライマリテキスト: オフホワイト */
    --text-secondary: #9ca3af;   /* セカンダリテキスト: ライトグレー */
    --text-muted: #6b7280;       /* ミュートテキスト: ミディアムグレー */
    
    /* ブランドグラデーション */
    --grad-primary: linear-gradient(135deg, #6366f1, #a855f7); /* インディゴからパープル */
    --grad-success: linear-gradient(135deg, #10b981, #059669); /* エメラルドからダークグリーン */
    --grad-danger: linear-gradient(135deg, #f43f5e, #e11d48);  /* ローズからダークレッド */
    --grad-info: linear-gradient(135deg, #0ea5e9, #0284c7);    /* スカイブルーからダークブルー */
    --grad-dark: linear-gradient(135deg, #1f2937, #111827);    /* ダークグレー */

    /* シャドウ効果 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* トランジション */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* リセット & グローバルスタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    line-height: 1.6;
    overflow-x: hidden;
    /* 背景のダイナミックなグラデーション球体エフェクト */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
    background-attachment: fixed;
}

/* アプリ全体のコンテナ */
.app-container {
    width: 100%;
    max-width: 1280px;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* ヘッダーのスタイリング */
.app-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.logo-icon {
    font-size: 2.25rem;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(168, 85, 247, 0.3));
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, #ffffff 60%, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo h1 span {
    font-weight: 400;
    color: var(--text-secondary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.75rem, 2vw, 0.95rem);
    font-weight: 400;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    letter-spacing: 0.01em;
    line-height: 1.5;
    text-align: center;
}

/* メインコンテンツレイアウト (左右2カラム) */
.app-main {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 2rem;
    align-items: stretch;
}

@media (max-width: 1024px) {
    .app-main {
        grid-template-columns: 1fr;
    }
}

/* 共通カードスタイル (グラスモフィズム) */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.card-header i {
    font-size: 1.25rem;
    color: #a855f7;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* 左カラム: コントロールパネルの配置 */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ドラッグ＆ドロップエリア */
.upload-card {
    padding: 0.75rem; /* 内側のドロップゾーンを目立たせるためにカードパディングを調整 */
}

.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-normal);
    background: rgba(255, 255, 255, 0.01);
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.04);
    box-shadow: var(--shadow-glow);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none; /* 子要素がクリックイベントを邪魔しないようにする */
}

.icon-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-normal);
    border: 1px solid var(--border-color);
}

.drop-zone:hover .icon-circle, .drop-zone.drag-over .icon-circle {
    background: var(--grad-primary);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    border-color: transparent;
}

.icon-circle i {
    font-size: 1.75rem;
    color: var(--text-secondary);
    transition: color var(--transition-normal);
}

.drop-zone:hover .icon-circle i, .drop-zone.drag-over .icon-circle i {
    color: #ffffff;
}

.drop-zone h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.drop-zone p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.drop-zone p span {
    color: #6366f1;
    font-weight: 600;
    text-decoration: underline;
}

.file-types {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 設定セクションの入力要素 */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-label-row label {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-label-row label i {
    color: #a855f7;
}

.value-display {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* スライダーのスタイリング */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: background var(--transition-fast);
}

.slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #a855f7;
    cursor: pointer;
    margin-top: -6px;
    transition: transform var(--transition-fast), background var(--transition-fast);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #b55fe6;
}

/* テキスト入力、数値入力、セレクトボックスのスタイリング */
.text-input, .input-wrapper input, .input-wrapper select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    width: 100%;
    box-sizing: border-box;
}

.text-input:focus, .input-wrapper input:focus, .input-wrapper select:focus {
    outline: none;
    border-color: var(--border-focus);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.resize-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-wrapper label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 右カラム: ステータスパネル */
.status-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

/* 統計ダッシュボードカード */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}

.stat-card.highlighted {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(5, 150, 105, 0.05));
}

.stat-card.highlighted .stat-value {
    color: #34d399;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* アクションバーとボタン */
.action-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .action-bar {
        flex-direction: column;
    }
}

.btn {
    flex: 1;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 12px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: var(--grad-primary);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.4);
}

.btn-success {
    background: var(--grad-success);
}

.btn-success:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: var(--grad-danger);
}

.btn-danger:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(244, 63, 94, 0.4);
}

.btn-info {
    background: var(--grad-info);
}

.btn-info:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.4);
}

/* リストカードとプレビューリスト */
.list-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 400px;
    height: 0;
}

.list-header {
    margin-bottom: 0;
    padding-bottom: 1rem;
}

.badge {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: auto;
}

.list-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
    color: var(--text-muted);
    padding: 3rem;
}

.list-placeholder i {
    font-size: 3rem;
    opacity: 0.3;
}

.list-placeholder p {
    font-size: 0.95rem;
    text-align: center;
}

/* 動的画像リスト */
.image-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* スクロールバーのカスタマイズ */
.image-list::-webkit-scrollbar {
    width: 6px;
}

.image-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.image-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.image-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* リストアイテム (個別画像カード) */
.image-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-fast);
}

.image-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

/* サムネイルプレビュー */
.thumbnail-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 画像情報エリア */
.image-info {
    display: flex;
    flex-direction: column;
    min-width: 0; /* 折り返しを有効にするため */
}

/* 流れるテキスト（見切れるフォルダ名・ファイル名の電光掲示板アニメーション） */
.scroll-text-parent {
    display: block;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip; /* 常にアニメーションするため三点リーダーは不要 */
    cursor: default;
    position: relative;
    container-type: inline-size; /* コンテナクエリで親幅を取得 */
}

.scroll-text-child {
    display: inline-block;
    white-space: nowrap;
    will-change: transform;
}

/* スクロール有効化クラス */
.scroll-text-child.marquee-active {
    /* 14秒かけて滑らかに往復（alternate）するアニメーションを無限ループ */
    animation: marqueeScroll 14s ease-in-out infinite alternate;
}

@keyframes marqueeScroll {
    /* 0%〜15%（開始）と 85%〜100%（端に達した時）に静止時間を設け、中間の移動を滑らかにする */
    0%, 15% {
        transform: translateX(0);
    }
    85%, 100% {
        /* -100% (自分自身のテキスト幅) + 100cqw (親コンテナの幅) で、はみ出た分だけ正確に左スクロールする */
        transform: translateX(calc(-100% + 100cqw));
    }
}

.image-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.image-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
}

.size-tag {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.savings-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: #34d399;
    background: rgba(52, 211, 153, 0.12);
    padding: 0.05rem 0.4rem;
    border-radius: 4px;
}

/* ステータスバッジ */
.status-indicator {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-waiting {
    color: var(--text-secondary);
}

.status-converting {
    color: #60a5fa;
}

.status-converting i {
    animation: spin 1s linear infinite;
}

.status-completed {
    color: #34d399;
}

.status-error {
    color: #f87171;
}

/* 個別アクションエリア */
.item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon.btn-download-item {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.2);
}

.btn-icon.btn-download-item:hover {
    background: rgba(52, 211, 153, 0.1);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.4);
}

.btn-icon.btn-remove-item:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

/* アニメーション */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* フッターのスタイリング */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    margin-top: 1rem;
}

/* アーカイブ展開中のローディング */
.archive-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    flex-grow: 1;
    color: #60a5fa;
    padding: 3rem;
    text-align: center;
}

.loading-spinner {
    font-size: 3rem;
    color: #60a5fa;
    animation: spin 1s linear infinite;
    filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.4));
}

/* -------------------------------------------------------------
 * アーカイブ単位のグループ表示用スタイル
 * ------------------------------------------------------------- */

/* グループ全体のコンテナカード */
.group-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    margin-bottom: 1.25rem;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.group-card:hover {
    border-color: rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.025);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* グループヘッダー */
.group-header {
    background: rgba(255, 255, 255, 0.025);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background var(--transition-fast);
}

.group-header:hover {
    background: rgba(255, 255, 255, 0.045);
}

.group-toggle-icon {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.group-card.collapsed .group-toggle-icon {
    transform: rotate(-90deg);
}

.group-title-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex-grow: 1;
}

.group-title {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.group-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.group-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.group-meta .savings-badge {
    color: #34d399;
    font-weight: 700;
}

/* グループアクション */
.group-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* バブルクリックがアコーディオン開閉を誘発しないようにするため */
    position: relative;
    z-index: 10;
}

.group-actions .btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* アコーディオン開閉用コンテナ */
.group-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 100000px;
    opacity: 1;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1), opacity 0.2s ease-out, padding 0.3s ease-out;
}

.group-card.collapsed .group-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
}

/* 内側要素の微調整 */
.group-content .image-item {
    margin-left: 0.25rem;
}

/* -------------------------------------------------------------
 * Before-After 画像比較モーダル用スタイル
 * ------------------------------------------------------------- */

/* モーダルウィンドウ背景 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 12, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal.show {
    display: flex;
    opacity: 1;
}

/* モーダルコンテンツ */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 95%;
    max-width: 900px;
    padding: 1.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.85rem;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.modal-close-btn:hover {
    color: #f43f5e;
    transform: scale(1.1);
}

/* スライダービューポート */
.comparison-viewport {
    position: relative;
    width: 100%;
    height: 520px;
    border-radius: 16px;
    overflow: hidden;
    background: #06090e;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (max-width: 768px) {
    .comparison-viewport {
        height: 380px;
    }
}

.comparison-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.comparison-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}

/* Before画像（元画像）を上層に配置してclip-pathでカットする */
.image-before {
    z-index: 2;
    clip-path: inset(0 50% 0 0); /* 初期状態で右側50%をカット */
}

/* After画像（WebP）は下層 */
.image-after {
    z-index: 1;
}

/* ドラッグ操作用の透明スライダー（全画面をカバー） */
.comparison-slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    opacity: 0;
    cursor: ew-resize;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
}

/* 中央の分割線（ホワイトカラー） */
.comparison-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: #ffffff;
    z-index: 3;
    pointer-events: none;
    transform: translateX(-50%);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

/* スライド操作用中央ツマミハンドル */
.comparison-handle-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #6366f1;
    z-index: 4;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #6366f1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.comparison-slider-input:hover ~ .comparison-handle-knob {
    transform: translate(-50%, -50%) scale(1.1);
    background: #f3f4f6;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* BEFORE / AFTER の表示用タグ */
.comparison-label {
    position: absolute;
    bottom: 12px;
    padding: 0.35rem 0.75rem;
    background: rgba(4, 6, 12, 0.75);
    backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 8px;
    pointer-events: none;
    z-index: 4;
    letter-spacing: 0.05em;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.label-before {
    left: 12px;
}

.label-after {
    right: 12px;
}

/* -------------------------------------------------------------
 * ズーム＆パン操作関連のスタイル
 * ------------------------------------------------------------- */

/* ズーム時の拡大・移動基準点 */
.comparison-wrapper {
    transform-origin: center center;
}

/* ドラッグによるパン移動中のカーソル */
.comparison-viewport.panning {
    cursor: grabbing !important;
}

.comparison-viewport.pan-mode {
    cursor: grab;
}

.comparison-viewport.pan-mode .comparison-slider-input {
    display: none; /* 移動モード時は透明インプットを隠し、画像全体のドラッグでパン移動できるようにする */
}

/* ツールバー内のボタン用のアクティブ表示 */
.zoom-controls .btn-icon.active {
    background: #6366f1;
    color: #ffffff;
    border-color: #6366f1;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

/* セレクトボックスのオプション項目のダークモード対応 */
select option {
    background-color: #121520; /* 濃い紺色の背景 */
    color: #e2e8f0; /* 明るいグレーの文字 */
}

/* -------------------------------------------------------------
 * 広告・プロモーションセクションのスタイル
 * ------------------------------------------------------------- */
.ad-section {
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.ad-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    width: 100%;
}

.ad-card {
    background: var(--card-bg, #161b26);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.ad-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.ad-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.ad-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted, #94a3b8);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.ad-title-tag {
    font-size: 0.75rem;
    font-weight: 700;
    color: #38bdf8;
}

.ad-content {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    overflow: hidden;
}

.ad-placeholder {
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted, #64748b);
}

.ad-placeholder i {
    font-size: 2.2rem;
    color: rgba(255, 255, 255, 0.2);
    margin-bottom: 0.25rem;
}

.ad-placeholder p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary, #cbd5e1);
}

.ad-placeholder span {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
}

.affiliate-banner-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.affiliate-promo-text {
    padding: 0.75rem 1rem;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
}

.affiliate-promo-text h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 0.25rem;
}

.affiliate-promo-text p {
    font-size: 0.78rem;
    color: var(--text-secondary, #cbd5e1);
    line-height: 1.4;
}

@media (max-width: 900px) {
    .ad-grid {
        grid-template-columns: 1fr;
    }
}
