* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 12px;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.title-icon {
    width: 41px;
    height: 41px;
    object-fit: contain;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Editor Section */
.editor-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

/* Editor Header - Horizontal Controls */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.format-dropdown {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--surface);
    cursor: pointer;
    outline: none;
}

.format-dropdown:focus {
    border-color: var(--primary);
}

/* Editor Footer */
.editor-footer {
    display: none;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.editor-footer.visible {
    display: flex;
}

.editor-footer strong {
    color: var(--text);
    font-weight: 500;
}

.editor-footer .preview-hint {
    flex: 1;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Quality Row */
.quality-row {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 8px;
}

.quality-row.visible {
    display: flex;
}

.quality-row label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.quality-row input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.quality-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

/* Legacy Steps (for result section) */
.step {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.reset-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.reset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.reset-btn svg {
    width: 18px;
    height: 18px;
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.step h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area.hidden {
    display: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-area p {
    color: var(--text);
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Toolbar */
.toolbar {
    display: none;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: var(--radius);
    margin-bottom: 16px;
    align-items: center;
}

.toolbar.visible {
    display: flex;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}

.tool-group:last-child {
    border-right: none;
    padding-right: 0;
}

/* Mode Toggle Buttons (裁切/繪圖) */
.mode-btn {
    height: 32px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 500;
}

.mode-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Tool Buttons (Drawing tools icons) */
.tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    color: var(--text-secondary);
}

.tool-btn svg {
    width: 18px;
    height: 18px;
}

.tool-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Action Buttons (復原/重做/清除) */
.action-btn {
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.action-btn.icon-btn {
    width: 32px;
    padding: 0;
    font-size: 1.1rem;
}

.action-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Draw Tools - Hidden by default */
.draw-tools,
.draw-options {
    display: none;
}

.draw-tools.visible,
.draw-options.visible {
    display: flex;
}

/* Color Picker */
#colorPicker {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

#colorPicker::-webkit-color-swatch-wrapper {
    padding: 3px;
}

#colorPicker::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

/* Stroke Width */
.stroke-width-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
}

.stroke-width-wrapper input[type="range"] {
    width: 70px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    -webkit-appearance: none;
}

.stroke-width-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

#strokeValue {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 16px;
    text-align: center;
}

/* Fill Option */
.fill-option {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.fill-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: #1e293b;
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 300px;
    display: none;
    align-items: center;
    justify-content: center;
}

.canvas-container.visible {
    display: flex;
}

/* Canvas Top Actions */
.canvas-top-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 50;
}

.canvas-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
    opacity: 0.8;
}

.canvas-action-btn:hover {
    background: rgba(79, 70, 229, 0.9);
    opacity: 1;
}

.canvas-action-btn.remove-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.canvas-action-btn.remove-btn:hover {
    background: rgba(239, 68, 68, 0.9);
}

.canvas-action-btn svg {
    width: 16px;
    height: 16px;
}

.canvas-action-btn.remove-btn svg {
    width: 20px;
    height: 20px;
}

.canvas-action-btn.success {
    background: rgba(34, 197, 94, 0.9) !important;
    opacity: 1;
}

.canvas-action-btn.error {
    background: rgba(239, 68, 68, 0.9) !important;
    opacity: 1;
}

/* Canvas Wrapper - wraps canvas and overlays together */
.canvas-wrapper {
    position: relative;
    display: inline-block;
}

#mainCanvas {
    max-width: 100%;
    max-height: 500px;
}

#drawCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.canvas-container.draw-mode #drawCanvas {
    pointer-events: auto;
    cursor: crosshair;
}

/* Crop Box */
.crop-box {
    position: absolute;
    border: 2px solid white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    display: none;
}

.canvas-container.crop-mode .crop-box {
    display: block;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }
.crop-handle.e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

/* Text Input Container */
.text-input-container {
    position: absolute;
    display: none;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    padding: 12px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 200px;
}

.text-input-container.visible {
    display: flex;
}

.text-input-container textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.text-input-container textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.text-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.text-size-row label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.text-size-row select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--surface);
    cursor: pointer;
}

.text-size-row select:focus {
    outline: none;
    border-color: var(--primary);
}

.text-size-row input[type="number"] {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
}

.text-size-row input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}

.text-input-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.text-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--primary);
    color: white;
}

.text-btn:hover {
    background: var(--primary-hover);
}

.text-btn-cancel {
    background: var(--border);
    color: var(--text);
}

.text-btn-cancel:hover {
    background: #cbd5e1;
}

