/* ============================================================
   easy-crop-stitch - style.css
   デザインシステム: easy-minimap-maker 準拠
   ============================================================ */

:root {
    --primary-color: #1565c0;
    --primary-hover: #0d47a1;
    --primary-light: #e3f2fd;
    --primary-border: #90caf9;

    --accent-color: #2e7d32;
    --accent-hover: #1b5e20;
    --accent-light: #e8f5e9;

    --warning-color: #ed6c02;
    --warning-light: #fff3e0;
    --warning-border: #ffb74d;

    --danger-color: #d32f2f;
    --danger-hover: #b71c1c;
    --danger-light: #ffebee;
    --danger-border: #ef9a9a;

    --bg-light: #f4f6f8;
    --bg-dark: #1e222b;
    --bg-darker: #15181f;
    --panel-bg: #272c37;
    --panel-border: #383f4f;

    --text-main: #222222;
    --text-light: #f5f5f7;
    --text-muted: #8e95a5;
    --text-muted-dark: #666666;

    --border-color: #d0d7de;
    --border-dark: #3a4150;

    --radius-lg: 14px;
    --radius-md: 8px;
    --radius-sm: 4px;

    --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-dark: 0 4px 20px rgba(0, 0, 0, 0.35);

    --transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button,
input,
select,
textarea {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-feature-settings: "palt";
    -webkit-font-feature-settings: "palt";
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   共通ボタンスタイル
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.2;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}

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

.btn-secondary {
    background: #ffffff;
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--primary-color);
}

.btn-accent {
    background: var(--accent-color);
    color: #ffffff;
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger-color);
    color: #ffffff;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-xs {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    gap: 4px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: var(--radius-md);
    font-weight: 700;
}

/* ============================================================
   スタート画面 (案内・利用設定)
   ============================================================ */
.start-screen-container {
    width: 100%;
    min-height: 100vh;
    padding: 24px 16px 48px 16px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f1f8e9 100%);
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.container {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
}

/* ヘッダー・メタ情報 */
.header-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.version-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-badge {
    background: var(--primary-color);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.changelog-link,
.credit-link {
    color: var(--text-muted-dark);
    text-decoration: none;
    transition: color 0.2s;
    font-size: 14px;
}

.changelog-link:hover,
.credit-link:hover {
    color: var(--primary-color);
}

.credit-link strong {
    color: var(--text-main);
    text-decoration: underline;
}

/* タイトルエリア */
.main-title {
    font-size: 26px;
    font-weight: 900;
    color: var(--text-main);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.sub-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin-top: 4px;
}

.eng-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-muted-dark);
    margin-bottom: 16px;
}

/* ツールリンク */
.tool-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tool-link,
.tool-link-subtle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    text-decoration: none;
    transition: var(--transition);
}

.tool-link {
    background: #ffffff;
    color: #333333;
    border: 1px solid var(--border-color);
}

.tool-link:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary-color);
}

.tool-link-subtle {
    background: transparent;
    color: var(--text-muted-dark);
}

.tool-link-subtle:hover {
    color: var(--primary-color);
}

/* カードコンポーネント */
.card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--text-main);
}

.card-title svg {
    color: var(--primary-color);
}

/* ドロップゾーン */
.dropzone {
    border: 2px dashed #b0bec5;
    border-radius: 12px;
    padding: 36px 20px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.dropzone-icon-wrapper {
    margin-bottom: 12px;
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    opacity: 0.85;
}

.dropzone-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.dropzone-desc {
    font-size: 13px;
    color: var(--text-muted-dark);
    margin-bottom: 20px;
}

.dropzone-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}


/* プライバシー注記 */
.section-note {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    margin: 12px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.section-note svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.dropzone-privacy-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted-dark);
    background: #f0fdf4;
    border-left: 3px solid var(--accent-color);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

.dropzone-privacy-note svg {
    color: var(--accent-color);
    flex-shrink: 0;
}

/* 特徴セクション (Features Grid) */
.tool-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border: 1px solid #e8ebee;
    transition: border-color 0.2s;
}

.feature-item:hover {
    border-color: #cbd5e1;
}

.feature-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(21, 101, 192, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon-box svg {
    width: 20px;
    height: 20px;
}

.feature-text strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
}

.feature-text p {
    font-size: 12px;
    color: var(--text-muted-dark);
    margin: 0;
    line-height: 1.55;
}

/* ガイドステップ */
.guide-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.guide-step-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    border: 1px solid #e8ebee;
}

.guide-step-num {
    background: var(--primary-color);
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.guide-step-text strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-main);
}

