/* === BASE STYLES === */

:root {
    --ink: #1a1410;
    --paper: #f5f0e8;
    --cream: #ede8dc;
    --rust: #8b3a2a;
    --gold: #c4973a;
    --muted: #7a7060;
    --line: #d4cec0;
    --white: #fefcf8;
}

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

body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    min-height: 100vh;
}

.cover {
    background: var(--ink);
    color: var(--paper);
    padding: 80px 60px 60px;
    position: relative;
    overflow: hidden;
}

.cover::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -80px;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    border: 1px solid rgba(196, 151, 58, 0.2);
}

.cover::after {
    content: '';
    position: absolute;
    bottom: -120px;
    left: -60px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 1px solid rgba(196, 151, 58, 0.15);
}

.cover-inner {
    max-width: 760px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.cover-label {
    font-size: 10px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 20px;
}

.cover h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(36px, 5vw, 58px);
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: 16px;
}

.cover h1 em {
    font-style: italic;
    color: var(--gold);
}

.cover-desc {
    font-size: 15px;
    color: rgba(245, 240, 232, 0.65);
    line-height: 1.7;
    max-width: 520px;
    margin-bottom: 40px;
}

.scale-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.scale-item {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scale-num {
    font-weight: 500;
    color: var(--gold);
    font-size: 14px;
}

.main {
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 24px 100px;
}

.domain-block {
    margin-bottom: 64px;
}

.domain-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.domain-number {
    font-family: 'Playfair Display', serif;
    font-size: 42px;
    color: var(--line);
    font-weight: 400;
    line-height: 1;
    min-width: 48px;
}

.domain-info {
    flex: 1;
}

.domain-name {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 2px;
}

.domain-subtitle {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.schema-block {
    margin-bottom: 40px;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.schema-header {
    padding: 16px 24px;
    background: var(--cream);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
}

.schema-badge {
    width: 28px;
    height: 28px;
    background: var(--rust);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.schema-name {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 600;
}

.schema-desc {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
    margin-left: auto;
    text-align: right;
    max-width: 280px;
    line-height: 1.4;
}

.questions {
    padding: 8px 0;
}

.question-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(212, 206, 192, 0.4);
    transition: background 0.15s;
}

.question-row:last-child {
    border-bottom: none;
}

.question-row:hover {
    background: rgba(196, 151, 58, 0.04);
}

.question-text {
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
}

.rating-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.rating-group input[type="radio"] {
    display: none;
}

.rating-group label {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.rating-group label:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.rating-group input[type="radio"]:checked+label {
    background: var(--rust);
    border-color: var(--rust);
    color: white;
}

.progress-bar-wrap {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--ink);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar-track {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 12px;
    color: rgba(245, 240, 232, 0.6);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

.submit-wrap {
    text-align: center;
    padding: 40px 0 20px;
}

.submit-btn {
    background: var(--rust);
    color: white;
    border: none;
    padding: 16px 48px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.submit-btn:hover {
    background: #a04535;
    transform: translateY(-1px);
}

.submit-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 12px;
}

@media (max-width: 600px) {
    .cover {
        padding: 48px 24px 40px;
    }

    .schema-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .schema-desc {
        margin-left: 0;
        text-align: left;
    }

    .question-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .rating-group label {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .domain-number {
        font-size: 30px;
    }
}

/* === RESULTS & AI STYLES === */

.results-cover {
    background: var(--ink);
    color: var(--paper);
    padding: 72px 60px 56px;
    position: relative;
    overflow: hidden;
}

.results-cover::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 350px;
    height: 350px;
    border-radius: 50%;
    border: 1px solid rgba(196, 151, 58, 0.18);
}

.results-cover-inner {
    max-width: 760px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.results-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(32px, 4vw, 50px);
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: 16px;
}

.results-title em {
    font-style: italic;
    color: var(--gold);
}

.results-intro {
    font-size: 14px;
    color: rgba(245, 240, 232, 0.65);
    line-height: 1.75;
    max-width: 580px;
    margin-bottom: 36px;
}

.summary-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px 24px;
    min-width: 140px;
}

.stat-val {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    font-weight: 400;
    color: var(--gold);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: rgba(245, 240, 232, 0.5);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.results-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 56px 24px 100px;
}

.results-section-title {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-row {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 300;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.leg-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.bars-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: 200px 1fr 40px;
    align-items: center;
    gap: 12px;
}

.bar-label {
    font-size: 13px;
    color: var(--ink);
    text-align: right;
    line-height: 1.3;
}

.bar-label small {
    display: block;
    font-size: 10px;
    color: var(--muted);
    margin-top: 1px;
}

.bar-track {
    height: 24px;
    background: var(--cream);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px 4px 0 0;
}

/* Reference line at 4.0 */
.bar-track::after {
    content: '';
    position: absolute;
    left: calc(50% * (3/5));
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: rgba(139, 58, 42, 0.3);
}

.bar-score {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    text-align: left;
}

.domain-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.domain-bar-row {
    background: var(--white);
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.domain-bar-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.domain-bar-name {
    font-family: 'Playfair Display', serif;
    font-size: 15px;
    font-weight: 600;
}

.domain-bar-score {
    font-size: 20px;
    font-family: 'Playfair Display', serif;
    color: var(--rust);
}

.domain-bar-track {
    height: 10px;
    background: var(--cream);
    border-radius: 6px;
    overflow: hidden;
}

.domain-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.top-schemas {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-schema-card {
    background: var(--white);
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: grid;
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    gap: 16px;
    border-left: 4px solid var(--rust);
}

.top-schema-card.elevated {
    border-left-color: #c4703a;
}

.top-schema-card.high {
    border-left-color: #8b1a1a;
}

.top-rank {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: var(--line);
    font-weight: 400;
    text-align: center;
}

.top-schema-name {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 3px;
}

.top-schema-desc {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
    line-height: 1.4;
}

.top-schema-domain {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.top-score-badge {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 400;
    min-width: 48px;
    text-align: center;
}

.disclaimer-box {
    margin-top: 56px;
    background: var(--cream);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px 24px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.65;
}

.disclaimer-box strong {
    color: var(--ink);
}

/* Unanswered highlight */
.unanswered-highlight .question-row {
    animation: pulse-row 1.2s ease;
}

@keyframes pulse-row {

    0%,
    100% {
        background: transparent
    }

    50% {
        background: rgba(139, 58, 42, 0.08)
    }
}

@media (max-width: 600px) {
    .results-cover {
        padding: 48px 24px 40px;
    }

    .bar-row {
        grid-template-columns: 130px 1fr 36px;
    }

    .bar-label {
        font-size: 11px;
    }

    .top-schema-card {
        grid-template-columns: 36px 1fr auto;
        gap: 10px;
    }

    .api-key-row {
        flex-direction: column;
    }

    .api-key-field {
        min-width: 100%;
    }
}

/* AI Evaluation Section */
.ai-eval-section {
    margin-top: 16px;
}

.ai-eval-intro {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 24px;
}

.api-key-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.api-key-field {
    flex: 1;
    min-width: 280px;
}

.api-key-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.api-input-wrap {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.api-input-wrap:focus-within {
    border-color: var(--gold);
}

.api-input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 14px;
    font-family: 'DM Sans', monospace;
    font-size: 14px;
    background: transparent;
    color: var(--ink);
}

.toggle-vis-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    color: var(--muted);
    transition: color 0.15s;
}

.toggle-vis-btn:hover {
    color: var(--ink);
}

.api-key-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    font-style: italic;
}

.ai-eval-btn {
    white-space: nowrap;
    height: 46px;
    padding: 0 32px;
    flex-shrink: 0;
}

.ai-eval-status {
    margin-top: 16px;
    font-size: 13px;
    color: var(--muted);
    min-height: 20px;
}

.ai-eval-status.error {
    color: #8b3a2a;
}

.ai-eval-status .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--line);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

.ai-eval-result {
    margin-top: 24px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid var(--line);
}

.eval-header {
    background: var(--ink);
    color: var(--paper);
    padding: 24px 28px;
}

.eval-header-label {
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

.eval-header-title {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 400;
}

.eval-body {
    padding: 28px;
}

.eval-body h3 {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin: 24px 0 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.eval-body h3:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.eval-body p {
    font-size: 14px;
    line-height: 1.75;
    color: #3a3530;
    margin-bottom: 12px;
}

.eval-body ul,
.eval-body ol {
    margin: 8px 0 16px 20px;
    font-size: 14px;
    line-height: 1.75;
    color: #3a3530;
}

.eval-body li {
    margin-bottom: 6px;
}

.eval-body strong {
    color: var(--ink);
    font-weight: 500;
}

.eval-body em {
    color: var(--rust);
    font-style: italic;
}

.eval-footer {
    padding: 16px 28px;
    background: var(--cream);
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
    line-height: 1.6;
}

/* Follow-Up Questions */
.diff-dx-intro {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 20px;
}

.diff-dx-questions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diff-dx-category {
    margin-bottom: 8px;
}

.diff-dx-category-header {
    font-family: 'Playfair Display', serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    padding: 10px 0 8px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.diff-dx-cat-badge {
    width: 24px;
    height: 24px;
    background: var(--rust);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'DM Sans', sans-serif;
}

.diff-dx-q-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 20px;
    transition: border-color 0.2s;
}

.diff-dx-q-card.answered {
    border-color: rgba(196, 151, 58, 0.4);
}

.diff-dx-q-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
    margin-bottom: 12px;
}

.diff-dx-q-context {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 10px;
}

/* Follow-up answer area with toggle */
.diff-dx-answer-area {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

.diff-dx-answer-area .diff-dx-freetext-wrap {
    flex: 1 1 100%;
    margin-top: 0;
}

.freetext-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    align-self: center;
}

.freetext-toggle:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.freetext-toggle.active {
    background: var(--gold);
    border-color: var(--gold);
    color: white;
}

.diff-dx-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.diff-dx-options input[type="radio"] {
    display: none;
}

.diff-dx-options label {
    padding: 7px 16px;
    border: 1.5px solid var(--line);
    border-radius: 20px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.diff-dx-options label:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.diff-dx-options input[type="radio"]:checked+label {
    background: var(--rust);
    border-color: var(--rust);
    color: white;
}

.diff-dx-progress-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.diff-dx-progress-text {
    font-size: 13px;
    color: var(--muted);
}

/* Round separator for follow-up questions */
.diff-dx-round-separator {
    text-align: center;
    margin: 28px 0 20px;
    position: relative;
}

.diff-dx-round-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--line);
}

.diff-dx-round-separator span {
    position: relative;
    background: var(--paper);
    padding: 0 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Freetext question input */
.diff-dx-freetext-wrap {
    margin-top: 4px;
}

.diff-dx-freetext {
    width: 100%;
    min-height: 80px;
    padding: 12px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: 6px;
    resize: vertical;
    transition: border-color 0.2s;
}

.diff-dx-freetext:focus {
    outline: none;
    border-color: var(--gold);
}

.diff-dx-freetext::placeholder {
    color: var(--muted);
    font-style: italic;
}

/* Diagnostic Impressions Result */
.dx-impressions-header {
    background: linear-gradient(135deg, #2a1a10 0%, var(--ink) 100%);
    color: var(--paper);
    padding: 28px;
}

.dx-impressions-header .eval-header-label {
    color: #e8c97a;
}
