/* Enumerator styles — black on white, one accent, 1px borders, no shadows. */

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

:root {
    --ink: #000;
    --paper: #fff;

    /* Brand palette — editorial green + blue on warm paper. One set, no duplicates. */
    --t-green: #0D3D26;       /* dark brand green: primary fills, active states */
    --t-green-mid: #157049;   /* legible green: links, live status, focus rings */
    --t-blue: #1A4FA0;        /* brand blue: chat, highlights */
    --t-green-tint: #EAF2ED;  /* soft green: hover surfaces */
    --muted: #6B655C;         /* warm gray text */
    --t-line: #E6E2D9;        /* hairline rules */
    --t-wash: #F6F4EF;        /* warm paper wash: inset panels, editor question boxes */
    --error: #b00020;

    /* Internal-surface amber: debug panels here, and the django-admin
       theme (survey/assets/css/admin.css) mirrors these values. */
    --t-amber: #C77D00;
    --t-amber-ink: #8A5A00;
    --t-cream: #FFF7E0;

    /* Semantic aliases so existing rules keep reading naturally */
    --accent: var(--t-green-tint);  /* hover surface (was yellow) */
    --go: var(--t-green-mid);       /* go / live / primary fill */
    --go-ink: #fff;
    --chat-blue: var(--t-blue);     /* chat bubbles */
    --rule: var(--ink);             /* hard card / input borders */
    --soft-rule: var(--t-line);     /* soft inner rules */
    --t-mut: var(--muted);

    /* Type system — Fraunces display, Inter body, IBM Plex Mono meta */
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html, body {
    background: var(--paper);
    color: var(--ink);
}

body {
    font-family: var(--font-body);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    background: var(--accent);
}

h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.15;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }

p { margin-bottom: 1rem; }

/* Back link */
.esco-back-link {
    display: inline-block;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
    text-decoration: none;
}

.esco-back-link:hover {
    color: var(--ink);
    text-decoration: underline;
}

/* Account dropdown menu — uses native <details>/<summary> */
.esco-menu {
    position: relative;
}

.esco-menu-trigger {
    list-style: none;
    cursor: pointer;
    padding: 0.3rem 0.7rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.esco-menu-trigger::-webkit-details-marker { display: none; }

.esco-menu[open] .esco-menu-trigger,
.esco-menu-trigger:hover {
    background: var(--accent);
}

.esco-menu-caret {
    font-size: 0.7rem;
    line-height: 1;
}

.esco-menu-panel {
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    min-width: 10rem;
    background: var(--paper);
    border: 1px solid var(--ink);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.esco-menu-item {
    display: block;
    padding: 0.5rem 0.85rem;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--soft-rule);
}

.esco-menu-item:last-child {
    border-bottom: none;
}

.esco-menu-item:hover {
    background: var(--accent);
}

/* Containers */
.esco-container,
.esco-container-narrow {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

.esco-container-narrow {
    max-width: 720px;
}

/* Cards = simple line boxes */
.esco-card {
    background: var(--paper);
    border: 1px solid var(--rule);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.esco-card-compact { padding: 1rem; }

.esco-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.esco-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Buttons — plain HTML feel, hard borders, no shadows */
.esco-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--ink);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    border-radius: 0;
}

.esco-btn:hover {
    background: var(--accent);
    color: var(--ink);
}

.esco-btn-primary {
    background: var(--go);
    color: var(--go-ink);
    border-color: var(--ink);
}

.esco-btn-primary:hover {
    background: var(--t-green);
    color: var(--paper);
}

.esco-btn-secondary,
.esco-btn-outline,
.esco-btn-light,
.esco-btn-light-outline {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--ink);
}

.esco-btn-secondary:hover,
.esco-btn-outline:hover,
.esco-btn-light:hover,
.esco-btn-light-outline:hover {
    background: var(--accent);
}

.esco-btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.875rem;
}

.esco-btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1.05rem;
}

/* Form controls — plain HTML controls, just bordered */
.esco-form-group {
    margin-bottom: 1.25rem;
}

.esco-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.esco-input,
.esco-textarea,
.esco-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: 0;
}

.esco-input:focus,
.esco-textarea:focus,
.esco-select:focus {
    outline: 2px solid var(--t-green-mid);
    outline-offset: -1px;
}

.esco-textarea {
    resize: vertical;
    min-height: 8rem;
}

.esco-input:disabled,
.esco-textarea:disabled,
.esco-select:disabled {
    background: #f3f3f3;
    color: var(--muted);
    cursor: not-allowed;
}

.esco-textarea-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.esco-textarea-row .esco-textarea {
    flex: 1 1 auto;
    min-width: 0;
}

.esco-textarea-row .esco-btn {
    flex: 0 0 auto;
}

/* Messages */
.esco-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--ink);
    background: var(--paper);
}

.esco-message-success {
    border-color: var(--t-green-mid);
    background: var(--t-green-tint);
}

.esco-message-error {
    border-color: var(--error);
    color: var(--error);
}

/* Misc components */
.esco-metric {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

.esco-metric-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Utility classes */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-6 { margin-bottom: 3rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium   { font-weight: 500; }

.text-sm  { font-size: 0.875rem; }
.text-base{ font-size: 1rem; }
.text-lg  { font-size: 1.125rem; }
.text-xl  { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }

.text-forest { color: var(--ink); }
.text-sage   { color: var(--muted); }
.text-gold   { color: var(--ink); }
.text-white  { color: var(--paper); }
.text-danger { color: var(--error); }

/* Shared website page styles */
.esco-google-icon {
    margin-right: 8px;
    vertical-align: middle;
    display: inline-block;
}

/* Round and left-aligned so Google's flat letter-avatars read as a
   deliberate avatar rather than an unstyled image block. */
.esco-profile-picture {
    width: 56px;
    height: 56px;
    display: block;
    border-radius: 50%;
    border: 1px solid var(--ink);
}

.esco-info-panel {
    padding: 1rem;
    border: 1px solid var(--soft-rule);
}

.esco-info-grid {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.esco-info-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--soft-rule);
}

.esco-section { margin-bottom: 1.5rem; }
.esco-heading-stack { margin-bottom: 1.5rem; }
.esco-page-title { margin-bottom: 0.25rem; }

.esco-section-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.04em;
    padding-bottom: 0.25rem;
}

.esco-draft-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.esco-results-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.esco-results-heading .esco-section-title,
.esco-results-heading .esco-segmented {
    margin-bottom: 0;
}

/* In-progress results banner: the poll is still fielding, numbers will move. */
.esco-preview-note {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px dashed var(--ink);
    color: var(--muted);
    font-size: 0.9rem;
}

