:root {
    --primary: #5E5CE6;
    --primary-light: #F0F0FF;
    --accent: #FF2D55;
    --success: #34C759;
    --gradient-brand: linear-gradient(135deg, #FF2D55, #5E5CE6);
    --bg-main: #F4F5F9;
    --bg-card: #FFFFFF;
    --text-main: #1C1C1E;
    --text-muted: #8E8E93;
    --border-color: #E5E5EA;
    --shadow-soft: 0 4px 12px rgba(0,0,0,0.04);
    --shadow-brand: 0 8px 20px rgba(94, 92, 230, 0.12);
    --shadow-hover: 0 8px 20px rgba(0,0,0,0.08);
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    /* Made the background slightly more vibrant than plain grey */
    background: linear-gradient(135deg, #F4F5F9 0%, #EAEAF2 100%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.4;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Header & Nav */
.top-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: max(env(safe-area-inset-top), 12px);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    padding: 0 16px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #FF2D55, #5E5CE6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.logo .emoji {
    -webkit-text-fill-color: initial;
}

.nav-scroll-container {
    overflow-x: auto;
    padding: 0 16px 12px;
}
/* Show subtle scrollbar for desktop sliding */
.nav-scroll-container::-webkit-scrollbar {
    height: 6px;
}
.nav-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.nav-scroll-container::-webkit-scrollbar-thumb {
    background: #E5E5EA;
    border-radius: 10px;
}

.category-nav {
    display: flex;
    gap: 8px;
}

.nav-pill {
    white-space: nowrap;
    padding: 8px 16px;
    border-radius: 20px;
    background: #E5E5EA;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-pill.active {
    background: var(--gradient-brand);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 45, 85, 0.25);
    border-color: transparent;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

.bottom-padding {
    height: 40px;
}

/* Compact Personalize Card */
.personalize-card.compact {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 0 0 24px 0;
    box-shadow: var(--shadow-brand);
    border: none;
    position: relative;
}

.personalize-card.compact::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: var(--gradient-brand);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.var-inputs-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .var-inputs-compact {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    
    .personalize-card.compact {
        padding: 12px 20px;
        margin: 0 0 24px 0;
        position: sticky;
        top: -16px;
        z-index: 40;
    }
}

/* V2 FEATURES: Modals & FAB */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 450px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-main);
}

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

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
}

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

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.15);
}

.primary-btn {
    width: 100%;
    background: var(--gradient-brand);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: var(--shadow-brand);
}

.primary-btn:active {
    transform: scale(0.98);
}

/* FAB for Link Generator */
.fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 60;
}

.fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: white;
    border: none;
    box-shadow: 0 10px 20px rgba(255, 45, 85, 0.3);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 25px rgba(255, 45, 85, 0.4);
}

/* My Scripts Card styling */
.my-script-card {
    border-top: 4px solid var(--success);
}

/* V2 FEATURES: Formatting Studio Toolbars */
.format-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    background: #F4F5F9;
    padding: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.emoji-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.emoji-btn {
    flex: 1;
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 8px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.emoji-btn:hover {
    background: #e5e5ea;
    transform: translateY(-1px);
}
.char-counter {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: -12px;
    margin-bottom: 16px;
    font-weight: 600;
}

/* V2 FEATURES: Footer */
.app-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 24px 20px;
    margin-top: 40px;
    text-align: center;
}
.footer-content {
    max-width: 600px;
    margin: 0 auto;
}
.footer-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
}
.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}
.footer-links a:hover {
    text-decoration: underline;
}
.format-btn {
    flex: 1;
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    font-size: 1.1rem;
}
.format-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}
.top-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 16px;
}
.header-tool-btn {
    background: var(--gradient-brand);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 45, 85, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s;
}
.header-tool-btn:hover {
    transform: scale(1.05);
}

.var-input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.var-input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid transparent;
    background: var(--bg-main);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}
.var-input-group input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.15);
}

/* Scripts Section */
.category-section {
    margin-bottom: 40px;
    scroll-margin-top: 120px;
}

.category-section h2 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 16px;
}

.scripts-grid {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 16px;
    margin: 0 -16px; 
    padding-left: 16px;
    padding-right: 16px;
    scroll-snap-type: x mandatory;
}

.scripts-grid::-webkit-scrollbar {
    height: 8px;
}
.scripts-grid::-webkit-scrollbar-track {
    background: transparent;
}
.scripts-grid::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 10px;
}

.script-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid var(--border-color);
    width: 280px; 
    flex-shrink: 0;
    scroll-snap-align: start;
    /* Added hover transition to feel less plain */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.script-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

@media (min-width: 600px) {
    .script-card {
        width: 320px; 
    }
}

.script-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.script-text {
    font-size: 0.95rem;
    color: #3A3A3C;
    background: #F2F2F7;
    padding: 12px;
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    flex-grow: 1;
}

.copy-btn {
    width: 100%;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: auto;
}

.copy-btn:active {
    transform: scale(0.97);
}

.copy-btn.copied {
    background: var(--success);
    color: white;
}

/* Affiliate Cards */
.affiliate-card {
    background: linear-gradient(145deg, #1C1C1E, #2C2C2E);
    color: white;
    border: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.affiliate-badge {
    background: rgba(255, 215, 0, 0.15);
    color: #FFD700;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-block;
    width: fit-content;
    margin-bottom: -4px;
}

.affiliate-title {
    color: white;
}

.affiliate-text {
    background: rgba(255,255,255,0.05);
    color: #E5E5EA;
    border: 1px solid rgba(255,255,255,0.1);
}

.affiliate-btn {
    background: var(--primary);
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.affiliate-btn:hover {
    background: #4845D2;
}
