.email-container { max-width: 1400px; margin: 0 auto; padding: 0 16px 80px; }
.email-textarea {
    width: 100%;
    min-height: 160px;
    padding: 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg-card);
    color: var(--text);
    resize: vertical;
    transition: border-color 0.2s;
}
.email-textarea:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.email-textarea::placeholder { color: var(--text-secondary); opacity: 0.6; }
.email-output {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    line-height: 1.7;
    font-size: 14px;
    white-space: pre-wrap;
    position: relative;
    min-height: 120px;
}
.email-output.generating {
    color: var(--text-secondary);
}
.email-output .cursor-blink {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: #7c3aed;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.8s step-end infinite;
}
@keyframes blink-cursor {
    50% { opacity: 0; }
}
.email-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.email-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.email-btn-primary {
    background: #7c3aed;
    color: #fff;
}
.email-btn-primary:hover { background: #6d28d9; }
.email-btn-primary:disabled { background: #a78bfa; cursor: not-allowed; }
.email-btn:focus-visible { outline: 2px solid var(--apple-blue); outline-offset: 2px; }
.email-btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.email-btn-secondary:hover { background: color-mix(in srgb, var(--border) 30%, var(--bg-card)); }
.email-context-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.email-context-input {
    flex: 1;
    min-width: 140px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text);
    font-family: inherit;
}
.email-context-input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.email-tone-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.email-tone-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all 0.15s;
}
.email-tone-chip.active {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
}
.email-tone-chip:hover:not(.active) {
    border-color: #7c3aed;
    color: #7c3aed;
}
.email-history-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.email-history-item:hover { border-color: #7c3aed; }
.email-history-meta {
    font-size: 12px;
    color: var(--text-secondary);
}
.email-lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #059669;
    background: rgba(5,150,105,0.1);
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

/* ── Custom AI Persona ── */
.email-custom-prompt-section {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.email-custom-prompt-section summary {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.email-custom-prompt-section summary::-webkit-details-marker { display: none; }
.email-custom-prompt-section summary::before {
    content: '▸ ';
    display: inline;
    transition: transform 0.15s;
}
.email-custom-prompt-section[open] summary::before {
    content: '▾ ';
}
.email-custom-prompt-body {
    padding: 0 14px 12px;
}
.email-custom-prompt-textarea {
    min-height: 120px;
    font-size: 13px;
    line-height: 1.55;
}
.email-custom-prompt-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}
.email-custom-prompt-count {
    font-size: 11px;
    color: var(--text-tertiary);
}
.email-custom-prompt-count.over-limit {
    color: var(--danger);
    font-weight: 600;
}
.email-custom-prompt-actions {
    display: flex;
    gap: 6px;
}
.email-btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 8px;
}

/* ── Desktop enhancements ── */
@media (min-width: 960px) {
    .email-container {
        padding: 0 24px 80px;
    }
    .email-desktop-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        align-items: start;
    }
    .email-col-right {
        position: sticky;
        top: 24px;
    }
    .email-compose-area textarea {
        min-height: 200px;
        font-size: 15px;
    }
    .email-history-item {
        padding: 14px 18px;
    }
}

/* ─── Dark Mode ─────────────────────────────────────────────────────────────
   Purple accent (#7c3aed) is intentional. Boost focus-ring alpha and the
   low-opacity success badge background.
   ─────────────────────────────────────────────────────────────────────────── */
body.dark-mode .email-textarea:focus,
body.dark-mode .email-context-input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}
body.dark-mode .email-tone-chip.active {
    background: #6d28d9;
    border-color: #6d28d9;
}
body.dark-mode .email-tone-chip:hover:not(.active) {
    border-color: #a78bfa;
    color: #a78bfa;
}
body.dark-mode .email-history-item:hover  { border-color: #a78bfa; }
body.dark-mode .email-output .cursor-blink { background: #a78bfa; }
body.dark-mode .email-lock-badge {
    background: rgba(52, 211, 153, 0.18);
    color: #34D399;
}