.esco-subtle-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.esco-prewrap {
    white-space: pre-wrap;
}

.esco-inline-detail {
    margin-left: 0.5rem;
    color: var(--muted);
}

.esco-action-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 1rem;
}

.esco-action-bar form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin: 0;
}

/* Launch tier picker — selectable cards, one per tier. The native radio is
   hidden; the whole card is the target and the checked state carries the
   green accent. Takes the full row so the submit button drops below it. */
.esco-tier-options {
    flex: 1 1 100%;
    min-width: 0;
    border: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.esco-tier-options legend {
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}

/* A form holding the tier picker spans the container, so the cards share
   a right edge with the Launch button on the row below it. */
.esco-action-bar form:has(.esco-tier-options) {
    flex: 1 1 100%;
}

.esco-tier-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.esco-tier-option {
    display: block;
    padding: 1rem 1.1rem;
    border: 1px solid var(--ink);
    cursor: pointer;
    background: var(--paper);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

.esco-tier-option:hover {
    background: var(--accent);
}

/* Hide the native control but keep it in the a11y tree / focusable. */
.esco-tier-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.esco-tier-option:has(input:checked) {
    border-color: var(--go);
    background: var(--t-green-tint);
    box-shadow: inset 0 0 0 1px var(--go);
}

.esco-tier-option:has(input:focus-visible) {
    outline: 2px solid var(--t-green-mid);
    outline-offset: 2px;
}

.esco-tier-label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.esco-tier-blurb {
    display: block;
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Segmented control — a view switch, not an action */
.esco-segmented {
    display: inline-flex;
    border: 1px solid var(--ink);
    margin-bottom: 0.75rem;
}

.esco-segment {
    padding: 0.3rem 0.9rem;
    font-size: 0.875rem;
    color: var(--ink);
    text-decoration: none;
}

.esco-segment + .esco-segment {
    border-left: 1px solid var(--ink);
}

.esco-segment:hover {
    background: var(--accent);
}

.esco-segment-active {
    background: var(--t-green);
    color: var(--paper);
    font-weight: 600;
}

/* Pulse status / list cards */
.esco-status-card {
    padding: 0.75rem 1rem;
    border: 1px solid var(--ink);
}

.esco-status-card-live {
    background: var(--go);
    color: var(--go-ink);
    border-color: var(--ink);
}

.esco-status-card-live .esco-inline-detail {
    color: var(--go-ink);
}

.esco-status-card-filled {
    background: var(--paper);
}

.esco-poll-list,
.esco-poll-preview,
.esco-poll-results,
.esco-poll-bar-list {
    display: grid;
}

.esco-poll-list {
    gap: 0.5rem;
}

.esco-poll-list-item,
.esco-poll-preview-card,
.esco-poll-result-card {
    display: block;
    padding: 0.85rem 1rem;
    border: 1px solid var(--ink);
    text-decoration: none;
    color: inherit;
    background: var(--paper);
    border-radius: 0;
    margin-top: 1rem;
}

.esco-poll-list-item:hover {
    background: var(--accent);
}

.esco-poll-list-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.esco-poll-list-title,
.esco-poll-question-title,
.esco-poll-result-title {
    font-weight: 700;
}

.esco-poll-list-meta,
.esco-poll-result-meta,
.esco-empty-state {
    color: var(--muted);
}

.esco-poll-list-meta {
    font-size: 0.9rem;
}

.esco-pill {
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    border: 1px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
}

.esco-pill-live {
    background: var(--go);
    color: var(--go-ink);
    border-color: var(--ink);
}

.esco-pill-draft {
    background: var(--paper);
}

.esco-pill-complete {
    background: var(--t-green);
    color: var(--paper);
    border-color: var(--ink);
}

.esco-pill-failed {
    background: var(--paper);
    color: var(--error);
    border-color: var(--error);
}

.esco-pill-preview {
    background: var(--paper);
    color: var(--ink);
    text-transform: uppercase;
}

.esco-poll-preview {
    gap: 1.25rem;
}

.esco-poll-preview-card,
.esco-poll-result-card {
    padding: 1rem 1.1rem;
}

.esco-poll-preview-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.esco-poll-preview-text {
    margin-bottom: 1rem;
}

.esco-poll-question-list {
    display: grid;
    gap: 0.75rem;
}

.esco-poll-question {
    padding: 0.75rem;
    border: 1px solid var(--soft-rule);
}

.esco-poll-question-title {
    margin-bottom: 0.5rem;
}

.esco-chat-monitor-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.esco-chat-session-list {
    display: grid;
    gap: 0.75rem;
}

.esco-chat-session-item {
    display: block;
    padding: 1rem;
    border: 1px solid var(--ink);
    color: inherit;
    text-decoration: none;
}

.esco-chat-session-item:hover {
    background: var(--accent);
}

.esco-chat-session-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.esco-chat-session-title {
    font-weight: 700;
}

.esco-chat-session-preview {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.esco-chat-demographic-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.esco-chat-demographic-chip {
    border: 1px solid var(--soft-rule);
    color: var(--muted);
    display: inline-block;
    font-size: 0.8rem;
    padding: 0.15rem 0.45rem;
}

.esco-chat-watch {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.esco-chat-watch-sidebar {
    border: 1px solid var(--ink);
    padding: 1rem;
}

.esco-chat-watch-main {
    min-width: 0;
}

.esco-chat-demographics {
    display: grid;
    gap: 0.55rem;
}

.esco-chat-demographic-row {
    border-bottom: 1px solid var(--soft-rule);
    display: grid;
    gap: 0.15rem;
    padding-bottom: 0.55rem;
}

.esco-chat-demographic-label {
    color: var(--muted);
    font-size: 0.8rem;
}

.esco-chat-demographic-value {
    font-weight: 600;
}

.esco-chat-transcript {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    padding: 1rem;
}

.esco-chat-message {
    display: flex;
    max-width: 76%;
}

.esco-chat-message-assistant {
    align-self: flex-start;
}

.esco-chat-message-respondent {
    align-self: flex-end;
}

.esco-chat-bubble {
    background: var(--paper);
    border: 1px solid transparent;
    border-radius: 1.2rem;
    line-height: 1.4;
    padding: 0.6rem 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.esco-chat-message-assistant .esco-chat-bubble {
    background: #ebebf0;
    border-bottom-left-radius: 0.35rem;
}

.esco-chat-message-respondent .esco-chat-bubble {
    background: var(--chat-blue);
    border-bottom-right-radius: 0.35rem;
    color: #fff;
}

.esco-chat-bubble-typing {
    min-width: 3rem;
}

/* New-chat composer: the opening message styled as a blue "sent" bubble */
.esco-chat-compose {
    display: flex;
    justify-content: flex-end;
    margin: 1.25rem 0;
}

.esco-chat-bubble-compose {
    background: var(--chat-blue);
    border-bottom-right-radius: 0.35rem;
    color: #fff;
    max-width: 88%;
    white-space: normal;
    width: 100%;
}

.esco-chat-compose-input {
    display: block;
    width: 100%;
    height: 1.4em;
    min-height: 1.4em;
    background: transparent;
    border: 0;
    color: #fff;
    font: inherit;
    line-height: 1.4;
    padding: 0;
    resize: none;
    overflow: hidden;
}

.esco-chat-compose-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.esco-chat-compose-input:focus {
    outline: none;
}

.esco-chat-typing-code {
    align-items: center;
    display: inline-flex;
    font-family: var(--font-family-monospace, monospace);
    font-size: 0.9em;
    gap: 0.15rem;
    opacity: 0.7;
}

.esco-chat-typing-code-cursor {
    animation: esco-chat-typing-cursor 1s step-end infinite;
    background: currentColor;
    display: inline-block;
    height: 1em;
    width: 0.5em;
}

@keyframes esco-chat-typing-cursor {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

.esco-choice-list {
    display: grid;
    gap: 0.3rem;
}

.esco-choice-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Preview images. Capped rather than full-bleed: the preview is a summary of
   the instrument, not a facsimile of the respondent's screen. */
.esco-poll-preview-image {
    display: block;
    max-width: min(100%, 320px);
    height: auto;
    margin: 0.5rem 0 1rem;
    border: 1px solid var(--soft-rule);
}

.esco-choice-image {
    max-width: 96px;
    height: auto;
    border: 1px solid var(--soft-rule);
}

.esco-preview-input {
    padding: 0.5rem 0.6rem;
}

.esco-poll-results {
    gap: 1rem;
}

.esco-poll-result-title {
    margin-bottom: 0.25rem;
}

.esco-poll-result-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    line-height: 1.25;
}

.esco-poll-result-meta {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Card header: title/meta on the left, the per-question copy button on the
   right, kept clear of the ledger columns below. */
.esco-poll-result-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.esco-poll-copy-btn {
    flex-shrink: 0;
}

/* Ledger-style results table: a header row of column labels, then one grid
   row per option sharing the same column tracks, so N/% line up cleanly. */
.esco-poll-bar-list,
.esco-poll-ledger-header {
    --ledger-cols: minmax(6rem, 14rem) 1fr 2.5rem 3.25rem;
}

/* Modeled (MRP) results have no raw N per row, so the ledger drops that column. */
.esco-poll-no-n {
    --ledger-cols: minmax(6rem, 14rem) 1fr 3.25rem;
}

.esco-poll-ledger-header {
    display: grid;
    grid-template-columns: var(--ledger-cols);
    gap: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--ink);
}

.esco-poll-ledger-n,
.esco-poll-ledger-pct {
    text-align: right;
}

.esco-poll-bar-list {
    gap: 0;
}

.esco-poll-bar-row {
    display: grid;
    grid-template-columns: var(--ledger-cols);
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--t-line);
}

.esco-poll-bar-list .esco-poll-bar-row:last-child {
    border-bottom: none;
}

.esco-poll-bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.esco-poll-bar-row-lead .esco-poll-bar-label {
    font-weight: 700;
}

.esco-poll-bar-track {
    background: var(--t-green-tint);
    height: 0.7rem;
    position: relative;
    overflow: hidden;
}

.esco-poll-bar-fill {
    background: var(--t-green-mid);
    opacity: 0.55;
    height: 100%;
}

.esco-poll-bar-row-lead .esco-poll-bar-fill {
    background: var(--t-green);
    opacity: 1;
}

.esco-poll-bar-n {
    text-align: right;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.esco-poll-bar-pct {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.esco-poll-result-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--ink);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.esco-poll-result-brand {
    color: var(--t-green);
    font-weight: 700;
}

.esco-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.esco-results-summary {
    cursor: pointer;
}

/* Demographic crosstabs — one table per dimension inside a result card. */
.esco-poll-crosstabs {
    margin-top: 0.9rem;
}

.esco-crosstab {
    margin-top: 0.9rem;
}

.esco-crosstab-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.esco-crosstab-scroll {
    overflow-x: auto;
}

/* Plain data table (e.g. the credits history). */
.esco-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

.esco-table th,
.esco-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--t-line);
    text-align: left;
}

.esco-table thead th {
    font-weight: 700;
}

.esco-crosstab-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

.esco-crosstab-table th,
.esco-crosstab-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--t-line);
    text-align: right;
    white-space: nowrap;
}

.esco-crosstab-table thead th {
    font-weight: 700;
    vertical-align: bottom;
}

.esco-crosstab-table tbody th {
    text-align: left;
    font-weight: 400;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The national comparison column stands slightly apart. */
.esco-crosstab-table th:nth-child(2),
.esco-crosstab-table td:nth-child(2) {
    border-right: 1px solid var(--t-line);
}

.esco-crosstab-n {
    display: block;
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--muted);
}

.esco-crosstab-note {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.esco-results-values {
    margin-top: 0.5rem;
    padding-left: 1.25rem;
    display: grid;
    gap: 0.3rem;
}

.esco-result-value {
    white-space: pre-wrap;
}

/* Pulse loading — replaces the dot grid with a plain blinking text block */
.esco-poll-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    text-align: center;
}

/* Animated bar chart loader — mirrors the wordmark logo:
   four rounded bars rising left to right, three green + one blue. */
.esco-loader-chart {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 7px;
    height: 96px;
}

.esco-loader-bar {
    display: block;
    width: 18px;
    border-radius: 3px;
    background: var(--t-green);
    height: var(--lo);
    animation: esco-loader-jitter var(--dur) ease-in-out infinite;
    animation-delay: var(--delay);
}

/* Each bar wanders within its own low/high band, with the band climbing
   left to right so the resting shape still reads as an ascending chart.
   The per-bar durations are deliberately non-harmonic and the start
   offsets (negative delays) are staggered, so the bars keep drifting out
   of phase and the whole thing never settles into an obvious loop —
   giving it a live, jittery, "numbers coming in" feel. */
.esco-loader-bar-1 { --lo: 22%; --hi: 54%; --dur: 2.9s; --delay: -0.5s; }
.esco-loader-bar-2 { --lo: 36%; --hi: 70%; --dur: 3.7s; --delay: -1.8s; }
.esco-loader-bar-3 { --lo: 52%; --hi: 90%; --dur: 3.1s; --delay: -1.1s; }
.esco-loader-bar-4 { --lo: 68%; --hi: 100%; --dur: 4.3s; --delay: -3.0s; background: var(--t-blue); }

/* Irregular stops (not a clean sine) so each cycle looks like an
   unpredictable tick up/down rather than a smooth breathing pulse.
   Heights interpolate across each bar's own --lo/--hi band. */
@keyframes esco-loader-jitter {
    0%   { height: calc(var(--lo) + (var(--hi) - var(--lo)) * 0.35); }
    12%  { height: var(--hi); }
    24%  { height: calc(var(--lo) + (var(--hi) - var(--lo)) * 0.48); }
    37%  { height: var(--lo); }
    49%  { height: calc(var(--lo) + (var(--hi) - var(--lo)) * 0.88); }
    61%  { height: calc(var(--lo) + (var(--hi) - var(--lo)) * 0.18); }
    73%  { height: calc(var(--lo) + (var(--hi) - var(--lo)) * 0.66); }
    86%  { height: var(--hi); }
    100% { height: calc(var(--lo) + (var(--hi) - var(--lo)) * 0.35); }
}

.esco-poll-loading-status {
    color: var(--muted);
    font-size: 0.9rem;
    letter-spacing: 0.08em;
}

/* Splash page — homepage hero */
.pulse-splash {
    max-width: 720px;
    margin: 0 auto;
    padding: 4rem 1.25rem;
}

.pulse-splash h1 {
    font-size: 2.75rem;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.pulse-splash .tagline {
    font-size: 1.15rem;
    margin-bottom: 2rem;
    color: var(--ink);
}

.pulse-splash form {
    display: grid;
    gap: 0.75rem;
}

.pulse-splash textarea {
    min-height: 10rem;
    font-size: 1rem;
}

.pulse-splash .splash-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pulse-splash .splash-hint {
    color: var(--muted);
    font-size: 0.9rem;
}

.product-splash-box {
    border: 1px solid var(--ink);
    padding: 2rem;
    background: var(--paper);
}

.product-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.product-choice {
    display: grid;
    gap: 0.35rem;
    min-height: 4rem;
    padding: 1rem;
    border: 1px solid var(--ink);
    background: #f0f0f0;
    color: var(--ink);
    text-decoration: none;
    align-content: space-between;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.product-choice:hover {
    background: var(--accent);
}

.product-choice-name {
    font-size: 1.5rem;
    line-height: 1.1;
    font-weight: 700;
}

.product-choice-description {
    color: var(--muted);
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 768px) {
    .esco-header-content {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .esco-header-nav,
    .esco-header-nav-top {
        width: 100%;
        justify-content: flex-start;
    }

    .esco-card { padding: 1.25rem; }

    .esco-container,
    .esco-container-narrow {
        padding: 1.5rem 1rem;
    }

    .esco-action-bar,
    .esco-action-bar form,
    .esco-results-heading,
    .esco-poll-list-row,
    .esco-textarea-row {
        flex-direction: column;
        align-items: stretch;
    }

    .esco-textarea-row .esco-btn {
        width: 100%;
    }

    .esco-pill { align-self: flex-start; }

    .esco-poll-ledger-header {
        display: none;
    }

    .esco-poll-bar-row {
        grid-template-columns: 1fr auto auto;
        grid-template-areas:
            "label label label"
            "track n pct";
        row-gap: 0.3rem;
    }

    .esco-poll-bar-label { grid-area: label; }
    .esco-poll-bar-track { grid-area: track; }
    .esco-poll-bar-n { grid-area: n; }
    .esco-poll-bar-pct { grid-area: pct; }

    .esco-poll-no-n .esco-poll-bar-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label label"
            "track pct";
    }

    .esco-chat-monitor-stats,
    .esco-chat-watch {
        grid-template-columns: 1fr;
    }

    .esco-chat-message {
        max-width: 92%;
    }

    .esco-chat-transcript {
        min-height: 24rem;
    }

    .pulse-splash h1 { font-size: 2rem; }

    .product-splash-box {
        padding: 1.25rem;
    }

    .product-choice-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   Topline brand refresh — masthead, hero, footer
   =================================================================== */

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 28px;
}

/* ---------- masthead ---------- */
.masthead {
    border-bottom: 2px solid var(--ink);
    background: var(--paper);
}

.masthead .mh-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-top: 18px;
    padding-bottom: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: var(--ink);
}

.logo:hover { background: transparent; }
.logo svg { display: block; }

.logo .word {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 25px;
    letter-spacing: -0.025em;
    color: var(--ink);
}

.mh-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.mh-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    padding-bottom: 2px;
}

.mh-link:hover {
    background: transparent;
    color: var(--t-green-mid);
}

.mh-link-active {
    border-bottom: 2px solid var(--ink);
}

.mh-signin {
    font-size: 14px;
    font-weight: 600;
    color: var(--t-mut);
    text-decoration: none;
}

.mh-signin:hover { background: transparent; color: var(--ink); }

/* ---------- hero ---------- */
.hero {
    text-align: center;
    padding: 60px 28px 28px;
    max-width: 900px;
    margin: 0 auto;
}

.hero .kicker {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--t-green-mid);
    margin-bottom: 26px;
}

.hero-error {
    max-width: 480px;
    margin: 0 auto 24px;
    text-align: left;
}

.fitb {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(31px, 4.7vw, 53px);
    line-height: 1.12;
    letter-spacing: -0.02em;
    margin-bottom: 0;
}

.fitb .blank {
    display: inline-block;
    position: relative;
    color: var(--t-green);
    border: none;
    border-bottom: 3px solid var(--t-green);
    padding: 0 6px 2px;
    background: none;
    font: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    text-align: inherit;
}

.fitb .blank:hover {
    color: var(--t-green-mid);
    border-bottom-color: var(--t-green-mid);
}

.askrow {
    margin-top: 32px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    justify-content: center;
}

.qfield {
    display: block;
    flex: 1 1 300px;
    max-width: 430px;
    min-width: 0;
}

.qfield textarea {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.4;
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--t-line);
    border-radius: 3px;
    background: #fff;
    outline: none;
    transition: 0.15s;
    color: var(--ink);
    resize: none;
    overflow: hidden;
    display: block;
    /* Always at least two lines tall (line-height 1.4 x2 + vertical padding + borders). */
    min-height: calc(2.8em + 31px);
}

