/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0e0e11;
    --surface: #18181c;
    --surface-2: #222228;
    --border: #2a2a34;
    --text: #e4e4ec;
    --text-muted: #7c7c8a;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-soft: rgba(59, 130, 246, 0.12);
    --accent: #93c5fd;
    --danger: #ff6b6b;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
}

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== APP SHELL ===== */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s ease; }

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

/* ===== UPLOAD SCREEN HEADER ===== */
.header {
    text-align: center;
    padding: 48px 0 24px;
}
.header h1 {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
    text-transform: uppercase;
}
.header h1 svg {
    flex-shrink: 0;
    opacity: 0.9;
}
.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 6px;
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #fff;
    text-transform: uppercase;
}
.topbar-logo svg {
    flex-shrink: 0;
    opacity: 0.9;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.topbar-btn:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--accent);
    background: var(--primary-soft);
}
.topbar-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.topbar-btn svg { flex-shrink: 0; }
.topbar-btn-danger:hover:not(:disabled) {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(255, 107, 107, 0.1);
}
.topbar-btn-save {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}
.topbar-btn-save:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
    box-shadow: 0 0 18px rgba(59, 130, 246, 0.45);
}

/* ===== UPLOAD ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 64px 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--primary-soft);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}
.upload-icon {
    color: var(--text-muted);
    margin-bottom: 16px;
}
.upload-zone:hover .upload-icon { color: var(--primary); }
.upload-text { font-size: 1rem; color: var(--text); }
.browse-link { color: var(--accent); text-decoration: underline; cursor: pointer; }
.upload-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }

/* Preview area */
.preview-area { text-align: center; }
.preview-img-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: inline-block;
    max-width: 100%;
}
.preview-img-wrap img {
    max-width: 100%;
    max-height: 420px;
    border-radius: var(--radius-sm);
}
.file-info {
    margin: 16px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== CROP ===== */
.crop-canvas-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    overflow: hidden;
    height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.crop-canvas-wrap img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 12px;
}
.preset-btn {
    padding: 8px 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.preset-btn:hover { border-color: var(--accent); color: var(--text); background: var(--primary-soft); }
.preset-btn.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--accent);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

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

/* ===== EDIT LAYOUT (combined crop + resize + adjust) ===== */
.edit-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.edit-preview-area {
    flex: 1;
    min-width: 0;
}
.canvas-preview-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 520px;
}
.canvas-preview-wrap canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-sm);
    object-fit: contain;
}
.edit-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.edit-sidebar::-webkit-scrollbar { width: 5px; }
.edit-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Edit mode tabs */
.edit-mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 8px;
}
.mode-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.mode-tab:hover { color: var(--text); background: var(--primary-soft); }
.mode-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* Mode panels */
.mode-panel { display: none; }
.mode-panel.active { display: block; animation: fadeIn 0.2s ease; }

.hint-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
    line-height: 1.4;
}

/* ===== COMPRESS RESULT ===== */
.compress-result {
    margin-top: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
}
.compress-actions {
    margin-top: 12px;
}
.compress-actions .btn {
    flex: 1;
}
.compress-actions .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.compress-apply-row {
    margin-top: 10px;
}
.compress-apply-row .btn {
    flex: 1;
}
.btn-success {
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}
.btn-success:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 14px rgba(59, 130, 246, 0.45);
}
.btn-danger {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    box-shadow: none;
}
.btn-danger:hover {
    background: var(--surface, #1e2028);
    color: #fff;
    box-shadow: none;
}
.compress-result-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 8px;
}
.compress-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 0.78rem;
}
.compress-result-grid .cr-label {
    color: var(--text-muted);
}
.compress-result-grid .cr-value {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}
.compress-result-grid .cr-value.cr-success { color: var(--accent); }
.compress-result-grid .cr-value.cr-warn { color: var(--danger); }
.compress-result-grid .cr-value.cr-changed { color: var(--primary); }

.edit-bottom-actions { display: none; }

/* ===== SAVE MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 24px;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: fadeIn 0.2s ease;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}
.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: var(--transition);
}
.modal-close:hover {
    color: var(--text);
    background: var(--border);
}
.modal-body {
    padding: 20px;
    display: flex;
    gap: 20px;
}
.modal-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.modal-preview canvas {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
}
.modal-options {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Confirm dialog */
.confirm-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
    animation: fadeIn 0.15s ease;
}
.confirm-text {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.confirm-dialog .btn-row {
    margin-top: 20px;
}
.confirm-dialog .btn {
    min-width: 100px;
}
.confirm-dialog .btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
}
.confirm-dialog .btn-danger:hover {
    background: #ff8787;
    box-shadow: 0 2px 14px rgba(255, 107, 107, 0.45);
}

