/* ---------- A run of the persona agent ---------- */

.run-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.run-head h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--text-gray);
    font-size: 0.85rem;
    text-decoration: none;
}

.back-link:hover { color: var(--primary); }

.run-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 6px;
    color: var(--text-gray);
    font-size: 0.85rem;
}

.run-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-color: #F5C2C0;
    background: #FFF8F7;
}

.run-error h3 {
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.run-error p {
    color: var(--text-gray);
    font-size: 0.9rem;
}

.thinking {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 10px;
    background: var(--light-gray);
    font-size: 0.85rem;
    color: var(--text-gray);
    overflow: hidden;
}

.thinking__dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    align-self: center;
    animation: pulse 1.2s ease-in-out infinite;
}

.thinking__label {
    flex: 0 0 auto;
    font-weight: 700;
    color: var(--primary);
}

.thinking__text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;
    text-align: left;
    min-width: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1); }
}

.prompt-box--static {
    min-height: 0;
    white-space: pre-wrap;
    resize: none;
}

/* The agent's report, rendered from Markdown. */
.md {
    font-size: 0.95rem;
    line-height: 1.65;
}

.md:empty { display: none; }

.md > :first-child { margin-top: 0; }

.md h1, .md h2, .md h3, .md h4 {
    margin: 1.6em 0 0.5em;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.md h1 { font-size: 1.5rem; }
.md h2 { font-size: 1.2rem; padding-top: 1.2em; border-top: 1px solid var(--border-gray); }
.md h3 { font-size: 1.02rem; }
.md h4 { font-size: 0.95rem; }

.md p, .md ul, .md ol, .md blockquote, .md table { margin: 0.6em 0; }
.md ul, .md ol { padding-left: 1.3em; }
.md li + li { margin-top: 0.25em; }

.md blockquote {
    padding: 4px 14px;
    border-left: 3px solid var(--accent);
    color: var(--text-gray);
}

.md code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--light-gray);
    font-size: 0.85em;
}

.md table {
    display: block;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.md th, .md td {
    padding: 8px 12px;
    border: 1px solid var(--border-gray);
    text-align: left;
    vertical-align: top;
}

.md th { background: var(--light-gray); }

/* Persona cards, over the report. */
.persona-grid {
    display: grid;
    /* SA-033: at most 9 personas per run — a 3 × 3 grid. */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.persona-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
    background: var(--white);
    border: 1px solid var(--border-gray);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.persona-card__head {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.persona-card__num {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent);
}

.persona-card h3 {
    font-size: 1.08rem;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.persona-card__meta {
    color: var(--text-gray);
    font-size: 0.84rem;
}

.persona-card__summary {
    font-size: 0.92rem;
}

.persona-card__label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.persona-card__stance p {
    font-size: 0.9rem;
}

.persona-card__quote {
    margin-top: auto;
    padding-left: 12px;
    border-left: 3px solid var(--accent);
    font-style: italic;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 2px 9px;
    border: 1px solid var(--border-gray);
    border-radius: 999px;
    font-size: 0.76rem;
    color: var(--text-gray);
}

.chip b {
    font-weight: 600;
    color: var(--primary);
}

.reply .ac-input--area {
    margin-top: 4px;
}

.reply__acts {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

/* ---------- Interview with a persona (SA-003) ---------- */

.persona-card__talk {
    align-self: flex-start;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.85rem;
}

/* The conversation fills the screen and scrolls inside itself; the input stays
   put under it. */
.chat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    max-width: 1240px;
    margin: 0 auto;
    height: calc(100vh - var(--header-height) - 64px);
}

.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 24px 28px;
}

.chat-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-gray);
}

.chat-head h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.chat-head__acts {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-pick {
    width: 260px;
}

.chat-head__acts .btn {
    height: var(--ac-control-h);
    gap: 6px;
}

.chat-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 2px;
}

.chat-empty {
    margin: auto 0;
    text-align: center;
    color: var(--text-gray);
    font-size: 0.92rem;
}

.chat-empty p {
    max-width: 440px;
    margin: 0 auto 16px;
}

.chat-starters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto;
}