/* Crop Info */
.crop-info {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.crop-info.visible {
    display: flex;
}

.crop-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crop-info strong {
    color: var(--text);
    font-weight: 500;
}

.preview-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.change-image-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.change-image-btn:hover {
    background: var(--primary);
    color: white;
}

/* Ratio Dropdown */
.ratio-dropdown-wrapper {
    position: relative;
}

.ratio-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}

.ratio-dropdown-btn:hover {
    border-color: var(--primary);
}

.ratio-dropdown-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.current-ratio-icon {
    font-size: 1rem;
    display: none;
}

.current-ratio-text {
    font-weight: 500;
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.ratio-dropdown-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.ratio-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    max-height: 350px;
    overflow-y: auto;
}

.ratio-dropdown-menu.visible {
    display: block;
}

.ratio-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-weight: 400;
    font-size: 0.9rem;
}

.ratio-option:hover {
    background: var(--primary-light);
}

.ratio-option.active {
    background: var(--primary-light);
    font-weight: 500;
}

.ratio-option .ratio-icon {
    display: none;
}

.ratio-option .ratio-label {
    font-weight: 500;
}

.ratio-option .ratio-size {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Custom Ratio Option */
.custom-ratio-option {
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
}

/* Lock Ratio Label in Floating Bar */
.floating-group .lock-ratio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.floating-group .lock-ratio-label:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.floating-group .lock-ratio-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--primary);
}

.floating-group .lock-ratio-label .lock-text {
    transition: color 0.2s;
}

.floating-group .lock-ratio-label input[type="checkbox"]:checked + .lock-text {
    color: var(--primary);
}

.custom-ratio-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.custom-ratio-inputs input {
    width: 60px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
}

.custom-ratio-inputs input:focus {
    outline: none;
    border-color: var(--primary);
}

.custom-ratio-inputs span {
    font-weight: 600;
    color: var(--text-secondary);
}

.custom-ratio-inputs .apply-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-ratio-inputs .apply-btn:hover {
    background: var(--primary-hover);
}

/* Export Options */
.export-options {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 24px;
}

.format-select,
.quality-select {
    width: 100%;
}

.format-select label,
.quality-select label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.format-select select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    background: var(--surface);
    transition: border-color 0.2s;
}

.format-select select:focus {
    border-color: var(--primary);
}

.quality-select {
    margin-top: 12px;
}

.quality-select input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.quality-select input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.quality-select input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Export Button */
.export-btn {
    width: 100%;
    padding: 14px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: auto;
}

.export-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.export-btn:disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.export-btn svg {
    width: 24px;
    height: 24px;
}

/* Result Section */
.result-section {
    display: none;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.result-section.visible {
    display: block;
}

/* Responsive */
@media (max-width: 800px) {
    .editor-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* Result Tip */
.result-tip {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: #92400e;
}

.result-tip p {
    margin: 0 0 6px 0;
}

.result-tip ul {
    margin: 0;
    padding-left: 20px;
}

.result-tip li {
    margin: 4px 0;
}

.result-tip strong {
    color: #78350f;
}

.result-preview {
    position: relative;
    background: #1e293b;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.result-top-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 50;
}

.result-close-btn:hover {
    background: rgba(239, 68, 68, 0.9) !important;
}

.result-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    object-fit: contain;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-preview img:hover {
    transform: scale(1.01);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.result-preview img:active {
    cursor: grabbing;
}

.result-preview img.dragging {
    opacity: 0.6;
    transform: scale(0.98);
}

.drag-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

.result-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.result-actions select {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--surface);
    cursor: pointer;
}

.result-actions select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    flex: 1;
    height: 44px;
    padding: 0 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

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

/* Canvas drop zone for replacing image */
.canvas-container.drag-over {
    outline: 3px dashed var(--primary);
    outline-offset: -3px;
}

.canvas-container.drag-over::after {
    content: '放開以更換圖片';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(79, 70, 229, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    z-index: 100;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding-bottom: 100px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Tab System */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-buttons {
    display: flex;
    gap: 0;
}

.tab-info {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding-right: 8px;
}

.tab-info.visible {
    display: flex;
}

.tab-info .output-size strong {
    color: var(--text);
    font-weight: 600;
}

.tab-info .info-divider {
    color: var(--border);
}

.tab-info .preview-hint {
    opacity: 0.8;
}

.tab-btn {
    padding: 10px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover:not(:disabled) {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Floating Container */
.floating-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1000;
}

.floating-container.visible {
    display: flex;
}

/* Draw Toolbar (upper bar) */
.draw-toolbar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.2s ease-out;
    flex-wrap: nowrap;
    white-space: nowrap;
    flex-shrink: 0;
}

.floating-container.draw-mode .draw-toolbar {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

/* Tool Dropdown */
.tool-dropdown {
    position: relative;
}

.tool-dropdown-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 44px;
    height: 32px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.tool-dropdown-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.tool-dropdown-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3), 0 2px 8px rgba(99, 102, 241, 0.4);
    transform: scale(1.08);
}

.tool-dropdown-btn .tool-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-dropdown-btn .tool-icon svg {
    width: 18px;
    height: 18px;
}

.tool-dropdown-btn .dropdown-arrow {
    font-size: 12px;
    opacity: 1;
    color: var(--text);
}

.tool-dropdown-btn.active .dropdown-arrow {
    opacity: 1;
}

.tool-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    min-width: 100px;
}

.tool-dropdown-menu.visible {
    display: flex;
}

.tool-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
    font-size: 0.8rem;
    white-space: nowrap;
}

.tool-option:hover {
    background: var(--primary-light);
}

.tool-option.active {
    background: var(--primary);
    color: white;
}

.tool-option svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tool-option-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Main Floating Bar (lower bar) */
.floating-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 12px;
    flex-wrap: nowrap;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
}