.guide-step-text p {
    font-size: 12px;
    color: var(--text-muted-dark);
    margin: 0;
    line-height: 1.5;
}

/* スタート画面フッター */
.start-footer {
    text-align: center;
    color: var(--text-muted-dark);
    font-size: 13px;
    margin-top: 24px;
}

.start-footer a {
    color: var(--text-muted-dark);
    text-decoration: underline;
}

.start-footer a:hover {
    color: var(--primary-color);
}


/* ============================================================
   メインワークスペース画面
   ============================================================ */
.workspace-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    overflow: hidden;
}

/* ワークスペースヘッダー */
.workspace-header {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

.workspace-header-top-brand {
    display: none;
}

.workspace-header-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.workspace-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.workspace-header-desktop-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.workspace-header-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: block;
}

.workspace-header-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.workspace-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.workspace-header-actions .btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 13px;
    min-height: 32px;
    box-sizing: border-box;
}

/* ワークスペース メイン 2ペイン */
.workspace-main-content {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(360px, 48%) 1fr;
    gap: 16px;
    padding: 16px;
    overflow: hidden;
    height: calc(100vh - 56px);
}

/* 左ペイン: クロップ */
.crop-pane {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.pane-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pane-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.pane-title svg {
    color: var(--primary-color);
}

.pane-sub-info {
    font-size: 11px;
    color: var(--text-muted-dark);
}

/* クロップステージビューア */
.crop-viewer-wrapper {
    flex: 1 1 0%;
    height: 0;
    min-height: 0;
    min-width: 0;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 12px;
    user-select: none;
    box-sizing: border-box;
}

.crop-stage {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.crop-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* インタラクティブなクロップ枠 */
.crop-box {
    position: absolute;
    box-sizing: border-box;
    cursor: move;
    border: 2px solid #38bdf8;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65);
    z-index: 5;
    touch-action: none;
}

.crop-box-grid {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.35);
}

.grid-line-v1 {
    top: 0;
    bottom: 0;
    left: 33.333%;
    width: 1px;
}

.grid-line-v2 {
    top: 0;
    bottom: 0;
    left: 66.666%;
    width: 1px;
}

.grid-line-h1 {
    left: 0;
    right: 0;
    top: 33.333%;
    height: 1px;
}

.grid-line-h2 {
    left: 0;
    right: 0;
    top: 66.666%;
    height: 1px;
}

/* クロップハンドル */
.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 2px solid #0284c7;
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    z-index: 6;
}

.handle-tl {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.handle-tr {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.handle-bl {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.handle-br {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.handle-t {
    top: -6px;
    left: calc(50% - 5px);
    cursor: ns-resize;
}

.handle-b {
    bottom: -6px;
    left: calc(50% - 5px);
    cursor: ns-resize;
}

.handle-l {
    top: calc(50% - 5px);
    left: -6px;
    cursor: ew-resize;
}

.handle-r {
    top: calc(50% - 5px);
    right: -6px;
    cursor: ew-resize;
}

.crop-box-badge {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    font-size: 11px;
    font-family: 'SF Mono', monospace;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
}

/* 座標入力コントロール */
.crop-controls-card {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
    flex-shrink: 0;
}

.crop-coords-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 0;
}

.coord-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted-dark);
    margin-bottom: 4px;
}

/* 数値入力コンポーネント */
.custom-input-with-unit {
    position: relative;
    width: 100%;
}

.detail-custom-input {
    width: 100%;
    padding: 7px 28px 7px 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'SF Mono', monospace;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text-main);
    transition: var(--transition);
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.detail-custom-input::-webkit-outer-spin-button,
.detail-custom-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.detail-custom-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2);
}

.custom-input-with-unit .unit-suffix {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted-dark);
    pointer-events: none;
    user-select: none;
}

.crop-quick-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}


/* 右ペイン: 結合設定 ＆ プレビュー */
.stitch-pane {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 4px;
}

/* 設定カード */
.settings-card,
.tray-card,
.preview-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
}

.settings-title,
.tray-title,
.preview-title {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    margin-bottom: 12px;
}

.settings-title svg,
.tray-title svg,
.preview-title svg {
    color: var(--primary-color);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.setting-val-display {
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    color: var(--primary-color);
    font-weight: 700;
}

.col-slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quick-col-presets {
    display: flex;
    gap: 4px;
}

.btn-preset {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-preset:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-border);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.color-presets-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-color-preset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #ffffff;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-color-preset.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    font-weight: 700;
    color: var(--primary-color);
}

