* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
    max-width: 800px;
    width: 100%;
    position: relative;
}

/* Top Language Selector */
.top-language-selector {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
}

.top-language-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.top-language-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.top-language-select:hover {
    border-color: #bbb;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    margin-top: 10px;
}

.header h1 {
    color: #2d3748;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.2;
}

.header p {
    color: #718096;
    font-size: 1rem;
    line-height: 1.5;
}

.method-info {
    background: #e8f0fe;
    border: 1px solid #d2e3fc;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 25px;
}

.method-info h3 {
    color: #1a365d;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.ptcf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.ptcf-item {
    background: white;
    padding: 6px 10px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: #2d3748;
    line-height: 1.3;
}

.ptcf-item.persona { border-left: 4px solid #4285F4; }
.ptcf-item.task { border-left: 4px solid #34A853; }
.ptcf-item.context { border-left: 4px solid #FBBC04; }
.ptcf-item.format { border-left: 4px solid #EA4335; }

.method-info p {
    color: #4a5568;
    font-size: 0.9rem;
    line-height: 1.4;
}

.api-config {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
}

.api-config h4 {
    color: #856404;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.model-selector {
    margin-bottom: 15px;
}

.model-label {
    display: block;
    color: #856404;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.model-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #2d3748;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.model-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.model-select:hover {
    border-color: #bbb;
}

.api-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
}

.api-note {
    color: #6c757d;
    font-size: 0.8rem;
    line-height: 1.3;
}

.input-section {
    margin-bottom: 25px;
}

.input-label {
    display: block;
    color: #2d3748;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1rem;
}

.input-textarea {
    width: 100%;
    min-height: 110px;
    padding: 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    background: #f7fafc;
    line-height: 1.4;
}

.input-textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-textarea::placeholder {
    color: #a0aec0;
}

.optimize-button {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 25px;
}

.optimize-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.optimize-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.result-section {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.result-section.show {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-label {
    display: block;
    color: #2d3748;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1rem;
}

.result-container {
    position: relative;
    background: #f8f9fa;
    border-left: 4px solid #4285F4;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.result-text {
    color: #2d3748;
    line-height: 1.5;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.copy-button {
    background: #48bb78;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 0.9rem;
}

.copy-button:hover {
    background: #38a169;
    transform: translateY(-1px);
}

.copy-button.copied {
    background: #319795;
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #c53030;
    display: none;
    font-size: 0.9rem;
}

.error-message.show {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.disclaimer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    color: #718096;
    font-size: 0.85rem;
    line-height: 1.4;
}

.disclaimer h3 {
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 20px 16px;
        margin: 5px;
        border-radius: 12px;
    }

    .top-language-selector {
        top: 10px;
        right: 10px;
    }

    .top-language-select {
        font-size: 12px;
        padding: 5px 8px;
    }

    .header {
        margin-bottom: 25px;
        margin-top: 15px;
    }

    .header h1 {
        font-size: 1.8rem;
        line-height: 1.1;
    }

    .header p {
        font-size: 0.9rem;
    }

    .method-info {
        padding: 15px;
        margin-bottom: 20px;
    }

    .method-info h3 {
        font-size: 1rem;
    }

    .ptcf-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .ptcf-item {
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    .method-info p {
        font-size: 0.85rem;
    }

    .api-config {
        padding: 12px;
        margin-bottom: 20px;
    }

    .api-config h4 {
        font-size: 0.9rem;
    }

    .model-label {
        font-size: 0.8rem;
    }

    .model-select {
        font-size: 12px;
        padding: 6px 10px;
    }

    .api-input {
        font-size: 12px;
        padding: 6px 10px;
    }

    .api-note {
        font-size: 0.75rem;
    }

    .input-section {
        margin-bottom: 20px;
    }

    .input-label {
        font-size: 0.95rem;
    }

    .input-textarea {
        min-height: 100px;
        padding: 12px;
        font-size: 14px;
    }

    .optimize-button {
        padding: 12px 24px;
        font-size: 0.95rem;
        margin-bottom: 20px;
    }

    .result-label {
        font-size: 0.95rem;
    }

    .result-container {
        padding: 14px;
    }

    .result-text {
        font-size: 14px;
    }

    .copy-button {
        padding: 8px 14px;
        font-size: 0.85rem;
        gap: 4px;
    }

    .disclaimer {
        margin-top: 25px;
        font-size: 0.8rem;
    }

    .disclaimer h3 {
        font-size: 0.9rem;
    }

    .loading-spinner {
        width: 12px;
        height: 12px;
        margin-right: 4px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .container {
        padding: 15px 12px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .ptcf-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .ptcf-item {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    .input-textarea {
        min-height: 90px;
        padding: 10px;
        font-size: 13px;
    }

    .optimize-button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}