/* ========================================
   IMAGE TOOLS - MOBILE-FIRST RESPONSIVE CSS
   ======================================== */

/* CSS Variables for responsiveness */
:root {
    --toolbar-height: 60px;
    --drawer-height: 50vh;
    --nav-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base Container */
.image-tools-container {
    font-family: var(--font-family);
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    position: relative;
    min-height: 100vh;
}

.image-tools-container * {
    box-sizing: border-box;
}

/* ==========================================
   HEADER - Responsive
   ========================================== */
.img-tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.08), rgba(var(--secondary-rgb), 0.05));
    border-radius: 14px;
    border: 1px solid rgba(var(--primary-rgb), 0.1);
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    font-size: 1.4rem;
    color: white;
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.3);
    flex-shrink: 0;
}

.header-text h2 {
    margin: 0 0 0.2rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.header-text p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-background);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-icon:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ==========================================
   PRIVACY NOTICE
   ========================================== */
.privacy-notice {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.2);
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: var(--text-color);
}

.privacy-notice i {
    color: #27ae60;
    flex-shrink: 0;
}

/* ==========================================
   TOOL SEARCH BAR (Mobile Priority)
   ========================================== */
.tool-search-wrapper {
    display: none;
    margin-bottom: 1rem;
    position: relative;
}

.tool-search {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-background);
    color: var(--text-color);
    font-size: 0.9rem;
}

.tool-search-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color);
    opacity: 0.5;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-top: 0.25rem;
    display: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.search-result-item i {
    color: var(--primary-color);
    width: 20px;
    text-align: center;
}

/* ==========================================
   TOOL NAVIGATION - Desktop Horizontal
   ========================================== */
.tool-nav-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tool-nav-wrapper::-webkit-scrollbar {
    height: 4px;
}

.tool-nav-wrapper::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

.tool-nav {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.35rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    white-space: nowrap;
}

.tool-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.55rem 0.7rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.25s;
    min-width: 55px;
}

.tool-nav-btn i {
    font-size: 0.95rem;
}

.tool-nav-btn:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.tool-nav-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.3);
}

/* ==========================================
   RECENT TOOLS (Smart Shortcuts)
   ========================================== */
.recent-tools {
    display: none;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(var(--primary-rgb), 0.04);
    border-radius: 10px;
}

.recent-tools h4 {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
}

.recent-tools-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.recent-tool-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 0.75rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.recent-tool-chip:hover {
    border-color: var(--primary-color);
}

.recent-tool-chip i {
    font-size: 0.7rem;
    color: var(--primary-color);
}

/* ==========================================
   MAIN WORKSPACE - Desktop Grid
   ========================================== */
.img-workspace {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
    min-height: 400px;
}

/* ==========================================
   UPLOAD SECTION
   ========================================== */
.upload-section {
    grid-column: 1 / -1;
}

.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(var(--primary-rgb), 0.02);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.06);
}

.upload-dropzone i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.upload-dropzone h3 {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
    color: var(--text-color);
}

.upload-dropzone p {
    margin: 0;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 0.85rem;
}

.upload-dropzone .file-types {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--primary-color);
}

/* ==========================================
   CANVAS WORKSPACE - Adaptive Scaling
   ========================================== */
.canvas-workspace {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    position: relative;
}

.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#80808012 0% 25%, transparent 0% 50%) 50% / 14px 14px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    min-height: 300px;
    touch-action: none;
    /* Enable custom touch handling */
}

.dark-theme .canvas-container {
    background: repeating-conic-gradient(#ffffff08 0% 25%, #00000012 0% 50%) 50% / 14px 14px;
}

#main-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
}

/* Zoom Controls */
.canvas-zoom-controls {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.35rem;
    z-index: 10;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.zoom-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.zoom-level {
    padding: 0 0.5rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    color: var(--text-color);
}

/* Full Screen Toggle */
.fullscreen-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.fullscreen-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Image Info Bar */
.image-info-bar {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding: 0.5rem 0.6rem;
    margin-top: 0.5rem;
    background: rgba(var(--primary-rgb), 0.04);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-color);
    flex-wrap: wrap;
}

