:root {
    --font-sans: "Inter", sans-serif;
    --text-color: rgb(25, 25, 24);
    --bg-color: #fafafa;
    --border-color: rgba(55, 53, 47, 0.12);
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-20: 20px;
    --space-24: 24px;
    --space-32: 32px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    color: var(--text-color);
    background-color: var(--bg-color);
    background-image: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-32) var(--space-24);
}

/* ========== APP HEADER ========== */
.app-header {
    text-align: center;
    margin-bottom: var(--space-24);
    padding: var(--space-16) var(--space-24);
    margin: calc(-1 * var(--space-32)) calc(-1 * var(--space-24)) var(--space-24);
}

.app-header__title {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
    color: var(--text-color);
    margin: 0;
    padding-bottom: var(--space-16);
}

.app-header__title::after {
    content: "";
    display: block;
    width: 40%;
    height: 1px;
    background: var(--border-color);
    margin: var(--space-16) auto 0;
}

/* Input Section */
.input-section {
    margin-bottom: 32px;
}

.input-card {
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.input-wrapper {
    margin-bottom: 24px;
}

.input-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: rgba(25, 25, 24, 0.6);
    margin-bottom: 8px;
}

textarea {
    width: 100%;
    min-height: 140px;
    padding: 16px;
    font-family: "Inter";
    font-size: 18px;
    font-weight: 400;
    line-height: 1.55;
    color: rgb(25, 25, 24);
    background: rgba(55, 53, 47, 0.04);
    border: 0.5px solid rgba(55, 53, 47, 0.16);
    border-radius: 8px;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s ease, background 0.2s ease;
}

textarea:focus {
    border-color: #2383E2;
    background: white;
}

textarea::placeholder {
    color: rgba(25, 25, 24, 0.4);
}

/* Options Row */
.options-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.option-group {
    flex: 0 0 auto;
    min-width: 150px;
    display: flex;
    flex-direction: column;
}

.option-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: rgba(25, 25, 24, 0.5);
    margin-bottom: 6px;
}

select,
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    font-family: "Inter";
    font-size: 15px;
    color: rgb(25, 25, 24);
    background: white;
    border: 0.5px solid rgba(55, 53, 47, 0.16);
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

select:focus,
input[type="number"]:focus {
    border-color: #2383E2;
}

input[type="number"] {
    width: 80px;
    cursor: text;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgba(25, 25, 24, 0.7);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2383E2;
}

.button-row {
    display: flex;
    justify-content: flex-end;
}

/* Primary Button */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 50px;
    background: #000000;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: "Inter";
}

.btn-primary:hover:not(:disabled) {
    background: #1a1a1a;
}

.btn-primary:active:not(:disabled) {
    background: #333333;
}

.btn-primary:disabled {
    background: rgba(0, 0, 0, 0.3);
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

/* Secondary Button */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    background: white;
    color: rgb(25, 25, 24);
    border: 0.5px solid rgba(55, 53, 47, 0.16);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(55, 53, 47, 0.08);
    border-color: rgba(55, 53, 47, 0.24);
}

.btn-secondary.primary {
    background: #2383E2;
    color: white;
    border-color: #2383E2;
}

.btn-secondary.primary:hover {
    background: #1B6DC1;
    border-color: #1B6DC1;
}

