/* Image Editor — Rich Light (violet category accent)
   Tokens come from style.css (:root). This file styles page-specific chrome only. */

/* ============ Page accent scope (§D — root-level: crop modal is a <body> child) ============ */
:root { --pg: var(--cat-image); --pg-hover: #6d28d9; --pg-text: var(--cat-image-text);
        --pg-subtle: var(--cat-image-bg); --pg-border: var(--cat-image-border);
        --pg-ring: rgba(124, 58, 237, 0.16); }

/* ============ Layout shell ============ */
.editor-main {
    min-height: calc(100vh - 60px);
    padding: 0;
    padding-top: 60px; /* fixed 60px navbar */
    background: var(--bg-inset);
}

/* ============ Upload Section (hidden by default — JS toggles) ============ */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 160px);
    padding: 24px;
}

.upload-card {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border: 1px solid var(--border-lifted);
    border-radius: var(--r-xl);
    box-shadow: var(--e3);
    padding: 16px;
}

/* ============ Dropzone (§C.6 base, violet hover/dragover tints) ============ */
.dropzone {
    position: relative;
    padding: 56px 40px;
    text-align: center;
    background: linear-gradient(180deg, #fbfaff 0%, #f7f6fd 100%);
    border: 1.5px dashed #d8d5ee;
    border-radius: var(--r-lg);
    transition: border-color var(--t-base), background var(--t-base), box-shadow var(--t-base);
}

.dropzone:hover {
    border-color: #c9baf4;
    background: linear-gradient(180deg, #faf8ff, #f5f1fd);
}

.dropzone.dragover {
    border: 1.5px solid var(--pg);
    background: linear-gradient(180deg, #f6f1ff, #efe8fe);
    box-shadow: 0 0 0 5px var(--pg-ring), inset 0 0 0 1px rgba(124, 58, 237, 0.20);
}

.dropzone:focus-within {
    box-shadow: var(--focus-ring);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    pointer-events: none;
}

/* .upload-icon brand-gradient tile comes from style.css (§C.6) */

.upload-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 20px;
}

.upload-button {
    pointer-events: auto;
    height: 40px;
    padding: 0 20px;
    font-size: 0.9375rem;
}

.upload-hint {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.supported-formats {
    margin-top: 16px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ============ Editor Section ============ */
.editor-section {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 108px); /* 60px navbar + 48px toolbar chrome unit */
}

/* ============ Toolbar (§C.12 — 48px lid over the workspace) ============ */
.editor-toolbar {
    height: 48px;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    border-radius: 0;
    margin: 0;
    box-shadow: 0 1px 8px rgba(30, 27, 75, 0.04);
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-center {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* Ghost sm */
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--r-sm);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

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

.toolbar-btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.07);
    color: var(--text-primary);
}

.toolbar-btn:active:not(:disabled) {
    background: rgba(99, 102, 241, 0.12);
}

.toolbar-btn:disabled {
    color: var(--text-ghost-disabled);
    background: none;
    cursor: not-allowed;
}

/* Primary sm (§C.1 gradient recipe — restated locally to win the ghost-hover specificity race) */
.toolbar-btn.primary {
    background: var(--grad-btn);
    color: #fff;
    box-shadow: var(--shadow-btn-brand);
    transition: background var(--t-fast), box-shadow var(--t-lift), transform var(--t-lift);
}

.toolbar-btn.primary:hover:not(:disabled) {
    background: var(--grad-btn-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn-brand-hover);
}

.toolbar-btn.primary:active:not(:disabled) {
    background: #4338ca;
    transform: translateY(0);
    box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.20);
}

.toolbar-btn.primary:focus-visible {
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.20), var(--focus-ring);
}

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

/* Center info — status chip (§C.12) */
.image-info {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-xs);
    padding: 4px 12px;
    white-space: nowrap;
}

/* ============ Editor Container — hairline-divided panes ============ */
.editor-container {
    display: flex;
    flex: 1;
    gap: 0;
    min-height: 0;
}

/* ============ Tools Panel (§C.12 — left sidebar on panel wash) ============ */
.tools-panel {
    width: 200px;
    flex-shrink: 0;
    background: var(--wash-panel);
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    padding: 12px 8px;
    overflow-y: auto;
}