/* ===== CONTROL GROUPS ===== */
.control-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.control-group h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.input-row {
    margin-bottom: 10px;
}
.input-row:last-child { margin-bottom: 0; }
.input-row label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.unit { opacity: 0.5; }

.input-row input[type="number"],
.input-row select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}
.input-row input[type="number"]:focus,
.input-row select:focus {
    border-color: var(--primary);
}

.inline-input {
    display: flex;
    gap: 8px;
}
.inline-input input { flex: 1; }
.inline-input select { width: 80px; flex-shrink: 0; }

/* Range slider */
.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.range-row input[type="range"] { flex: 1; }
.range-row span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 42px;
    text-align: right;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 2px var(--accent), 0 0 8px rgba(59, 130, 246, 0.4);
}

/* Checkbox */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-top: 4px;
}
.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Resize Sub-tabs (Manual / Automatic) */
.resize-subtabs {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
}
.resize-subtab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.02em;
}
.resize-subtab:hover {
    color: var(--text);
    background: var(--primary-soft);
}
.resize-subtab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}
.resize-subpanel { display: none; }
.resize-subpanel.active { display: block; animation: fadeIn 0.2s ease; }

/* Tabs (Pixels / Percentage) */
.resize-mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 12px;
}
.tab-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}
.tab-btn.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ===== EXPORT (inside modal) ===== */
.export-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.8;
}
.format-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.format-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.format-btn:hover { border-color: var(--accent); color: var(--text); background: var(--primary-soft); }
.format-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}
.export-size-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 8px 0;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ===== FILMSTRIP ===== */
.filmstrip {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.filmstrip:empty { display: none; }
.filmstrip::-webkit-scrollbar { height: 5px; }
.filmstrip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.filmstrip-thumb {
    position: relative;
    flex-shrink: 0;
    width: 72px;
    height: 54px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface);
}
.filmstrip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.filmstrip-thumb:hover { border-color: var(--text-muted); }
.filmstrip-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.filmstrip-thumb .thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border: none;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.filmstrip-thumb:hover .thumb-remove { opacity: 1; }
.filmstrip-thumb .thumb-remove:hover { background: var(--danger); }

/* ===== SAVE MODAL (multi-image) ===== */
.modal-save { max-width: 820px; }
.save-body {
    display: block;
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}
.save-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.save-grid:has(.save-single) {
    display: block;
}
.save-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.save-card-preview {
    width: 100%;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.save-card-preview canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.save-card-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.save-card-size {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.save-card-format {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.save-card-format .format-btn {
    padding: 4px 10px;
    font-size: 0.7rem;
}
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Single image save layout */
.save-single {
    display: flex;
    gap: 20px;
    width: 100%;
}
.save-single-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.save-single-preview canvas {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
}
.save-single-info {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== LIVE SIZE INDICATOR ===== */
.live-size-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    height: 44px;
    overflow: hidden;
}
.live-size-bar .live-size-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    min-height: 1.4em;
    display: flex;
    align-items: center;
}
.live-size-bar .live-size-value.warn { color: var(--danger); }
.live-size-bar .live-size-dims {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== BOUNCING DOTS LOADER ===== */
.dots-loader {
    display: inline-flex;
    gap: 3px;
}
.dots-loader span {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    animation: dotBounce 1.2s infinite ease-in-out;
}
.dots-loader span:nth-child(2) { animation-delay: 0.2s; }
.dots-loader span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 14px rgba(59, 130, 246, 0.45); }
.btn-secondary {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--accent); background: var(--primary-soft); }
.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: grid;
    place-items: center;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }
.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 4px 0;
    font-family: inherit;
}
.btn-text:hover { color: var(--danger); }
.btn-lg {
    width: 100%;
    padding: 14px 24px;
    font-size: 0.95rem;
}
.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .edit-layout {
        flex-direction: column;
    }
    .edit-sidebar {
        width: 100%;
        max-height: none;
    }
    .topbar { flex-wrap: wrap; gap: 8px; }
    .topbar-actions { flex-wrap: wrap; }
    .topbar-btn span { display: none; }
    .topbar-btn { padding: 7px 10px; }
    .modal-body { flex-direction: column; }
    .modal-options { width: 100%; }
    .save-single { flex-direction: column; }
    .save-single-info { width: 100%; }
}

/* ===== CROPPER.JS OVERRIDES ===== */
.cropper-view-box,
.cropper-face {
    border-radius: 0;
}
.cropper-line, .cropper-point {
    background-color: var(--primary);
}
.cropper-modal {
    background: rgba(0,0,0,0.6);
}
.cropper-view-box {
    outline: 2px solid var(--primary);
    outline-color: var(--primary);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.85);
    display: grid;
    place-items: center;
    z-index: 1000;
}
.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
