:root {
    --bg-dark: #0f0c29;
    --bg-mid: #302b63;
    --bg-light: #24243e;
    
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-glow: rgba(255, 255, 255, 0.05);
    
    --text-main: #ffffff;
    --text-muted: #a0a0bd;
    
    --accent-blue: #00f2fe;
    --accent-pink: #ff0844;
    --accent-green: #00b09b;
    --accent-yellow: #f6d365;
    --accent-purple: #b224ef;
    --accent-orange: #ff512f;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Animated Background Mesh Gradient */
.bg-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(125deg, var(--bg-dark), var(--bg-mid), var(--bg-light));
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--accent-purple);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: var(--accent-blue);
    bottom: -200px;
    right: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: var(--accent-pink);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

.glass-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255,255,255,0.2);
    border-left: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    border-radius: 24px;
}

.glass-inset {
    background: rgba(0,0,0,0.2);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
}

/* Typography & Colors */
.gradient-text {
    background: linear-gradient(to right, var(--accent-blue), var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

.text-glow {
    text-shadow: 0 0 20px rgba(255,255,255,0.3);
}

.color-blue { color: var(--accent-blue); }
.color-pink { color: var(--accent-pink); }
.color-green { color: var(--accent-green); }
.color-yellow { color: var(--accent-yellow); }
.color-purple { color: var(--accent-purple); }
.color-orange { color: var(--accent-orange); }

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    padding: 1rem 0;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.logo i {
    color: var(--accent-blue);
    font-size: 2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    opacity: 0.8;
    transition: opacity 0.3s, color 0.3s;
}

.nav-links a:hover {
    opacity: 1;
    color: var(--accent-blue);
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 2rem 4rem;
    position: relative;
    z-index: 10;
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero Section */
.hero {
    text-align: center;
    margin: 4rem 0 6rem;
}

.hero h1 {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    padding-bottom: 4rem;
}

.tool-card {
    padding: 2rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
    transform: skewX(-20deg);
    transition: all 0.6s ease;
}

.tool-card:hover::before {
    left: 150%;
}

.tool-card.hover-glow:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.icon-wrap {
    font-size: 3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-wrap .ph-arrow-right {
    font-size: 1.5rem;
    opacity: 0.5;
}

.tool-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.tool-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Workspace View */
#workspace-view {
    max-width: 800px;
    margin: 0 auto;
}

.workspace-header {
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
}

.btn-back {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s;
}

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

.workspace-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

.workspace-body {
    padding: 3rem;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.flex-col {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Drop Zone */
.drop-zone {
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed rgba(255,255,255,0.2);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.drop-zone:hover {
    border-color: var(--accent-blue);
    background: rgba(0, 242, 254, 0.05);
}

.drop-zone.dragover {
    border-color: var(--accent-pink);
    background: rgba(255, 8, 68, 0.1);
    transform: scale(1.02);
}

.hidden-input {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.pointer-events-none {
    pointer-events: none;
}

.drop-icon {
    font-size: 4rem;
    color: var(--accent-blue);
    transition: transform 0.3s;
}

.drop-zone:hover .drop-icon {
    transform: translateY(-5px);
}

/* Config Area */
.config-area {
    width: 100%;
}

.config-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.compression-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

.stat-box {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit;
}

.saved-badge {
    background: var(--accent-green);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0, 176, 155, 0.3);
}

.saved-badge.negative {
    background: var(--accent-pink);
    box-shadow: 0 4px 10px rgba(255, 42, 133, 0.3);
}

.text-status-green { color: var(--accent-green); text-shadow: 0 0 10px rgba(0, 176, 155, 0.4); }
.text-status-red { color: var(--accent-pink); text-shadow: 0 0 10px rgba(255, 42, 133, 0.4); }

.file-list::-webkit-scrollbar {
    width: 6px;
}
.file-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--glass-bg);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
}

.file-item.dragging {
    opacity: 0.5;
    background: var(--glass-border);
    transform: scale(0.98);
}

.cursor-move {
    cursor: grab;
}

.cursor-move:active {
    cursor: grabbing;
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
}

.file-item-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background-color: rgba(255,255,255,0.05); /* placeholder background */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.file-item-icon {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.file-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.file-item-size {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.file-item-remove:hover {
    color: var(--accent-pink);
}

/* Tool Options Section */
.options-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.option-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.option-group h4 {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
    color: var(--text-main);
}

.option-grid {
    display: grid;
    gap: 1rem;
}

.option-grid-2 { grid-template-columns: 1fr 1fr; }
.option-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.option-card {
    background: rgba(255,255,255,0.03);
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.option-card i {
    font-size: 1.8rem;
}

.option-card span {
    font-size: 0.85rem;
    font-weight: 500;
}

.option-card:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
}

.option-card.active {
    border-color: #ef4444; /* Premium Red from reference */
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.glass-select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.glass-select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

/* CSS-Drawn Orientation Icons (Portrait/Landscape) */
.orientation-icon {
    display: block;
    border: 2px solid currentColor;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.portrait-icon {
    width: 22px;
    height: 30px;
}

.landscape-icon {
    width: 30px;
    height: 22px;
}

/* Split Layout for Options & Preview */
.config-split-layout {
    display: flex;
    gap: 2rem;
    align-items: stretch;
}

.config-controls {
    flex: 1;
}

.config-preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-left: 2rem;
    border-left: 1px solid var(--glass-border);
}

.config-preview-panel h4 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.2rem;
}

.preview-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* The Live Preview Canvas Wrapper */
.preview-canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 1rem;
    min-height: 250px;
    overflow: hidden;
}

/* The Paper Element */
.preview-paper {
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    position: relative;
    max-width: 100%;
    max-height: 100%;
}

/* Aspect Ratios */
.aspect-portrait { aspect-ratio: 1 / 1.414; width: auto; height: 100%; } 
.aspect-landscape { aspect-ratio: 1.414 / 1; width: 100%; height: auto; }
.aspect-fit { width: 100%; height: 100%; object-fit: contain; }

/* Margins on the Paper */
.preview-margin {
    flex: 1;
    border: 1px dashed rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.margin-none { margin: 0; }
.margin-small { margin: 4%; }
.margin-big { margin: 10%; }

/* The Simulated Image Layer */
.preview-image-layer {
    background-color: var(--accent-blue); /* fallback */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 100%;
    height: 100%;
    opacity: 0.8;
    transition: all 0.3s ease;
}

/* Buttons */
.btn-primary, .btn-success, .btn-outline {
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    border: none;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, var(--accent-blue), var(--accent-purple));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-primary:not(.disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 242, 254, 0.5);
}

.btn-primary.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--glass-bg);
    box-shadow: none;
    border: 1px solid var(--glass-border);
}

.btn-success {
    background: linear-gradient(45deg, var(--accent-green), #00d2ff);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 176, 155, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 176, 155, 0.5);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--glass-bg);
}

.btn-compact {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    width: auto;
    display: inline-flex;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.glow-submit {
    position: relative;
    overflow: hidden;
}

.glow-submit::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { left: -100%; }
    20% { left: 100%; }
    100% { left: 100%; }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 12, 41, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    gap: 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Result Area */
.result-area {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.success-icon {
    font-size: 4rem;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Ad Placements */
.ad-placeholder {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.ad-container-top {
    margin: 0 auto 2rem;
    max-width: 728px;
    height: 110px; /* 90px ad + 20px label */
}

.ad-container-square {
    margin: 0 auto;
    width: 300px;
    height: 270px; /* 250px ad + 20px label */
}

.ad-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 0;
}

.mt-2 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1.5rem; }

.hidden {
    display: none !important;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    position: absolute;
    bottom: 0;
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 90px 1rem 2rem; }
    
    .ad-container-top {
        margin-bottom: 0px; /* Reduced gap significantly based on feedback */
    }
    
    .hero {
        margin: 0.5rem 0 1.5rem; /* Reduced gap based on feedback */
    }
    
    .hero h1 { font-size: 2.2rem; margin-bottom: 0.2rem; }
    .hero p { font-size: 1rem; }
    
    .workspace-body { padding: 1.2rem; }
    .btn-back { position: static; transform: none; margin-bottom: 0.5rem; justify-content: center; }
    
    /* Config Options - fit all 3 options in one row, no swiping */
    .option-grid { 
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        overflow-x: unset;
    }
    
    .option-card {
        flex: unset;
        min-width: unset;
        padding: 0.8rem 0.3rem;
        font-size: 0.75rem;
    }
    
    .option-card i {
        font-size: 1.3rem;
    }
    
    .option-card span {
        font-size: 0.7rem;
    }
    
    .config-split-layout { 
        flex-direction: column; 
    }
    
    .config-preview-panel {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--glass-border);
        padding-top: 1rem;
        margin-top: 0.3rem;
    }
    
    .options-section {
        margin-top: 0.8rem;
        padding-top: 0.8rem;
    }
    
    .option-group {
        margin-bottom: 0.8rem;
    }
    
    .option-group h4 {
        margin-bottom: 0.5rem;
    }
    
    .preview-hint {
        margin-bottom: 0.5rem;
    }
    
    .config-title {
        margin-bottom: 0.5rem;
        padding-bottom: 0.3rem;
    }
    
    /* Slim down Live Preview canvas on mobile for faster load */
    .preview-canvas-wrapper {
        min-height: 170px;
        height: 170px;   /* Fixed height so portrait has a reference */
        padding: 1rem;
    }
    
    /* Fix portrait sizing on mobile - use width-based instead of height-based */
    .preview-paper.aspect-portrait {
        height: auto;
        width: 55%;
        aspect-ratio: 1 / 1.414;
    }
    
    .preview-paper.aspect-landscape {
        width: 100%;
        height: auto;
        aspect-ratio: 1.414 / 1;
    }

    /* 3 Column Vertical Grid on Mobile */
    .tools-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        padding-bottom: 2rem;
        margin: 0;
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Make cards smaller and square */
    .tool-card {
        aspect-ratio: 1 / 1;
        padding: 0.8rem 0.2rem;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 0.5rem;
        border-radius: 12px;
    }
    
    /* Shrink Icons */
    .icon-wrap {
        font-size: 1.5rem;
        justify-content: center;
    }
    .icon-wrap .ph-arrow-right {
        display: none; /* Hide arrows for space */
    }
    
    /* Shrink Title */
    .tool-card h3 {
        font-size: 0.70rem;
        line-height: 1.2;
    }
    
    /* Hide Description completely */
    .tool-card p {
        display: none;
    }
}