.qfield textarea:focus {
    border-color: var(--t-green);
    box-shadow: 0 0 0 3px var(--t-green-tint);
}

.ask {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    padding: 16px 26px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: 0.15s;
    flex: 0 0 auto;
}

.ask:hover { background: var(--t-green); }

.ask .price {
    font-family: var(--font-mono);
    font-size: 13px;
    opacity: 0.85;
}

.hsub {
    margin-top: 22px;
    margin-bottom: 0;
    font-size: 15px;
    color: var(--t-mut);
}

.hsub b { color: var(--ink); font-weight: 600; }

/* ---------- footer ---------- */
.topline-footer {
    max-width: 1080px;
    margin: 0 auto;
    padding: 30px 28px;
    border-top: 1px solid var(--t-line);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--t-mut);
    text-transform: uppercase;
}

.topline-footer a { color: inherit; text-decoration: none; }
.topline-footer a:hover { background: transparent; color: var(--t-green-mid); }

@media (max-width: 720px) {
    .wrap { padding: 0 18px; }
    .hero { padding: 44px 18px 24px; }
    .topline-footer { padding: 24px 18px; }

    .askrow {
        flex-direction: column;
        align-items: stretch;
    }

    .qfield {
        flex: none;
        max-width: none;
    }

    .ask {
        width: 100%;
        justify-content: center;
        padding: 18px 26px;
    }
}