.checker-bg {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    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: 6px 6px;
    background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
    border: 1px solid #bbb;
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    display: inline-block;
}

.custom-color-picker input[type="color"] {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    background: none;
}

.styled-select {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    outline: none;
    cursor: pointer;
}

/* サムネイル一覧トレイ */
.tray-card {
    padding: 12px 16px;
}

.tray-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tray-title {
    margin-bottom: 0;
}

.tray-help {
    font-size: 11px;
    color: var(--text-muted-dark);
}

.tray-sort-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
}

.tray-sort-bar .sort-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted-dark);
}

.tray-sort-bar .sort-btn-group {
    display: flex;
    gap: 6px;
}

.image-thumb-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 8px;
    padding: 2px;
    overflow: visible;
}



/* ============================================================
   スライダーステップボタン (btn-adjust-step)
   ============================================================ */
.slider-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.btn-adjust-step {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    transition: var(--transition);
    padding: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.btn-adjust-step:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary-color);
}

.btn-adjust-step:active {
    transform: scale(0.92);
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-adjust-step svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.5;
    pointer-events: none;
}


.adjust-slider-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.adjust-range {
    width: 100%;
}

.quick-col-presets {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.btn-col-preset,
.btn-val-preset {
    flex: 1;
    text-align: center;
}

.btn-col-preset.active,
.btn-val-preset.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* ============================================================
   カスタムドロップダウン (custom-dropdown)
   ============================================================ */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.dropdown-trigger:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
}

.dropdown-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2);
}

.dropdown-selected-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.dropdown-selected-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
}

.dropdown-chevron {
    transition: transform 0.2s ease;
    color: #64748b;
    flex-shrink: 0;
}

.custom-dropdown.open .dropdown-chevron {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 200;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 6px 0;
    display: none;
    flex-direction: column;
    max-height: 280px;
    overflow-y: auto;
}

.custom-dropdown.open .dropdown-menu {
    display: flex;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    width: 100%;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

.dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary-color);
    font-weight: 700;
}

/* ============================================================
   サムネイルトレイのドラッグ並び替え ＆ 削除モード
   ============================================================ */
.thumb-card {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: var(--transition);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    /* スマホ・タブレットでのタッチドラッグ並び替えを有効化 */
    box-sizing: border-box;
    overflow: hidden;
}

.thumb-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.thumb-card:active {
    cursor: grabbing;
}

.thumb-card.dragging {
    opacity: 0.35;
    transform: scale(0.95);
    border-style: dashed;
    border-color: var(--primary-color);
}

.thumb-card.drag-over {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.4);
    transform: scale(1.05);
}

.thumb-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    pointer-events: none;
}

.thumb-index-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    font-family: 'SF Mono', monospace;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.2;
    z-index: 2;
    pointer-events: none;
    backdrop-filter: blur(2px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.thumb-delete-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--danger-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(211, 47, 47, 0.45);
    border: 2px solid #ffffff;
    transition: transform 0.15s ease;
    z-index: 10;
    padding: 0;
    animation: badgePopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.thumb-delete-badge:hover {
    transform: scale(1.15);
    background: var(--danger-hover);
}

.tray-bottom-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.delete-mode-hint {
    font-size: 12px;
    color: var(--danger-color);
    font-weight: 600;
}

/* ============================================================
   easy-minimap-maker 準拠 モーダルダイアログ
   ============================================================ */
@keyframes modalBackdropFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalContentPopIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}

.modal-backdrop.open {
    display: flex;
    pointer-events: auto;
    animation: modalBackdropFadeIn 0.2s ease forwards;
}

.modal-content {
    background: #ffffff;
    color: var(--text-main);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 440px;
    box-shadow: var(--shadow-dark);
    overflow: hidden;
}

.modal-backdrop.open .modal-content {
    animation: modalContentPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfc;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted-dark);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--text-main);
    background: #f0f0f0;
}

.modal-body {
    padding: 18px;
}

.modal-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafbfc;
}

