:root {
    /* --- Thème Sombre (Défaut) --- */
    --color-background: #121217;
    --color-surface: #1C1E26;
    --color-text: #EAECEF;
    --color-text-muted: #8892B0;
    --color-accent-start: #3B82F6;
    --color-accent-end: #8B5CF6;
    --color-border: rgba(136, 146, 176, 0.15);
    --color-shadow: rgba(139, 92, 246, 0.1);
    --color-code-bg: #0d0d10;
    --particle-color: rgba(139, 92, 246, 0.6);
    --particle-link-color: rgba(139, 92, 246, 0.2);
    --font-main: 'Poppins', sans-serif;
    --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
}

body.light-theme {
    /* --- Thème Clair (Alternative) --- */
    --color-background: #F8F9FA;
    --color-surface: #FFFFFF;
    --color-text: #212529;
    --color-text-muted: #6C757D;
    --color-border: rgba(0, 0, 0, 0.1);
    --color-shadow: rgba(139, 92, 246, 0.15);
    --color-code-bg: #F1F3F5;
    --particle-color: rgba(59, 130, 246, 0.7);
    --particle-link-color: rgba(59, 130, 246, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.8;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

#background-canvas {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; z-index: 0;
}

#particle-canvas {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%; height: 100%; z-index: 1;
}

.container {
    max-width: 960px; margin: 0 auto; padding: 0 2rem; 
    position: relative; z-index: 2;
}

.hero {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    text-align: center; position: relative; overflow: hidden;
}

.hero-content { position: relative; z-index: 2; }

.hero-content > * {
    opacity: 0;
    animation: fadeInUp 0.8s var(--ease-out-quint) forwards;
}
.hero h1 { animation-delay: 0.2s; }
.hero p { animation-delay: 0.4s; }
.hero .btn { animation-delay: 0.6s; }

@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

.hero h1 {
    font-size: 4.5rem; font-weight: 700; line-height: 1.2;
    letter-spacing: -0.02em; margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--color-accent-start), var(--color-accent-end));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    transform: translateY(30px);
}

.hero p {
    font-size: 1.25rem; max-width: 600px;
    margin: 0 auto 2.5rem auto; color: var(--color-text-muted);
    transform: translateY(30px);
}

.btn {
    display: inline-block;
    background: linear-gradient(45deg, var(--color-accent-start), var(--color-accent-end));
    color: white; padding: 1rem 2.5rem; border-radius: 50px;
    text-decoration: none; font-weight: 500;
    transition: all 0.4s var(--ease-out-quint);
    box-shadow: 0 10px 20px var(--color-shadow);
    border: none; cursor: pointer;
    transform: translateY(30px);
}

.btn:hover {
    box-shadow: 0 12px 25px rgba(139, 92, 246, 0.22);
    filter: brightness(1.1);
}

.section {
    padding: 8rem 0; opacity: 0; transform: translateY(40px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.section.visible { opacity: 1; transform: translateY(0); }

h2 { font-size: 3rem; text-align: center; margin-bottom: 4rem; }

.card {
    background: var(--color-surface); 
    padding: 3rem; border-radius: 20px; margin-bottom: 2.5rem; 
    border: 1px solid var(--color-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    position: relative; overflow: hidden;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.card::before {
    content: ''; position: absolute;
    left: 0; top: 0; width: 100%; height: 100%; border-radius: inherit;
    background: radial-gradient(800px circle at var(--mouse-x) var(--mouse-y), rgba(139, 92, 246, 0.1), transparent 40%);
    opacity: 0; transition: opacity 0.5s; pointer-events: none;
}
.card:hover::before { opacity: 1; }
body.light-theme .card::before {
     background: radial-gradient(800px circle at var(--mouse-x) var(--mouse-y), rgba(59, 130, 246, 0.1), transparent 40%);
}

h3 { font-size: 1.75rem; margin-bottom: 1rem; font-weight: 600; color: var(--color-text); }

code {
    background-color: var(--color-code-bg); padding: 0.2rem 0.5rem;
    border-radius: 5px; border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.prompt-examples h4 { font-weight: 500; color: var(--color-text-muted); margin-bottom: 1rem; }

.example-btn {
    background: transparent; border: 1px solid var(--color-border);
    border-radius: 20px; padding: 0.5rem 1rem; margin: 0 0.5rem 0.5rem 0;
    cursor: pointer; transition: all 0.3s var(--ease-out-quint);
    font-family: var(--font-main); color: var(--color-text-muted);
}
.example-btn:hover { 
    background-color: var(--color-accent-end); color: white;
    border-color: var(--color-accent-end); transform: translateY(-2px); 
}

textarea {
    width: 100%; min-height: 120px; background-color: var(--color-background); 
    border: 1px solid var(--color-border); border-radius: 10px; padding: 1rem; 
    color: var(--color-text); font-family: var(--font-main); font-size: 1rem; 
    resize: vertical; transition: all 0.3s;
}
textarea:focus {
    outline: none; border-color: var(--color-accent-start);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

#response-title { display: none; }

#result-container {
    background-color: var(--color-background); border: 1px solid var(--color-border);
    border-radius: 10px; padding: 2rem; min-height: 200px;
    display: flex; justify-content: center; align-items: center;
    transition: background-color 0.5s var(--ease-out-quint), border-color 0.5s var(--ease-out-quint);
}

#result-container.has-content {
    text-align: left; align-items: flex-start;
    justify-content: flex-start; flex-direction: column;
}

.typing-indicator { display: flex; align-items: center; justify-content: center; }
.typing-indicator span {
    height: 10px; width: 10px; margin: 0 4px; background-color: var(--color-text-muted);
    border-radius: 50%; opacity: 0.4; animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(1) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.4s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.6s; }
@keyframes typing { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-8px); opacity: 1; } }

.reveal-on-load {
    opacity: 0; transform: translateY(15px);
    transition: opacity 0.5s var(--ease-out-quint), transform 0.5s var(--ease-out-quint);
}

#result-container pre {
    background-color: var(--color-code-bg); padding: 1rem; 
    border-radius: 8px; margin: 1rem 0; width: 100%;
    border: 1px solid var(--color-border);
}
#result-container a { color: var(--color-accent-start); text-decoration: none; font-weight: 500; }
#result-container a:hover { text-decoration: underline; }

.btn-spinner {
    border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; 
    border-radius: 50%; width: 1.2em; height: 1.2em;
    animation: spin 1s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.theme-switcher {
    position: fixed; bottom: 20px; right: 20px;
    width: 50px; height: 50px; background-color: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: 50%;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); transition: all 0.3s ease; z-index: 100;
}
.theme-switcher:hover { transform: translateY(-3px) scale(1.05); border-color: var(--color-accent-start); }
.theme-switcher svg {
    width: 24px; height: 24px; color: var(--color-text-muted);
    transition: transform 0.4s ease, opacity 0.4s ease; position: absolute;
}
.theme-switcher .sun-icon { opacity: 0; transform: rotate(-90deg) scale(0); }
.theme-switcher .moon-icon { opacity: 1; transform: rotate(0deg) scale(1); }
body.light-theme .theme-switcher .sun-icon { opacity: 1; transform: rotate(0deg) scale(1); }
body.light-theme .theme-switcher .moon-icon { opacity: 0; transform: rotate(90deg) scale(0); }

.analyzer-section, .history-section {
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--color-border);
}

