:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text: #334155;
    --text-light: #64748b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --nav-height: 60px;
    --container-padding: 20px;
    --card-padding: 20px;
    --section-gap: 20px;
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --primary-light: #93c5fd;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --dark: #f8fafc;
    --light: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background:
        radial-gradient(ellipse at top left, rgba(59, 130, 246, 0.1), transparent 50%),
        radial-gradient(ellipse at top right, rgba(139, 92, 246, 0.1), transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(16, 185, 129, 0.05), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(245, 158, 11, 0.05), transparent 50%),
        var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    min-height: 100vh;
    padding: var(--nav-height) 0 0 0;
    line-height: 1.6;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
}

input,
textarea,
select {
    font: inherit;
}

ul,
ol {
    list-style: none;
}

.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .navbar {
    background: rgba(30, 41, 59, 0.85);
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.navbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--dark);
    text-decoration: none;
}

.navbar-brand .icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.95rem;
    margin-right: 8px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-item {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-item:hover,
.nav-item.active {
    background: var(--light);
    color: var(--primary);
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle .fa-chevron-down {
    font-size: 0.7rem;
    margin-left: 4px;
    transition: transform 0.2s;
}

.nav-dropdown.show .fa-chevron-down {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 200;
}

.nav-dropdown.show .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.nav-dropdown-item:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-dropdown-item.active {
    background: var(--primary);
    color: white;
}

.nav-dropdown-item .fa-solid {
    width: 18px;
    text-align: center;
    margin-right: 8px;
}

.container {
    padding: var(--container-padding);
    max-width: 1200px;
    margin: 0 auto;
}

.page-header,
.header {
    margin-bottom: var(--section-gap);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--light);
    color: var(--primary);
}

.theme-toggle .fa-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .fa-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .fa-moon {
    display: inline;
}

.help-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
    z-index: 999;
}

.help-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(59, 130, 246, 0.5);
}

.main-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: var(--card-padding);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .main-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.5);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

@media (max-width: 900px) {
    :root {
        --nav-height: 56px;
        --container-padding: 16px;
        --card-padding: 16px;
        --section-gap: 16px;
    }

    .navbar-nav {
        gap: 2px;
    }

    .nav-item {
        padding: 6px 10px;
        font-size: 0.8rem;
        gap: 4px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .workspace {
        flex-wrap: wrap;
    }

    .preview-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    :root {
        --container-padding: 16px;
        --card-padding: 16px;
        --section-gap: 16px;
    }

    .container {
        padding: 16px !important;
        padding-bottom: 36px !important;
    }

    .navbar-inner {
        height: auto;
        padding: 12px 16px !important;
        flex-wrap: wrap;
        gap: 10px;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .navbar-brand .icon {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .navbar-nav {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }

    .nav-item {
        padding: 6px 8px;
        font-size: 0.75rem;
        white-space: nowrap;
        -webkit-tap-highlight-color: transparent;
        min-height: 36px;
        display: flex;
        align-items: center;
    }

    .nav-item:active {
        background: var(--light);
        color: var(--primary);
    }

    .nav-dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: 0 0 0 10px;
        opacity: 1;
        visibility: visible;
        display: none;
    }

    .nav-dropdown.show .nav-dropdown-menu {
        display: block;
    }

    .nav-dropdown-item {
        padding: 8px 10px;
    }

    .nav-dropdown-toggle .fa-chevron-down {
        display: none;
    }

    .help-btn {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 1.1rem;
        -webkit-tap-highlight-color: transparent;
    }

    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        cursor: pointer;
    }

    .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .btn+.btn {
        margin-top: 8px;
    }

    .main-card {
        border-radius: 12px;
        padding: 12px;
    }

    .theme-toggle {
        padding: 6px 8px;
        min-width: 44px;
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
    }

    .workspace {
        flex-direction: column;
    }

    .preview-container {
        grid-template-columns: 1fr;
    }

    .options {
        flex-direction: column;
        gap: 12px;
    }

    .option-group {
        width: 100%;
    }

    .tab-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tab-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
        padding: 8px 12px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .page-header p {
        font-size: 0.875rem;
    }

    .info-panel {
        padding: 10px;
        font-size: 13px;
    }

    input,
    select,
    textarea {
        font-size: 14px;
    }

    .tool-card {
        min-height: 44px;
        padding: 16px;
        -webkit-tap-highlight-color: transparent;
    }

    .tool-card:active {
        transform: scale(0.98);
    }

    .sidebar-link {
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-link:active {
        background: var(--border);
    }

    .upload-zone {
        padding: 40px 20px;
        min-height: 150px;
    }

    .upload-zone:active {
        border-color: var(--primary);
        background: #eff6ff;
    }

    input[type="range"] {
        min-height: 44px;
        padding: 10px 0;
        -webkit-tap-highlight-color: transparent;
    }
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    background: var(--border);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-overlay.show {
    display: block;
    opacity: 1;
    visibility: visible;
}

.mobile-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85%;
    height: 100%;
    background: var(--card-bg);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
}

.mobile-sidebar.show {
    transform: translateX(0);
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.sidebar-brand .icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.sidebar-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: var(--border);
    color: var(--text);
}

.sidebar-content {
    padding: 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-link:hover {
    background: var(--border);
}

.sidebar-link.active {
    background: var(--primary);
    color: white;
}

.sidebar-group {
    margin-bottom: 8px;
}

.sidebar-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 8px;
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-group-items {
    padding-left: 8px;
}

.sidebar-group-items .sidebar-link {
    padding: 10px 16px 10px 24px;
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay {
        display: block;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .mobile-sidebar {
        display: block;
    }

    .navbar-nav {
        display: none;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
    background: var(--primary-dark);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background: #64748b;
    color: white;
    border-color: #64748b;
}

.btn-secondary:hover {
    background: #475569;
    border-color: #475569;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.btn-info {
    background: #06b6d4;
    color: white;
    border-color: #06b6d4;
}

.btn-info:hover {
    background: #0891b2;
    border-color: #0891b2;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}