.modal-footer-main {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.modal-footer-sub {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
}

.btn-link-action {
    background: none;
    border: none;
    padding: 4px 6px;
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-link-action:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}


/* ============================================================
   結合プレビューエリア
   ============================================================ */
.preview-pane {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #fafbfc;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.preview-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.canvas-dimension-badge {
    display: inline-block;
    color: var(--text-muted-dark);
    font-size: 13px;
    font-weight: 600;
    font-family: 'SF Mono', monospace;
    letter-spacing: 0.2px;
    padding: 2px 4px;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    user-select: text;
}

.preview-zoom-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stitch-canvas-viewport {
    flex: 1;
    min-height: 0;
    background-color: #f1f5f9;
    background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    overflow: auto;
    display: flex;
    padding: 16px;
    position: relative;
}

#stitchCanvas {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    background: transparent;
    display: block;
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.stitch-canvas-viewport.zoom-100 #stitchCanvas,
#stitchCanvas.zoom-100 {
    max-width: none !important;
    max-height: none !important;
    width: auto !important;
    height: auto !important;
}

/* ============================================================
   タブ・マルチ画面レイアウト制御
   ============================================================ */
.workspace-panel {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.panel-title svg {
    color: var(--primary-color);
    flex-shrink: 0;
}

/* デスクトップ用 メインタブバー */
.desktop-main-tabs {
    display: flex;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    flex-shrink: 0;
}

.desktop-main-tabs .tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    background: #f1f5f9;
    border: none;
    position: relative;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.desktop-main-tabs .tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.6);
}

.desktop-main-tabs .tab-btn.active {
    color: var(--primary-color);
    background: #ffffff;
    font-weight: 700;
}

.desktop-main-tabs .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

/* 第1カラム パネルスタイル */
.workspace-col-main .workspace-panel {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-top: none;
}

/* モバイル用 4タブバー */
.mobile-tabs {
    display: none;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.mobile-tabs .tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.mobile-tabs .tab-btn svg {
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.mobile-tabs .tab-btn:hover {
    color: var(--text-main);
}

.mobile-tabs .tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(21, 101, 192, 0.04);
    font-weight: 700;
}

/* デスクトップ 3カラムレイアウト */
@media (min-width: 961px) {
    .desktop-main-tabs {
        display: flex;
    }

    .mobile-tabs {
        display: none !important;
    }

    .workspace-main-content {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr;
        gap: 16px;
        padding: 16px;
        height: calc(100vh - 54px);
        overflow: hidden;
    }

    .workspace-col-main,
    .workspace-col-layout,
    .workspace-col-tray {
        display: flex;
        flex-direction: column;
        min-width: 0;
        height: 100%;
        overflow: hidden;
    }

    .workspace-panel {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .panel-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
    }

    /* 第1カラムのタブ切り替え */
    body[data-desktop-tab="crop"] #sectionCrop {
        display: flex;
        flex: 1;
        height: 100%;
        overflow: hidden;
    }

    body[data-desktop-tab="crop"] #sectionPreview {
        display: none !important;
    }

    body[data-desktop-tab="preview"] #sectionCrop {
        display: none !important;
    }

    body[data-desktop-tab="preview"] #sectionPreview {
        display: flex;
        flex: 1;
        height: 100%;
        overflow: hidden;
    }

    /* 第2・第3カラムは常時表示 */
    #sectionLayout {
        display: flex !important;
    }

    #sectionTray {
        display: flex !important;
    }
}


/* ============================================================
   エクスポート設定モーダル (easy-minimap-maker の exportModal 準拠)
   ============================================================ */
.export-modal-info-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.export-info-row .info-label {
    font-size: 13px;
    color: var(--text-muted);
}

.export-info-row .info-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'SF Mono', monospace;
}

.color-presets-row {
    display: flex;
    gap: 6px;
    width: 100%;
    align-items: center;
}

.btn-color-preset {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 8px;
    font-size: 12px;
    cursor: pointer;
}

.custom-color-picker {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.btn-color-preset.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-color);
    font-weight: 700;
}