/* ===================================================================
   Marketing pages — Home, How it works, Pricing, Customers, About,
   Contact. Full-width sections separated by hairline rules, content on
   the 1080px .wrap. Design handoff: docs/design/marketing-pages/.
   =================================================================== */

.mk-kicker {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.mk-intro {
    padding-top: 4rem;
    padding-bottom: 3rem;
}

.mk-narrow { max-width: 820px; }

.mk-lead {
    font-size: 1.1rem;
    color: var(--muted);
    margin-bottom: 0;
}

.mk-lead + .mk-lead { margin-top: 0.75rem; }

.mk-section { border-top: 1px solid var(--soft-rule); }

.mk-section > .wrap {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
}

.mk-section-loose > .wrap {
    padding-top: 4rem;
    padding-bottom: 4rem;
}

.mk-section h2 { margin-bottom: 2rem; }

/* Prose sections keep the tighter default heading margin. */
.mk-section-prose h2 { margin-bottom: 1rem; }

/* Card grids — step cards, principles, testimonials, tiers */
.mk-grid-2,
.mk-grid-3 {
    display: grid;
    gap: 1.5rem;
}

.mk-grid-2 { grid-template-columns: 1fr 1fr; }
.mk-grid-3 { grid-template-columns: repeat(3, 1fr); }

.mk-card {
    border: 1px solid var(--ink);
    padding: 1.5rem;
}

.mk-card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.mk-card p {
    margin: 0;
    color: var(--muted);
}

.mk-step-num {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

/* Split sections — copy on one side, a bordered panel on the other */
.mk-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3.5rem;
    align-items: center;
}

.mk-split-rev > :first-child { order: 2; }

.mk-split h2 { margin-bottom: 0.75rem; }

.mk-split p {
    margin: 0 0 0.75rem;
    color: var(--muted);
}

.mk-split p:last-child { margin-bottom: 0; }

.mk-panel {
    border: 1px solid var(--ink);
    padding: 1.5rem;
}

.mk-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
}

