* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(ellipse at bottom, #0d1b2a 0%, #1b263b 50%, #0f172a 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ヘッダースタイル */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    font-weight: 600;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.header-link:hover {
    color: #60a5fa;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.container {
    max-width: 1200px;
    margin: 60px auto 0; /* ヘッダーの高さ分の余白 */
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

h1 {
    text-align: center;
    color: #f1f5f9;
    margin-bottom: 30px;
    font-size: 2em;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 4px 6px rgba(0, 0, 0, 0.5);
}

.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
    align-items: start;
}

.upload-box {
    border: 3px dashed rgba(59, 130, 246, 0.5);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    background: rgba(15, 23, 42, 0.5);
    transition: all 0.3s;
    cursor: pointer;
}

.upload-box:hover {
    background: rgba(30, 41, 59, 0.7);
    border-color: #3b82f6;
}

.upload-box.has-image {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.upload-box input[type="file"] {
    display: none;
}

.upload-label {
    display: block;
    font-size: 1.2em;
    color: #60a5fa;
    margin-bottom: 10px;
    font-weight: bold;
}

.upload-box.has-image .upload-label {
    color: #3b82f6;
}

.upload-instruction {
    color: rgba(241, 245, 249, 0.7);
    font-size: 0.9em;
}

.controls {
    background: rgba(15, 23, 42, 0.5);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    position: sticky;
    top: 80px;
}

.control-group {
    margin-bottom: 20px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    display: block;
    margin-bottom: 10px;
    color: #f1f5f9;
    font-weight: 600;
}

.checkbox-input {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
}

.mode-description {
    font-size: 0.85em;
    color: rgba(241, 245, 249, 0.7);
    margin-top: 5px;
    margin-left: 26px;
    line-height: 1.4;
}

.fine-tune-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-fine-tune {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.85em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    background: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.5);
    width: auto;
}

.btn-fine-tune:hover {
    background: rgba(59, 130, 246, 0.5);
    color: #f1f5f9;
    transform: translateY(-1px);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-toggle {
    padding: 8px 16px;
    font-size: 0.9em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    background: linear-gradient(45deg, #3b82f6, #1e40af);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    user-select: none;
    white-space: nowrap;
}

.btn-toggle:hover {
    background: linear-gradient(45deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.6);
}

.btn-toggle:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
}

input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 5px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: all 0.3s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
}

.value-display {
    min-width: 60px;
    text-align: right;
    font-weight: bold;
    color: #60a5fa;
}

.canvas-container {
    background: radial-gradient(ellipse at center, #0f172a 0%, #020617 100%);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 600px;
    position: relative;
    overflow: auto;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease;
}

.canvas-container.white-bg {
    background: #ffffff;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: 12px 30px;
    font-size: 1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, #3b82f6, #1e40af);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(45deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-secondary {
    background: linear-gradient(45deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: linear-gradient(45deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.btn-swap {
    background: linear-gradient(45deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-swap:hover {
    background: linear-gradient(45deg, #d97706, #b45309);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

.preview-thumbnail {
    max-width: 100%;
    max-height: 100px;
    margin-top: 10px;
    border-radius: 8px;
}

.pdf-page-selector {
    margin-top: 10px;
    padding: 8px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.pdf-page-selector label {
    display: block;
    font-size: 0.85em;
    color: #60a5fa;
    margin-bottom: 5px;
}

.pdf-page-selector select {
    width: 100%;
    padding: 6px;
    background: rgba(15, 23, 42, 0.9);
    color: #f1f5f9;
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
}

.pdf-page-selector select:focus {
    outline: none;
    border-color: #3b82f6;
}

@media (max-width: 768px) {
    .upload-section {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .controls {
        position: static;
    }
}