.checker-bg {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 8px 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.custom-color-picker input[type="color"] {
    -webkit-appearance: none;
    border: 1.5px solid var(--border-color);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.custom-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.custom-color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* ============================================================
   レスポンシブスタイル (モバイル・タブレット: 幅960px以下)
   ============================================================ */
@media (max-width: 960px) {
    .desktop-main-tabs {
        display: none !important;
    }

    /* タブを画面下部に固定 (ボトムナビゲーション) */
    .mobile-tabs {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        top: auto;
        background: #ffffff;
        border-top: 1px solid var(--border-color);
        border-bottom: none;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .mobile-tabs .tab-btn {
        padding: 7px 4px 6px 4px;
        border-bottom: none;
        border-top: 3px solid transparent;
    }

    .mobile-tabs .tab-btn svg {
        width: 18px;
        height: 18px;
    }

    .mobile-tabs .tab-btn.active {
        border-top-color: var(--primary-color);
        border-bottom-color: transparent;
        color: var(--primary-color);
        background: rgba(21, 101, 192, 0.04);
    }

    .workspace-container {
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* モバイル ヘッダー: 1行目にタイトル中央寄せ、2行目にナビゲーション */
    .workspace-header {
        height: auto;
        min-height: 48px;
        padding: 8px 12px;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .workspace-header-top-brand {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border-light);
        user-select: none;
    }

    .workspace-header-top-brand .workspace-header-icon {
        width: 18px;
        height: 18px;
    }

    .workspace-header-top-brand .workspace-header-title {
        font-size: 13px;
        font-weight: 700;
    }

    .workspace-header-desktop-brand {
        display: none !important;
    }

    .workspace-header-nav-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 8px;
    }

    .workspace-header-left {
        display: flex;
        align-items: center;
    }

    /* メインコンテンツエリア */
    .workspace-main-content {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 12px 12px calc(54px + env(safe-area-inset-bottom, 0px) + 12px) 12px;
        box-sizing: border-box;
    }

    /* クロップおよびプレビュー表示時は画面全体いっぱいに展開 (デスクトップの workspace-col-main と同様) */
    body[data-mobile-tab="crop"] .workspace-main-content,
    body[data-mobile-tab="preview"] .workspace-main-content {
        overflow: hidden;
        padding: 8px 8px calc(54px + env(safe-area-inset-bottom, 0px) + 8px) 8px;
    }

    .workspace-col-main,
    .workspace-col-layout,
    .workspace-col-tray {
        display: contents;
    }

    /* スマートフォン表示ではパネルヘッダーを非表示 */
    .panel-header,
    .pane-header {
        display: none !important;
    }

    /* モバイル タブ切り替え: デフォルト共通 */
    #sectionCrop,
    #sectionLayout,
    #sectionTray,
    #sectionPreview {
        display: none !important;
        box-sizing: border-box;
    }

    /* クロップ画面: 画面いっぱいに広げる */
    body[data-mobile-tab="crop"] #sectionCrop {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        height: 100%;
        flex: 1 1 0%;
        min-height: 0;
        margin: 0;
        padding: 10px;
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
        overflow: hidden;
        gap: 8px;
    }

    /* プレビュー画面: 画面いっぱいに広げる */
    body[data-mobile-tab="preview"] #sectionPreview {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
        height: 100%;
        flex: 1 1 0%;
        min-height: 0;
        margin: 0;
        padding: 10px;
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-card);
        overflow: hidden;
        gap: 8px;
    }

    /* レイアウト画面・並び順管理画面: 中央寄せ・スクロール可能 */
    body[data-mobile-tab="layout"] #sectionLayout,
    body[data-mobile-tab="tray"] #sectionTray {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        max-width: 580px;
        margin: auto;
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 14px;
        box-shadow: var(--shadow-card);
        height: auto;
        overflow: visible;
    }

    /* クロップパネル内の配置 */
    #sectionCrop .crop-quick-actions {
        background: transparent;
        border: none;
        padding: 0 0 4px 0;
        flex-shrink: 0;
    }

    #sectionCrop .crop-viewer-wrapper {
        border-radius: var(--radius-md);
        flex: 1 1 0%;
        height: 0;
        min-height: 0;
        max-height: none;
        padding: 6px;
    }

    #sectionCrop .crop-controls-card {
        border: none;
        padding: 4px 0 0 0;
        flex-shrink: 0;
        overflow-y: auto;
        max-height: 160px;
    }

    /* プレビューパネル内の配置 */
    #sectionPreview .preview-toolbar {
        background: transparent;
        border: none;
        padding: 0 0 4px 0;
        flex-shrink: 0;
    }

    #sectionPreview .stitch-canvas-viewport {
        border-radius: var(--radius-md);
        flex: 1 1 0%;
        height: 0;
        min-height: 0;
        max-height: none;
        padding: 8px;
    }

    .panel-body {
        padding: 0 !important;
        overflow: visible;
    }
}

@media (max-width: 768px) {

    .workspace-header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .btn-text-full {
        display: none;
    }

    .btn-text-short {
        display: inline;
    }
}

@media (max-width: 480px) {

    .crop-coords-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .crop-quick-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .crop-quick-actions .btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 80px;
        justify-content: center;
    }

    .card,
    .crop-pane,
    .settings-card,
    .tray-card,
    .preview-card {
        padding: 12px;
    }

    .start-screen-container {
        padding: 16px 12px 36px 12px;
    }

    .main-title {
        font-size: 22px;
    }

    .sub-title {
        font-size: 14px;
    }
}