.mk-panel-head .mk-panel-label {
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mk-panel-q {
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Stacked value props (Why topline) */
.mk-props { display: grid; gap: 1.25rem; }

.mk-props h3 {
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}

.mk-props p {
    margin: 0;
    color: var(--muted);
}

/* Testimonial / case-study quote cards */
.mk-quote {
    margin: 0;
    border: 1px solid var(--ink);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mk-quote blockquote {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.2rem;
    line-height: 1.4;
    font-weight: 600;
}

.mk-quote figcaption {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: auto;
}

.mk-metrics {
    display: flex;
    gap: 3rem;
}

/* FAQ accordions — native details/summary, hairline separated */
.mk-faq details {
    border-top: 1px solid var(--soft-rule);
    padding: 0.9rem 0;
}

.mk-faq details:last-child {
    border-bottom: 1px solid var(--soft-rule);
}

.mk-faq summary {
    font-weight: 600;
    cursor: pointer;
}

.mk-faq p {
    margin: 0.6rem 0 0;
    color: var(--muted);
}

/* Pricing tier cards */
.mk-tier {
    border: 1px solid var(--ink);
    padding: 1.75rem;
}

/* Featured tier — the existing selected-tier treatment */
.mk-tier-featured { box-shadow: inset 0 0 0 1px var(--ink); }

.mk-tier-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.mk-tier-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--ink);
    padding: 0.15rem 0.45rem;
}

.mk-tier-price {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0.5rem 0 0.25rem;
}

.mk-tier-price .esco-metric { font-size: 2.6rem; margin: 0; }

.mk-tier-price-unit { color: var(--muted); }

.mk-tier > p {
    margin: 0 0 1.25rem;
    color: var(--muted);
}

.mk-tier ul {
    margin: 0 0 1.5rem;
    padding-left: 1.1rem;
    color: var(--muted);
    display: grid;
    gap: 0.4rem;
}

/* Worked-example ledger — mono line items */
.mk-ledger {
    border: 1px solid var(--ink);
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.mk-ledger-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--soft-rule);
}

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

/* Final CTA bands */
.mk-cta { border-top: 2px solid var(--ink); }

.mk-cta > .wrap {
    text-align: center;
    padding-top: 4rem;
    padding-bottom: 4rem;
}

.mk-cta h2 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.mk-cta p {
    color: var(--muted);
    margin: 0 0 1.5rem;
}

.mk-cta-dark {
    border-top: none;
    background: var(--t-green);
    color: var(--paper);
}

.mk-cta-dark > .wrap {
    padding-top: 4.5rem;
    padding-bottom: 4.5rem;
}

.mk-cta-dark h2 {
    color: var(--paper);
    font-size: 2.2rem;
}

.mk-cta-dark p { color: var(--t-green-tint); }

.mk-cta-dark .esco-btn {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--paper);
}

.mk-cta-dark .esco-btn:hover {
    background: var(--t-green-tint);
    border-color: var(--t-green-tint);
}

/* Contact page — info column + bordered form card */
.mk-contact {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 3.5rem;
    padding-top: 4rem;
    padding-bottom: 4rem;
}

.mk-contact-facts {
    border-top: 1px solid var(--soft-rule);
    padding-top: 1.25rem;
    display: grid;
    gap: 0.75rem;
}

.mk-contact-facts .mk-kicker { margin-bottom: 0; }

.mk-form-card {
    border: 1px solid var(--ink);
    padding: 1.75rem;
}

