/* === カラー変数 === */
:root {
    /* メインカラー */
    --primary-color: #B97E4D;
    --primary-hover: #A06D3E;
    --primary-light: #D4A679;
    --primary-dark: #8F6238;
    
    /* デバイスフレームカラー */
    --frame-pc: #D4C4B0;
    --frame-tablet: #D4C4B0;
    --frame-mobile: #D4C4B0;
    
    /* 背景色 */
    --bg-main: #f4f7f9;
    --bg-sidebar: #ffffff;
    --bg-hover: #f7fafc;
    --bg-active: #e2e8f0;
    
    /* テキストカラー */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-light: #a0aec0;
    
    /* ボーダーカラー */
    --border-color: #e2e8f0;
    --border-light: #cbd5e0;
    
    /* その他 */
    --shadow: rgba(0, 0, 0, 0.1);
    --white: #ffffff;
}

/* === 基本スタイルとリセット === */
html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: 'Kosugi Maru', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

/* === メインレイアウト === */
.main-container {
    display: flex;
    padding: 8px;
    margin: 8px;
    align-items: flex-start; /* サイドバーとコンテンツの上端を揃える */
    gap: 40px;
    height: calc(100vh - 48px);
    overflow: hidden;
}

.sidebar {
    flex: 0 0 400px; /* サイドバーの幅を400pxに固定 */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative; /* z-index制御用 */
    z-index: 2000;
    height: 100%;
    overflow-y: auto; /* サイドバー内がはみ出たらスクロール */
    border-right: 1px solid #e2e8f0;
    padding-right: 20px;
    padding-bottom: 0; /* フッター用に調整 */
}

.content {
    flex: 1; /* 残りのスペースをすべて使用 */
    display: flex;
    flex-direction: column;
    margin-right: 24px;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

#preview-container {
    flex: 1;
    overflow: auto !important;
    min-height: 0;
    height: 100%;
}

/* === タイポグラフィ === */
h1 {
    font-size: 1rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 300;
    color: var(--white);
    margin: 0;
    padding: 0 40px;
    background-color: var(--primary-color);
    width: 100%;
    height: 48px;
    line-height: 48px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

h1 .logo {
    height: 32px;
    width: auto;
}

h2 {
    font-size: 0.9rem;
    color: #4a5568;
    border-bottom: none;
    padding-bottom: 10px;
    margin-top: 0; /* .sidebarのgapで管理するためリセット */
    margin-bottom: 1rem;
}

.content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

hr {
    display: none;
}

/* === サイドバーの各セクション === */
.sidebar > div:not(#file-info):not(.sidebar-footer) {
    background-color: transparent;
    padding: 20px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    border-bottom: 1px solid #e2e8f0;
}

/* アップロードセクションを画面いっぱいに広げる */
#upload-section {
    flex: 1; /* サイドバー内の残りスペースをすべて使用 */
    display: flex;
    flex-direction: column;
    background-color: transparent;
    padding: 20px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    transition: all 0.3s ease;
    border-bottom: 1px solid #e2e8f0;
}

/* アップロードエリアが非表示の時はセクションを小さく */
#upload-section:has(#upload-area[style*="display: none"]) {
    flex: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background-color: transparent;
}

/* 編集とダウンロードセクションの下線を削除 */
#slicing-controls {
    border-bottom: 1px solid #e2e8f0 !important;
}

#download-area {
    border-bottom: none !important;
}

/* === タイポグラフィ === */

#upload-section h2 {
    margin-top: 0;
    margin-bottom: 1rem;
}

#upload-section #upload-area {
    flex: 1; /* アップロードエリアを広げる */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px; /* 最小高さを確保 */
}

/* h2とdivをグループ化してgapを適用するため */
.sidebar > h2 {
    margin-bottom: -1rem; /* h2と次のdivの間の隙間を詰める */
}