.image-info-bar span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Mini Preview (Mobile Float) */
.mini-preview {
    display: none;
    position: fixed;
    bottom: calc(var(--toolbar-height) + 10px + var(--safe-bottom));
    right: 10px;
    width: 80px;
    height: 80px;
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.mini-preview canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mini-preview-toggle {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 0.6rem;
    cursor: pointer;
}

/* ==========================================
   TOOL PANELS - Desktop Sidebar
   ========================================== */
.tool-panels {
    display: flex;
    flex-direction: column;
}

.tool-panel {
    display: none;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.tool-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-panel h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.75rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    background: rgba(var(--primary-rgb), 0.04);
    border-bottom: 1px solid var(--border-color);
}

.tool-panel h3 i {
    color: var(--primary-color);
    font-size: 0.85rem;
}

.panel-content {
    padding: 0.9rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* ==========================================
   COMMON FORM ELEMENTS
   ========================================== */
.format-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.format-option {
    cursor: pointer;
}

.format-option input {
    display: none;
}

.format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.65rem 0.4rem;
    background: rgba(var(--primary-rgb), 0.03);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.25s;
}

.format-option input:checked+.format-card {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
}

.format-card i {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.format-card strong {
    font-size: 0.75rem;
    color: var(--text-color);
}

.slider-control {
    margin-bottom: 0.75rem;
}

.slider-control label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-color);
}

.slider-control input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
    height: 6px;
}

/* Button Groups */
.preset-btns,
.ratio-btns,
.filter-btns,
.method-btns,
.type-btns,
.mode-btns,
.sim-btns,
.scale-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.preset-btn,
.ratio-btn,
.filter-btn,
.method-btn,
.type-btn,
.mode-btn,
.sim-btn,
.scale-btn {
    flex: 1;
    padding: 0.45rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 55px;
    text-align: center;
}

.preset-btn:hover,
.ratio-btn:hover,
.filter-btn:hover,
.method-btn:hover,
.type-btn:hover,
.mode-btn:hover,
.sim-btn:hover,
.scale-btn:hover {
    border-color: var(--primary-color);
}

.preset-btn.active,
.ratio-btn.active,
.filter-btn.active,
.method-btn.active,
.type-btn.active,
.mode-btn.active,
.sim-btn.active,
.scale-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.checkbox-opt {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0;
    font-size: 0.8rem;
    color: var(--text-color);
    cursor: pointer;
}

.checkbox-opt input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color);
}

/* Resize Inputs */
.resize-inputs {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.input-grp {
    flex: 1;
    min-width: 70px;
}

.input-grp label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 0.2rem;
}

.input-grp input {
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 0.8rem;
}

.dark-theme .input-grp input {
    background: #1a1d24;
}

.link-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.link-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Presets */
.presets h4 {
    font-size: 0.75rem;
    color: var(--text-color);
    margin: 0 0 0.4rem;
    opacity: 0.7;
}

.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.chip {
    padding: 0.35rem 0.55rem;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-color);
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
}

/* Action Buttons */
.action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.65rem 0.4rem;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 60px;
}

.action-btn:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.action-btn i {
    font-size: 1rem;
}

.action-btn span {
    font-size: 0.65rem;
}

.btn-action {
    width: 100%;
    padding: 0.6rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.25s;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-sm {
    padding: 0.4rem 0.65rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover {
    border-color: var(--primary-color);
}

.btn-sm.btn-danger {
    background: #ff4757;
    border-color: #ff4757;
    color: white;
}

/* Filter Sliders */
.filter-sliders {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Notices */
.notice,
.warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-color);
}

.notice {
    background: rgba(var(--primary-rgb), 0.08);
}

.notice i {
    color: var(--primary-color);
}

.warning {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.2);
}

.warning i {
    color: #ff4757;
}

/* Color Inputs */
.color-pick-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.color-pick-row input[type="color"] {
    width: 40px;
    height: 32px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.color-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.color-input {
    flex: 1;
}

.color-input label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 0.2rem;
}

