* {
    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, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== ヘッダー ===== */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    position: relative;
}

.header-content {
    position: relative;
}

.back-button {
    position: absolute;
    left: 0;
    top: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: #000080;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-5px);
}

.back-button svg {
    flex-shrink: 0;
}

.header-title {
    display: inline-block;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* ===== アップロードエリア ===== */
.upload-area {
    background: white;
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    border: 3px dashed #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #764ba2;
    background: #f8f9ff;
    transform: translateY(-5px);
}

.upload-content svg {
    color: #667eea;
    margin-bottom: 20px;
}

.upload-content p {
    font-size: 1.2rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.file-info {
    font-size: 0.9rem !important;
    color: #999 !important;
    margin-top: 10px;
}

/* ===== エディタコンテナ ===== */
.editor-container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.5s ease;
}

/* ===== 広告スペース ===== */
.ad-space {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-placeholder {
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px;
}

.ad-top,
.ad-bottom {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ad-top .ad-placeholder,
.ad-bottom .ad-placeholder,
.ad-middle .ad-placeholder {
    width: 728px;
    height: 90px;
    max-width: 100%;
}

/* ===== エディタレイアウト ===== */
.editor-layout {
    display: flex;
    gap: 20px;
}

.editor-main {
    flex: 1;
    min-width: 0;
}

/* ===== コントロール ===== */
.controls {
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

/* ===== ボタングループ ===== */
.button-group {
    display: flex;
    gap: 8px;
}

.button-group button {
    padding: 10px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.button-group button:hover:not(:disabled) {
    background: #f0f0ff;
}

.button-group button.active {
    background: #667eea;
    color: white;
}

.button-group button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== アイコンボタン ===== */
.btn-icon {
    width: 44px;
    height: 44px;
    padding: 8px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover:not(:disabled) {
    background: #f0f0ff;
    transform: scale(1.05);
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

/* ===== 履歴操作ボタン（Undo/Redo） ===== */
.btn-history {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    border: 2px solid;
}

.btn-history svg {
    flex-shrink: 0;
}

.btn-undo {
    background: white;
    color: #1976d2;
    border-color: #1976d2;
}

.btn-undo:hover:not(:disabled) {
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.btn-redo {
    background: white;
    color: #388e3c;
    border-color: #388e3c;
}

.btn-redo:hover:not(:disabled) {
    background: #e8f5e9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 142, 60, 0.3);
}

.btn-history:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #f5f5f5;
    color: #9e9e9e;
    border-color: #e0e0e0;
}

.btn-history:disabled svg {
    opacity: 0.5;
}

/* ===== スライダー ===== */
input[type="range"] {
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

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

/* ===== プライマリ・セカンダリボタン ===== */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

/* ===== Canvasラッパー ===== */
.canvas-wrapper {
    position: relative;
    overflow: auto;
    background: #f0f0f0;
    border-radius: 12px;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

#mainCanvas,
#overlayCanvas {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

#mainCanvas {
    position: absolute;
}

#overlayCanvas {
    position: relative;
}

/* ===== カーソル ===== */
.cursor {
    position: fixed;
    width: 30px;
    height: 30px;
    border: 2px solid #667eea;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    display: none;
    background: rgba(102, 126, 234, 0.1);
    transition: width 0.1s, height 0.1s;
}

/* ===== 情報エリア ===== */
.info {
    margin-top: 20px;
    padding: 15px;
    background: #fff9e6;
    border-left: 4px solid #ffc107;
    border-radius: 8px;
}

.info p {
    margin: 8px 0;
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ===== EXIF情報 ===== */
.exif-info {
    margin-top: 20px;
    padding: 20px;
    background: #fff3e0;
    border-left: 4px solid #ff6f00;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(255, 111, 0, 0.1);
}

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

.exif-header h3 {
    color: #e65100;
    font-size: 1.1rem;
    margin: 0;
}

.btn-link {
    background: none;
    border: none;
    color: #ff6f00;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
    transition: color 0.2s;
}

.btn-link:hover {
    color: #e65100;
}

.exif-details {
    margin-bottom: 15px;
}

.exif-details ul {
    list-style: none;
    padding-left: 0;
}

.exif-details li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 111, 0, 0.1);
    color: #666;
}

.exif-details li:last-child {
    border-bottom: none;
}

.exif-warning-item {
    color: #d84315 !important;
    font-weight: 600;
}

.exif-note {
    font-size: 0.85rem;
    color: #777;
    font-style: italic;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 111, 0, 0.2);
}

.exif-warning {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #ff6f00;
}

.exif-warning p {
    margin: 0 0 10px 0;
    color: #e65100;
    font-weight: 600;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.checkbox-label span {
    line-height: 1.5;
}

.checkbox-label:hover span {
    color: #333;
}

/* ===== ローディングオーバーレイ ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 20px;
}

.loading-overlay p {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== アニメーション ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== レスポンシブデザイン ===== */
@media (max-width: 1200px) {
    .editor-layout {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .back-button {
        position: static;
        display: inline-flex;
        margin-bottom: 20px;
    }
    
    .back-button:hover {
        transform: translateY(-2px);
    }
    
    .header-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .editor-container {
        padding: 15px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 15px;
    }

    .control-group {
        width: 100%;
    }

    input[type="range"] {
        width: 100%;
    }

    .button-group {
        flex-wrap: wrap;
    }

    .button-group button {
        flex: 1;
        min-width: 100px;
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    .btn-history {
        min-width: 0;
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .btn-history span {
        display: inline;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 10px 16px;
    }

    .ad-top .ad-placeholder,
    .ad-bottom .ad-placeholder,
    .ad-middle .ad-placeholder {
        width: 100%;
        height: 100px;
    }

    .canvas-wrapper {
        min-height: 300px;
    }

    #mainCanvas,
    #overlayCanvas {
        max-height: 50vh;
    }

    /* EXIF情報のモバイル対応 */
    .exif-info {
        padding: 15px;
    }

    .exif-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .exif-header h3 {
        font-size: 1rem;
    }

    .checkbox-label {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .upload-content p {
        font-size: 1rem;
    }

    .back-button {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .control-group label {
        font-size: 0.85rem;
    }

    .info p {
        font-size: 0.85rem;
    }
}

/* ===== プリント対応 ===== */
@media print {
    body {
        background: white;
    }

    .back-button,
    .controls,
    .info,
    .ad-space,
    footer {
        display: none;
    }

    .canvas-wrapper {
        box-shadow: none;
        background: white;
    }
}

/* ===== ダークモード対応 ===== */
@media (prefers-color-scheme: dark) {
    .upload-area {
        background: #2a2a2a;
        border-color: #667eea;
        color: #e0e0e0;
    }

    .upload-area:hover,
    .upload-area.dragover {
        background: #333;
    }

    .upload-content p {
        color: #b0b0b0;
    }

    .file-info {
        color: #888 !important;
    }
}

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

/* フォーカスインジケーター */
button:focus-visible,
input:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}