.tools-section {
    margin-bottom: 20px;
}

.tools-section:last-child {
    margin-bottom: 0;
}

.tools-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.3;
    margin: 0;
    padding: 0 8px 6px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 32px;
    padding: 0 8px;
    border: none;
    background: none;
    color: var(--text-secondary);
    border-radius: var(--r-sm);
    cursor: pointer;
    user-select: none;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: left;
    transition: background var(--t-fast), color var(--t-fast);
}

.tool-btn:hover {
    background: var(--bg-inset);
    color: var(--text-primary);
}

/* Category-accented active tool — the signature move (§C.12) */
.tool-btn.active {
    background: var(--pg-subtle);
    color: var(--pg-text);
    font-weight: 600;
    box-shadow: inset 2.5px 0 0 var(--pg), inset 0 0 0 1px var(--pg-border);
}

.tool-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    stroke-width: 1.75;
}

.tool-btn.active svg {
    color: var(--pg);
}

/* ============ Canvas Area (§E2 — violet-washed dotted stage) ============ */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-inset);
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    position: relative;
    background:
        radial-gradient(90% 55% at 50% 0%, rgba(124, 58, 237, 0.055) 0%, transparent 65%),
        radial-gradient(circle, #dcdfe8 1px, transparent 1px) 0 0 / 24px 24px,
        #f3f4f8;
}

/* Fabric.js canvas container styling */
.canvas-container {
    box-shadow: none !important;
    background: transparent !important;
}

.canvas-container .upper-canvas {
    background: transparent !important;
}

#editor-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(30, 27, 75, 0.10), 0 16px 40px rgba(124, 58, 237, 0.14);
}

/* Canvas Upload Placeholder — empty-state card (§E2) */
.canvas-upload-placeholder {
    position: relative;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 64px 40px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    border: 1.5px dashed var(--pg-border);
    border-radius: var(--r-xl);
    box-shadow: var(--e1);
    transition: border-color var(--t-base), background var(--t-base), box-shadow var(--t-base);
}

.canvas-upload-placeholder:hover {
    border-color: var(--pg);
    box-shadow: var(--e2);
}

.canvas-upload-placeholder:hover .dz-icon {
    transform: translateY(-2px);
}

.canvas-upload-placeholder.dragover {
    border-style: solid;
    border-color: var(--pg);
    background: #fdfcff;
    box-shadow: 0 0 0 4px var(--pg-ring), 0 12px 32px rgba(124, 58, 237, 0.20);
}

.canvas-upload-placeholder.dragover .dz-icon {
    transform: scale(1.06);
}

.canvas-upload-placeholder:focus-within {
    box-shadow: var(--focus-ring);
}

.canvas-upload-placeholder .file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.canvas-upload-content {
    pointer-events: none;
    color: var(--text-secondary);
}

/* Empty-state dropzone icon (§C.13) */
.dz-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: var(--pg-subtle);
    color: var(--pg);
    box-shadow: inset 0 0 0 1px var(--pg-border), 0 8px 20px var(--pg-ring);
    transition: transform var(--t-lift), box-shadow var(--t-lift);
}

.dz-icon svg {
    width: 28px;
    height: 28px;
    margin: 0;
}

.canvas-upload-content p {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.canvas-upload-content span {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============ Zoom Controls (§E2 — floating pill, e2) ============ */
.zoom-controls {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--border-lifted);
    border-radius: var(--r-full);
    box-shadow: var(--e2);
    padding: 3px;
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--r-full);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

.zoom-btn:hover {
    background: var(--bg-inset);
    color: var(--text-primary);
}

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

.zoom-level {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    min-width: 44px;
    text-align: center;
}

/* ============ Options Panel (§C.12 — right panel) ============ */
.options-panel {
    width: 272px;
    flex-shrink: 0;
    background: #fff;
    border-left: 1px solid var(--border);
    border-radius: 0;
    box-shadow: -1px 0 8px rgba(30, 27, 75, 0.03);
    padding: 16px;
    overflow-y: auto;
    transition: opacity var(--t-base);
}

/* Empty-state dim: placeholder visible => no image loaded. Dim only — JS owns interactivity. */
.editor-container:has(#canvas-upload-placeholder:not([style*="none"])) .options-panel {
    opacity: 0.5;
}

.options-content h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    position: relative;
    padding-left: 11px;
}

