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

html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #1a1a2e;
    background: #f8f9fa;
}

body {
    min-height: 100vh;
    padding: 24px 16px 48px;
}

main {
    max-width: 720px;
    margin: 0 auto;
}

h1 {
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
    text-align: center;
    margin-bottom: 16px;
    letter-spacing: 0.04em;
}

form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

textarea {
    width: 100%;
    padding: 14px 16px;
    font: inherit;
    font-size: 1rem;
    color: #1a1a2e;
    background: #fff;
    border: 2px solid #d4d4d8;
    border-radius: 12px;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
    width: 100%;
    padding: 14px 24px;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    min-height: 48px;
    transition: background 0.2s ease;
}

button:hover {
    background: #1d4ed8;
}

button:active {
    background: #1e40af;
}

button:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

#loading {
    margin: 0 0 4px;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

.htmx-request #validation-message {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#validation-message {
    margin-top: 12px;
    padding: 12px 16px;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    font-size: 0.9rem;
}

#validation-message[hidden] {
    display: none;
}

.conversation {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0 16px;
    min-height: 45vh;
}

.empty-state {
    padding: 56px 8px;
    color: #6b7280;
    font-size: 1.05rem;
    text-align: center;
}

.empty-state[hidden] {
    display: none;
}

.turn {
    display: flex;
}

.turn-user {
    justify-content: flex-end;
}

.turn-assistant {
    justify-content: flex-start;
}

.turn-user .bubble {
    max-width: 85%;
    padding: 12px 16px;
    color: #fff;
    background: #2563eb;
    border-radius: 16px 16px 4px 16px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.turn-assistant .bubble {
    width: 100%;
    max-width: 92%;
    padding: 20px 22px;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 16px 16px 16px 4px;
    overflow-wrap: anywhere;
}

.turn-assistant .bubble.typing {
    width: auto;
    color: #6b7280;
    font-size: 0.9rem;
    animation: pulse 1.4s ease-in-out infinite;
}

.composer {
    position: sticky;
    bottom: 0;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 0 16px;
    background: #f8f9fa;
}

.composer textarea {
    flex: 1;
    min-height: 52px;
    max-height: 140px;
    padding: 14px 16px;
    border-width: 1px;
    border-radius: 16px;
    resize: none;
}

.composer button {
    width: auto;
    min-width: 88px;
    min-height: 52px;
    padding: 14px 20px;
    border-radius: 16px;
}

.response-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.75;
    color: #1f2937;
    white-space: pre-wrap;
}

.response-body::first-line {
    font-weight: 600;
}

.question-card {
    padding: 24px 24px;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    width: 100%;
    transition: opacity 0.2s ease;
}

.question-card.answered {
    opacity: 0.55;
    pointer-events: none;
}

.question-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 20px;
    line-height: 1.4;
}

.question-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.question-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
}

.question-description {
    font-size: 0.9rem;
    color: #6b7280;
}

.question-option {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: #1f2937;
    cursor: pointer;
}

.question-option input {
    width: 18px;
    height: 18px;
    flex: none;
    accent-color: #2563eb;
}

.question-field input[type="text"],
.question-field input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    font: inherit;
    font-size: 0.95rem;
    color: #1a1a2e;
    background: #fff;
    border: 2px solid #d4d4d8;
    border-radius: 10px;
    transition: border-color 0.2s ease;
}

.question-field input[type="text"]:focus,
.question-field input[type="number"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.error-message {
    text-align: center;
}

.error-message p {
    color: #4b5563;
    margin-bottom: 16px;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.retry-button {
    width: auto;
    min-width: 140px;
    background: #6b7280;
}

.retry-button:hover {
    background: #4b5563;
}

@media (min-width: 640px) {
    body {
        padding: 40px 32px 64px;
    }
}

@media (min-width: 1024px) {
    body {
        padding: 56px 40px 80px;
    }

    textarea {
        padding: 16px 20px;
        font-size: 1.05rem;
        min-height: 110px;
    }

    .response-body {
        font-size: 1.05rem;
        line-height: 1.75;
    }

    .question-card {
        padding: 28px 28px;
    }
}
