/* Email thread modal */
.thread-modal-paper {
    position: relative;
    width: min(820px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    padding: 0;
    background: linear-gradient(180deg, #fffaf6 0%, #fdf3ee 100%);
    border: 1px solid var(--paper-edge);
    border-radius: 24px;
    box-shadow: 0 40px 100px -30px rgba(146,82,106,.5);
    animation: paperUp var(--t-mid) cubic-bezier(.2,.7,.2,1) both;
    -webkit-overflow-scrolling: touch;
}
.thread-head {
    position: sticky; top: 0; z-index: 5;
    padding: 22px clamp(20px, 4vw, 36px) 18px;
    background: linear-gradient(180deg, rgba(255,250,246,.96), rgba(255,250,246,.84));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hairline-2);
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
}
.thread-head .head-left { min-width: 0; flex: 1; }
.thread-head .eyebrow { display: inline-block; margin-bottom: 6px; }
.thread-head h2 {
    margin: 0;
    font-family: 'Fraunces', serif; font-style: italic; font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    line-height: 1.1;
    color: var(--ink);
    overflow-wrap: break-word;
}
.thread-head .meta {
    margin-top: 6px;
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: .12em; text-transform: uppercase;
}
.thread-head .head-actions {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}

.thread-list {
    position: relative;
    padding: 24px clamp(16px, 3vw, 28px) 32px;
    display: flex; flex-direction: column; gap: 18px;
}
.thread-list::before {
    content: '';
    position: absolute;
    left: clamp(38px, 4.5vw, 50px); top: 40px; bottom: 40px;
    width: 1px;
    background: linear-gradient(180deg, transparent, var(--paper-edge) 18%, var(--paper-edge) 82%, transparent);
    z-index: 0;
}

.thread-msg {
    position: relative; z-index: 1;
    background: var(--paper);
    border: 1px solid var(--paper-edge);
    border-radius: 18px;
    padding: 18px 22px 20px 22px;
    box-shadow: 0 12px 28px -18px rgba(146,82,106,.28);
    display: grid;
    grid-template-columns: 40px 1fr;
    column-gap: 16px;
    row-gap: 4px;
    align-items: start;
    transition: transform var(--t-mid), box-shadow var(--t-mid);
}
.thread-msg:hover {
    box-shadow: 0 22px 40px -20px rgba(146,82,106,.35);
    transform: translateY(-1px);
}
.thread-msg.from-rania { background: linear-gradient(180deg, #fff5f7 0%, #fde9ee 100%); }
.thread-msg.from-hins  { background: linear-gradient(180deg, #fffaf6 0%, #fdf0e8 100%); }

.thread-msg .avatar {
    grid-row: span 3;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: white;
    font-family: 'Fraunces', serif; font-style: italic; font-weight: 500;
    font-size: 1rem;
    box-shadow: 0 6px 14px -4px rgba(146,82,106,.4), 0 1px 0 rgba(255,255,255,.4) inset;
}
.thread-msg.from-hins .avatar  { background: linear-gradient(135deg, #ec9bb0, var(--rose-deep)); }
.thread-msg.from-rania .avatar { background: linear-gradient(135deg, #f7c5cf, #c66e80); }

.thread-msg .lines { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.thread-msg .from-line {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 0.84rem;
}
.thread-msg .from-line .name {
    font-family: 'Fraunces', serif; font-style: italic; font-weight: 500;
    font-size: 0.96rem;
    color: var(--ink);
}
.thread-msg .from-line .email {
    color: var(--ink-faint);
    font-size: 0.78rem;
    word-break: break-all;
}
.thread-msg .from-line .badge {
    margin-left: auto;
    font-size: 0.62rem;
    letter-spacing: .14em; text-transform: uppercase;
    color: var(--rose-deep);
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(217,122,139,.10);
    border: 1px solid rgba(217,122,139,.18);
}
.thread-msg .to-line, .thread-msg .date-line, .thread-msg .enc-line {
    font-size: 0.7rem; color: var(--ink-faint);
    letter-spacing: .02em;
}
.thread-msg .to-line strong { color: var(--ink-soft); font-weight: 500; }
.thread-msg .meta-row {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    margin-top: 3px;
}
.thread-msg .enc-line {
    display: inline-flex; align-items: center; gap: 5px;
    color: #7a8d6f;
    font-size: 0.66rem;
    letter-spacing: .04em;
}
.thread-msg .enc-line svg { width: 11px; height: 11px; }

.thread-msg .body {
    grid-column: 2 / -1;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--hairline);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    line-height: 1.78;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.thread-msg .body p { margin: 0 0 14px; }
.thread-msg .body p:last-child { margin-bottom: 0; }
.thread-msg .body a { color: var(--rose-deep); text-decoration: underline; text-underline-offset: 3px; word-break: break-all; }
.thread-msg .body .session-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 22px 0 18px;
    color: var(--rose-deep);
    font-family: 'Inter', sans-serif;
    font-size: 0.62rem; letter-spacing: .22em; text-transform: uppercase;
    font-weight: 500;
}
.thread-msg .body .session-divider::before,
.thread-msg .body .session-divider::after {
    content: ''; flex: 1; height: 1px;
    background: linear-gradient(90deg, transparent, var(--paper-edge), transparent);
}
.thread-msg .body .citation {
    margin-top: 16px; padding: 10px 12px;
    border-left: 2px solid var(--paper-edge);
    background: rgba(255,255,255,.45);
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: var(--ink-faint);
    line-height: 1.5;
}
.thread-msg .body .citation .ref { color: var(--ink-soft); display: block; margin-bottom: 4px; }
.thread-msg .body .citation .show-original { color: var(--rose-deep); font-size: 0.7rem; }