.options-content h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--pg), var(--pg-hover));
}

.option-group {
    margin-bottom: 14px;
}

.option-group label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.option-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 12px 0;
}

/* ============ Inputs / selects (§C.5 — 32px inside editor panels) ============ */
.option-input,
.option-select {
    width: 100%;
    height: 32px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.04), 0 1px 1px rgba(30, 27, 75, 0.03);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.option-input::placeholder {
    color: var(--text-disabled);
}

.option-input:focus,
.option-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.option-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    cursor: pointer;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236f7683' stroke-width='1.5'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center;
}

/* ============ Sliders (§C.5 — gradient thumbs) ============ */
.option-slider {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.option-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--grad-btn);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40);
    cursor: pointer;
    transition: box-shadow var(--t-fast);
}

.option-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40), 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.option-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--grad-btn);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40);
    cursor: pointer;
    transition: box-shadow var(--t-fast);
}

.option-slider::-moz-range-thumb:hover {
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40), 0 0 0 4px rgba(99, 102, 241, 0.16);
}

/* ============ Checkbox (§C.5) ============ */
.checkbox-group {
    margin-top: 8px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    user-select: none;
    position: relative;
}

.checkbox-label input {
    position: absolute;
    opacity: 0;
    width: 16px;
    height: 16px;
    margin: 0;
    pointer-events: none;
}

.checkbox-custom {
    display: inline-block;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xs);
    position: relative;
    transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
    background: #fff;
    vertical-align: middle;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--grad-btn);
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.35);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4.5px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.checkbox-label input:focus-visible + .checkbox-custom {
    box-shadow: var(--focus-ring);
}

.checkbox-text {
    line-height: 1;
}

/* ============ Apply Button (full-width primary sm; gradient visuals via .apply-btn in style.css) ============ */
.apply-btn {
    width: 100%;
    margin-top: 16px;
    height: 32px;
    padding: 0 12px;
    font-size: 0.8125rem;
}

/* ============ Export Section ============ */
.export-section {
    border-top: 1px solid var(--border);
    margin-top: 20px;
    padding-top: 16px;
}

.export-section h4 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.3;
    margin: 0 0 10px;
}

.export-formats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.export-format-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
                transform var(--t-lift), box-shadow var(--t-lift);
}

.export-format-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.05), 0 4px 12px rgba(30, 27, 75, 0.08);
}

.export-format-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.export-format-btn.active {
    background: var(--pg-subtle);
    border-color: var(--pg);
    color: var(--pg-text);
    font-weight: 600;
    box-shadow: 0 0 0 3px var(--pg-ring);
}

.export-quality-group {
    margin-bottom: 14px;
}

.export-quality-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Primary sm — gradient visuals inherited from .export-btn group in style.css (§C.1).
   Local rules are layout-only; honest disabled state kept EXACTLY. */
.export-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

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

.export-btn:disabled {
    background: var(--bg-inset);
    color: var(--text-disabled);
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

/* ============ Rotate & Flip Tiles (§C.12 micro-interaction) ============ */
.rotate-buttons,
.flip-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.rotate-btn,
.flip-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
                transform var(--t-lift), box-shadow var(--t-lift);
}

.rotate-btn:hover,
.flip-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.05), 0 4px 12px rgba(30, 27, 75, 0.08);
}

.rotate-btn:active,
.flip-btn:active {
    background: var(--bg-inset);
    transform: translateY(0);
    box-shadow: var(--shadow-xs);
}

.flip-btn.active {
    background: var(--pg-subtle);
    border-color: var(--pg);
    color: var(--pg-text);
    box-shadow: 0 0 0 3px var(--pg-ring);
}

.rotate-btn svg,
.flip-btn svg {
    width: 20px;
    height: 20px;
}

.rotate-btn span,
.flip-btn span {
    font-size: 0.6875rem;
    font-weight: 500;
}

