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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* --- Header --- */
header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
}

.subtitle {
    color: #6b7280;
    margin-top: 0.25rem;
}

/* --- Input Section --- */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.question-toggle {
    display: flex;
    align-items: center;
}

.question-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #4b5563;
    cursor: pointer;
}

.question-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4f46e5;
    cursor: pointer;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: -0.35rem;
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.15s;
    background: #fff;
}

textarea:focus {
    outline: none;
    border-color: #6366f1;
}

button#validate-btn {
    align-self: flex-end;
    padding: 0.7rem 2rem;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

button#validate-btn:hover {
    background: #4338ca;
}

button#validate-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* --- Loading --- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #6b7280;
    font-size: 1rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #d1d5db;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Error --- */
.error-banner {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

/* --- Results --- */
.results {
    margin-top: 2rem;
}

.hidden {
    display: none !important;
}

/* Score badge */
.score-section {
    text-align: center;
    padding: 1.5rem 0;
}

.score-badge {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.5rem;
}

.score-badge.pass {
    background: #22c55e;
}

.score-badge.excellent {
    background: #16a34a;
}

.score-badge.fail {
    background: #ef4444;
}

.status-label {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-label.pass {
    color: #16a34a;
}

.status-label.fail {
    color: #dc2626;
}

/* Message type badge */
.message-type-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-top: 0.75rem;
    letter-spacing: 0.02em;
}

.message-type-badge.buying-time {
    background: #fef3c7;
    color: #92400e;
    border: 2px solid #f59e0b;
}

.message-type-badge.explaining-issue {
    background: #dbeafe;
    color: #1e40af;
    border: 2px solid #3b82f6;
}

.message-type-badge.starting-investigation {
    background: #e0e7ff;
    color: #3730a3;
    border: 2px solid #6366f1;
}

.message-type-badge.final-solution {
    background: #dcfce7;
    color: #166534;
    border: 2px solid #22c55e;
}

.message-type-reason {
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 0.35rem;
    font-style: italic;
}

.summary {
    color: #4b5563;
    margin-top: 0.5rem;
    font-size: 1rem;
}

/* --- Section Cards --- */
.sections {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.section-card {
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.section-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.section-score-text {
    font-weight: 700;
    font-size: 0.95rem;
}

.section-score-text.good {
    color: #16a34a;
}

.section-score-text.ok {
    color: #d97706;
}

.section-score-text.bad {
    color: #dc2626;
}

.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-fill.good {
    background: #22c55e;
}

.progress-fill.ok {
    background: #f59e0b;
}

.progress-fill.bad {
    background: #ef4444;
}

.section-feedback {
    font-size: 0.88rem;
    color: #4b5563;
}

/* --- Relevance Section --- */
.relevance-section {
    margin-top: 1.5rem;
}

.relevance-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #111827;
}

.relevance-card {
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.relevance-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.relevance-score-label {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.relevance-score-label.good {
    background: #dcfce7;
    color: #166534;
}

.relevance-score-label.ok {
    background: #fef3c7;
    color: #92400e;
}

.relevance-score-label.bad {
    background: #fef2f2;
    color: #b91c1c;
}

.relevance-summary-text {
    font-size: 0.9rem;
    color: #4b5563;
}

.unanswered-parts {
    margin-top: 0.5rem;
}

.unanswered-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #dc2626;
    margin-bottom: 0.25rem;
}

.unanswered-parts ul {
    padding-left: 1.25rem;
    font-size: 0.85rem;
    color: #b91c1c;
}

.unanswered-parts li {
    margin-bottom: 0.25rem;
}

/* --- Flagged Phrases --- */
.flagged-section {
    margin-top: 1.5rem;
}

.flagged-section h3,
.improvements-section h3,
.strengths-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #111827;
}

.flagged-card {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    padding: 0.75rem 1rem;
    border-radius: 0 6px 6px 0;
    margin-bottom: 0.5rem;
}

.flagged-phrase {
    font-weight: 600;
    color: #92400e;
    font-size: 0.9rem;
}

.flagged-reason {
    font-size: 0.85rem;
    color: #78350f;
    margin-top: 0.15rem;
}

.flagged-category {
    display: inline-block;
    background: #fde68a;
    color: #78350f;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.25rem;
    text-transform: uppercase;
}

.no-flags {
    color: #16a34a;
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- Improvements & Strengths --- */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.improvements-section ol,
.strengths-section ul {
    padding-left: 1.25rem;
    font-size: 0.9rem;
    color: #374151;
}

.improvements-section li,
.strengths-section li {
    margin-bottom: 0.4rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    .score-badge {
        width: 100px;
        height: 100px;
        font-size: 2rem;
    }

    .two-col {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    button#validate-btn {
        align-self: stretch;
    }
}