@media (max-width: 720px) {
    .mk-grid-2,
    .mk-grid-3,
    .mk-split,
    .mk-contact {
        grid-template-columns: 1fr;
    }

    .mk-split,
    .mk-contact {
        gap: 1.5rem;
    }

    .mk-split-rev > :first-child { order: 0; }

    .mk-intro { padding-top: 2.5rem; }

    .mk-metrics { gap: 2rem; }
}

/* ===================================================================
   Debug mode — admin-only panels. Deliberately loud (amber, dashed)
   so it's obvious these parts of the page are debug-only.
   =================================================================== */
.debug-panel {
    margin: 1rem 0;
    padding: 0.5rem 0.75rem;
    border: 2px dashed var(--t-amber);
    background: var(--t-cream);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.debug-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.debug-panel-label {
    color: var(--t-amber-ink);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.debug-panel-hide {
    border: 1px solid var(--t-amber);
    background: transparent;
    color: var(--t-amber-ink);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    cursor: pointer;
}

.debug-panel-hide:hover {
    background: var(--t-amber);
    color: #fff;
}

.debug-panel-actions {
    display: flex;
    gap: 0.4rem;
}

/* Collapsed impersonation banner: a small amber dot pinned out of the layout,
   so a demo screen isn't dominated by the banner but the session still reads
   as impersonated. Click restores the banner. */
.impersonation-dot-form {
    position: fixed;
    left: 0.5rem;
    bottom: 0.5rem;
    z-index: 50;
}

.impersonation-dot {
    display: block;
    width: 0.6rem;
    height: 0.6rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--t-amber);
    opacity: 0.5;
    cursor: pointer;
}

.impersonation-dot:hover,
.impersonation-dot:focus-visible {
    opacity: 1;
}

.debug-panel-links {
    margin: 0.35rem 0 0;
    padding: 0;
    list-style: none;
}

.debug-panel-links a {
    color: var(--t-amber-ink);
}

.debug-panel-note {
    margin: 0.5rem 0;
}

/* Job/status tables inside a debug panel. Narrow screens scroll the table
   rather than the page. */
.debug-panel-scroll {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.debug-panel-table {
    border-collapse: collapse;
    font-size: 0.75rem;
    white-space: nowrap;
}

.debug-panel-table caption {
    text-align: left;
    color: var(--t-amber-ink);
    padding-bottom: 0.2rem;
}

.debug-panel-table th,
.debug-panel-table td {
    text-align: left;
    padding: 0.1rem 0.6rem 0.1rem 0;
}

.debug-panel-table th {
    color: var(--t-amber-ink);
    font-weight: 600;
}

.debug-panel-table a {
    color: var(--t-amber-ink);
}

/* The debug toggle in the account dropdown: a form button styled to match
   the surrounding <a> menu items. */
.esco-menu-item-button {
    width: 100%;
    text-align: left;
    background: none;
    font: inherit;
    cursor: pointer;
    border: none;
    border-bottom: 1px solid var(--soft-rule);
}

/* ===================================================================
   Advanced poll editor — a single-column visual editor with a
   collapsible code panel. Same brand rules (black on white, one green
   accent, hard 1px borders, no shadows) but denser and control-heavy.
   =================================================================== */

.esco-adv {
    position: relative; /* anchors the review margin rail */
    max-width: 46rem;
    margin: 0 auto;
    padding: 0 1rem 4rem;
    color: var(--ink);
}

/* top bar — sticky so the estimate and actions ride along */
.esco-adv-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--ink);
    background: var(--paper);
}
.esco-adv-bar form { display: flex; }
.esco-adv-bar-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1 1 auto;
}
.esco-adv-bar-meta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--t-green);
    white-space: nowrap;
}
.esco-adv.is-syncing .esco-adv-bar-meta { opacity: 0.5; }

.esco-adv-error {
    padding: 0.5rem 0.75rem;
    margin-top: 1rem;
    border: 1px solid var(--error);
    color: var(--error);
    background: var(--paper);
}

.esco-adv-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
}

/* collapsible code panel */
.esco-adv-code-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ink);
}
.esco-adv-code-panel[hidden] { display: none; }

.esco-adv-pane-head {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    border-bottom: 1px solid var(--soft-rule);
    background: var(--t-green-tint);
}
.esco-adv-pane-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--t-green);
    font-weight: 600;
}
.esco-adv-pane-tools { display: flex; gap: 0.4rem; }
.esco-adv-tool {
    font: inherit;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.esco-adv-tool:hover { background: var(--accent); }

.esco-adv-code {
    flex: 1 1 auto;
    width: 100%;
    min-height: 18rem;
    max-height: 55vh;
    resize: none;
    border: 0;
    outline: none;
    padding: 0.85rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    tab-size: 2;
    color: var(--ink);
    background: var(--paper);
    white-space: pre;
    overflow: auto;
}

/* Syntax highlighting: a colored <pre> copy of the code sits behind the
   textarea, whose own text is transparent. Both carry .esco-adv-code so the
   font metrics — and therefore the two layers — line up exactly. */
.esco-adv-editor {
    position: relative;
    display: flex;
}
.esco-adv-editor textarea.esco-adv-code {
    position: relative;
    z-index: 1;
    background: transparent;
    color: transparent;
    caret-color: var(--ink);
}
.esco-adv-highlight {
    position: absolute;
    inset: 0;
    z-index: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
}
/* Color only — weight or style changes would shift glyph widths out of
   alignment with the textarea. */
.esco-adv-hl-key { color: var(--t-blue); }
.esco-adv-hl-str { color: var(--t-green-mid); }
.esco-adv-hl-num { color: var(--t-amber-ink); }
.esco-adv-hl-kw { color: var(--t-amber-ink); }
.esco-adv-hl-punc { color: var(--muted); }
.esco-adv-hl-comment { color: var(--muted); }
.esco-adv-status {
    flex: 0 0 auto;
    padding: 0.35rem 0.85rem;
    border-top: 1px solid var(--soft-rule);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
    min-height: 1.5rem;
    white-space: pre-line;
}
.esco-adv-status.is-error { color: var(--error); }
.esco-adv-status.is-ok { color: var(--t-green-mid); }

/* stale banner: code is broken, the visual editor is frozen on last-good */
.esco-adv-stale {
    border: 1px solid var(--error);
    color: var(--error);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    background: var(--paper);
}

/* the visual editor column */
.esco-adv-wysiwyg {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}
.esco-adv.is-frozen .esco-adv-wysiwyg,
.esco-adv.is-code-dirty .esco-adv-wysiwyg {
    opacity: 0.45;
    pointer-events: none;
}

.esco-adv-name-row { display: flex; flex-direction: column; gap: 0.3rem; }
.esco-adv-name-input {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
}

/* Cards: tinted header band + white body. The band goes solid green while the
   page is in edit mode, so the current mode is legible at a glance. */
.esco-adv-card {
    border: 1px solid var(--ink);
    background: var(--paper);
}
.esco-adv-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.85rem;
    background: var(--t-green-tint);
}
.esco-adv-card.is-editing .esco-adv-card-head { background: var(--t-green); }
.esco-adv-card.is-editing .esco-adv-card-label { color: var(--paper); }
.esco-adv-card-body {
    border-top: 1px solid var(--soft-rule);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    align-items: flex-start;
}
.esco-adv-card-body > * { width: 100%; }
.esco-adv-card-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--t-green);
    font-weight: 600;
    white-space: nowrap;
}
.esco-adv-page-chip {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--t-green);
    color: var(--paper);
    white-space: nowrap;
}
.esco-adv-card.is-editing .esco-adv-page-chip {
    background: var(--paper);
    color: var(--t-green);
}
.esco-adv-page-loi {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--t-green);
    white-space: nowrap;
}
.esco-adv-card.is-editing .esco-adv-page-loi { color: var(--paper); }