/* Crop Dimensions (legacy layout helpers — selectors kept) */
.crop-dimensions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.option-group.half {
    margin-bottom: 0;
}

/* ============ Crop Overlay ============ */
.crop-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

.crop-overlay.active {
    pointer-events: auto;
}

.crop-box {
    position: absolute;
    border: 2px solid white;
    background: transparent;
    box-shadow: 0 0 0 9999px rgba(23, 24, 28, 0.5);
    cursor: move;
}

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

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

/* ============ Filters Grid (§E2 — colorful previews, violet selection) ============ */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: var(--r-sm);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    transition: background var(--t-fast), border-color var(--t-fast),
                transform var(--t-lift), box-shadow var(--t-lift);
}

.filter-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.05), 0 4px 12px rgba(30, 27, 75, 0.08);
}

.filter-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.filter-btn.active {
    background: var(--pg-subtle);
    border-color: var(--pg);
    box-shadow: 0 0 0 3px var(--pg-ring);
}

.filter-preview {
    width: 100%;
    height: 44px;
    border-radius: var(--r-xs);
    border: 1px solid var(--border);
    background: linear-gradient(135deg, #fbbf24 0%, #f472b6 34%, #8b5cf6 68%, #2563eb 100%);
}

.filter-btn:hover .filter-preview {
    transform: scale(1.02);
    transition: transform var(--t-lift);
}

.filter-preview.grayscale { filter: grayscale(100%); }
.filter-preview.sepia { filter: sepia(100%); }
.filter-preview.invert { filter: invert(100%); }
.filter-preview.vintage { filter: sepia(50%) contrast(90%) brightness(90%); }
.filter-preview.cold { filter: saturate(80%) hue-rotate(180deg); }
.filter-preview.warm { filter: sepia(30%) saturate(140%); }
.filter-preview.dramatic { filter: contrast(150%) saturate(120%); }

.filter-btn span {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-btn.active span {
    color: var(--pg-text);
    font-weight: 600;
}

/* ============ Modal (§C.10) ============ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Reset shared style.css .modal hidden state: this page's JS toggles
       display flex/none directly and never adds .show */
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(30, 27, 75, 0.45);
}

.modal-content {
    position: relative;
    background: #fff;
    border: 1px solid rgba(30, 27, 75, 0.05);
    border-radius: var(--r-xl);
    box-shadow: var(--e4);
    width: 90%;
    max-width: 400px;
    animation: modalSlideIn 160ms var(--ease);
}

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

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

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

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-subtle);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.modal-footer button {
    flex: 1;
}

.modal-footer button svg {
    width: 16px;
    height: 16px;
}

/* ============ Toasts (§C.9 — white cards, colored edge; JS toggles classes) ============ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--border-lifted);
    border-left-width: 3px;
    border-radius: var(--r-md);
    box-shadow: var(--e3);
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 12px 16px 12px 14px;
    animation: toastSlideIn 200ms var(--ease) forwards;
    opacity: 1;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(16px);
    }
}

.toast.fade-out {
    animation: toastSlideOut 500ms var(--ease) forwards;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error-strong);
}

.toast.info {
    border-left-color: var(--accent);
}

.toast-message {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ============ Crop Modal Overlay (§E2 — deliberate dark stage) ============ */
.crop-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: radial-gradient(120% 90% at 50% 0%, #1d2027 0%, #16181d 50%, #101216 100%);
    display: flex;
    flex-direction: column;
}

.crop-modal-toolbar {
    height: 48px;
    background: #1f242c;
    border-bottom: 1px solid #343b45;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.crop-modal-title {
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    color: #f2f3f6;
}

.crop-modal-actions {
    display: flex;
    gap: 8px;
}

.crop-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.8125rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    border: none;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.crop-modal-btn.secondary {
    background: transparent;
    color: #c6ccd6;
    border: 1px solid #4a5260;
}

.crop-modal-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f2f3f6;
}

/* .crop-modal-btn.primary — gradient primary inherited from style.css (§C.1); no local overrides */

.crop-modal-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
    background: transparent;
}

.crop-modal-content img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Cropper.js Overrides — category accent (§E2) */
.crop-modal-overlay .cropper-view-box,
.crop-modal-overlay .cropper-face {
    border-radius: 0;
}