/* === タブナビゲーション === */
.tab-navigation {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #718096;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    cursor: pointer;
    transition: color 0.2s ease-in-out, border-color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

.tab-btn:hover {
    color: #4a5568;
    background-color: #f7fafc;
    transform: none; /* デフォルトのボタンホバー効果を上書き */
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: transparent;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* タブ内のボタンは通常のボタンスタイルを維持 */
.tab-content button {
    background-color: var(--primary-color);
}

.tab-content button:hover {
    background-color: var(--primary-hover);
    transform: none;
}

/* === ファイルアップロードエリア === */
#upload-area {
    border: 2px solid #e2e8f0;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    text-align: center;
    transition: all 0.3s ease-in-out;
    border-radius: 12px;
    padding: 40px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* フォルダアイコン */
.folder-icon {
    width: 80px;
    height: 80px;
    color: #a0aec0;
    margin-bottom: 20px;
    transition: all 0.3s ease-in-out;
}

#upload-area.dragover {
    background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(66, 153, 225, 0.2);
    transform: translateY(-2px);
}

#upload-area.dragover .folder-icon {
    color: var(--primary-color);
    transform: scale(1.1);
}

#upload-area p {
    margin: 0 0 1rem 0;
    color: #718096;
    font-size: 0.8rem;
}

/* === オプションとボタン === */
#options-area fieldset {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

#options-area legend {
    padding: 0 0.5rem;
    color: #4a5568;
    font-weight: 600;
}

#options-area label {
    display: block;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

button {
    width: 70%;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--white);
    background-color: var(--primary-color);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    margin: 0 auto;
    display: block;
}

button:hover {
    background-color: var(--primary-hover);
}

button:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

/* === ログエリア === */
#log-area {
    flex-grow: 1; /* 残りの高さをすべて使用 */
    display: flex;
    flex-direction: column;
    min-height: 150px; /* ログエリアの最小の高さを確保 */
}

#log-output {
    flex-grow: 1;
    background-color: #1a202c; /* ダークな背景 */
    color: #f7fafc;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 0.75rem;
    padding: 1rem;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-all; /* 長い文字列でも折り返す */
    overflow-y: auto;      /* 内容がはみ出たらスクロール */
    margin: 0;
}

/* === エディタサイドバーのスタイル === */
#editor-sidebar {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04);
    margin-top: 1.5rem; /* h2との間隔 */
}

#editor-sidebar h3 {
    font-size: 0.85rem;
    color: #4a5568;
    margin-top: 0;
    margin-bottom: 1rem;
}

#editor-controls .control-group {
    margin-bottom: 10px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#editor-controls label {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: #555;
}

#editor-controls input[type="text"] {
    width: 100%;
    padding: 6px;
    padding-right: 28px; /* ボタンのスペースを確保 */
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 0.75rem;
}

.multi-input-wrapper {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.multi-input-wrapper .sub-control-group {
    flex: 1;
    min-width: 0; /* flexアイテムが縮小できるように */
}

.multi-input-wrapper .sub-control-group label {
    font-size: 0.75rem;
    color: #718096;
    text-align: center;
    margin-bottom: 2px;
}

.stepper {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    display: flex;
    flex-direction: column;
    width: 22px;
}

.stepper button {
    flex: 1;
    width: 100%;
    padding: 0;
    font-size: 8px;
    line-height: 1;
    background-color: #f0f2f5;
    color: #555;
    border: none;
    border-left: 1px solid #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stepper button:hover {
    background-color: #e4e6e9;
}

.stepper .stepper-up {
    border-top-right-radius: 3px;
}
.stepper .stepper-down {
    border-bottom-right-radius: 3px;
}

/* === プレビューエリア === */
#preview-area {
    flex: 1; /* .content内で残りのスペースを埋める */
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04); /* iframeの角を丸く見せるため */
    position: relative; /* ローディング表示などの基準点 */
    overflow: auto; /* プレビュー内容がはみ出たらスクロール */
    min-height: 500px; /* プレビューエリアの最小高さを確保 */
}

#preview-content-wrapper {
    position: relative;
    transform-origin: top left;
    /* スケールはJSで適用 */
}

/* プレビュー内の要素のハイライト */
#editor-overlay {
    box-sizing: border-box;
    border: 2px solid var(--primary-color);
    background-color: rgba(185, 126, 77, 0.1);
    position: absolute;
    pointer-events: none; /* オーバーレイ自体がクリックを妨げないように */
    z-index: 999;
}

/* プレビュー内の要素のツールチップ */
#editor-tooltip {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px;
    border-radius: 3px;
    font-size: 12px;
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}

