:root {
    /* Spacing System */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --spacing-3xl: 64px;

    /* Border Radius System */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    /* Typography Scale */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;

    /* Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Light Theme Color System */
    --color-gray-50: #f7fafc;
    --color-gray-100: #edf2f7;
    --color-gray-200: #e2e8f0;
    --color-gray-300: #cbd5e0;
    --color-gray-400: #a0aec0;
    --color-gray-500: #718096;
    --color-gray-600: #4a5568;
    --color-gray-700: #2d3748;
    --color-gray-800: #1a202c;
    --color-gray-900: #171923;

    --color-blue-50: #ebf8ff;
    --color-blue-100: #bee3f8;
    --color-blue-200: #90cdf4;
    --color-blue-300: #63b3ed;
    --color-blue-400: #4299e1;
    --color-blue-500: #3182ce;
    --color-blue-600: #2c5282;
    --color-blue-700: #2a4365;
    --color-blue-800: #1a365d;
    --color-blue-900: #152451;

    --color-purple-50: #faf5ff;
    --color-purple-100: #e9d8fd;
    --color-purple-200: #d6bcfa;
    --color-purple-300: #b794f6;
    --color-purple-400: #9f7aea;
    --color-purple-500: #805ad5;
    --color-purple-600: #6b46c1;
    --color-purple-700: #553c9a;
    --color-purple-800: #44337a;
    --color-purple-900: #322659;

    --color-pink-50: #fdf2f8;
    --color-pink-100: #fce7f3;
    --color-pink-200: #fbcfe8;
    --color-pink-300: #f9a8d4;
    --color-pink-400: #f472b6;
    --color-pink-500: #ec4899;
    --color-pink-600: #db2777;
    --color-pink-700: #be185d;
    --color-pink-800: #9d174d;
    --color-pink-900: #831843;

    --color-green-50: #f0fff4;
    --color-green-100: #c6f6d5;
    --color-green-200: #9ae6b4;
    --color-green-300: #68d391;
    --color-green-400: #48bb78;
    --color-green-500: #38a169;
    --color-green-600: #2f855a;
    --color-green-700: #276749;
    --color-green-800: #22543d;
    --color-green-900: #1a202c;

    --color-red-50: #fed7d7;
    --color-red-100: #feb2b2;
    --color-red-200: #fc8181;
    --color-red-300: #f56565;
    --color-red-400: #e53e3e;
    --color-red-500: #c53030;
    --color-red-600: #9b2c2c;
    --color-red-700: #822727;
    --color-red-800: #63171b;
    --color-red-900: #3c1011;

    /* Light Theme Variables */
    --bg-primary: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-600) 50%, var(--color-pink-500) 100%);
    --bg-secondary: rgba(255, 255, 255, 0.95);
    --bg-tertiary: linear-gradient(135deg, var(--color-gray-50) 0%, var(--color-gray-100) 100%);
    --bg-card: var(--color-gray-50);
    --bg-input: var(--color-gray-50);
    --bg-code: var(--color-gray-100);

    --text-primary: var(--color-gray-800);
    --text-secondary: var(--color-gray-600);
    --text-tertiary: var(--color-gray-500);
    --text-accent: var(--color-blue-600);

    --border-primary: var(--color-gray-200);
    --border-secondary: rgba(255, 255, 255, 0.3);

    --shadow-primary: 0 20px 60px rgba(0, 0, 0, 0.15);
    --shadow-secondary: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-tertiary: 0 2px 10px rgba(0, 0, 0, 0.1);

    --gradient-primary: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-600) 100%);
    --gradient-secondary: linear-gradient(135deg, var(--color-green-400) 0%, var(--color-green-600) 100%);
    --gradient-accent: linear-gradient(135deg, var(--color-pink-500) 0%, var(--color-pink-600) 100%);

    --overlay-light: rgba(120, 119, 198, 0.3);
    --overlay-dark: rgba(255, 119, 198, 0.3);
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-primary: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #4a5568 100%);
    --bg-secondary: rgba(45, 55, 72, 0.95);
    --bg-tertiary: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    --bg-card: #2d3748;
    --bg-input: #1a202c;
    --bg-code: #1a202c;

    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-tertiary: #a0aec0;
    --text-accent: #63b3ed;

    --border-primary: #4a5568;
    --border-secondary: rgba(74, 85, 104, 0.3);

    --shadow-primary: 0 20px 60px rgba(0, 0, 0, 0.4);
    --shadow-secondary: 0 4px 20px rgba(0, 0, 0, 0.2);
    --shadow-tertiary: 0 2px 10px rgba(0, 0, 0, 0.3);

    --gradient-primary: linear-gradient(135deg, #63b3ed 0%, #4299e1 100%);
    --gradient-secondary: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    --gradient-accent: linear-gradient(135deg, #ed64a6 0%, #d53f8c 100%);

    --overlay-light: rgba(99, 179, 237, 0.2);
    --overlay-dark: rgba(237, 100, 166, 0.2);
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    background-attachment: fixed;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    transition: background 0.3s ease;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%);
    pointer-events: none;
}

