/* CSS Variables */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 50, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-primary: #7c3aed;
    --accent-secondary: #a855f7;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 8px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Card */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.instruction {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* File Input */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-label:hover {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.1);
}

.file-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.file-text {
    color: var(--text-secondary);
}

.file-name {
    margin-top: 1rem;
    color: var(--accent-secondary);
    text-align: center;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

#imageCanvas,
#resultCanvas {
    max-width: 100%;
    cursor: crosshair;
}

.eyedropper-info {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Color Controls */
.color-controls {
    display: grid;
    gap: 1.5rem;
}

.color-preview-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.color-preview {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    border: 3px solid var(--border-color);
    background: #000;
    box-shadow: var(--shadow);
}

.color-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* RGB Inputs */
.rgb-inputs {
    display: flex;
    gap: 1rem;
}

.rgb-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rgb-input-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

.rgb-input-group input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

.rgb-input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Tolerance Control */
.tolerance-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tolerance-control label {
    font-size: 0.9rem;
}

#toleranceSlider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-secondary);
    -webkit-appearance: none;
    appearance: none;
}

#toleranceSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.5);
}

.tolerance-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Mode Control */
.mode-control {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mode-control>label {
    font-size: 0.9rem;
    font-weight: 500;
}

.mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.mode-option {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.mode-option:hover {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.1);
}

.mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.mode-option:has(input:checked) {
    border-color: var(--accent-primary);
    background: rgba(124, 58, 237, 0.2);
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

.mode-label {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.mode-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 150px;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-success), #059669);
    color: white;
    width: 100%;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

/* Result Container */
.result-container {
    display: flex;
    justify-content: center;
    background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .rgb-inputs {
        flex-direction: column;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        min-width: auto;
    }
}