:root {
    --bg-page: #fafafa;
    --bg-surface: #ffffff;
    --text-primary: #111111;
    --text-secondary: #666666;
    --border-color: #e5e5e5;
    --focus-ring: #000000;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: 0.2s ease;
}

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

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Header */
.app-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
}

.nav-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

/* Layout for Main + Side Ads */
.page-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    padding: 4rem 1rem;
    flex: 1;
}

.main-content {
    flex: 1;
    max-width: 640px;
    width: 100%;
}

/* Side Ads */
.side-ad {
    display: none;
    position: sticky;
    top: 4rem;
}

@media (min-width: 1024px) {
    .side-ad { display: block; }
}

.ad-placeholder-vertical {
    width: 160px;
    height: 600px;
    background: transparent;
    border: 1px dashed #d0d0d0;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #a0a0a0;
    font-size: 0.85rem;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.4;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
}

/* Tool Section */
.tool-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    padding: 0.5rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.input-wrap:focus-within {
    border-color: var(--focus-ring);
    box-shadow: 0 0 0 1px var(--focus-ring);
}

.icon-link {
    color: var(--text-secondary);
    margin: 0 0.75rem;
}

.input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: transparent;
    padding: 0.5rem 0;
}

.input-wrap input::placeholder {
    color: #a0a0a0;
}

.btn-paste {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-paste:hover {
    background: #f0f0f0;
    color: var(--text-primary);
}

.btn-primary {
    width: 100%;
    background: var(--text-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    padding: 1.1rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: #2a2a2a;
}

/* Alerts */
.hidden { display: none !important; }

.alert {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.95rem;
}

.alert.error { background: #fff0f0; color: #d32f2f; border: 1px solid #ffcdd2; }
.alert.info { background: #f5f5f5; color: var(--text-secondary); border: 1px solid var(--border-color); }

/* Results */
.results-area { margin-top: 2rem; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.preview-box {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-page);
    aspect-ratio: 16/9;
    margin-bottom: 2rem;
}

.preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.downloads-list { display: flex; flex-direction: column; gap: 0.75rem; }

.dl-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem; background: #fafafa; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); transition: var(--transition);
}

.dl-row:hover { background: #ffffff; border-color: #d0d0d0; }

.dl-info { display: flex; flex-direction: column; }
.dl-info strong { font-size: 0.95rem; font-weight: 600; }
.dl-info span { font-size: 0.85rem; color: var(--text-secondary); }

.btn-secondary {
    text-decoration: none; background: white; border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 0.6rem 1.2rem; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg-page); border-color: #c0c0c0; }

/* Bottom Ad Placement */
.ad-container-bottom {
    margin-top: 3rem; background: transparent; border: 1px dashed #d0d0d0;
    border-radius: var(--radius-md); min-height: 100px; display: flex;
    justify-content: center; align-items: center;
}

.ad-label {
    font-size: 0.85rem; color: #a0a0a0; text-transform: uppercase; letter-spacing: 0.05em;
}

/* Modal Popup Ad Styles */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 100%;
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}
.btn-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-placeholder-popup {
    width: 336px;
    height: 280px;
    background: transparent;
    border: 1px dashed #d0d0d0;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #a0a0a0;
    font-size: 0.85rem;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.4;
}

@media (max-width: 400px) {
    .ad-placeholder-popup { width: 300px; height: 250px; }
}

/* Footer */
.app-footer {
    text-align: center; padding: 2rem 0; color: var(--text-secondary);
    font-size: 0.85rem; border-top: 1px solid var(--border-color);
}