.color-input input[type="color"] {
    width: 100%;
    height: 30px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

/* Text Inputs */
textarea,
select {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 0.8rem;
    margin-bottom: 0.65rem;
}

.dark-theme textarea,
.dark-theme select {
    background: #1a1d24;
}

textarea {
    min-height: 60px;
    resize: vertical;
}

/* Upload Small */
.upload-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-color);
}

.upload-sm:hover {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.05);
}

.upload-sm i {
    color: var(--primary-color);
}

/* Position Grid */
.pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.pos-btn {
    padding: 0.5rem;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.pos-btn:hover {
    border-color: var(--primary-color);
}

.pos-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Metadata, Colors, etc. */
.meta-display {
    max-height: 150px;
    overflow-y: auto;
    padding: 0.65rem;
    background: rgba(var(--primary-rgb), 0.03);
    border-radius: 8px;
    margin-bottom: 0.65rem;
}

.meta-display .placeholder {
    text-align: center;
    color: var(--text-color);
    opacity: 0.5;
    font-style: italic;
    margin: 0;
    font-size: 0.8rem;
}

.meta-display table {
    width: 100%;
    font-size: 0.75rem;
}

.meta-display td {
    padding: 0.2rem 0;
    color: var(--text-color);
}

.meta-display td:first-child {
    font-weight: 500;
    opacity: 0.7;
    width: 40%;
}

.meta-actions {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}

.color-tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.color-tab {
    flex: 1;
    padding: 0.45rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.color-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.color-content {
    min-height: 80px;
}

.picked-color {
    display: flex;
    gap: 0.6rem;
    padding: 0.65rem;
    background: rgba(var(--primary-rgb), 0.03);
    border-radius: 8px;
}

.swatch {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: #000;
    flex-shrink: 0;
}

.values {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.values div {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-color);
}

.values code {
    font-family: monospace;
    background: var(--background-color);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.7rem;
}

.dark-theme .values code {
    background: #1a1d24;
}

.palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.65rem;
}

#histogram {
    width: 100%;
    height: 80px;
    background: rgba(var(--primary-rgb), 0.03);
    border-radius: 6px;
}

/* Size Compare */
.size-compare {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem;
    background: rgba(var(--secondary-rgb), 0.08);
    border-radius: 8px;
    margin-top: 0.65rem;
    flex-wrap: wrap;
    justify-content: center;
}

.size-box {
    text-align: center;
}

.size-box span {
    display: block;
    font-size: 0.65rem;
    color: var(--text-color);
    opacity: 0.7;
}

.size-box strong {
    font-size: 0.85rem;
    color: var(--text-color);
}

.savings {
    font-weight: 700;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* Batch, Draw, SEO */
.batch-list {
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 0.65rem;
}

.batch-item {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    background: rgba(var(--primary-rgb), 0.05);
    border-radius: 5px;
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
}

.progress-bar {
    height: 6px;
    background: rgba(var(--primary-rgb), 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.65rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s;
}

.draw-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.65rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-color);
}

.draw-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.draw-btn:hover,
.draw-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.draw-opts {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.65rem;
    flex-wrap: wrap;
}

.seo-checks {
    padding: 0.65rem;
    background: rgba(var(--primary-rgb), 0.03);
    border-radius: 8px;
    margin-bottom: 0.65rem;
    min-height: 70px;
}

.seo-form label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-color);
    margin-bottom: 0.2rem;
}

.seo-form input,
.seo-form textarea {
    margin-bottom: 0.5rem;
}

.seo-pass,
.seo-warn,
.seo-info {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.5rem;
    border-radius: 5px;
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
}

.seo-pass {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
}

.seo-warn {
    background: rgba(241, 196, 15, 0.1);
    color: #f39c12;
}

.seo-info {
    background: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
}

.dark-theme .seo-pass,
.dark-theme .seo-warn,
.dark-theme .seo-info {
    color: var(--text-color);
}

.hint {
    margin: 0.65rem 0 0;
    padding: 0.5rem;
    background: rgba(var(--primary-rgb), 0.04);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
    text-align: center;
}

.placeholder {
    color: var(--text-color);
    opacity: 0.5;
    font-style: italic;
    text-align: center;
}