.floating-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Mode buttons in floating bar */
.floating-bar .mode-btn {
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 500;
}

.floating-bar .mode-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.floating-bar .mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Tool buttons in toolbars */
.floating-bar .tool-btn,
.draw-toolbar .tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.floating-bar .tool-btn svg,
.draw-toolbar .tool-btn svg {
    width: 16px;
    height: 16px;
}

.floating-bar .tool-btn:hover,
.draw-toolbar .tool-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.floating-bar .tool-btn.active,
.draw-toolbar .tool-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3), 0 2px 8px rgba(99, 102, 241, 0.4);
    transform: scale(1.08);
}

.floating-bar .tool-btn:disabled,
.draw-toolbar .tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Color picker in toolbars */
.floating-bar #colorPicker,
.draw-toolbar #colorPicker {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.floating-bar #colorPicker::-webkit-color-swatch-wrapper,
.draw-toolbar #colorPicker::-webkit-color-swatch-wrapper {
    padding: 3px;
}

.floating-bar #colorPicker::-webkit-color-swatch,
.draw-toolbar #colorPicker::-webkit-color-swatch {
    border-radius: 3px;
    border: none;
}

/* Stroke width in toolbars */
.floating-bar .stroke-width-wrapper,
.draw-toolbar .stroke-width-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 8px;
    background: var(--bg);
    border-radius: 6px;
}

.floating-bar .stroke-width-wrapper input[type="range"],
.draw-toolbar .stroke-width-wrapper input[type="range"] {
    width: 50px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    -webkit-appearance: none;
}

.floating-bar .stroke-width-wrapper input[type="range"]::-webkit-slider-thumb,
.draw-toolbar .stroke-width-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.floating-bar #strokeValue,
.draw-toolbar #strokeValue {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 14px;
    text-align: center;
}

/* Fill option in toolbars */
.floating-bar .fill-option,
.draw-toolbar .fill-option {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 32px;
    padding: 0 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    background: var(--bg);
    border-radius: 6px;
}

.floating-bar .fill-option input[type="checkbox"],
.draw-toolbar .fill-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Color Picker Popover */
.color-picker-wrapper {
    position: relative;
}

.color-picker-btn {
    width: 32px;
    height: 32px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
}

.color-picker-btn:hover {
    border-color: var(--primary);
}

.color-picker-btn .color-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    background: #ff0000;
}

.color-code-display {
    font-size: 0.7rem;
    font-family: monospace;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.color-picker-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1100;
}

.color-picker-popover.visible {
    display: flex;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    width: 168px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-swatch.active {
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.color-swatch[data-color="#ffffff"] {
    border-color: #e2e8f0;
}

/* Hue Slider */
.hue-slider-wrapper {
    padding: 4px 0;
}

.hue-slider {
    width: 100%;
    height: 12px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 6px;
    background: linear-gradient(to right,
        hsl(0, 100%, 50%),
        hsl(30, 100%, 50%),
        hsl(60, 100%, 50%),
        hsl(90, 100%, 50%),
        hsl(120, 100%, 50%),
        hsl(150, 100%, 50%),
        hsl(180, 100%, 50%),
        hsl(210, 100%, 50%),
        hsl(240, 100%, 50%),
        hsl(270, 100%, 50%),
        hsl(300, 100%, 50%),
        hsl(330, 100%, 50%),
        hsl(360, 100%, 50%)
    );
    cursor: pointer;
    outline: none;
}

.hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.hue-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.color-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.color-custom input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: none;
}

.color-custom input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-custom input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.color-custom input[type="text"] {
    flex: 1;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: monospace;
    text-transform: uppercase;
}

.color-custom input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.eyedropper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s ease;
}