.analyzer-content, .history-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.analyzer-score-card, .analyzer-feedback-card, .history-stat {
    background-color: var(--color-background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
}

.score-circle {
    width: 80px; height: 80px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 2rem; font-weight: 600; margin: 0 auto 1rem;
    background: conic-gradient(from 0deg, var(--color-accent-start), var(--color-accent-end));
    color: var(--color-text);
}

.analyzer-score-card p {
    text-align: center; color: var(--color-text-muted); font-size: 0.9rem;
}

.analyzer-feedback-card h4, .history-stat h4 {
    margin-bottom: 1rem; font-weight: 500; color: var(--color-text);
}

.analyzer-feedback-card ul { list-style-type: none; padding-left: 0; }

.analyzer-feedback-card li {
    padding-left: 1.5em; position: relative;
    color: var(--color-text-muted); font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.analyzer-feedback-card li::before {
    content: '✓'; position: absolute; left: 0;
    color: var(--color-accent-start);
}

.history-stat p { font-size: 1.5rem; font-weight: 600; color: var(--color-text); }
.history-stat.full-width { grid-column: 1 / -1; }

.score-chart {
    display: flex; align-items: flex-end; justify-content: space-around;
    height: 100px; padding: 1rem 0.5rem 0; border-radius: 8px;
    background-color: rgba(0,0,0,0.1);
}

.score-bar {
    width: 10%;
    background: linear-gradient(to top, var(--color-accent-start), var(--color-accent-end));
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease-out; position: relative;
}
.score-bar:hover::after {
    content: attr(data-score); position: absolute;
    top: -25px; left: 50%; transform: translateX(-50%);
    background-color: var(--color-surface); color: var(--color-text);
    padding: 2px 8px; border-radius: 4px;
    font-size: 0.8rem; font-weight: 600;
}

.suggestion-card {
    background-color: var(--color-background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    margin-top: 1.5rem;
}

.suggestion-card h5 {
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 0.8rem;
}

#improved-prompt-text {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9rem;
    color: var(--color-text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.btn-secondary {
    background: transparent;
    color: var(--color-accent-start);
    border: 1px solid var(--color-accent-start);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-secondary:hover {
    background-color: var(--color-accent-start);
    color: white;
}

.api-key-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.api-key-modal {
    background-color: var(--color-surface);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--color-border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.api-key-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.api-key-overlay.hidden .api-key-modal {
    transform: scale(0.95);
}

.api-key-modal h3 {
    margin-bottom: 0.5rem;
}

.api-key-modal p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.api-key-modal input {
    width: 100%;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: var(--color-text);
    font-family: var(--font-main);
    margin-bottom: 1.5rem;
}

.api-key-modal input:focus {
    outline: none;
    border-color: var(--color-accent-start);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.api-key-modal .btn {
    /* MODIFIÉ : Marge ajustée */
    width: 100%;
    margin-bottom: 0;
}

.api-key-error {
    color: #ff8a80 !important;
    font-weight: 500;
}

.api-key-error.hidden {
    display: none;
}
