:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    padding: 20px;
    padding-top: 60px;
}

.container {
    max-width: 1400px;
    margin: 10px auto 40px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 25px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.back-button {
    position: fixed;
    top: 10px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 10px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.back-button:hover {
    background: white;
    transform: translateX(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Breadcrumb */
.breadcrumb-nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 20px 5px;
}

.breadcrumb {
    list-style: none;
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.9);
}

.breadcrumb li:not(:last-child)::after {
    content: '›';
    margin-left: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
}

.breadcrumb a {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s;
}

.breadcrumb a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
    color: white;
    font-weight: 600;
}

/* SEO Content */
.seo-content {
    padding: 30px;
    border-top: 1px solid #eee;
}

.seo-content h2 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 10px;
    margin-top: 25px;
}

.seo-content h2:first-child {
    margin-top: 0;
}

.seo-content p {
    color: #555;
    line-height: 1.7;
    margin-bottom: 10px;
}

/* FAQ */
.faq-section {
    padding: 30px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.faq-section h2 {
    font-size: 1.4rem;
    color: #2c3e50;
    margin-bottom: 20px;
}

.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.faq-item {
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.faq-item summary {
    padding: 15px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    list-style: none;
    position: relative;
    padding-right: 35px;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--primary-color);
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item p {
    padding: 0 15px 15px;
    color: #555;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Related Tools */
.related-tools {
    padding: 30px;
    text-align: center;
    border-top: 1px solid #eee;
}

.related-tools h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.4rem;
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.related-link {
    display: inline-block;
    padding: 10px 20px;
    background: #e9ecef;
    color: #333;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.related-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

footer {
    background: #2c3e50;
    color: white;
    padding: 20px;
    text-align: center;
    font-size: 0.9rem;
}

footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

footer a:hover {
    color: white;
    text-decoration: underline;
}

.cropper-area {
    padding: 30px;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
}

.main-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.upload-box {
    border: 3px dashed var(--primary-color);
    border-radius: 10px;
    padding: 50px 20px;
    text-align: center;
    margin-bottom: 25px;
    transition: all 0.2s;
    background: #f8f9fa;
    cursor: pointer;
}

.upload-box:hover {
    border-color: var(--secondary-color);
    background: #e9ecef;
}

.upload-box.dragover {
    border-color: var(--success-color);
    background: #d4edda;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.browse-button {
    background: var(--primary-color);
    color: white;
    padding: 10px 25px;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
    font-weight: 600;
}

.browse-button:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

#fileInput {
    display: none;
}

.file-info {
    margin-top: 20px;
    padding: 12px;
    background: #e9ecef;
    border-radius: 8px;
    display: none;
    font-size: 0.9rem;
}

.file-info.show {
    display: block;
}

.crop-container {
    flex: 1;
    display: none;
    position: relative;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    min-height: 500px;
    touch-action: none;
}

.crop-container.show {
    display: block;
}

.crop-canvas-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.crop-image {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    pointer-events: none;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-box {
    position: absolute;
    border: 2px solid var(--success-color);
    background: rgba(40, 167, 69, 0.1);
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: all;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--success-color);
    border: 2px solid white;
    border-radius: 2px;
    pointer-events: all;
    z-index: 10;
}

.handle-n {
    top: -6px;
    left: 50%;
    margin-left: -6px;
    cursor: n-resize;
}

.handle-s {
    bottom: -6px;
    left: 50%;
    margin-left: -6px;
    cursor: s-resize;
}

.handle-e {
    right: -6px;
    top: 50%;
    margin-top: -6px;
    cursor: e-resize;
}

.handle-w {
    left: -6px;
    top: 50%;
    margin-top: -6px;
    cursor: w-resize;
}

.handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.grid-line {
    position: absolute;
    background: white;
    opacity: 0.7;
}

.grid-vertical {
    width: 1px;
    height: 100%;
}

.grid-horizontal {
    width: 100%;
    height: 1px;
}

.controls-sidebar {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    height: fit-content;
    position: sticky;
    top: 30px;
}

.ratio-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 25px;
}

.ratio-preset {
    padding: 12px 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    font-size: 0.9rem;
}

.ratio-preset:hover {
    border-color: var(--primary-color);
}

.ratio-preset.selected {
    border-color: var(--success-color);
    background: #d4edda;
}

.control-group {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.dimension-inputs {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
}

.dimension-input {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
    font-size: 0.95rem;
    text-align: center;
}

.dimension-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.aspect-lock {
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    color: var(--primary-color);
    user-select: none;
}

.aspect-lock.locked {
    color: var(--success-color);
}

.grid-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.grid-option {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    text-align: center;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}

.grid-option:hover {
    border-color: var(--primary-color);
}

.grid-option.selected {
    border-color: var(--success-color);
    background: #d4edda;
}

.preview-box {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    text-align: center;
}

.preview-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-stats {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #666;
}

.crop-button {
    background: var(--success-color);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 25px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 25px;
    font-weight: 600;
}

.crop-button:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
}

.crop-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.crop-button.loading {
    opacity: 0.7;
    pointer-events: none;
}

.crop-button.loading::after {
    content: ' ⏳';
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        content: ' ⏳';
    }

    25% {
        content: ' ⌛';
    }

    50% {
        content: ' ⏳';
    }

    75% {
        content: ' ⌛';
    }

    100% {
        content: ' ⏳';
    }
}

.result-area {
    margin-top: 30px;
    padding: 25px;
    background: #d4edda;
    border-radius: 10px;
    text-align: center;
    display: none;
}

.result-area.show {
    display: block;
}

.action-button {
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 20px;
    text-decoration: none;
    display: inline-block;
    margin: 10px;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
}

.download-button {
    background: var(--success-color);
}

.download-button:hover {
    background: #218838;
    transform: translateY(-2px);
}

.new-crop-button {
    background: var(--primary-color);
}

.new-crop-button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.batch-download-button {
    background: var(--info-color);
}

.batch-download-button:hover {
    background: #138496;
    transform: translateY(-2px);
}

.crop-info {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--success-color);
    margin: 15px 0;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 40px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 10px;
}