.eyedropper-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.eyedropper-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.eyedropper-btn svg {
    width: 16px;
    height: 16px;
}

/* Stroke Preview */
.draw-toolbar .stroke-width-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 8px;
    background: var(--bg);
    border-radius: 6px;
}

.draw-toolbar .stroke-width-wrapper input[type="range"] {
    width: 60px;
}

.stroke-preview {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.stroke-preview .stroke-dot {
    width: 3px;
    height: 3px;
    background: #ff0000;
    border-radius: 50%;
    transition: all 0.15s;
}

.floating-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    margin: 0 4px;
}

/* Floating Dropdown Buttons */
.floating-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.floating-dropdown-btn:hover {
    border-color: var(--primary);
}

.floating-dropdown-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.dropdown-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.dropdown-value {
    font-weight: 500;
    color: var(--text);
}

/* Fixed width for format dropdown value */
#currentFormatText {
    min-width: 36px;
    text-align: center;
}

.floating-dropdown-btn .dropdown-arrow {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.floating-dropdown-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Format Dropdown */
.format-dropdown-wrapper {
    position: relative;
}

.format-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: none;
    min-width: 100px;
    z-index: 101;
}

.format-dropdown-menu.visible {
    display: block;
}

.format-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.format-option:hover {
    background: var(--primary-light);
}

.format-option.active {
    background: var(--primary-light);
    font-weight: 500;
    color: var(--primary);
}

/* Quality Control in Floating Bar */
.quality-control {
    display: none;
    align-items: center;
}

.quality-control.visible {
    display: flex;
}

/* Quality Dropdown */
.quality-dropdown-wrapper {
    position: relative;
}

.quality-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: none;
    min-width: 160px;
    padding: 12px;
    z-index: 101;
}

.quality-dropdown-menu.visible {
    display: block;
}

.quality-slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.quality-slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 3px;
}

.quality-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.quality-slider-container .quality-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 38px;
    text-align: right;
}

.quality-presets {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.quality-preset {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
    color: var(--text);
}

.quality-preset:hover {
    background: var(--primary-light);
}

.quality-preset.active {
    background: var(--primary-light);
    font-weight: 500;
    color: var(--primary);
}

/* Fixed width for quality dropdown value */
#currentQualityText {
    min-width: 36px;
    text-align: center;
}

/* Floating Buttons */
.floating-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.floating-btn svg {
    width: 18px;
    height: 18px;
}

.floating-bar .reset-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.floating-bar .reset-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.floating-bar .complete-btn {
    height: 38px;
    padding: 0 20px;
    background: var(--primary);
    color: white;
    font-size: 0.9rem;
}

.floating-bar .complete-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.floating-bar .complete-btn:disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Ratio Dropdown in Floating Bar */
.floating-bar .ratio-dropdown-wrapper {
    position: relative;
}

.floating-bar .ratio-dropdown-menu {
    position: absolute;
    top: auto;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    display: none;
    max-height: 350px;
    overflow-y: auto;
}

.floating-bar .ratio-dropdown-menu.visible {
    display: block;
}

.floating-bar .ratio-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.floating-bar .ratio-option:hover {
    background: var(--primary-light);
}

.floating-bar .ratio-option.active {
    background: var(--primary-light);
    font-weight: 500;
}

.floating-bar .ratio-option .ratio-label {
    font-weight: 500;
}