.container {
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-primary),
                0 0 0 1px var(--border-secondary);
    max-width: 900px;
    width: 90%;
    margin: 20px;
    position: relative;
    border: 1px solid var(--border-secondary);
    animation: slideIn 0.6s ease-out;
    transition: all 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

.header-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
}

.theme-switch-checkbox {
    display: none;
}

.theme-switch-label {
    display: inline-block;
    width: 60px;
    height: 30px;
    background: var(--bg-card);
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    border: 2px solid var(--border-primary);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-tertiary);
}

.theme-switch-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: var(--gradient-primary);
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-switch-sun, .theme-switch-moon {
    font-size: 14px;
    transition: opacity 0.3s ease;
}

.theme-switch-sun {
    opacity: 1;
}

.theme-switch-moon {
    opacity: 0;
}

.theme-switch-checkbox:checked + .theme-switch-label .theme-switch-slider {
    transform: translateX(30px);
    background: var(--gradient-accent);
}

.theme-switch-checkbox:checked + .theme-switch-label .theme-switch-sun {
    opacity: 0;
}

.theme-switch-checkbox:checked + .theme-switch-label .theme-switch-moon {
    opacity: 1;
}

.theme-switch-label:hover {
    transform: scale(1.05);
}

.theme-switch-label:active {
    transform: scale(0.95);
}

h1 {
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
    transition: all 0.3s ease;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.copyright {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-style: italic;
    margin: 0 0 16px 0;
    transition: all 0.3s ease;
}

.contact-links {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid var(--border-primary);
    background: var(--bg-card);
    color: var(--text-secondary);
}

.contact-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
}

.facebook:hover {
    border-color: #1877f2;
    background: rgba(24, 119, 242, 0.1);
}

.website:hover {
    border-color: var(--text-accent);
    background: rgba(102, 126, 234, 0.1);
}

.video-tutorial:hover {
    border-color: var(--color-red-400);
    background: var(--color-red-100);
    color: var(--color-red-800);
}

.coffee-support:hover {
    border-color: var(--color-orange-400);
    background: var(--color-orange-100);
    color: var(--color-orange-800);
}

.contact-icon {
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-text {
    white-space: nowrap;
}

.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.form-group textarea {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border-primary);
    border-radius: 12px;
    font-size: 16px;
    box-sizing: border-box;
    background: var(--bg-input);
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    margin-top: 8px;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group textarea::placeholder {
    color: var(--text-tertiary);
    font-style: italic;
}

/* API Card Styling */
.api-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-secondary);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.api-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.api-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}

.api-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.api-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.api-header-content h3 {
    margin: 0 0 4px 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.api-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s ease;
}

.api-input-container {
    margin-bottom: 24px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 18px 20px 18px 52px;
    border: 2px solid var(--border-primary);
    border-radius: 14px;
    font-size: 16px;
    background: var(--bg-input);
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--text-primary);
    box-sizing: border-box;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.input-wrapper input::placeholder {
    color: var(--text-tertiary);
    font-style: italic;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: all 0.3s ease;
}

.input-wrapper input:focus + .input-icon {
    color: var(--text-accent);
}

