/* Base mobile first */
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.5;
}

.app-header {
    background: #fff;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e5ea;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header h1 {
    margin: 0 0 10px;
    font-size: 20px;
    color: #4a3d7a;
}

.tabs { display: flex; gap: 10px; }

.tab {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #d1d1d6;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    color: #1d1d1f;
    transition: all 0.2s;
}

.tab--active {
    background: #4a3d7a;
    color: #fff;
    border-color: #4a3d7a;
}

.app-main { padding: 15px; max-width: 900px; margin: 0 auto; }

.panel { display: none; }
.panel--active { display: block; }

/* Chat */
.chat-messages {
    background: #fff;
    border-radius: 15px;
    padding: 15px;
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #e5e5ea;
}

.message {
    padding: 10px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    max-width: 85%;
    word-wrap: break-word;
}

.message--user {
    background: #4a3d7a;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message--assistant {
    background: #f0eef7;
    color: #1d1d1f;
    border-bottom-left-radius: 5px;
}

.message--assistant p:first-child { margin-top: 0; }
.message--assistant p:last-child { margin-bottom: 0; }
.message--assistant pre {
    background: #1d1d1f;
    color: #f5f5f7;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 13px;
}
.message--assistant code {
    background: rgba(0,0,0,0.05);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
}
.message--assistant pre code { background: transparent; padding: 0; }

/* Formulaires */
.chat-form, .image-form {
    background: #fff;
    padding: 15px;
    border-radius: 15px;
    border: 1px solid #e5e5ea;
    margin-bottom: 15px;
}

.chat-input, .image-prompt {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d1d6;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
    margin-bottom: 10px;
}

.chat-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: #4a3d7a; color: #fff; }
.btn--secondary { background: #e5e5ea; color: #1d1d1f; }

/* Options image */
.image-form label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    font-size: 14px;
}

.image-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.image-options select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d1d6;
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    margin-top: 5px;
}

/* Résultats image */
.image-results {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.image-item {
    background: #fff;
    padding: 10px;
    border-radius: 15px;
    border: 1px solid #e5e5ea;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-item img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
}

.loading, .error {
    text-align: center;
    padding: 20px;
    color: #6e6e73;
}

.error { color: #c93030; }

/* Desktop */
@media (min-width: 1000px) {
    .app-header h1 { font-size: 25px; }
    .app-main { padding: 25px; }
    .chat-messages { min-height: 400px; }
    .image-options { flex-direction: row; }
    .image-options label { flex: 1; }
    .image-results { grid-template-columns: repeat(2, 1fr); }
}

.debug {
    margin-top: 10px;
    font-size: 12px;
}
.debug summary { cursor: pointer; color: #4a3d7a; }
.debug pre {
    background: #1d1d1f;
    color: #f5f5f7;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 11px;
    max-height: 300px;
}