.feature {
    text-align: center;
    padding: 20px;
}

.feature-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
    color: var(--primary-color);
}

.message {
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    display: none;
    font-size: 0.9rem;
}

.message.show {
    display: block;
}

.error-message {
    background: #f8d7da;
    color: var(--error-color);
    border: 1px solid #f5c6cb;
}

.warning-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.info-message {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.batch-results {
    margin-top: 20px;
    display: none;
}

.batch-results.show {
    display: block;
}

.batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.batch-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: all 0.2s;
}

.batch-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    margin: 15px 0;
    overflow: hidden;
    display: none;
}

.progress-bar.show {
    display: block;
}

.progress-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 100;
}

.zoom-controls.show {
    display: flex;
    gap: 10px;
}

.zoom-button {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-button:hover:not(:disabled) {
    background: #f8f9fa;
}

.zoom-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.zoom-level {
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navigation-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: none;
    gap: 5px;
    z-index: 100;
}

.navigation-controls.show {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.nav-button {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-button:hover {
    background: #f8f9fa;
}

@media (max-width: 1024px) {
    .cropper-area {
        grid-template-columns: 1fr;
    }

    .controls-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 50px;
    }

    .container {
        margin: 15px auto;
    }

    .cropper-area {
        padding: 20px;
    }

    .upload-box {
        padding: 30px 15px;
    }

    .ratio-presets {
        grid-template-columns: repeat(2, 1fr);
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .back-button {
        top: 8px;
        left: 10px;
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .zoom-controls,
    .navigation-controls {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .faq-grid {
        grid-template-columns: 1fr;
    }

    .related-links {
        flex-direction: column;
        align-items: stretch;
    }

    .related-link {
        text-align: center;
    }

    .seo-content,
    .faq-section,
    .related-tools {
        padding: 20px 15px;
    }
}

/* Image Gallery Strip */
.image-gallery {
    display: none;
    margin-bottom: 20px;
    min-width: 0;
    width: 100%;
}

.image-gallery.show {
    display: block;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #555;
    font-weight: 600;
}

.gallery-clear-btn {
    background: #e9ecef;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #555;
    transition: all 0.2s;
}

.gallery-clear-btn:hover {
    background: var(--error-color);
    color: white;
}

.gallery-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 4px;
    min-width: 0;
    width: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) #f0f0f0;
}

.gallery-strip::-webkit-scrollbar {
    height: 5px;
}

.gallery-strip::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.gallery-strip::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.gallery-thumb {
    flex-shrink: 0;
    width: 90px;
    border-radius: 8px;
    border: 3px solid #ddd;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
    position: relative;
}

.gallery-thumb:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.gallery-thumb.active {
    border-color: var(--success-color);
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

.gallery-thumb img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    display: block;
}

.gallery-thumb-label {
    font-size: 0.65rem;
    padding: 4px 5px;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
}

.gallery-thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    background: rgba(220, 53, 69, 0.85);
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

.gallery-thumb:hover .gallery-thumb-remove {
    opacity: 1;
}

/* Tool Switcher */
.tool-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 10px 16px;
    margin-bottom: 16px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.tool-switcher-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
    white-space: nowrap;
}

.tool-switch-btn {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-block;
}

.tool-switch-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.tool-switch-btn.active {
    background: white;
    color: #667eea;
    font-weight: 700;
    border-color: white;
    pointer-events: none;
}

@media (max-width: 600px) {
    .tool-switcher {
        gap: 6px;
        padding: 8px 12px;
    }

    .tool-switch-btn {
        font-size: 0.78rem;
        padding: 5px 10px;
    }
}