:root {
    /* Brand Colors */
    --primary: #5b5bf6;
    /* Vivid Purple */
    --primary-hover: #4a4ae0;
    --primary-light: #eef2ff;

    /* UI Colors */
    --bg-body: #f3f4f6;
    --bg-surface: #ffffff;
    --bg-subtle: #f9fafb;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;

    --border: #e5e7eb;
    --border-hover: #d1d5db;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --error: #ef4444;
    --error-bg: #fef2f2;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Compatibility & Aliases */
    --bg-card: var(--bg-surface);

    /* Font */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

.brand-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: white;
    font-size: 1.2rem;
}

.nav-actions {
    display: flex;
    gap: 0.5rem;
}

.page-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    padding: 2rem 0;
    align-items: start;
}

@media (max-width: 1024px) {
    .page-layout {
        grid-template-columns: 1fr;
    }
}

/* Sidebar / Form */
.sidebar {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 1.25rem;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.375rem;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    font-size: 0.9375rem;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Channel Selector */
.channel-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--bg-subtle);
    padding: 0.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.channel-option {
    position: relative;
    text-align: center;
    cursor: pointer;
}

.channel-option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.channel-content {
    padding: 0.625rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.channel-option input:checked+.channel-content {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.channel-icon {
    font-size: 1.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.btn-block {
    width: 100%;
}

.icon-only {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 12px;
    font-size: 1.25rem;
    display: grid;
    place-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-muted);
}

.icon-only:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.icon-svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
}

.nav-text {
    display: none;
    font-size: 0.875rem;
    font-weight: 600;
}

@media (min-width: 1024px) {
    .icon-only {
        width: auto;
        padding: 0 1rem;
    }

    .nav-text {
        display: block;
    }
}

.btn.active {
    background: var(--bg-subtle);
    color: var(--primary);
    border-color: var(--primary);
}

/* Results Area */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.score-badge {
    background: var(--success-bg);
    color: var(--success);
    font-weight: 700;
    font-size: 0.8125rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.action-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
}

.action-icon.saved {
    color: var(--success);
    background: var(--success-bg);
}

.action-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
}

.action-icon.saved svg {
    fill: #10b981;
}

.content-block {
    margin-bottom: 1.25rem;
}

.content-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.copy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.copy-trigger {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.15rem 0.45rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.copy-trigger:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.copy-trigger.copied {
    background: var(--success-bg);
    color: var(--success);
}

.content-text {
    font-size: 1.0625rem;
    color: var(--text-main);
    line-height: 1.6;
}

.insight-box {
    background: #eff6ff;
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    font-size: 0.9375rem;
    color: #1e40af;
}

.insight-icon {
    font-size: 1.1rem;
}

.footer-actions {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.pill-btn {
    padding: 0.375rem 0.875rem;
    border-radius: 6px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.pill-btn:hover {
    background: #e5e7eb;
    color: var(--text-main);
}

/* Utilities */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-muted);
}

.font-bold {
    font-weight: 700;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9375rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background: var(--bg-surface);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-subtle);
}

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
    max-height: 80vh;
    overflow-y: auto;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-card {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-subtle);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}