/* ==========================================
   DESKTOP ACTION BAR
   ========================================== */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 0.65rem;
    padding: 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 1rem;
    position: sticky;
    bottom: 0.75rem;
    z-index: 10;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
}

.btn {
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

.btn-secondary {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
}

.export-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.35rem;
    margin-bottom: 0.35rem;
    min-width: 140px;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu button {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-radius: 5px;
    color: var(--text-color);
    text-align: left;
    font-size: 0.8rem;
    cursor: pointer;
}

.dropdown-menu button:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */
.toast-container {
    position: fixed;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast-container.desktop {
    top: 1rem;
    right: 1rem;
}

.toast-container.mobile {
    bottom: calc(var(--toolbar-height) + 10px + var(--safe-bottom));
    left: 1rem;
    right: 1rem;
}

.toast {
    padding: 0.75rem 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-color);
    animation: slideIn 0.3s ease;
    pointer-events: auto;
}

.toast.success {
    border-left: 3px solid #27ae60;
}

.toast.error {
    border-left: 3px solid #ff4757;
}

.toast.info {
    border-left: 3px solid var(--primary-color);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================
   KEYBOARD SHORTCUTS HINT
   ========================================== */
.keyboard-hints {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--text-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 50;
}

.keyboard-hints h4 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
}

.keyboard-hints kbd {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.7rem;
    margin-right: 0.25rem;
}

/* ==========================================
   MOBILE BOTTOM TOOLBAR
   ========================================== */
.mobile-toolbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--toolbar-height);
    padding-bottom: var(--safe-bottom);
    background: var(--card-background);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.mobile-toolbar-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    padding: 0 0.5rem;
}

.mobile-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.4rem 0.6rem;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    min-width: 50px;
}

.mobile-tool-btn i {
    font-size: 1.1rem;
}

.mobile-tool-btn.active {
    color: var(--primary-color);
}

.mobile-tool-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px;
    padding: 0.5rem 0.8rem;
}

/* ==========================================
   MOBILE DRAWER PANEL
   ========================================== */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s;
}

.drawer-overlay.show {
    display: block;
    opacity: 1;
}

.drawer-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--drawer-height);
    max-height: 70vh;
    background: var(--card-background);
    border-radius: 20px 20px 0 0;
    z-index: 160;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.drawer-panel.show {
    transform: translateY(0);
}

.drawer-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0.75rem auto;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.drawer-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-color);
}

.drawer-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* ==========================================
   MOBILE TOOL GRID (In Drawer)
   ========================================== */