.api-actions {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.btn-save, .btn-guide {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

.btn-save {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.4);
}

.btn-guide {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-guide:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-save::before, .btn-guide::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-save:hover::before, .btn-guide:hover::before {
    left: 100%;
}

.btn-save:active, .btn-guide:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.api-security-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: rgba(72, 187, 120, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(72, 187, 120, 0.2);
    transition: all 0.3s ease;
}

.security-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.security-text {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.security-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

textarea {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    box-sizing: border-box;
    background: #ffffff;
    transition: all 0.3s ease;
    font-family: inherit;
    color: #2d3748;
    resize: vertical;
    min-height: 120px;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

textarea::placeholder {
    color: #a0aec0;
    font-style: italic;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}



#optimizeBtn {
    width: 100%;
    margin-top: 30px;
    padding: 18px 24px;
    font-size: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#optimizeBtn:hover {
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.5);
}

.result {
    margin-top: 40px;
    padding: 30px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-secondary);
    animation: fadeIn 0.5s ease-out;
    transition: all 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    text-align: center;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s ease;
}

.tabs {
    display: flex;
    margin-bottom: 25px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 4px;
    box-shadow: var(--shadow-tertiary);
    transition: all 0.3s ease;
}

.tab-btn {
    flex: 1;
    padding: 14px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    color: var(--text-secondary);
    position: relative;
}

.tab-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--text-accent);
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.tab-content {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-secondary);
    min-height: 200px;
    animation: slideUp 0.4s ease-out;
    transition: all 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.content-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--color-blue-300);
    background: var(--color-blue-50);
    color: var(--color-blue-700);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.export-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    background: var(--color-blue-100);
    border-color: var(--color-blue-400);
}

.export-btn:active {
    transform: translateY(0);
}

.export-btn.exported {
    background: var(--color-green-50);
    color: var(--color-green-700);
    border-color: var(--color-green-400);
}

.export-icon {
    font-size: 1rem;
}

.content-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.copy-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s;
}

.copy-btn:hover::before {
    left: 100%;
}

.copy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--text-accent);
    color: var(--text-accent);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-btn.copied {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border-color: #48bb78;
    animation: copiedPulse 0.6s ease-out;
}

@keyframes copiedPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.copy-btn.copied .copy-icon::before {
    content: '✅';
}

.copy-icon {
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.6;
    color: var(--text-primary);
    font-size: 15px;
    margin: 0;
    background: var(--bg-code);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    overflow-x: auto;
    transition: all 0.3s ease;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.loading-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.4s ease-out 0.1s both;
    border: 1px solid var(--border-secondary);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--border-primary) 25%, rgba(255, 255, 255, 0.1) 50%, var(--border-primary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 60%;
    margin-bottom: 0;
}

.skeleton-title {
    height: 24px;
    width: 80%;
    margin: 0 auto 16px;
}

.skeleton-button {
    height: 48px;
    width: 120px;
    margin: 16px auto;
    border-radius: 12px;
}

.loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid var(--text-accent);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(2) {
    animation-delay: 0.2s;
    border-top-color: var(--gradient-primary);
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
}

.spinner-ring:nth-child(3) {
    animation-delay: 0.4s;
    border-top-color: var(--gradient-accent);
    width: 50%;
    height: 50%;
    top: 25%;
    left: 25%;
}

.spinner-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    40% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    60% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.loading-text h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    animation: fadeInUp 0.5s ease-out 0.3s both;
}

.loading-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 20px 0;
    animation: fadeInUp 0.5s ease-out 0.4s both;
}

.loading-progress {
    animation: fadeInUp 0.5s ease-out 0.5s both;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    animation: progress 3s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading {
    text-align: center;
    color: var(--text-accent);
    font-size: 18px;
    font-weight: 600;
    margin-top: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    animation: pulse 2s infinite;
    transition: all 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.error {
    background: linear-gradient(135deg, var(--color-red-50) 0%, var(--color-red-100) 100%);
    color: var(--color-red-700);
    padding: 20px;
    border-radius: 12px;
    margin-top: 25px;
    border: 1px solid var(--color-red-200);
    box-shadow: 0 4px 15px rgba(197, 48, 48, 0.1);
    font-weight: 500;
    animation: shake 0.5s ease-out;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.error::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-red-400) 0%, var(--color-red-600) 100%);
}

