body {
    font-family: Arial, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
}

.container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
}

.app-header h1 {
    margin: 0;
    text-align: left;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.github-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid #cfd8e3;
    border-radius: 4px;
    color: #12315a;
    background: #f8fafc;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s, border-color 0.2s;
}

.github-link:hover {
    background: #edf4fb;
    border-color: #b5c5d6;
}

.language-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    white-space: nowrap;
}

.language-switch select {
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid #cfd8e3;
    border-radius: 4px;
    background: white;
    color: #223;
    font-size: 14px;
}

.upload-section {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    background-color: #fafafa;
}

#file-input {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.upload-btn:hover {
    background-color: #45a049;
}

.canvas-container {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    margin: 20px 0;
    position: relative;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
    width: 100%;
    max-width: 100%;
    overflow: auto;
    max-height: 72vh;
}

.canvas-container canvas {
    width: auto;
    height: auto;
    flex-shrink: 0;
}

.brush-preview {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    border: 2px solid rgba(21, 101, 192, 0.7);
    border-radius: 50%;
    background: rgba(21, 101, 192, 0.12);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85) inset;
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.12s ease;
    z-index: 3;
}

.brush-preview.visible {
    opacity: 1;
}

canvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
}

canvas.tool-move {
    cursor: grab;
}

canvas.tool-move.is-panning {
    cursor: grabbing;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0;
    padding: 16px;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
    border: 1px solid #dbe5ef;
    border-radius: 12px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(21, 101, 192, 0.1);
    box-shadow: 0 4px 14px rgba(20, 43, 75, 0.05);
}

.group-title {
    margin-bottom: 2px;
    font-weight: bold;
    color: #555;
    text-align: left;
}

.tool-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.control-group label {
    margin-bottom: 0;
}

.control-group input[type="range"] {
    width: 100%;
}

.zoom-group {
    min-width: 0;
}

.auto-group {
    grid-column: 1 / -1;
}

.quality-group {
    grid-column: 1 / -1;
}

.auto-group input[type="range"] {
    width: 100%;
}

.threshold-range-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    font-size: 12px;
    color: #66758d;
}

.auto-preview-wrap {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, #111827 0%, #243447 100%);
    border: 1px solid rgba(18, 49, 90, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.auto-threshold-preview {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 auto;
    border-radius: 10px;
    background: #111;
    image-rendering: pixelated;
}

.auto-action-buttons {
    margin-top: 10px;
    justify-content: flex-start;
}

.quality-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.quality-option {
    min-width: 0;
    padding: 10px;
    border: 1px solid #dbe5ef;
    border-radius: 6px;
    background: #fff;
}

.quality-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
    margin: 0;
    padding: 0;
    color: #23344d;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.quality-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    accent-color: #1565c0;
}

.quality-slider-label {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 0 0;
    color: #66758d;
    font-size: 12px;
    font-weight: bold;
}

.quality-option input[type="range"] {
    width: 100%;
    margin-top: 6px;
}

.zoom-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-bottom: 8px;
}

.tool-btn,
.secondary-btn {
    min-width: 86px;
    background-color: #e0e0e0;
    color: #333;
}

.tool-btn:hover,
.secondary-btn:hover {
    background-color: #cfcfcf;
}

.tool-btn.active {
    background-color: #1565c0;
    color: white;
}

.tool-btn.active:hover {
    background-color: #0d47a1;
}

.shortcut-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

input[type="range"] {
    width: 150px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.preview-panel {
    margin-top: 28px;
    padding: 20px;
    border-radius: 14px;
    border: 1px solid #d8e4f0;
    background: linear-gradient(180deg, #ffffff 0%, #f6f9fc 100%);
    box-shadow: 0 8px 24px rgba(30, 60, 90, 0.08);
}

.preview-header h3,
.hdr-test-header h3 {
    margin: 0 0 8px;
    color: #12315a;
}

.preview-header p {
    margin: 0;
    line-height: 1.7;
    color: #445;
}

.preview-controls {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: #23344d;
    font-weight: bold;
    cursor: pointer;
}

.preview-toggle input {
    width: 16px;
    height: 16px;
    accent-color: #1565c0;
}

.preview-refresh-btn {
    min-width: 120px;
}

.preview-image-wrap {
    position: relative;
    margin-top: 16px;
    min-height: 220px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #d5dde6;
    background: linear-gradient(135deg, #151b26 0%, #26354a 100%);
}

.preview-image {
    display: none;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.preview-image.visible {
    display: block;
}

.preview-empty {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    line-height: 1.7;
}

.preview-status {
    margin-top: 12px;
    font-size: 13px;
    color: #5a6d86;
    text-align: center;
}

.hdr-test-panel {
    margin-top: 28px;
    padding: 20px;
    border-radius: 14px;
    border: 1px solid #d7e3ff;
    background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
    box-shadow: 0 8px 24px rgba(20, 60, 120, 0.08);
}

.hdr-test-header h3 {
    margin: 0 0 8px;
    color: #12315a;
}

.hdr-test-header p {
    margin: 0;
    line-height: 1.7;
    color: #345;
}

.hdr-test-header a {
    color: #0b5ed7;
    text-decoration: none;
    font-weight: bold;
}

.hdr-test-header a:hover {
    text-decoration: underline;
}

.hdr-test-image-wrap {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.hdr-test-image {
    display: block;
    width: min(100%, 860px);
    max-height: 460px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(18, 49, 90, 0.14);
    background-color: #111;
    box-shadow: 0 10px 30px rgba(18, 49, 90, 0.12);
}

.hdr-test-note {
    margin-top: 12px;
    font-size: 13px;
    color: #5a6d86;
    text-align: center;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.download-btn {
    background-color: #2196F3;
    color: white;
}

.download-btn:hover {
    background-color: #0b7dda;
}

.clear-btn {
    background-color: #f44336;
    color: white;
}

.clear-btn:hover {
    background-color: #d32f2f;
}

.secondary-btn:hover:disabled,
.tool-btn:hover:disabled {
    background-color: #e0e0e0;
}

.reset-btn {
    background-color: #ff9800;
    color: white;
}

.reset-btn:hover {
    background-color: #e68a00;
}

.export-hdr-btn {
    background-color: #9c27b0;
    color: white;
}

.export-hdr-btn:hover {
    background-color: #7b1fa2;
}

.instructions {
    background-color: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 14px;
    color: #333;
}

.instructions h3 {
    margin-top: 0;
    color: #1565c0;
}

.status-message {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    display: none;
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .canvas-container {
        max-width: 100%;
        border-radius: 8px;
        max-height: 60vh;
    }

    #canvas-container canvas {
        max-width: none;
        height: auto;
    }

    .preview-panel,
    .hdr-test-panel {
        padding: 16px;
    }

    .preview-image-wrap,
    .preview-empty {
        min-height: 180px;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .auto-group {
        width: 100%;
    }

    .preview-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .preview-refresh-btn {
        width: 100%;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    button {
        width: 200px;
    }
}
