:root {
    --pico-font-family: 'IBM Plex Sans', sans-serif;
    --pico-background-color: #0b1020;
    --pico-card-background-color: rgba(12, 18, 36, 0.92);
    --pico-card-sectioning-background-color: rgba(15, 22, 42, 0.96);
    --pico-primary: #79d6ff;
    --pico-primary-hover: #9be4ff;
    --pico-muted-border-color: rgba(166, 184, 210, 0.22);
    --pico-muted-color: #8fa1be;
    --pico-color: #e8f0ff;
}

body {
    background:
        radial-gradient(circle at top left, rgba(121, 214, 255, 0.16), transparent 35%),
        radial-gradient(circle at top right, rgba(109, 126, 255, 0.14), transparent 28%),
        linear-gradient(180deg, #09101e 0%, #0b1020 55%, #050814 100%);
    min-height: 100vh;
}

header, footer, main {
    position: relative;
    z-index: 1;
}

.shell {
    max-width: 1120px;
    margin: 0 auto;
}

.brand {
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.panel {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 18px;
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.panel--padded {
    padding: 2rem;
}

.panel--padded-lg {
    padding: 3.5rem 2rem;
}

.panel--stack {
    margin: 2rem 0 1.5rem;
}

.panel--stack-lg {
    margin-bottom: 1.5rem;
}

.text-dense {
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.55;
}

.page-kicker {
    color: var(--pico-primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.page-kicker--compact {
    font-size: 0.8rem;
}

.page-kicker--wide {
    margin-bottom: 0.75rem;
}

.muted {
    color: var(--pico-muted-color);
}

.title-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: baseline;
}

.section-title {
    margin-bottom: 0.5rem;
}

.hero-copy {
    max-width: 760px;
}

.action-row,
.hero-actions,
.export-actions,
.editor-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-actions {
    margin-top: 1.5rem;
}

.grid-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.metric-card strong {
    display: block;
    margin-bottom: 0.75rem;
}

.metric-card p {
    margin: 0;
}

.form-note {
    margin-top: 1rem;
    margin-bottom: 0;
}

.editor-shell {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: stretch;
    min-height: calc(100vh - 12rem);
}

.editor-pane {
    min-width: 0;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 18px;
    background: var(--pico-card-background-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.editor-pane--pdf {
    flex: 3;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-pane--form {
    flex: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-pane__header {
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}

.editor-pane__body {
    padding: 1.25rem 1.5rem 1.5rem;
    overflow: auto;
    min-height: 0;
}

.editor-pane__body--flush {
    padding: 0;
}

.pdf-frame {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 17rem);
    border: 0;
}

.response-shell {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.response-head,
.response-form {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 18px;
    background: var(--pico-card-background-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.response-head {
    padding: 1.5rem 2rem;
}

.response-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.response-submit {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.response-submit__hint {
    margin: 0;
    font-size: 0.9rem;
    color: var(--pico-muted-color);
}

.response-submit button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.ai-analysis {
    padding: 1.5rem 2rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 18px;
    background: var(--pico-card-background-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-analysis__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.ai-analysis__header h3 {
    margin: 0;
}

.ai-analysis__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--pico-muted-border-color);
    background: rgba(255, 255, 255, 0.02);
    white-space: nowrap;
    cursor: pointer;
}

.ai-analysis__body {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--pico-color);
    max-height: 26rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--pico-muted-border-color) transparent;
}

.ai-analysis__body::-webkit-scrollbar {
    width: 8px;
}

.ai-analysis__body::-webkit-scrollbar-thumb {
    background: var(--pico-muted-border-color);
    border-radius: 999px;
}

.ai-analysis__body p {
    margin: 0 0 0.75rem;
}

.ai-analysis__note {
    margin: 0;
    font-size: 0.9rem;
}

.ai-analysis__loading {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-analysis__loading p {
    margin: 0;
    color: var(--pico-muted-color);
}

.ai-analysis-preview {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-analysis-preview h3 {
    margin: 0;
}

/* HTMX loading indicator (hidden by default, shown while a request runs) */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline;
}

.htmx-request.htmx-indicator {
    display: inline;
}

.upload-indicator {
    color: var(--pico-muted-color);
    font-size: 0.9rem;
    margin-left: 0.75rem;
}

.question-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid var(--pico-muted-border-color);
    background: rgba(255, 255, 255, 0.02);
}

.question-card__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.question-card__eyebrow {
    margin: 0 0 0.35rem;
    color: var(--pico-primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
}

.question-card__title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
}

.question-card__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--pico-muted-border-color);
    background: rgba(255, 255, 255, 0.02);
    white-space: nowrap;
}

.question-card__panes {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: stretch;
}

.question-card__pane {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 14px;
    padding: 1rem;
    background: rgba(7, 11, 22, 0.28);
}

.question-card__pane--single {
    flex: 1 1 100%;
}

.question-card--single .question-card__panes {
    gap: 0;
}

.question-card--single .question-card__pane--client {
    display: none;
}

.question-card__pane label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.75rem;
}

.question-card__pane textarea {
    margin-bottom: 0;
    min-height: 10rem;
}

.question-card__pane textarea.is-invalid {
    border-color: #ff7b7b;
    box-shadow: 0 0 0 1px rgba(255, 123, 123, 0.55);
    background: rgba(255, 123, 123, 0.06);
}

.response-validation {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 123, 123, 0.6);
    background: rgba(255, 123, 123, 0.08);
    color: #ffd6d6;
    font-weight: 600;
    margin-bottom: 1rem;
}

.complete-shell {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.complete-panel {
    padding: 1.5rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 18px;
    background: var(--pico-card-background-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.meta-item {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.02);
}

.meta-item dt {
    color: var(--pico-muted-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.meta-item dd {
    margin: 0;
    font-weight: 600;
}

.response-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.response-summary__item {
    padding: 1.25rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
}

.response-summary__item h3 {
    margin: 0 0 0.75rem;
}

.response-summary__item p {
    margin: 0.3rem 0;
    white-space: pre-wrap;
}

footer.shell {
    padding: 2rem 0 3rem;
    color: var(--pico-muted-color);
}

@media (max-width: 900px) {
    .editor-shell {
        flex-direction: column;
    }

    .pdf-frame {
        min-height: 60vh;
    }

    .question-card__panes {
        flex-direction: column;
    }
}
