/* Email draft: uses app vars from lockin-styles.css for consistent layout and theme */

.email-draft-page {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
}

.email-draft-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    max-width: 900px;
    margin: 0 auto;
    border-bottom: 1px solid var(--border-color);
}

.email-draft-header .back-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}
.email-draft-header .back-link:hover {
    text-decoration: underline;
}

.theme-toggle {
    padding: var(--space-sm) var(--space-md);
}

/* Page container: same as rest of app */
.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin: 0 0 var(--space-sm);
}

.page-subtitle {
    font-size: var(--text-base);
    color: var(--text-muted);
    margin: 0;
}

/* Two-column layout: input | output */
.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }
}

/* Tool card: same as grader-card style */
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 1px 3px var(--shadow-soft);
}

/* Section hierarchy */
.section-title {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 20px;
    font-weight: 600;
}

/* Fields: 20px gap */
.field {
    margin-bottom: 20px;
}

.field:last-of-type {
    margin-bottom: 24px;
}

.tool-card label {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin-bottom: 6px;
}

.tool-card .required {
    color: var(--error-color);
}

.tool-card input,
.tool-card textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-base);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tool-card textarea {
    min-height: 100px;
    resize: vertical;
}

.tool-card input::placeholder,
.tool-card textarea::placeholder {
    color: var(--text-muted);
}

.tool-card input:focus,
.tool-card textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(127, 168, 154, 0.2);
}

.char-count {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 4px;
}

/* Segmented tone group */
.tone-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    background: var(--bg-primary);
    box-shadow: inset 0 1px 2px var(--shadow-soft);
}

.tone {
    flex: 1 1 0;
    min-width: 72px;
    padding: 10px 14px;
    border: none;
    border-right: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.tone:last-child {
    border-right: none;
}

.tone:hover:not(.active) {
    background: var(--bg-secondary);
}

.tone.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 3px var(--shadow);
}

/* Age group: same segmented style as tone */
.age-group {
    display: flex;
    gap: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    background: var(--bg-primary);
    box-shadow: inset 0 1px 2px var(--shadow-soft);
}

.age-btn {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: none;
    border-right: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.age-btn:last-child {
    border-right: none;
}

.age-btn:hover:not(.active) {
    background: var(--bg-secondary);
}

.age-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 3px var(--shadow);
}

/* Audience: same segmented style as tone/age */
.audience-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    background: var(--bg-primary);
    box-shadow: inset 0 1px 2px var(--shadow-soft);
}

.audience-btn {
    flex: 1 1 0;
    min-width: 72px;
    padding: 10px 12px;
    border: none;
    border-right: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.audience-btn:last-child {
    border-right: none;
}

.audience-btn:hover:not(.active) {
    background: var(--bg-secondary);
}

.audience-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 3px var(--shadow);
}

.email-draft-error {
    color: var(--error-color);
    font-size: var(--text-sm);
    margin: 0 0 16px;
}

/* Primary CTA: full width, app button */
.email-draft-submit {
    width: 100%;
    margin: 0;
    margin-top: 8px;
    padding: 14px 22px;
}

.email-draft-submit .btn-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: email-draft-spin 0.8s linear infinite;
}

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

/* Example prompts */
.example-prompts {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.example-prompts-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.example-prompt {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
}

.example-prompt:last-child {
    margin-bottom: 0;
}

/* Result: document preview */
.result-placeholder {
    padding: 24px;
    border-radius: 12px;
    background: var(--bg-primary);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-align: center;
}

.email-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.email-preview .field {
    margin-bottom: 20px;
}

.email-preview .field:last-child {
    margin-bottom: 0;
}

.subject-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.subject-row span {
    flex: 1;
    font-weight: 500;
    font-size: var(--text-base);
}

.email-preview pre {
    white-space: pre-wrap;
    line-height: 1.55;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    font-family: inherit;
    font-size: var(--text-sm);
    margin: 0 0 10px;
    color: var(--text-primary);
}

.copy-btn-block {
    display: block;
    width: 100%;
}