/* move/delete clusters sit at the right edge of their row */
.esco-adv-structure { display: inline-flex; gap: 0.25rem; margin-left: auto; }
.esco-adv-structure-row {
    display: inline-flex;
    gap: 0.5rem;
    margin-left: auto;
    align-items: center;
}
.esco-adv-structure-row .esco-adv-structure { margin-left: 0; }
.esco-adv-icon-btn {
    font: inherit;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--soft-rule);
    cursor: pointer;
}
.esco-adv-icon-btn:hover { background: var(--accent); }
.esco-adv-icon-btn:disabled { opacity: 0.35; cursor: default; background: var(--paper); }

/* read-only constructs (conditions, splits, batteries, screeners) */
.esco-adv-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
    width: auto;
}
.esco-adv-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--soft-rule);
    color: var(--t-green);
    background: var(--t-green-tint);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Edit mode: each question sits in its own washed box so questions on the
   same page read as separate units, not a run of bare inputs. */
.esco-adv-question {
    border: 1px solid var(--soft-rule);
    background: var(--t-wash);
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.esco-adv-question-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.esco-adv-question-text { min-height: 2.6rem; }

/* View mode: clean survey-preview typography, soft rules between questions. */
.esco-adv-question.is-view {
    border: 0;
    background: none;
    padding: 0;
    border-top: 1px solid var(--soft-rule);
    padding-top: 0.7rem;
    gap: 0.45rem;
}
.esco-adv-question.is-view:first-child { border-top: 0; padding-top: 0; }
.esco-adv-view-row { display: flex; align-items: baseline; gap: 0.6rem; }
.esco-adv-view-row .esco-adv-option-code { margin-left: auto; }
.esco-adv-view-q { font-weight: 600; font-size: 0.95rem; }
.esco-adv-view-intro { color: var(--muted); font-size: 0.9rem; font-style: italic; margin: 0; }
.esco-adv-view-options { display: flex; flex-direction: column; gap: 0.3rem; }
.esco-adv-view-opt {
    font-size: 0.85rem;
    display: flex;
    gap: 0.45rem;
    align-items: center;
}
.esco-adv-view-hint { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.esco-adv-type-select {
    width: auto;
    padding: 0.25rem 0.4rem;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}
.esco-adv-required {
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
}
.esco-adv-required input { width: auto; }

.esco-adv-option-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
}
/* Fixed columns (input | code+badges | delete) so stacked option inputs all
   end at the same edge no matter how long the codes or badges are. */
.esco-adv-option-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7.5rem 1.6rem;
    gap: 0.4rem;
    align-items: center;
    width: 100%;
}
/* The first grid column: the option's text input, preceded by its image
   thumbnail (when it has one) and followed by the image buttons. */
.esco-adv-option-text-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}
.esco-adv-option-text-cell .esco-input { flex: 1; min-width: 0; }

.esco-adv-option-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    overflow: hidden;
}

/* Images in the editor: thumbnails only. The customer sees them at survey
   size in Preview and in the test survey. */
.esco-adv-image {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.esco-adv-image-thumb {
    height: 2.2rem;
    width: auto;
    max-width: 4.5rem;
    object-fit: cover;
    border: 1px solid var(--soft-rule);
}
.esco-adv-view-image {
    display: block;
    max-width: min(100%, 220px);
    height: auto;
    border: 1px solid var(--soft-rule);
}
.esco-adv-option-code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.esco-adv-option-readonly {
    font-size: 0.85rem;
    color: var(--muted);
}
.esco-adv-input-sm { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
.esco-adv-code-input {
    width: 9rem;
    padding: 0.25rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}
.esco-adv-add-row { display: flex; gap: 0.5rem; }
.esco-adv-add-row .esco-adv-tool { flex: 1 1 auto; padding: 0.3rem 0.45rem; }

/* Admin-only tools on the editor page. In flow (above the editor) on
   narrow screens; a fixed column on the RIGHT edge of the viewport when
   it is wide enough. Look comes from .debug-panel. */
.esco-adv-debug .esco-adv-examples {
    width: 100%;
    margin-top: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.25rem;
    border: 1px solid var(--t-amber);
    background: var(--paper);
    color: var(--t-amber-ink);
}
/* The review rail owns the space just right of the column (its right edge
   sits ~84.6rem in on a 100rem viewport), so the fixed panel kicks in only
   once the viewport leaves it 14.75rem clear of the rail. */
@media (min-width: 100rem) {
    .esco-adv-debug {
        position: fixed;
        top: 6.5rem;
        right: 0.75rem;
        width: 14rem;
        margin: 0;
    }
}

/* Bottom action row: Test and Save/Continue live under the document. */
.esco-adv-bottom {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ink);
}

/* The "Regenerate" AI-adjust form: its own row above the bottom bar. */
.esco-adv-adjust {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.esco-adv-adjust textarea {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--ink);
    background: var(--paper);
    color: var(--ink);
    resize: vertical;
}

.esco-adv-adjust .esco-adv-tool { align-self: flex-end; }

/* Notices that must show while the code panel (and its status line) is
   closed: AI-adjust progress and outcomes, Continue refusals. */
.esco-adv-notice {
    border: 1px solid var(--ink);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    background: var(--paper);
}

.esco-adv-notice.is-error {
    border-color: var(--error);
    color: var(--error);
}

/* While an LLM edit turn runs, the document is about to be replaced: lock
   the editing surfaces so local changes can't race the worker's rewrite. */
.esco-adv.is-adjusting .esco-adv-body > :not(.esco-adv-notice),
.esco-adv.is-adjusting .esco-adv-bar .esco-adv-tool {
    pointer-events: none;
    opacity: 0.5;
}

/* Whole-document work (writing a survey from a prompt, or waiting on the
   generation a complex homepage query started) dims the page behind a
   lightbox instead: there is nothing to edit until it lands. */
.esco-adv-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgb(0 0 0 / 45%);
}