/* リサイズ・ドラッグハンドル */
#editor-resize-handle, #editor-drag-handle {
    background: var(--primary-color);
    border: 1px solid #fff;
    position: absolute;
    z-index: 1001;
}

#editor-resize-handle {
    width: 10px;
    height: 10px;
    cursor: nwse-resize;
}

#editor-drag-handle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

#editor-value-display {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px;
    border-radius: 3px;
    font-size: 12px;
    position: absolute;
    pointer-events: none;
    z-index: 1000;
}

/* デバイス選択コントロール */
#device-selector {
    margin: 20px auto 30px;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* スライスカット選択中はデバイスセレクターを非表示 */
body.slicing-mode #device-selector {
    display: none !important;
}

.device-buttons {
    display: flex;
    gap: 15px;
    background: transparent;
    padding: 0;
    align-items: center;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: #718096;
    font-size: 0.75rem;
    font-weight: 500;
    border-bottom: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.device-item .material-symbols-outlined {
    font-size: 16px;
    font-variation-settings: 'FILL' 0;
}

.device-item .device-label {
    font-size: 0.75rem;
    font-weight: 500;
}

.device-item:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.device-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.device-item.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

.dropdown-toggle {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: inherit;
    margin-left: 4px;
}

.dropdown-toggle .material-symbols-outlined {
    font-size: 18px;
    transition: transform 0.2s;
}

.dropdown-toggle:hover .material-symbols-outlined {
    color: var(--primary-color);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 8px 12px;
    font-size: 12px;
    color: #2d3748;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: #f1f3f5;
}

.dropdown-item:first-child {
    border-radius: 0;
}

.dropdown-item:last-child {
    border-radius: 0;
}

.device-model-select:hover {
    border-color: #cbd5e0;
}

.device-model-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ラップトップフレーム */
.monitor-frame {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 10px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    transition: all 0.3s ease;
    position: relative;
    box-sizing: border-box;
}

.monitor-frame.show {
    display: flex;
}

.rotate-device-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rotate-device-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.rotate-device-btn .material-symbols-outlined {
    font-size: 24px;
    color: #4a5568;
}

.monitor-screen {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

#preview-iframe {
    width: 100%;
    flex: 1;
    border: none;
    display: block;
    background: #ffffff;
    transition: opacity 0.15s ease-in-out;
}

/* PCフレーム */
.monitor-frame.device-pc .monitor-screen {
    background: var(--frame-pc);
    border: 28px solid var(--frame-pc);
    border-radius: 28px;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
    /* width/heightとmax-widthはJSで動的に設定 */
}

.monitor-frame.device-pc .monitor-stand {
    width: calc(100% * 0.9);
    height: 20px;
    background: var(--frame-pc);
    margin: 0 auto;
    border-radius: 0;
}

.monitor-frame.device-pc .monitor-base {
    width: calc(100% * 1.2);
    height: 24px;
    background: var(--frame-pc);
    margin: 0 auto;
    margin-left: calc((100% * 1.2 - 100%) / -2);
    border-radius: 0 0 0px 0px;
}

/* タブレットフレーム */
.monitor-frame.device-tablet .monitor-screen {
    background: var(--frame-tablet);
    border: 32px solid var(--frame-tablet);
    border-radius: 28px;
    overflow: hidden;
    /* width/heightはJSで動的に設定 */
}

.monitor-frame.device-tablet .monitor-stand,
.monitor-frame.device-tablet .monitor-base {
    display: none;
}

/* タブレット/モバイルではタブバーのみ非表示、アドレスバーは表示 */
.monitor-frame.device-tablet .browser-tabs,
.monitor-frame.device-mobile .browser-tabs {
    display: none;
}

.monitor-frame.device-tablet .macos-traffic-lights,
.monitor-frame.device-mobile .macos-traffic-lights {
    display: none;
}

/* モバイルフレーム */
.monitor-frame.device-mobile .monitor-screen {
    background: var(--frame-mobile);
    border: 14px solid var(--frame-mobile);
    border-radius: 32px;
    overflow: hidden;
    /* width/heightはJSで動的に設定 */
}

.monitor-frame.device-mobile .monitor-stand,
.monitor-frame.device-mobile .monitor-base {
    display: none;
}

#preview-iframe {
    width: 100%;
    border: none;
    display: block;
    background: #ffffff;
    /* aspect-ratioは削除 - flexで自動調整 */
    transition: aspect-ratio 0.5s ease;
}