.mobile-tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.mobile-tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 0.5rem;
    background: rgba(var(--primary-rgb), 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-tool-item:hover,
.mobile-tool-item.active {
    border-color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
}

.mobile-tool-item i {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.mobile-tool-item span {
    font-size: 0.65rem;
    color: var(--text-color);
    text-align: center;
}

/* ==========================================
   GESTURE HINTS (Mobile)
   ========================================== */
.gesture-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    text-align: center;
    z-index: 200;
    display: none;
    pointer-events: none;
}

.gesture-hint.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.gesture-hint i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */

/* Tablet - 769px to 1024px */
@media (max-width: 1024px) {
    .img-workspace {
        grid-template-columns: 1fr 280px;
    }

    .tool-nav-btn {
        min-width: 50px;
        padding: 0.5rem 0.6rem;
    }
}

/* Small Tablet - 481px to 768px */
@media (max-width: 768px) {

    /* Show mobile elements */
    .mobile-toolbar {
        display: block;
    }

    .tool-search-wrapper {
        display: block;
    }

    .recent-tools {
        display: block;
    }

    .mini-preview.active {
        display: block;
    }

    /* Hide desktop elements */
    .tool-nav-wrapper {
        display: none;
    }

    .action-bar {
        display: none;
    }

    .keyboard-hints {
        display: none !important;
    }

    /* Layout changes */
    .img-workspace {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .tool-panels {
        display: none;
    }

    /* Moved to drawer */

    /* Header adjustments */
    .img-tool-header {
        padding: 1rem;
        justify-content: center;
        text-align: center;
    }

    .header-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .header-text h2 {
        font-size: 1.1rem;
    }

    .header-text p {
        font-size: 0.75rem;
    }

    /* Privacy notice */
    .privacy-notice {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    /* Canvas adjustments */
    .canvas-workspace {
        border-radius: 10px;
    }

    .canvas-container {
        min-height: 250px;
        border-radius: 8px;
    }

    .image-info-bar {
        font-size: 0.7rem;
        gap: 1rem;
    }

    /* Upload */
    .upload-dropzone {
        padding: 2rem 1rem;
        border-radius: 12px;
    }

    .upload-dropzone i {
        font-size: 2rem;
    }

    .upload-dropzone h3 {
        font-size: 1rem;
    }

    /* Body padding for fixed toolbar */
    .image-tools-container {
        padding-bottom: calc(var(--toolbar-height) + 10px + var(--safe-bottom));
    }
}

/* Mobile - ≤ 480px */
@media (max-width: 480px) {
    .img-tool-header {
        padding: 0.85rem;
    }

    .header-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .header-text h2 {
        font-size: 1rem;
    }

    .header-actions {
        gap: 0.35rem;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
    }

    .privacy-notice {
        font-size: 0.7rem;
    }

    .tool-search {
        padding: 0.65rem 0.85rem 0.65rem 2.25rem;
        font-size: 0.85rem;
    }

    .canvas-container {
        min-height: 220px;
    }

    .upload-dropzone {
        padding: 1.5rem 1rem;
    }

    .upload-dropzone i {
        font-size: 1.75rem;
    }

    .upload-dropzone h3 {
        font-size: 0.95rem;
    }

    .upload-dropzone p {
        font-size: 0.8rem;
    }

    .mobile-tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .mobile-tool-item {
        padding: 0.6rem 0.4rem;
    }

    .mobile-tool-item i {
        font-size: 1.1rem;
    }

    .mobile-tool-item span {
        font-size: 0.6rem;
    }

    .drawer-panel {
        max-height: 75vh;
    }

    .drawer-content {
        padding: 0.85rem;
    }

    /* Panel content in drawer */
    .format-grid {
        gap: 0.35rem;
    }

    .format-card {
        padding: 0.55rem 0.35rem;
    }

    .format-card i {
        font-size: 1rem;
    }

    .format-card strong {
        font-size: 0.7rem;
    }

    .action-btns {
        gap: 0.35rem;
    }

    .action-btn {
        min-width: 55px;
        padding: 0.55rem 0.35rem;
    }

    .action-btn i {
        font-size: 0.9rem;
    }

    .action-btn span {
        font-size: 0.6rem;
    }

    .resize-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .link-btn {
        align-self: center;
        transform: rotate(90deg);
        margin: 0.25rem 0;
    }
}

/* Extra Small - ≤ 360px */
@media (max-width: 360px) {
    .img-tool-header {
        padding: 0.75rem;
    }

    .header-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .header-text h2 {
        font-size: 0.9rem;
    }

    .mobile-tool-btn {
        min-width: 45px;
        padding: 0.35rem 0.5rem;
    }

    .mobile-tool-btn i {
        font-size: 1rem;
    }

    .mobile-tool-btn span {
        font-size: 0.55rem;
    }

    .mobile-tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }

    .mobile-tool-item {
        padding: 0.5rem 0.3rem;
        border-radius: 10px;
    }

    .canvas-container {
        min-height: 200px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .drawer-panel {
        max-height: 90vh;
    }

    .img-tool-header {
        padding: 0.5rem 1rem;
    }

    .header-icon {
        width: 36px;
        height: 36px;
    }

    .canvas-container {
        min-height: 150px;
    }

    .mobile-toolbar {
        height: 50px;
    }

    --toolbar-height: 50px;
}

/* Desktop with touch */
@media (hover: none) and (pointer: coarse) and (min-width: 769px) {
    .tool-nav-btn {
        padding: 0.75rem 1rem;
        min-width: 70px;
    }

    .btn {
        padding: 0.75rem 1.25rem;
    }
}