.floating-bar .ratio-option .ratio-size {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.floating-bar .ratio-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Custom ratio inputs in floating bar */
.floating-bar .custom-ratio-option {
    flex-wrap: wrap;
    padding: 10px 14px;
}

.floating-bar .custom-ratio-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

.floating-bar .custom-ratio-inputs input {
    width: 70px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
}

.floating-bar .custom-ratio-inputs input:focus {
    outline: none;
    border-color: var(--primary);
}

.floating-bar .custom-ratio-inputs .apply-btn {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.floating-bar .custom-ratio-inputs .apply-btn:hover {
    background: var(--primary-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .toolbar {
        gap: 10px;
    }

    .tool-group {
        border-right: none;
        padding-right: 0;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border);
    }

    .tool-group:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .draw-tools {
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 20px 16px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .step {
        padding: 16px;
    }

    .upload-area {
        padding: 32px 16px;
    }

    .mode-btn {
        padding: 0 10px;
        font-size: 0.8rem;
    }

    .action-btn {
        padding: 0 8px;
        font-size: 0.75rem;
    }

    .stroke-width-wrapper input[type="range"] {
        width: 50px;
    }

    .custom-ratio-inputs {
        width: 100%;
        margin-top: 8px;
        margin-left: 0;
    }
}

/* ====== NEW FEATURES STYLES ====== */

/* Adjustment Toolbar (top bar for adjust mode) */
.adjustment-toolbar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.2s ease-out;
}

.floating-container.adjust-mode .adjustment-toolbar {
    display: flex;
}

.adjust-sliders {
    display: flex;
    align-items: center;
    gap: 12px;
}

.adjust-slider-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.adjust-slider-item label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.adjust-slider-item label svg {
    width: 16px;
    height: 16px;
}

.adjust-slider-item input[type="range"] {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
}

.adjust-slider-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.adjust-slider-item .slider-value {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: center;
    font-family: monospace;
}

.quick-effects {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Filter Toolbar */
.filter-toolbar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.2s ease-out;
}

.floating-container.adjust-mode .filter-toolbar {
    display: flex;
}

.filter-presets {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Selection Box */
.selection-box {
    position: absolute;
    border: 2px dashed white;
    background: rgba(79, 70, 229, 0.1);
    pointer-events: none;
    display: none;
}

.selection-box.visible {
    display: block;
    animation: marchingAnts 0.5s linear infinite;
}

@keyframes marchingAnts {
    0% { border-color: white; }
    50% { border-color: var(--primary); }
    100% { border-color: white; }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

.modal-wide {
    max-width: 500px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn-cancel {
    background: var(--bg);
    color: var(--text);
}

.modal-btn-cancel:hover {
    background: var(--border);
}

.modal-btn-primary {
    background: var(--primary);
    color: white;
}

.modal-btn-primary:hover {
    background: var(--primary-hover);
}

.modal-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--surface);
    cursor: pointer;
}

.modal-select:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-color {
    width: 40px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: none;
}

.modal-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.modal-color::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Resize Modal */
.resize-inputs {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.resize-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resize-input-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 40px;
}

.resize-input-group input {
    width: 100px;
}

.resize-input-group span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.resize-ratio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.resize-ratio-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Watermark Modal */
.watermark-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    background: var(--bg);
    border-radius: 8px;
}

.watermark-tab {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.watermark-tab:hover {
    color: var(--text);
}

.watermark-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.watermark-content {
    margin-bottom: 16px;
}

.watermark-content.hidden {
    display: none;
}

.watermark-options {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 50px;
}

.option-group input[type="range"] {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 2px;
}

.option-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.option-group span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 30px;
}

.watermark-image-upload {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.watermark-image-upload:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.watermark-image-upload p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.watermark-position {
    margin-top: 16px;
}

.watermark-position > label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-width: 150px;
}

.position-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.position-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.position-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Side Panel */
.side-panel {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1500;
    display: none;
    min-width: 280px;
}

.side-panel.visible {
    display: block;
    animation: slideInRight 0.2s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.side-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.side-panel .panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.panel-close:hover {
    background: var(--bg);
    color: var(--text);
}

.panel-content {
    padding: 16px;
}

/* Histogram */
#histogramCanvas {
    width: 100%;
    height: 120px;
    background: #1e293b;
    border-radius: 8px;
    margin-bottom: 12px;
}

.histogram-channels {
    display: flex;
    gap: 4px;
}

.channel-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.channel-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.channel-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.channel-btn[data-channel="r"].active {
    background: #ef4444;
    border-color: #ef4444;
}

.channel-btn[data-channel="g"].active {
    background: #22c55e;
    border-color: #22c55e;
}

.channel-btn[data-channel="b"].active {
    background: #3b82f6;
    border-color: #3b82f6;
}

/* Adjust mode canvas styling */
.canvas-container.adjust-mode #mainCanvas {
    transition: filter 0.1s;
}

/* Eyedropper cursor */
.canvas-container.eyedropper-mode #drawCanvas {
    cursor: crosshair;
}

/* Clone tool indicator */
.clone-source-indicator {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px dashed var(--primary);
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    display: none;
}

.clone-source-indicator.visible {
    display: block;
}