.starter {
    padding: 8px 14px;
    border: 1px solid var(--border-gray);
    border-radius: 999px;
    background: var(--white);
    font: inherit;
    font-size: 0.84rem;
    color: var(--primary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.starter:hover {
    border-color: var(--primary);
}

.msg {
    display: flex;
}

.msg--me { justify-content: flex-end; }

.msg__body {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.93rem;
    line-height: 1.55;
    white-space: normal;
}

.msg--me .msg__body {
    background: var(--primary);
    color: var(--white);
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.msg--them .msg__body {
    background: var(--light-gray);
    border-bottom-left-radius: 4px;
}

.msg__body > :first-child { margin-top: 0; }
.msg__body > :last-child { margin-bottom: 0; }
.msg__body p + p { margin-top: 0.6em; }
.msg__body ul, .msg__body ol { padding-left: 1.2em; margin: 0.4em 0; }

.typing {
    color: var(--text-gray);
    font-size: 0.85rem;
}

.typing::after {
    content: '…';
    display: inline-block;
    animation: pulse 1.2s ease-in-out infinite;
}

.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-gray);
}

.chat-input .ac-input--area {
    flex: 1;
    min-height: 48px;
    max-height: 200px;
    resize: none;
}

.chat-input .btn {
    padding: 12px 18px;
    font-size: 0.92rem;
    gap: 8px;
}

.chat-profile {
    padding: 22px;
    overflow-y: auto;
    font-size: 0.88rem;
}

.chat-profile__title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-gray);
    margin-bottom: 10px;
}

.chat-profile__summary {
    margin-bottom: 14px;
}

.chat-profile__section {
    margin-top: 14px;
}

.chat-profile__section ul {
    padding-left: 1.1em;
}

.chat-profile__section li + li {
    margin-top: 2px;
}

@media (max-width: 1100px) {
    .chat {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }
    .chat-main { height: calc(100vh - var(--header-height) - 48px); }
    .chat-head { flex-wrap: wrap; }
}

/* ---------- Group interview (SA-011) ---------- */

.chat--group {
    grid-template-columns: minmax(0, 1fr);
}

.btn.icon-only {
    width: var(--ac-control-h);
    padding: 0;
}

.mode-switch {
    margin: 0;
}

.mode-switch button {
    padding: 8px 14px;
}

.avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--white);
    font-size: 0.72rem;
    font-weight: 800;
}

.who {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 600;
}

.who--btn {
    padding: 3px 10px 3px 3px;
    border: 1px solid var(--border-gray);
    border-radius: 999px;
    background: var(--white);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
}

.who--btn:hover {
    border-color: var(--primary);
}

.speaker {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
    font-size: 0.82rem;
}

.speaker span {
    color: var(--text-gray);
}

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

.round + .round {
    margin-top: 10px;
}

.round__to {
    align-self: flex-end;
    margin-top: -6px;
    font-size: 0.78rem;
    color: var(--text-gray);
}

.round__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.round__divider::before,
.round__divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-gray);
}

/* Panel: one column per persona, read across. */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.answer {
    padding: 14px 16px;
    border: 1px solid var(--border-gray);
    border-radius: 12px;
    background: var(--white);
}

/* Discussion: a feed, in speaking order. */
.feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.say {
    max-width: 82%;
}

.say .answer__body {
    padding: 10px 14px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    background: var(--light-gray);
}

.answer__body {
    font-size: 0.92rem;
    line-height: 1.55;
}

.answer__body > :first-child { margin-top: 0; }
.answer__body > :last-child { margin-bottom: 0; }
.answer__body p + p { margin-top: 0.6em; }

.group-people {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border-gray);
}

.group-people + .chat-input {
    border-top: 0;
    padding-top: 10px;
}

.group-people__label {
    font-size: 0.78rem;
    color: var(--text-gray);
    margin-right: 2px;
}

.group-acts {
    display: flex;
    gap: 8px;
}

/* ---------- Dialog (book-forms controls.js dialog()) ---------- */

.ac-dialog__back {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ac-dialog {
    width: min(440px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--white);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    padding: 22px 24px 18px;
}

.ac-dialog--wide { width: min(1040px, 100%); }

.ac-dialog__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.ac-dialog__note {
    margin: 0 0 14px;
    font-size: 0.85rem;
    color: var(--text-gray);
}

.ac-dialog__error {
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    background: #FDE8E8;
    color: #B42318;
    font-size: 0.85rem;
}

.ac-dialog__foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.ac-dialog__foot .btn {
    padding: 10px 18px;
    font-size: 0.9rem;
}