.error strong {
    color: var(--color-red-800);
    font-weight: 700;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.hidden {
    display: none;
}

@media (max-width: 768px) {
    .container {
        padding: 25px;
        margin: 15px;
        border-radius: 16px;
    }

    .header-controls {
        gap: 8px;
    }

    .coffee-support, .video-tutorial {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .coffee-icon, .video-tutorial .contact-icon {
        font-size: 0.9rem;
    }

    .coffee-text, .video-tutorial .contact-text {
        display: none; /* Ẩn text trên mobile để tiết kiệm chỗ */
    }

    h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .copyright {
        margin-bottom: 12px;
    }

    .contact-links {
        gap: 12px;
    }

    .contact-link {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .contact-icon {
        font-size: 0.9rem;
    }

    .api-card {
        padding: 24px;
    }

    .api-card-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .api-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .api-header-content h3 {
        font-size: 1.1rem;
    }

    .api-subtitle {
        font-size: 0.8rem;
    }

    .input-wrapper input {
        padding: 16px 16px 16px 44px;
        font-size: 16px;
    }

    .input-icon {
        left: 14px;
        font-size: 18px;
    }

    .api-actions {
        flex-direction: column;
        gap: 12px;
    }

    .btn-save, .btn-guide {
        width: 100%;
        padding: 16px 20px;
        font-size: 15px;
        min-width: unset;
    }

    .api-security-notice {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .security-icon {
        align-self: center;
    }

    .form-group {
        margin-bottom: 20px;
    }

    textarea {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 100px;
    }

    button {
        padding: 14px 20px;
        font-size: 15px;
    }

    #optimizeBtn {
        padding: 16px 20px;
        font-size: 16px;
        margin-top: 25px;
    }

    .result {
        padding: 20px;
        margin-top: 30px;
    }

    .tabs {
        flex-direction: column;
        gap: 4px;
    }

    .tab-btn {
        padding: 12px 16px;
        font-size: 15px;
    }

    .tab-content {
        padding: 20px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .content-header h4 {
        font-size: 1rem;
    }

    .copy-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    pre {
        padding: 16px;
        font-size: 14px;
    }
}

/* History Section */
.history-section {
    margin-top: 40px;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-secondary);
    transition: all 0.3s ease;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-primary);
}

.history-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.history-icon {
    font-size: 1.5rem;
}

.history-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.history-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.history-search {
    padding: 8px 12px;
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: all 0.3s ease;
    width: 200px;
}

.history-search:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.clear-history-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--color-red-300);
    background: var(--color-red-50);
    color: var(--color-red-700);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.clear-history-btn:hover {
    background: var(--color-red-100);
    border-color: var(--color-red-400);
    transform: translateY(-1px);
}

.clear-icon {
    font-size: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-primary);
    transition: all 0.3s ease;
    cursor: pointer;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
    border-color: var(--text-accent);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.history-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-item-date {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    margin-left: 12px;
}

.history-item-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.history-item-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.history-item-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-item-btn.use-btn {
    border-color: var(--color-green-300);
    color: var(--color-green-700);
}

.history-item-btn.use-btn:hover {
    background: var(--color-green-50);
    border-color: var(--color-green-400);
}

.history-item-btn.delete-btn {
    border-color: var(--color-red-300);
    color: var(--color-red-700);
}

.history-item-btn.delete-btn:hover {
    background: var(--color-red-50);
    border-color: var(--color-red-400);
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-history h3 {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: 600;
}

.empty-history p {
    margin: 0;
    font-size: 0.9rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.save-history-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--color-green-300);
    background: var(--color-green-50);
    color: var(--color-green-700);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.save-history-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.2);
    background: var(--color-green-100);
    border-color: var(--color-green-400);
}

.save-history-btn.saved {
    background: var(--color-green-100);
    border-color: var(--color-green-400);
    color: var(--color-green-800);
}

.save-icon {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .history-controls {
        width: 100%;
        justify-content: space-between;
    }

    .history-search {
        flex: 1;
        width: auto;
    }

    .history-item {
        padding: 16px;
    }

    .history-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .history-item-date {
        margin-left: 0;
        align-self: flex-end;
    }

    .history-item-actions {
        justify-content: flex-start;
        margin-top: 12px;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .save-history-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
        margin: 10px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .result h2 {
        font-size: 1.3rem;
    }

    .loading {
        font-size: 16px;
        padding: 16px;
    }

    .error {
        padding: 16px;
        font-size: 14px;
    }

    .history-section {
        padding: 20px;
    }

    .history-header h2 {
        font-size: 1.25rem;
    }

    .history-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .history-search {
        width: 100%;
    }

    .clear-history-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Title editing styles */
.title-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.edit-title-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    opacity: 0.7;
    flex-shrink: 0;
}

.edit-title-btn:hover {
    opacity: 1;
    background: var(--border-primary);
    transform: scale(1.1);
}

.title-edit-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--text-accent);
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-card);
    font-family: inherit;
    min-width: 0;
}

.title-edit-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Manual Copy Modal */
.manual-copy-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.manual-copy-content {
    background: var(--bg-card);
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.4s ease-out 0.1s both;
    border: 1px solid var(--border-secondary);
}

.manual-copy-content h3 {
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    text-align: center;
}

.manual-copy-content p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.manual-copy-textarea {
    width: 100%;
    min-height: 150px;
    padding: 16px;
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.manual-copy-textarea:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.manual-copy-actions {
    text-align: center;
}

.manual-copy-btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.manual-copy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--text-accent);
    color: var(--text-accent);
}