.btn-secondary svg {
    width: 16px;
    height: 16px;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    background: transparent;
    color: rgb(25, 25, 24);
    border: 0.5px solid rgba(55, 53, 47, 0.24);
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-outline:hover {
    background: rgba(55, 53, 47, 0.08);
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 48px 20px;
}

.spinner-container {
    display: inline-block;
    margin-bottom: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(35, 131, 226, 0.2);
    border-top-color: #2383E2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 16px;
    color: rgba(25, 25, 24, 0.7);
}

/* Error State */
.error-state {
    text-align: center;
    padding: 48px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.error-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: #e74c3c;
}

.error-icon svg {
    width: 100%;
    height: 100%;
}

.error-text {
    font-size: 16px;
    color: rgba(25, 25, 24, 0.8);
    margin-bottom: 20px;
}

/* Result Section */
.result-section {
    margin-top: 32px;
}

.metadata-card {
    background: white;
    border-radius: 12px;
    padding: 20px 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.metadata-content {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metadata-label {
    font-size: 13px;
    color: rgba(25, 25, 24, 0.5);
    font-weight: 500;
}

.metadata-value {
    font-size: 20px;
    font-weight: 600;
    color: rgb(25, 25, 24);
}

.section-title {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin-bottom: 20px;
    color: rgb(25, 25, 24);
}

.variants-container,
.ab-pairs-section {
    margin-bottom: 32px;
}

.variants-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.variant-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.variant-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.variant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 16px;
}

.variant-subject {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.005em;
    color: rgb(25, 25, 24);
    flex: 1;
    word-break: break-word;
}

.variant-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.badge.mobile-safe {
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
}

.badge.spam-low {
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
}

.badge.spam-medium {
    background: rgba(241, 196, 15, 0.1);
    color: #f1c40f;
}

.badge.spam-high {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.badge.score {
    background: rgba(35, 131, 226, 0.1);
    color: #2383E2;
}

.variant-preheader {
    font-size: 15px;
    color: rgba(25, 25, 24, 0.7);
    margin-bottom: 12px;
    padding-left: 8px;
    border-left: 1px solid rgba(55, 53, 47, 0.16);
}

.variant-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: rgba(25, 25, 24, 0.6);
}

.variant-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.variant-rationale {
    font-size: 14px;
    color: rgba(25, 25, 24, 0.7);
    font-style: italic;
    margin-bottom: 12px;
}

.variant-personalization {
    font-size: 13px;
    color: rgba(25, 25, 24, 0.6);
    margin-bottom: 12px;
}

.variant-personalization strong {
    color: rgba(25, 25, 24, 0.8);
}

.variant-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(55, 53, 47, 0.06);
    color: rgb(25, 25, 24);
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.action-btn:hover {
    background: rgba(55, 53, 47, 0.12);
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

.ab-pairs-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ab-pair-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ab-pair-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.ab-pair-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(25, 25, 24, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ab-pair-hypothesis {
    font-size: 13px;
    color: rgba(25, 25, 24, 0.6);
    font-style: italic;
}

.ab-variants {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.ab-variant {
    padding: 16px;
    background: rgba(55, 53, 47, 0.04);
    border-radius: 8px;
}

.ab-variant-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(25, 25, 24, 0.6);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.ab-variant-subject {
    font-size: 18px;
    font-weight: 600;
    color: rgb(25, 25, 24);
    margin-bottom: 6px;
}

.ab-variant-preheader {
    font-size: 13px;
    color: rgba(25, 25, 24, 0.7);
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 32px;
}

/* Inbox Preview */
.inbox-preview {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 16px;
}

.inbox-preview-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(25, 25, 24, 0.7);
    margin-bottom: 12px;
}

.inbox-item {
    padding: 12px;
    border-bottom: 0.5px solid rgba(55, 53, 47, 0.16);
}

.inbox-item:last-child {
    border-bottom: none;
}

.inbox-subject {
    font-size: 16px;
    font-weight: 600;
    color: rgb(25, 25, 24);
    margin-bottom: 4px;
}

.inbox-preheader {
    font-size: 13px;
    color: rgba(25, 25, 24, 0.6);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: var(--space-24) var(--space-16);
    }

    .app-header {
        padding: var(--space-12) var(--space-16);
        margin: calc(-1 * var(--space-24)) calc(-1 * var(--space-16)) var(--space-20);
    }

    .app-header__title {
        font-size: 28px;
    }

    .options-row {
        flex-direction: column;
    }

    .option-group {
        min-width: 100%;
    }

    .ab-variants {
        grid-template-columns: 1fr;
    }

    .metadata-content {
        flex-direction: column;
        gap: 16px;
    }
}