/* スライスカット時はフレームを非表示 */
#slicing-area:not([style*="display: none"]) ~ .monitor-frame .monitor-screen {
    background: transparent;
    border: none;
    box-shadow: none;
    margin-bottom: 0;
}

#slicing-area:not([style*="display: none"]) ~ .monitor-frame .monitor-stand {
    display: none;
}

#slicing-area:not([style*="display: none"]) ~ .monitor-frame .monitor-base {
    display: none;
}

#preview-iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    display: block;
    background: #ffffff;
}

/* === ファイルインプットのボタンを少し見やすく === */
#psd-file-input {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    width: auto;
    font-size: 0;
    max-width: 200px;
    margin-left: auto;
    margin-right: auto;
}

/* Webkit系ブラウザ用のファイル選択ボタンのスタイル */
#psd-file-input::file-selector-button {
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #ffffff;
    background-color: var(--primary-color);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

#psd-file-input::file-selector-button:hover {
    background-color: var(--primary-hover);
}

/* ファイル情報とリセットボタン */
#file-info {
    display: none !important;
    margin: 0;
    padding: 10px 14px;
    background-color: transparent;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    min-width: 0;
}

#file-info.visible {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
}

#file-name {
    font-size: 0.8rem !important;
    color: #2d3748 !important;
    font-weight: 500 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    flex: 1 !important;
    min-width: 0 !important;
    display: inline-block !important;
    order: 2;
}

#reset-layers-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #718096;
    transition: all 0.15s ease;
    flex-shrink: 0;
    border-radius: 4px;
    font-family: 'Material Symbols Outlined';
    font-variation-settings:
      'FILL' 0,
      'wght' 400,
      'GRAD' 0,
      'opsz' 20;
    order: 1;
}

#reset-layers-btn:hover {
    background-color: #e2e8f0;
    color: #2d3748;
}

#reset-layers-btn:active {
    background-color: #cbd5e0;
}

/* === モーダル === */
.modal-overlay {
    display: none; /* 初期状態では非表示 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* 親の高さを受け継ぐ */
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 600px;
    height: 100%; /* 親の高さを受け継ぐ */
    max-height: 80vh;
    display: flex; /* gridからflexに戻す */
    flex-direction: column;
    justify-content: center; /* 上下中央 */
    /* overflow-y: auto; */ /* モーダル全体にスクロールを追加 */
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1rem; /* 元に戻す */
}

.modal-content h2:has(.help-icon) {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-content p {
    margin-top: 0;
    margin-bottom: 1.5rem; /* 元に戻す */
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem; /* 元に戻す */
}

/* === レイヤーツリー === */
.layer-tree-container {
    /* flex-grow: 1; */ /* 削除 */
    overflow-y: auto; /* コンテンツがはみ出たらスクロール */
    border: 1px solid #e2e8f0;
    padding: 15px;
    border-radius: 6px;
    background-color: #fdfdfd;
    min-height: 0; /* flexアイテムが縮小できるようにする */
    /* height: calc(100% - 150px); */ /* 削除 */
    max-height: 50vh; /* 新しく追加 */
}

.layer-tree ul {
    padding-left: 20px;
    list-style: none;
    margin: 0;
}

.layer-tree li {
    padding: 4px 0;
}

.layer-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.layer-tree-item input[type="checkbox"] {
    cursor: pointer;
}

/* 不定状態（一部の子が選択されている）のチェックボックススタイル */
.layer-tree-item input[type="checkbox"]:indeterminate {
    position: relative;
}

.layer-tree-item input[type="checkbox"]:indeterminate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 2px;
    background-color: var(--primary-color);
}

.layer-tree-item label {
    cursor: pointer;
}

.layer-tree-item.group > label {
    font-weight: bold;
}

.layer-link-input {
    margin-left: 10px;
    padding: 4px 8px;
    font-size: 0.85rem;
    width: 200px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.layer-link-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.2);
}

/* === スライサー === */
#slicing-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#slicing-area {
    background-size: 100% auto;
    background-repeat: no-repeat;
    border: 1px solid #ccc;
}

