/* カラーパレット */
:root {
    /* 背景グラデーション */
    --bg-gradient-1: #f5f5f0;
    --bg-gradient-2: #e8e4d8;

    /* UIコンポーネント */
    --primary-blue: #3b82f6;
    --white: #ffffff;
    --gray-light: rgba(255, 255, 255, 0.2);
    --gray-dark: #2c3e50;
    --shadow-color: rgba(0, 0, 0, 0.1);

    /* RGB用 */
    --red: #ff0000;
    --green: #00ff00;
    --blue: #0000ff;

    /* CMY用 */
    --cyan: #00ffff;
    --magenta: #ff00ff;
    --yellow: #ffff00;

    /* 絵の具用 */
    --paint-red: #e63946;
    --paint-blue: #457b9d;
    --paint-yellow: #f4a261;
}

/* リセット */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    min-height: 100vh;
    color: var(--gray-dark);
    font-size: 16px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
}

/* ヘッダー */
header {
    text-align: center;
    color: var(--gray-dark);
    margin-bottom: 15px;
}

header h1 {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 18px;
    opacity: 0.7;
}

/* パネルヘッダー（高さを揃えるため） */
.panel-header {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.panel-header h2 {
    margin: 0;
    text-align: center;
    font-size: 20px;
    color: var(--gray-dark);
}

/* CMYヘッダー（タイトルとチェックボックス） */
.cmy-header {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cmy-header h2 {
    margin: 0;
}

/* インライン絵の具モードチェックボックス */
.paint-mode-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.paint-mode-inline:hover {
    background: rgba(255, 255, 255, 0.5);
}

.paint-mode-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 絵の具モード説明文 */
.paint-mode-note {
    text-align: center;
    font-size: 13px;
    color: #666;
    padding: 6px 12px;
    background: rgba(255, 235, 205, 0.5);
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 165, 0, 0.2);
    min-height: 32px;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 左側パネルのスペーサー（高さを揃えるため） */
.panel-spacer {
    min-height: 32px;
    margin-bottom: 10px;
}

/* メインコンテンツエリア */
.mode-panel {
    background: var(--white);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 16px var(--shadow-color);
    margin-bottom: 10px;
    transition: opacity 0.3s ease;
}

.mode-panel[hidden] {
    display: none;
}

/* 比較モード: 2つの独立したボックス */
.compare-panels {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.compare-panels.active {
    display: grid;
}

.compare-panels[hidden] {
    display: none;
}

.compare-panel-left,
.compare-panel-right {
    /* mode-panelのスタイルを継承 */
}

.compare-panels h2 {
    text-align: center;
    font-size: 20px;
    margin: 0;
    color: var(--gray-dark);
}

/* ビジュアルエリア */
.visual-area {
    position: relative;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: 10px;
}

.visual-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 10px;
}


.circles-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.circle-1 {
    left: 5px;
    bottom: 5px;
}

.circle-2 {
    left: calc(50% - 20px);
    top: 5px;
}

.circle-3 {
    right: 5px;
    bottom: 5px;
}

/* 重なり部分のスタイル */
.overlap {
    transition: all 0.3s ease;
}

.overlap-two {
    /* 2つの円が重なる部分 */
}

.overlap-center {
    /* 3つすべてが重なる中心部分 */
}

/* 結果表示エリア */
.result-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.result-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-dark);
    white-space: nowrap;
}

.result-bar {
    flex: 1;
    height: 60px;
    border-radius: 10px;
    border: 2px solid var(--gray-dark);
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: background-color 0.3s ease;
}

.color-info {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--gray-dark);
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #999999;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* スライダーセクション */
.controls-section {
    background: var(--white);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 16px var(--shadow-color);
    margin-bottom: 20px;
}

.sliders-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

/* 比較モード用のスライダーレイアウト */
.sliders-container.compare-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.slider-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.slider-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-dark);
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-light);
}

/* パネル内のスライダー */
.sliders-in-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--gray-light);
}

/* パネル内の色番号入力 */
.color-input-in-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--gray-light);
    flex-wrap: wrap;
}

.color-input-in-panel label {
    font-weight: 600;
    font-size: 14px;
}

.color-input-in-panel input[type="text"] {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border: 2px solid #cccccc;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s ease;
    background: #ffffff;
}

.color-input-in-panel input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.apply-btn-small {
    padding: 8px 16px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.apply-btn-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px var(--shadow-color);
}

.apply-btn-small:active {
    transform: translateY(0);
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider-label {
    min-width: 150px;
    font-weight: 600;
    font-size: 14px;
}

.slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #ddd, #999);
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.slider-value {
    min-width: 40px;
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
}

/* 色番号入力 */
.color-input-section {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.color-input-section label {
    font-weight: 600;
}

#colorInput {
    padding: 10px 15px;
    border: 2px solid #cccccc;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    width: 250px;
    transition: border-color 0.3s ease;
    background: #ffffff;
}

#colorInput:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.apply-btn {
    padding: 10px 24px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.apply-btn:active {
    transform: translateY(0);
}

/* 解説ボタン */
.explanation-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.explanation-btn {
    background: var(--white);
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.explanation-btn:hover {
    background: var(--primary-blue);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

/* フッター */
footer {
    text-align: center;
    color: var(--gray-dark);
    padding: 10px 0;
    font-size: 14px;
}

footer a {
    color: var(--primary-blue);
    text-decoration: underline;
}

footer a:hover {
    opacity: 0.8;
}

/* トースト通知 */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.toast {
    background: var(--white);
    border-left: 5px solid var(--primary-blue);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 10px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
}

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

.toast-header {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--gray-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.toast-close:active {
    transform: scale(0.95);
}

.toast-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--gray-dark);
    white-space: pre-line;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    header h1 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 16px;
    }

    /* 比較モードのボックスを上下に配置 */
    .compare-panels {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .visual-area {
        height: 100px;
    }

    .circle {
        width: 30px;
        height: 30px;
    }

    .circle-1 {
        left: 5px;
        bottom: 5px;
    }

    .circle-2 {
        left: calc(50% - 15px);
        top: 5px;
    }

    .circle-3 {
        right: 5px;
        bottom: 5px;
    }

    .slider-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .slider-label {
        min-width: auto;
    }

    .slider {
        width: 100%;
    }

    /* 比較モードのスライダーを上下に配置 */
    .sliders-container.compare-sliders {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .color-input-section {
        flex-direction: column;
    }

    #colorInput {
        width: 100%;
    }

    .explanation-section {
        gap: 8px;
    }

    .explanation-btn {
        font-size: 12px;
        padding: 8px 16px;
    }

    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    .mode-panel {
        padding: 20px;
    }

    .controls-section {
        padding: 20px;
    }

    .cmy-header {
        flex-direction: column;
        gap: 10px;
    }

    .paint-mode-inline {
        font-size: 13px;
    }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高コントラストモード */
@media (prefers-contrast: high) {
    .tab-button,
    .explanation-btn,
    .apply-btn {
        border-width: 3px;
    }
}
