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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1a202c;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 24px;
    font-size: 15px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 48px 36px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.header-content > div {
    flex: 1;
    text-align: center;
}

.history-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 11px 22px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.94rem;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    white-space: nowrap;
    backdrop-filter: blur(10px);
}

.history-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.history-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    padding: 3px 7px;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.05rem;
    opacity: 0.92;
    font-weight: 400;
    letter-spacing: -0.01em;
}

main {
    padding: 44px 36px;
}

.prompt-form {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.form-section {
    margin: 32px 0;
    padding: 24px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.form-section h2 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 16px;
    font-weight: 600;
}

label {
    display: block;
    margin-bottom: 9px;
    font-weight: 600;
    color: #374151;
    font-size: 0.94rem;
    letter-spacing: -0.01em;
}

input[type="text"], select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    color: #1f2937;
    font-family: inherit;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="text"]::placeholder {
    color: #a0aec0;
}

.radio-group {
    margin-top: 16px;
}

.radio-options {
    display: flex;
    gap: 24px;
    margin-top: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: #4a5568;
    position: relative;
}

.radio-label input[type="radio"] {
    opacity: 0;
    position: absolute;
    width: 0;
    height: 0;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e0;
    border-radius: 50%;
    margin-right: 10px;
    position: relative;
    transition: all 0.2s ease;
}

.radio-label input[type="radio"]:checked + .radio-custom {
    border-color: #667eea;
    background: #667eea;
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 1.02rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    letter-spacing: -0.01em;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.45);
}

.submit-btn:disabled,
.submit-btn.generating {
    background: #a0aec0;
    color: #718096;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.submit-btn.generating {
    position: relative;
}

.submit-btn.generating::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 20px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top: 2px solid #718096;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-loading {
    display: none;
}

.result-section {
    margin-top: 32px;
    padding: 24px;
    background: #f7fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.result-section h2 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 16px;
    font-weight: 600;
}

.result-container {
    position: relative;
}

#generatedPrompt {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    background: white;
}

#generatedPrompt:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.copy-btn {
    background: #48bb78;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #38a169;
    transform: translateY(-1px);
}

.copy-success {
    color: #48bb78;
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 16px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid #feb2b2;
    font-weight: 500;
}

.sample-prompts-section {
    padding: 30px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
}

.sample-prompts-section h2 {
    font-size: 1.4rem;
    color: #2d3748;
    margin-bottom: 20px;
    font-weight: 600;
    text-align: center;
}

.sample-prompts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 700px;
    margin: 0 auto;
}

.sample-prompt {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sample-prompt h3 {
    font-size: 1.1rem;
    color: #4a5568;
    margin-bottom: 12px;
    font-weight: 600;
}

.sample-text {
    font-style: italic;
    color: #667eea;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

/* Templates Section */
.templates-section {
    margin-bottom: 32px;
    padding: 24px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.templates-section h2 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.template-btn {
    background: white;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.template-btn:hover {
    border-color: #6366f1;
    background: #fafafa;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.12);
}

.template-btn.active {
    border-color: #6366f1;
    background: #f5f3ff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.template-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.template-title {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.9rem;
}

.template-desc {
    font-size: 0.8rem;
    color: #718096;
}

/* Enhanced Form Fields */
.field-hint {
    display: block;
    margin-top: 4px;
    color: #718096;
    font-size: 0.85rem;
    line-height: 1.3;
}

.form-group label {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

/* Advanced Options */
.advanced-section {
    margin: 24px 0;
    padding: 20px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.advanced-section h3 {
    font-size: 1.1rem;
    color: #2d3748;
    margin-bottom: 16px;
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    align-items: center;
}

.toggle-advanced {
    background: none;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.toggle-advanced:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.toggle-advanced.expanded .toggle-icon {
    transform: rotate(180deg);
}

.enhance-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.enhance-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.3);
}

/* Enhanced Results */
.results-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

.prompt-result {
    background: white;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.prompt-result:hover {
    border-color: #6366f1;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.12);
    transform: translateY(-1px);
}

.prompt-result.selected {
    border-color: #6366f1;
    background: #f5f3ff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.15);
}

.prompt-text {
    font-family: 'SF Mono', Monaco, 'Inconsolata', 'Roboto Mono', Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #374151;
    margin-bottom: 12px;
}

.prompt-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.copy-prompt-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
}

.copy-prompt-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.secondary-btn {
    background: white;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #48bb78;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-weight: 500;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: #e53e3e;
}

/* Enhanced Copy Button */
.copy-prompt-btn {
    position: relative;
    overflow: hidden;
}

.copy-prompt-btn.copying {
    background: #38a169 !important;
    transform: scale(0.95);
}

.copy-prompt-btn::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: white;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.copy-prompt-btn.copying::after {
    transform: translate(-50%, -50%) scale(1);
}

/* Prompt Header & Stats */
.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.prompt-label {
    font-weight: 600;
    color: #6366f1;
    font-size: 0.88rem;
    letter-spacing: -0.01em;
}

.prompt-stats {
    font-size: 0.85rem;
    color: #718096;
}

/* Export Actions */
.export-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 20px 0;
    padding: 16px;
    background: #f7fafc;
    border-radius: 8px;
}

.export-btn {
    background: white;
    border: 1.5px solid #e5e7eb;
    color: #4b5563;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.export-btn:hover {
    background: #f9fafb;
    border-color: #6366f1;
    color: #6366f1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

/* History Panel */
.history-panel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-panel.open {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
}

.history-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.close-history {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.close-history:hover {
    background: rgba(255, 255, 255, 0.3);
}

.history-filters {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.history-search {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.history-search:focus {
    outline: none;
    border-color: #667eea;
}

.history-tabs {
    display: flex;
    gap: 8px;
}

.history-tab {
    flex: 1;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.history-tab:hover {
    background: #f7fafc;
}

.history-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-size: 0.95rem;
}

.history-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.history-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.favorite-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s ease;
}

.favorite-btn:hover {
    transform: scale(1.2);
}

.favorite-btn.active {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.history-meta {
    flex: 1;
    font-size: 0.8rem;
    color: #718096;
}

.delete-history-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.delete-history-btn:hover {
    opacity: 1;
}

.history-topic {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.history-preview {
    color: #4a5568;
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 10px;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-action-btn {
    background: white;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.history-footer {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
}

.clear-history-btn {
    width: 100%;
    padding: 10px;
    background: #fed7d7;
    color: #c53030;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: #fc8181;
    color: white;
}

.seo-content {
    padding: 30px;
    background: #f7fafc;
    color: #4a5568;
    font-size: 0.95rem;
    line-height: 1.6;
    border-top: 1px solid #e2e8f0;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        border-radius: 12px;
    }
    
    header {
        padding: 30px 20px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    main {
        padding: 30px 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .radio-options {
        flex-direction: column;
        gap: 16px;
    }
    
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .sample-prompts {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .advanced-section {
        padding: 16px;
    }
    
    .seo-content {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .template-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .template-btn {
        padding: 12px;
    }
    
    .template-icon {
        font-size: 1.3rem;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    main {
        padding: 20px 15px;
    }
    
    .form-section {
        padding: 20px;
        margin: 24px 0;
    }
}