.slice-line {
    position: absolute;
    background-color: rgba(107, 114, 128, 0.7);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    user-select: none;
}

.slice-line:hover {
    background-color: rgba(75, 85, 99, 0.9);
}

.slice-line.horizontal {
    width: 100%;
    height: 2px;
    cursor: row-resize;
}

.slice-line.vertical {
    height: 100%;
    width: 2px;
    cursor: col-resize;
}

.slice-line.selected {
    background-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(185, 126, 77, 0.8);
}

/* スライスリスト */
#slice-list {
    margin-top: 1rem;
}

.slice-item {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    gap: 4px;
}

.slice-alt-label {
    font-size: 0.85rem;
    color: #718096;
    margin-right: 8px;
    flex-shrink: 0;
    width: 62px; /* スライスラベルの幅に合わせる */
    text-align: right; /* 右寄せ */
}

.slice-alt-input {
    flex: 1;
    padding: 4px 0;
    border: none;
    border-bottom: 1px solid #cbd5e0;
    font-size: 0.9rem;
    color: #2d3748;
    background-color: transparent;
    transition: border-color 0.15s ease;
}

.slice-alt-input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

.slice-alt-input::placeholder {
    color: #a0aec0;
}

.slice-alt-row {
    display: flex;
    align-items: center;
    margin: 4px 0;
    padding-left: 0; /* インデントなし */
}

.slice-header {
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.slice-item-label {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #4a5568;
    margin-right: 8px;
    min-width: 70px;
}

.slice-item-line {
    flex-grow: 1;
    height: 2px;
    background-color: rgba(185, 126, 77, 0.6);
    margin-right: 8px;
}

.slice-item-delete {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    background-color: transparent !important;
    color: #5f6368;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
    border-radius: 4px;
    font-family: 'Material Symbols Outlined';
    font-variation-settings:
      'FILL' 0,
      'wght' 300,
      'GRAD' 0,
      'opsz' 20;
}

.slice-item-delete:hover {
    background-color: rgba(95, 99, 104, 0.08) !important;
    color: #202124;
}

/* スライス線上のラベル */
.slice-label {
    position: absolute;
    left: 8px;
    top: -20px;
    color: rgba(75, 85, 99, 0.9);
    font-size: 0.65rem;
    font-weight: 500;
    pointer-events: none;
    user-select: none;
    /* 視認性向上: 半透明背景 + ぼかしでどんな背景でも読みやすく */
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    padding: 0px 0px;
    border-radius: 0px;
    /* box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); */
}

/* === カスタムチェックボックス（茶色系） === */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #B97E4D;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    position: relative;
    background-color: white;
    transition: all 0.2s;
}

input[type="checkbox"]:hover {
    border-color: #A06D3E;
    background-color: #f9f5f1;
}

input[type="checkbox"]:checked {
    background-color: #B97E4D;
    border-color: #B97E4D;
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* === ローディングドットアニメーション === */
.loading-dots span {
    animation: loading-dots 1.4s infinite;
    opacity: 0;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-dots {
    0%, 20% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* === WebP品質スライダー === */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, #D4A679 0%, #B97E4D 50%, #8F6238 100%);
    outline: none;
    border-radius: 3px;
    position: relative;
}

/* スライダーのつまみ（Chrome, Safari, Edge） */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #B97E4D;
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #A06D3E;
    transform: scale(1.1);
}

/* スライダーのつまみ（Firefox） */
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #B97E4D;
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #A06D3E;
    transform: scale(1.1);
}

/* 品質値の表示 */
.webp-quality-container {
    position: relative;
    padding-top: 28px;
}

#webp-quality-value {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: #B97E4D;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

#webp-quality-value.ready {
    transition: left 0.1s ease;
}

/* === トグルスイッチ === */
.toggle-switch-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch-input {
    display: none;
}

.toggle-switch-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #cbd5e0;
    border-radius: 10px;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-switch-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch-input:checked + .toggle-switch-slider {
    background-color: #B97E4D;
}

.toggle-switch-input:checked + .toggle-switch-slider::before {
    transform: translateX(16px);
}

.toggle-switch-text {
    font-size: 0.85rem;
    color: #4a5568;
}