.crop-modal-overlay .cropper-view-box {
    outline: 2px solid var(--pg);
    outline-offset: -2px;
}

.crop-modal-overlay .cropper-point {
    background-color: var(--pg);
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.crop-modal-overlay .cropper-line {
    background-color: var(--pg);
}

.crop-modal-overlay .cropper-modal {
    background-color: rgba(0, 0, 0, 0.7);
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
    .editor-section {
        height: auto;
        min-height: calc(100vh - 108px);
    }

    .editor-container {
        flex-direction: column;
    }

    /* Sidebar becomes a horizontal scroll strip */
    .tools-panel {
        width: 100%;
        display: flex;
        flex-direction: row;
        gap: 4px;
        padding: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .tools-section {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-bottom: 0;
    }

    .tools-section-title {
        display: none;
    }

    .tool-btn {
        width: auto;
        flex-shrink: 0;
    }

    .tool-btn.active {
        box-shadow: inset 0 -2.5px 0 var(--pg);
        background: var(--pg-subtle);
    }

    .options-panel {
        width: 100%;
        border-left: 0;
        border-top: 1px solid var(--border);
    }

    .canvas-area {
        min-height: 320px;
    }
}

@media (max-width: 768px) {
    .dropzone {
        padding: 40px 20px;
    }

    .canvas-upload-placeholder {
        padding: 40px 20px;
    }

    .toolbar-btn span {
        display: none;
    }

    .editor-toolbar {
        padding: 0 8px;
    }

    .options-panel {
        padding: 12px;
    }

    .upload-section {
        padding: 16px;
    }
}

/* ============ Annotate toolbox (§C.12 — action tile grid) ============ */
.ann-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.ann-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
                transform var(--t-lift), box-shadow var(--t-lift);
}

.ann-tool-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.05), 0 4px 12px rgba(30, 27, 75, 0.08);
}

.ann-tool-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-xs);
}

.ann-tool-btn.active {
    background: var(--pg-subtle);
    border-color: var(--pg);
    color: var(--pg-text);
    box-shadow: 0 0 0 3px var(--pg-ring);
}

.ann-tool-btn.active svg { color: var(--pg); }

.ann-tool-btn.danger:hover {
    border-color: var(--error-strong, #dc2626);
    color: var(--error-strong, #dc2626);
    background: #fef2f2;
}

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

.ann-tool-btn span {
    font-size: 0.6875rem;
    font-weight: 500;
}

/* Native color input styled to match panel inputs */
.option-color {
    width: 100%;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: #fff;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.04);
}
.option-color::-webkit-color-swatch-wrapper { padding: 0; }
.option-color::-webkit-color-swatch { border: none; border-radius: var(--r-xs); }

.full-btn { width: 100%; height: 32px; margin-top: 6px; }

/* ============ Layers list ============ */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.layer-row {
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: #fff;
    box-shadow: var(--shadow-xs);
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.layer-row:hover {
    border-color: var(--pg-border);
    box-shadow: 0 0 0 2px var(--pg-ring);
}

.layer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.layer-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.layer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--text-secondary);
    border-radius: var(--r-xs);
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.layer-btn:hover {
    background: var(--pg-subtle);
    color: var(--pg-text);
    border-color: var(--pg-border);
}

.layer-btn.danger:hover {
    background: #fef2f2;
    color: var(--error-strong, #dc2626);
    border-color: #fecaca;
}

.layer-opacity { width: 100%; }

/* ============ Combine modal ============ */
.combine-modal-content { max-width: 460px; }

.combine-result {
    margin-top: 16px;
}

.combine-result:empty { display: none; }

.combine-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 12px;
}

.combine-preview img {
    max-width: 100%;
    max-height: 240px;
    border-radius: var(--r-xs);
    box-shadow: var(--e1);
}

.combine-result-actions {
    display: flex;
    gap: 8px;
}

.combine-result-actions .primary-button,
.combine-result-actions .secondary-button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    height: 36px;
}

/* Keep the new Compose section usable in the mobile horizontal tool strip */
@media (max-width: 1024px) {
    .ann-grid { grid-template-columns: repeat(3, 1fr); }
}
