/*
 * Email Template Generator — page styles.
 *
 * Namespace: .eml-*  (EMaiL)
 * Built strictly on v2-core tokens — solid --rw-accent for primary
 * actions, plain backgrounds, --rw-card-bg / --rw-border for cards.
 * NO gradients. NO purple. NO multi-color hero overlays.
 */

/* ─── Page wrapper ────────────────────────────────────────────── */

.eml-page {
    min-height: 60vh;
}

/* ─── Hero (list page) ──────────────────────────────────────── */

.eml-hero {
    padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(1rem, 3vw, 2rem);
    text-align: center;
    background-color: var(--rw-bg);
}

.eml-hero-eyebrow {
    display: inline-block;
    color: var(--rw-accent);
    font-weight: 700;
    letter-spacing: 0.12em;
}

.eml-hero-title {
    font-family: 'Inter Tight', Inter, system-ui, sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 1rem auto 1.25rem;
    max-width: 24ch;
    color: var(--rw-text);
}

.eml-hero-sub {
    margin: 0 auto 2rem;
    max-width: 38rem;
    color: var(--rw-text-muted);
    font-size: clamp(1rem, 1.2vw, 1.1rem);
    line-height: 1.6;
}

/* ─── Buttons ─────────────────────────────────────────────────── */

.eml-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border: 0;
    border-radius: 0.5rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.eml-btn-primary {
    background-color: var(--rw-accent);
    color: var(--rw-white, #ffffff);
    box-shadow: 0 1px 3px rgba(13, 95, 63, 0.15);
}

.eml-btn-primary:hover:not(:disabled) {
    background-color: var(--rw-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 95, 63, 0.25);
    color: var(--rw-white, #ffffff);
}

.eml-btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(13, 95, 63, 0.15);
}

.eml-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.eml-btn-lg {
    padding: 1rem 1.75rem;
    font-size: 1rem;
}

/* ─── Sections ────────────────────────────────────────────────── */

.eml-section {
    padding: clamp(2rem, 5vw, 4rem) 0;
}

.eml-section--surface {
    background-color: var(--rw-surface);
}

.eml-section-head {
    margin-bottom: 1.5rem;
    text-align: left;
}

.eml-section-eyebrow {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--rw-accent);
    letter-spacing: 0.12em;
}

.eml-section-title {
    margin: 0.4rem 0 0;
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: clamp(1.4rem, 2.5vw, 1.85rem);
    font-weight: 800;
    color: var(--rw-text);
    letter-spacing: -0.01em;
}

/* ─── Categories grid ───────────────────────────────────────── */

.eml-categories-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .eml-categories-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .eml-categories-grid { grid-template-columns: repeat(4, 1fr); }
}

.eml-category-card {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 1.25rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.eml-category-card:hover {
    border-color: var(--rw-accent);
    transform: translateY(-2px);
    box-shadow: var(--rw-shadow-md, 0 4px 12px rgba(15, 23, 42, 0.08));
    color: inherit;
}

.eml-category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background-color: var(--rw-accent-light);
    color: var(--rw-accent);
}

.eml-category-card-title {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--rw-text);
}

.eml-category-card-blurb {
    margin: 0;
    color: var(--rw-text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    flex: 1;
}

.eml-category-card-cta {
    margin-top: 0.25rem;
    color: var(--rw-accent);
    font-weight: 600;
    font-size: 0.85rem;
}

/* ─── Saved emails grid ─────────────────────────────────────── */

.eml-saved-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: 1fr;
}

@media (min-width: 700px) {
    .eml-saved-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
    .eml-saved-grid { grid-template-columns: repeat(3, 1fr); }
}