.esco-adv-overlay[hidden] {
    display: none;
}

.esco-adv-overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 30rem;
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--paper);
    border: 1px solid var(--t-line);
    border-radius: 6px;
}

.esco-adv-overlay-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* QAS review presentation. The same card renders in two homes:
   - the margin rail right of the main column (Google-Docs-comment style,
     JS-positioned to align with its question) on wide screens;
   - inline under the question on narrow screens. */
.esco-adv-review {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    cursor: pointer;
}
.esco-adv-review-rail {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 100%;
    width: 22rem;
    margin-left: 1.25rem;
}
/* With the rail up, the document cedes the page center and shifts left so
   the wider cards fit; the pair (column + rail) is centered together. */
@media (min-width: 82rem) {
    .esco-adv {
        margin-left: max(1rem, calc((100vw - 46rem - 23.25rem) / 2));
        margin-right: 0;
    }
}
.esco-adv-review-card {
    position: absolute;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--soft-rule);
    background: var(--paper);
    font-size: 0.85rem;
}
.esco-adv-review-inline {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--soft-rule);
}
@media (max-width: 81.99rem) {
    .esco-adv-review-rail { display: none; }
}
@media (min-width: 82rem) {
    .esco-adv-review-inline { display: none; }
}
.esco-adv-review-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* The question's own words identify the card; the inline card sits right
   under its question, so the quote would just repeat it. */
.esco-adv-review-quote {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.esco-adv-review-inline .esco-adv-review-quote { display: none; }

/* Hovering a card or its question links the pair; a card click scrolls. */
.esco-adv-review-card { cursor: pointer; }
.esco-adv-review-card.is-review-linked { border-color: var(--ink); }
.esco-adv-question.is-review-linked { background: var(--t-green-tint); }
.esco-adv-review-score {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--soft-rule);
    white-space: nowrap;
}
.esco-adv-review-score.is-field { color: var(--t-green); background: var(--t-green-tint); }
.esco-adv-review-score.is-minor_revisions { color: var(--t-amber-ink); }
.esco-adv-review-score.is-needs_revision,
.esco-adv-review-score.is-do_not_field { color: var(--error); border-color: var(--error); }
.esco-adv-review-stale {
    font-size: 0.75rem;
    color: var(--t-amber-ink);
}
.esco-adv-review-clean {
    font-size: 0.85rem;
    color: var(--muted);
}
.esco-adv-finding {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    font-size: 0.85rem;
}
.esco-adv-sev {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--soft-rule);
    white-space: nowrap;
    flex: 0 0 auto;
    margin-top: 0.1rem;
}
.esco-adv-sev-fatal { color: var(--error); border-color: var(--error); }
.esco-adv-sev-major { color: var(--t-amber-ink); border-color: var(--t-amber); }
.esco-adv-sev-minor { color: var(--muted); }
.esco-adv-finding-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.esco-adv-finding-fix { color: var(--muted); }
.esco-adv-finding-why {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}
.esco-adv-apply { align-self: flex-start; }

/* Collapsed cards keep just the notes (clamped); a click reveals each
   finding's fix, its explainer, and the apply button. */
.esco-adv-review:not(.is-expanded) .esco-adv-finding-note {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.esco-adv-review:not(.is-expanded) .esco-adv-finding-fix,
.esco-adv-review:not(.is-expanded) .esco-adv-finding-why,
.esco-adv-review:not(.is-expanded) .esco-adv-apply {
    display: none;
}

@media (max-width: 900px) {
    .esco-adv-bar { flex-wrap: wrap; }
}

/* Advanced editor redesign (poll_editor_redesign flag): same structure and
   JS, a friendlier "SaaS app" skin layered on top — rounded corners, more
   color and breathing room, in place of the flat hard-edged brand look. */
.esco-adv--redesign {
    --adv-radius: 0.75rem;
    max-width: 50rem;
    padding: 0 1.25rem 4rem;
    background: var(--t-wash);
}
.esco-adv--redesign .esco-adv-bar {
    top: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--t-line);
    border-radius: var(--adv-radius);
    box-shadow: 0 1px 3px rgba(13, 61, 38, 0.08);
}
.esco-adv--redesign .esco-adv-bar-title { color: var(--t-green); }
.esco-adv--redesign .esco-adv-tool,
.esco-adv--redesign .esco-adv-icon-btn {
    border-radius: 0.4rem;
}
.esco-adv--redesign .esco-adv-tool:hover { background: var(--t-green-tint); border-color: var(--t-green-mid); }

.esco-adv--redesign .esco-adv-intro {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--adv-radius);
    background: var(--t-green-tint);
    border: 1px solid var(--t-line);
}
.esco-adv--redesign .esco-adv-intro-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--t-green);
    margin-bottom: 0.25rem;
}
.esco-adv--redesign .esco-adv-intro-text {
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.5;
}

.esco-adv--redesign .esco-adv-code-panel,
.esco-adv--redesign .esco-adv-card,
.esco-adv--redesign .esco-adv-stale,
.esco-adv--redesign .esco-adv-notice,
.esco-adv--redesign .esco-adv-review-card {
    border-radius: var(--adv-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(13, 61, 38, 0.06);
}
.esco-adv--redesign .esco-adv-card {
    border-color: var(--t-line);
}
.esco-adv--redesign .esco-adv-card-head {
    border-radius: var(--adv-radius) var(--adv-radius) 0 0;
}
.esco-adv--redesign .esco-adv-card-body {
    padding: 1.1rem;
    gap: 1rem;
}
.esco-adv--redesign .esco-adv-badge {
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    background: var(--paper);
}
.esco-adv--redesign .esco-adv-page-chip {
    border-radius: 999px;
}
.esco-adv--redesign .esco-adv-adjust {
    padding: 0.85rem;
    background: var(--paper);
    border: 1px solid var(--t-line);
    border-radius: var(--adv-radius);
}
.esco-adv--redesign .esco-adv-adjust textarea {
    border-radius: 0.5rem;
}
.esco-adv--redesign .esco-btn-primary {
    border-radius: 0.5rem;
}