.eml-saved-card {
    position: relative;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    padding: 1.1rem 1.2rem;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.eml-saved-card:hover {
    border-color: var(--rw-accent);
    transform: translateY(-2px);
    box-shadow: var(--rw-shadow-md, 0 4px 12px rgba(15, 23, 42, 0.08));
}

.eml-saved-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.eml-saved-pill {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    background-color: var(--rw-accent-light);
    color: var(--rw-accent);
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.eml-saved-subject {
    margin: 0 0 0.35rem;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--rw-text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.eml-saved-meta {
    margin: 0;
    color: var(--rw-text-muted);
    font-size: 0.82rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Body preview on saved-email cards — first ~140 chars of the
   actual body, truncated to two lines so cards stay roughly the
   same height. The subject is already in the title slot, so the
   preview gives a real sense of what the user wrote. */
.eml-saved-preview {
    margin: 0.6rem 0 0;
    color: var(--rw-text);
    font-size: 0.85rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.eml-saved-updated {
    margin: 0.5rem 0 0;
    color: var(--rw-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.eml-saved-delete {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 30px;
    height: 30px;
    border: 1px solid var(--rw-border);
    border-radius: 8px;
    background-color: var(--rw-card-bg);
    color: var(--rw-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.eml-saved-card:hover .eml-saved-delete { opacity: 1; }

.eml-saved-delete:hover {
    background-color: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.4);
}

/* ─── How it works ──────────────────────────────────────────── */

.eml-how-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .eml-how-grid { grid-template-columns: repeat(3, 1fr); }
}

.eml-how-tile {
    padding: 1.75rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
}

.eml-how-num {
    display: inline-block;
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--rw-accent);
    line-height: 1;
    margin-bottom: 0.85rem;
}

.eml-how-title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--rw-text);
}

.eml-how-desc {
    margin: 0;
    color: var(--rw-text-muted);
    font-size: 0.92rem;
    line-height: 1.55;
}

/* ════════════════════════════════════════════════════════════════
 * GENERATOR FORM
 * ════════════════════════════════════════════════════════════════ */

.eml-page[data-state="loading"] .eml-form-shell { display: none; }
.eml-page .eml-loading { display: none; }
.eml-page[data-state="loading"] .eml-loading { display: block; }

.eml-form-shell {
    padding: clamp(2rem, 5vw, 4rem) 0;
}

.eml-back-link {
    display: inline-block;
    margin-bottom: 1.25rem;
    color: var(--rw-text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
}

.eml-back-link:hover {
    color: var(--rw-accent);
}

.eml-form-title {
    margin: 0 0 0.5rem;
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: clamp(1.8rem, 3.5vw, 2.4rem);
    font-weight: 800;
    color: var(--rw-text);
    letter-spacing: -0.01em;
}

.eml-form-sub {
    margin: 0 0 2rem;
    color: var(--rw-text-muted);
    font-size: 1rem;
    line-height: 1.55;
    max-width: 36rem;
}

/* Step containers */
.eml-step {
    border: 0;
    padding: 0;
    margin: 0 0 2rem;
}

.eml-step-legend {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    padding: 0;
}

.eml-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--rw-accent);
    color: var(--rw-white, #ffffff);
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: 0.78rem;
    font-weight: 800;
}

.eml-step-label {
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--rw-text);
}

.eml-step-optional {
    color: var(--rw-text-muted);
    font-weight: 400;
    font-size: 0.85rem;
}

.eml-step-help {
    margin: 0 0 1rem 2.2rem;
    color: var(--rw-text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.eml-step-row {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .eml-step-row { grid-template-columns: repeat(2, 1fr); }
}

/* Fields */
.eml-field {
    display: block;
    margin-bottom: 0.85rem;
}

.eml-field[hidden] { display: none; }

.eml-field-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--rw-text);
}

.eml-field-optional {
    color: var(--rw-text-muted);
    font-weight: 400;
    font-size: 0.78rem;
}

.eml-input {
    width: 100%;
    padding: 0.72rem 0.95rem;
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
    background-color: var(--rw-card-bg);
    color: var(--rw-text);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.eml-input:focus {
    outline: none;
    border-color: var(--rw-accent);
    box-shadow: 0 0 0 3px rgba(13, 95, 63, 0.12);
}

.eml-field-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.74rem;
    color: var(--rw-text-muted);
}

/* Category pills */
.eml-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.eml-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 0.95rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 9999px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.eml-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.eml-pill:hover { border-color: var(--rw-accent); }

.eml-pill--selected {
    border-color: var(--rw-accent);
    background-color: var(--rw-accent-light);
    color: var(--rw-accent);
}

.eml-pill-label {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Resume cards */
.eml-resume-grid {
    display: grid;
    gap: 0.6rem;
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .eml-resume-grid { grid-template-columns: repeat(2, 1fr); }
}

.eml-resume-card {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
    background-color: var(--rw-card-bg);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.eml-resume-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.eml-resume-card:hover { border-color: var(--rw-accent); }

.eml-resume-card--selected {
    border-color: var(--rw-accent);
    background-color: var(--rw-accent-light);
    box-shadow: 0 0 0 3px rgba(13, 95, 63, 0.08);
}

.eml-resume-card-name {
    font-weight: 600;
    color: var(--rw-text);
    font-size: 0.92rem;
}

.eml-resume-card-tpl {
    font-size: 0.72rem;
    color: var(--rw-text-muted);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Tone cards */
.eml-tone-group {
    display: grid;
    gap: 0.6rem;
    grid-template-columns: 1fr;
}

@media (min-width: 700px) {
    .eml-tone-group { grid-template-columns: repeat(3, 1fr); }
}

.eml-tone-card {
    position: relative;
    padding: 1rem 1.1rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.eml-tone-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.eml-tone-card:hover { border-color: var(--rw-accent); }

.eml-tone-card--selected {
    border-color: var(--rw-accent);
    background-color: var(--rw-accent-light);
}

.eml-tone-card-title {
    display: block;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--rw-text);
    margin-bottom: 0.3rem;
}

.eml-tone-card-blurb {
    display: block;
    color: var(--rw-text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

/* Submit row */
.eml-submit-row {
    margin-top: 2rem;
    text-align: left;
}

.eml-error {
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #991b1b;
    border-radius: 0.5rem;
    font-size: 0.88rem;
}

.dark .eml-error { color: #fca5a5; }

.eml-submit-hint {
    margin: 0.85rem 0 0;
    color: var(--rw-text-muted);
    font-size: 0.78rem;
}

/* Empty state (no resume) */
.eml-empty {
    text-align: center;
    padding: 3rem 1rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
}

.eml-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    background-color: var(--rw-accent-light);
    color: var(--rw-accent);
    margin-bottom: 1rem;
}

.eml-empty-title {
    margin: 0 0 0.5rem;
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--rw-text);
}

.eml-empty-desc {
    margin: 0 auto 1.5rem;
    color: var(--rw-text-muted);
    max-width: 28rem;
}

/* ─── Loading card (generator) ──────────────────────────────── */

.eml-loading {
    padding: clamp(3rem, 8vw, 6rem) 0;
}

.eml-loading-card {
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    padding: clamp(2rem, 5vw, 3rem);
    max-width: 32rem;
    margin: 0 auto;
    text-align: center;
    box-shadow: var(--rw-shadow-md, 0 4px 12px rgba(15, 23, 42, 0.08));
}

.eml-stages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
    max-width: 24rem;
    margin: 0 auto 1.25rem;
}

.eml-stage {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
    background-color: var(--rw-surface);
    color: var(--rw-text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.eml-stage-dot {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--rw-border);
    position: relative;
    transition: border-color 0.2s ease;
}

.eml-stage--active {
    border-color: var(--rw-accent);
    color: var(--rw-text);
    background-color: var(--rw-accent-light);
}

.eml-stage--active .eml-stage-dot {
    border-color: var(--rw-accent);
    border-top-color: transparent;
    animation: eml-spin 0.9s linear infinite;
}

.eml-stage--done {
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--rw-text);
    background-color: rgba(16, 185, 129, 0.06);
}

.eml-stage--done .eml-stage-dot {
    border-color: #10b981;
    background-color: #10b981;
    animation: none;
}

.eml-stage--done .eml-stage-dot::after {
    content: "";
    position: absolute;
    inset: 3px 4px 5px 3px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

@keyframes eml-spin { to { transform: rotate(360deg); } }

.eml-loading-note {
    margin: 0;
    color: var(--rw-text-muted);
    font-size: 0.82rem;
}

/* ════════════════════════════════════════════════════════════════
 * EDITOR
 * ════════════════════════════════════════════════════════════════ */

.eml-editor-shell {
    padding: clamp(1.25rem, 3vw, 2.25rem) 0 4rem;
}

.eml-editor-tailoring {
    margin: 0 0 1.5rem;
    padding: 0.7rem 1rem;
    background-color: var(--rw-accent-light);
    border-left: 3px solid var(--rw-accent);
    border-radius: 0 0.5rem 0.5rem 0;
    color: var(--rw-text);
    font-size: 0.88rem;
    line-height: 1.55;
    max-width: 36rem;
}

/* Top bar */
.eml-editor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rw-border);
}

.eml-editor-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.eml-editor-title-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    padding: 0.4rem 0.5rem;
    margin-left: -0.5rem;
    border-radius: 0.375rem;
    font-family: 'Inter Tight', Inter, sans-serif;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    font-weight: 700;
    color: var(--rw-text);
    transition: background-color 0.15s ease;
}

.eml-editor-title-input:hover,
.eml-editor-title-input:focus {
    background-color: var(--rw-surface);
    outline: none;
}

.eml-save-status {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--rw-text-muted);
    padding: 0.3rem 0.65rem;
    border-radius: 9999px;
    background-color: var(--rw-surface);
}

.eml-save-status[data-status="dirty"] {
    color: #92400e;
    background-color: rgba(245, 158, 11, 0.12);
}
.eml-save-status[data-status="saving"] {
    color: var(--rw-accent);
    background-color: var(--rw-accent-light);
}
.eml-save-status[data-status="saved"] {
    color: #047857;
    background-color: rgba(16, 185, 129, 0.1);
}
.eml-save-status[data-status="error"] {
    color: #991b1b;
    background-color: rgba(239, 68, 68, 0.12);
}
.dark .eml-save-status[data-status="dirty"] { color: #fbbf24; }
.dark .eml-save-status[data-status="saved"] { color: #6ee7b7; }
.dark .eml-save-status[data-status="error"] { color: #fca5a5; }

/* Tone tabs (editor) */
.eml-tone-tabs {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background-color: var(--rw-surface);
    border: 1px solid var(--rw-border);
    border-radius: 0.625rem;
    margin-bottom: 1rem;
}

.eml-tone-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.95rem;
    background: transparent;
    border: 0;
    border-radius: 0.5rem;
    color: var(--rw-text-muted);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.eml-tone-tab:hover { color: var(--rw-text); }

.eml-tone-tab--active {
    background-color: var(--rw-card-bg);
    color: var(--rw-text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.eml-tone-tab-pro {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 0.1rem 0.4rem;
    background-color: var(--rw-accent);
    color: var(--rw-white, #ffffff);
    border-radius: 9999px;
}

/* Two-column grid */
.eml-editor-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
    align-items: start;
}

@media (min-width: 1024px) {
    .eml-editor-grid {
        grid-template-columns: minmax(0, 1fr) 22rem;
    }
}

/* Document panel (the "letterhead" but for email) */
.eml-doc {
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    padding: clamp(1.5rem, 3.5vw, 2.25rem);
    box-shadow: var(--rw-shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.04));
}

.eml-doc-to {
    margin: 0 0 1rem;
    color: var(--rw-text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.eml-doc-to-label {
    color: var(--rw-text);
    font-weight: 700;
    margin-right: 0.4rem;
}

.eml-doc-to--empty {
    color: var(--rw-text-muted);
    font-style: italic;
}

.eml-doc-subject-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
}

.eml-doc-subject-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--rw-text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex: 0 0 auto;
}

.eml-doc-subject-input {
    flex: 1;
    min-width: 0;
    border: 0;
    border-bottom: 1px dashed var(--rw-border);
    padding: 0.45rem 0.4rem;
    background: transparent;
    color: var(--rw-text);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.eml-doc-subject-input:hover { border-bottom-color: var(--rw-accent); }
.eml-doc-subject-input:focus {
    outline: none;
    border-bottom: 1px solid var(--rw-accent);
}

.eml-doc-divider {
    border: 0;
    border-top: 1px solid var(--rw-border);
    margin: 0 0 1.25rem;
}

.eml-doc-greeting,
.eml-doc-signoff {
    margin: 0 0 1rem;
    color: var(--rw-text);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: pre-line;
}

.eml-doc-signoff {
    margin-top: 1.25rem;
    margin-bottom: 0;
}

.eml-doc-body {
    width: 100%;
    min-height: 240px;
    padding: 0.85rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
    background-color: var(--rw-card-bg);
    color: var(--rw-text);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.7;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.eml-doc-body:focus {
    outline: none;
    border-color: var(--rw-accent);
    box-shadow: 0 0 0 3px rgba(13, 95, 63, 0.12);
}

/* Right rail */
.eml-rail {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 1rem;
}

.eml-rail-section {
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    padding: 1.1rem 1.15rem;
}

.eml-rail-section-title {
    margin: 0 0 0.3rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--rw-text);
}

.eml-rail-section-help {
    margin: 0 0 0.85rem;
    color: var(--rw-text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.eml-rail-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.eml-rail-btn-full {
    width: 100%;
    justify-content: center;
}

.eml-rail-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.7rem 1rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
    color: var(--rw-text);
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.eml-rail-btn-secondary:hover {
    border-color: var(--rw-accent);
    color: var(--rw-accent);
}

/* Pro panel */
.eml-rail-pro {
    background-color: var(--rw-accent-light);
    border-color: var(--rw-accent);
}

.eml-rail-pro-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.7rem 0.85rem;
    background-color: var(--rw-card-bg);
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
    color: var(--rw-text);
    font-family: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.eml-rail-pro-btn:hover:not(:disabled) {
    border-color: var(--rw-accent);
    transform: translateY(-1px);
}

.eml-rail-pro-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.eml-rail-pro-btn--loading .eml-rail-pro-icon {
    animation: eml-spin 0.9s linear infinite;
    display: inline-block;
}

.eml-rail-pro-icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    background-color: var(--rw-accent-light);
    color: var(--rw-accent);
    font-size: 0.95rem;
    font-weight: 700;
}

.eml-rail-pro-text {
    flex: 1;
    min-width: 0;
}

.eml-rail-pro-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--rw-text);
}

.eml-rail-pro-help {
    display: block;
    font-size: 0.72rem;
    color: var(--rw-text-muted);
    margin-top: 0.1rem;
    line-height: 1.4;
}

.eml-rail-pro-tag {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0.18rem 0.5rem;
    background-color: var(--rw-accent);
    color: var(--rw-white, #ffffff);
    border-radius: 9999px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

/* Recipient rail fields */
.eml-rail-field {
    display: block;
    margin-bottom: 0.7rem;
}

.eml-rail-field:last-child { margin-bottom: 0; }

.eml-rail-field-label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--rw-text);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Toast */
.eml-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    background-color: var(--rw-text, #0f172a);
    color: var(--rw-card-bg, #ffffff);
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    max-width: 90%;
    text-align: center;
}

.eml-toast[hidden] { display: none; }

/* Mobile: rail stacks below the doc */
@media (max-width: 1023px) {
    .eml-rail { position: static; }
}
