/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #5855eb;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --error-color: #ef4444;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* Dark theme variables */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --border-hover: #475569;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* The HTML `hidden` attribute is supposed to apply `display: none`,
   but our custom components use `display: flex` / `display: grid`
   which has higher specificity than the user-agent's `[hidden]`
   rule. Force `hidden` to win so we can keep using the attribute
   for show/hide logic. */
[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.logo i {
    font-size: 1.5rem;
}

/* ============================================ */
/* Header: compact icon-row on the right        */
/* ============================================ */

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Square icon button shared by theme + hamburger. Same size as the
   HF avatar circle so the three header controls line up visually. */
.theme-toggle,
.hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
    font-size: 0.95rem;
}

.theme-toggle:hover,
.hamburger:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.theme-toggle:focus-visible,
.hamburger:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.hamburger[aria-expanded="true"] {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* ============================================ */
/* Hugging Face login: compact icons in header  */
/* ============================================ */

.hf-auth {
    position: relative;
    display: flex;
    align-items: center;
}

/* Compact "Login with HF" button — just the hugging-face emoji on a
   square yellow tile, sized to match theme + hamburger. The full
   pill button is rendered inside the drawer instead. */
.hf-login-btn-compact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #FFD21E, #FF9D00);
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.hf-login-btn-compact:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 157, 0, 0.35);
    filter: brightness(1.05);
}

.hf-login-btn-compact:focus-visible {
    outline: 2px solid #FFD21E;
    outline-offset: 2px;
}

/* When the user is logged in, the yellow tile is replaced by their
   avatar in the same square slot. Clicking opens the drawer (which
   has the full account UI). */
.hf-avatar-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.hf-avatar-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.hf-avatar-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.hf-avatar-btn[aria-expanded="true"] {
    border-color: var(--primary-color);
}

.hf-avatar-btn .hf-user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.hf-avatar-btn .hf-user-avatar.is-broken {
    display: none;
}

/* ============================================ */
/* Slide-in drawer (mobile menu)                */
/* ============================================ */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.drawer-backdrop.is-open {
    opacity: 1;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 88vw);
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
    overflow-y: auto;
}

.drawer.is-open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.drawer-header .logo {
    font-size: 1.05rem;
}

.drawer-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.drawer-close:hover,
.drawer-close:focus-visible {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.15rem;
    border-bottom: 1px solid var(--border-color);
}

.drawer-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.drawer-link i:first-child {
    width: 1.1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.drawer-link:hover,
.drawer-link:focus-visible {
    background: var(--bg-tertiary);
    color: var(--primary-color);
    outline: none;
}

.drawer-link:hover i:first-child,
.drawer-link:focus-visible i:first-child {
    color: var(--primary-color);
}

.drawer-link-external {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.drawer-section {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.drawer-section:last-child {
    border-bottom: none;
}

/* Account block inside the drawer. JS swaps between two layouts. */
.drawer-account-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.drawer-account-card .hf-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.drawer-account-card .hf-user-avatar.is-broken {
    display: none;
}

.drawer-account-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.drawer-account-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-account-username {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.drawer-account-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.drawer-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.drawer-btn i {
    width: 1rem;
    text-align: center;
    color: var(--text-muted);
}

.drawer-btn:hover,
.drawer-btn:focus-visible {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
    color: var(--primary-color);
    outline: none;
}

.drawer-btn:hover i,
.drawer-btn:focus-visible i {
    color: var(--primary-color);
}

.drawer-btn-danger:hover,
.drawer-btn-danger:focus-visible {
    border-color: #f43f5e;
    color: #f43f5e;
}

.drawer-btn-danger:hover i,
.drawer-btn-danger:focus-visible i {
    color: #f43f5e;
}

.drawer-link-support {
    color: #f43f5e;
}

.drawer-link-support i:first-child {
    color: #f43f5e;
}

.drawer-link-support:hover,
.drawer-link-support:focus-visible {
    color: #ec4899;
    background: var(--bg-tertiary);
}

.drawer-link-support:hover i:first-child,
.drawer-link-support:focus-visible i:first-child {
    color: #ec4899;
}

/* Logged-out CTA: the full-width yellow "Sign in with Hugging Face"
   inside the drawer. Bigger and louder than the header icon, because
   this is the place where we want to convert visitors into users. */
.drawer-login-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.95rem 1rem;
    background: linear-gradient(135deg, #FFD21E, #FF9D00);
    color: #1a1a1a;
    border: none;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(255, 157, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.drawer-login-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 157, 0, 0.35);
    filter: brightness(1.05);
    color: #1a1a1a;
}

.drawer-login-cta:focus-visible {
    outline: 2px solid #FFD21E;
    outline-offset: 2px;
}

.drawer-login-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

/* ============================================ */
/* Login callout (above the upload area)        */
/* ============================================ */

.login-callout {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg,
        color-mix(in srgb, #FFD21E 18%, var(--bg-card)),
        color-mix(in srgb, #FF9D00 12%, var(--bg-card))
    );
    border: 1px solid color-mix(in srgb, #FF9D00 35%, var(--border-color));
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(255, 157, 0, 0.12);
    position: relative;
    animation: callout-in 0.4s ease-out;
}

@keyframes callout-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-callout-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.login-callout-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.login-callout-body strong {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.login-callout-body span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.35;
}

.login-callout-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    background: linear-gradient(135deg, #FFD21E, #FF9D00);
    color: #1a1a1a;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    border: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.login-callout-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 157, 0, 0.3);
    filter: brightness(1.05);
    color: #1a1a1a;
}

.login-callout-cta:focus-visible {
    outline: 2px solid #FFD21E;
    outline-offset: 2px;
}

.login-callout-dismiss {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: color 0.15s ease, background-color 0.15s ease;
    flex-shrink: 0;
}

.login-callout-dismiss:hover,
.login-callout-dismiss:focus-visible {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.06);
    outline: none;
}

@media (max-width: 480px) {
    .login-callout {
        flex-wrap: wrap;
        padding: 0.75rem 0.85rem;
    }
    .login-callout-body {
        flex-basis: calc(100% - 3rem);
    }
    .login-callout-cta {
        flex-basis: 100%;
        justify-content: center;
    }
    .login-callout-dismiss {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* Main content */
.main {
    min-height: calc(100vh - 140px);
    padding: 2rem 0;
}

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

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Performance optimization styles */
.image-processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xl);
    z-index: 10;
}

[data-theme="dark"] .image-processing-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.image-processing-overlay .processing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.mini-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--bg-tertiary);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Enhanced upload area with relative positioning */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--bg-secondary);
    position: relative; /* Added for overlay positioning */
}

/* Lazy loading and image optimization */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Progressive enhancement for modern browsers */
@supports (backdrop-filter: blur(10px)) {
    .header {
        background-color: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(10px);
    }
    
    [data-theme="dark"] .header {
        background-color: rgba(15, 23, 42, 0.8);
    }
}

/* GPU acceleration for smooth animations */
.upload-area,
.settings-panel,
.processing-section,
.results-section,
.comparison-slider {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimized transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .mini-spinner {
        animation: none;
    }
    
    .comparison-info i {
        animation: none;
    }
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-tertiary);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: var(--bg-tertiary);
    transform: scale(1.02);
}

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

.upload-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-link {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
}

.upload-info {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Settings panel */
.settings-panel {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.settings-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.settings-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.settings-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
}

/* Custom checkbox */
.setting-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all 0.2s ease;
}

.setting-label input[type="checkbox"]:checked + .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.setting-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Slider styles */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-md);
}

.slider-value {
    min-width: 3rem;
    text-align: center;
    font-weight: 500;
    color: var(--primary-color);
}

/* Hugging Face API key input */
.setting-group-wide {
    grid-column: 1 / -1;
}

.optional-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.hf-key-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.hf-key-input {
    width: 100%;
    padding: 0.7rem 2.6rem 0.7rem 0.9rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.hf-key-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Menlo, Consolas, monospace;
}

.hf-key-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.hf-key-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.hf-key-toggle:hover {
    color: var(--primary-color);
    background: var(--bg-card);
}

.hf-key-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.hf-key-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.hf-key-hint.is-active {
    color: var(--primary-color);
}

/* Tooltip */
.tooltip {
    color: var(--text-muted);
    cursor: help;
    margin-left: 0.25rem;
}

.tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.enhance-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.enhance-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.enhance-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Processing section */
.processing-section {
    text-align: center;
    padding: 3rem 2rem;
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.processing-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.processing-content p {
    color: var(--text-secondary);
}

/* Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

/* Results section */
.results-section {
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.results-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 1rem;
}

/* Comparison container */
.comparison-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-secondary);
}

.comparison-wrapper {
    position: relative;
    background: var(--bg-card);
}

/* Image comparison slider styles */
img-comparison-slider {
    border-radius: var(--radius-lg);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

img-comparison-slider img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 600px;
    object-fit: contain;
}

img-comparison-slider:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Comparison labels */
.comparison-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
}

.label-left,
.label-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.label-left i {
    color: var(--secondary-color);
}

.label-right i {
    color: var(--accent-color);
}

.comparison-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-info i {
    color: var(--primary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Comparison stats */
.comparison-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Enhanced responsive design for comparison */
@media (max-width: 768px) {
    /* Tighter header gap so the three icon controls (HF / theme /
       hamburger) plus the logo all fit on a 360px screen. The
       hamburger now holds all the navigation / account items, so
       the header itself doesn't need to do anything special here. */
    .header-actions {
        gap: 0.3rem;
    }
    .theme-toggle,
    .hamburger,
    .hf-login-btn-compact,
    .hf-avatar-btn {
        width: 36px;
        height: 36px;
    }

    .comparison-labels {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }
    
    .comparison-info {
        display: none;
    }
    
    .comparison-stats {
        grid-template-columns: repeat(2, 1fr);
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .stat-item {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .comparison-labels {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .label-left,
    .label-right {
        justify-content: center;
    }
    
    .comparison-stats {
        grid-template-columns: 1fr;
    }
}

/* Footer */
.footer {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
}

/* Responsive design */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .settings-content {
        grid-template-columns: 1fr;
    }
    
    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .results-actions {
        justify-content: center;
    }
    
    .container {
        padding: 0 0.5rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.75rem;
    }
    
    .upload-icon {
        font-size: 2rem;
    }
    
    .upload-area h3 {
        font-size: 1.25rem;
    }
    
    .settings-panel {
        padding: 1.5rem;
    }
    
    .results-actions {
        flex-direction: column;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Focus styles for accessibility */
button:focus,
input:focus,
.upload-area:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
    
    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================ */
/* Support / Tip nav link + Floating Action Btn */
/* ============================================ */
.support-nav-link,
.support-nav-link:link,
.support-nav-link:visited {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    background: linear-gradient(135deg, #f43f5e, #ec4899) !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    padding: 0.45rem 0.9rem !important;
    border-radius: var(--radius-md, 0.5rem) !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease !important;
}

.support-nav-link:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.35) !important;
    filter: brightness(1.05) !important;
    color: #ffffff !important;
}

.support-fab,
.support-fab:link,
.support-fab:visited,
.support-fab:hover,
.support-fab:active {
    position: fixed !important;
    right: 1.25rem !important;
    bottom: 1.25rem !important;
    z-index: 2147483647 !important;       /* sit above literally everything */
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    padding: 0.85rem 1.15rem !important;
    margin: 0 !important;
    background: linear-gradient(135deg, #f43f5e, #ec4899) !important;
    background-color: #ec4899 !important; /* fallback if gradient unsupported */
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important; /* override any browser dark-mode link color */
    border: none !important;
    border-radius: 999px !important;
    text-decoration: none !important;
    text-decoration-line: none !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    line-height: 1.2 !important;
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif) !important;
    box-shadow: 0 10px 25px rgba(236, 72, 153, 0.45),
                0 4px 10px rgba(0, 0, 0, 0.15) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease !important;
    animation: support-fab-pulse 2.4s ease-in-out infinite !important;
    /* Ensure the element is its own containing block in case an ancestor
       has filter/transform/perspective set, which would otherwise break
       position: fixed on some browsers. */
    transform: translateZ(0);
    isolation: isolate;
    contain: layout style;
}

.support-fab i {
    font-size: 1.05rem !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    animation: support-fab-heart 1.6s ease-in-out infinite !important;
    display: inline-block !important;
    font-style: normal !important;
    line-height: 1 !important;
}

.support-fab:hover {
    transform: translateY(-2px) scale(1.03) translateZ(0) !important;
    box-shadow: 0 14px 30px rgba(236, 72, 153, 0.55),
                0 6px 14px rgba(0, 0, 0, 0.18) !important;
    filter: brightness(1.05) !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

.support-fab:focus-visible {
    outline: 3px solid #fff !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(236, 72, 153, 0.5) !important;
    color: #ffffff !important;
}

@keyframes support-fab-pulse {
    0%, 100% { box-shadow: 0 10px 25px rgba(236, 72, 153, 0.45), 0 4px 10px rgba(0, 0, 0, 0.15); }
    50%      { box-shadow: 0 14px 32px rgba(236, 72, 153, 0.65), 0 6px 14px rgba(0, 0, 0, 0.18); }
}

@keyframes support-fab-heart {
    0%, 100% { transform: scale(1); }
    20%      { transform: scale(1.25); }
    40%      { transform: scale(0.95); }
    60%      { transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
    .support-fab,
    .support-fab i {
        animation: none;
    }
}

@media (max-width: 480px) {
    .support-fab {
        right: 0.85rem;
        bottom: 0.85rem;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    .support-nav-link span {
        display: none;
    }
}

/* ============================================ */
/* Telegram Mini App adjustments                */
/* ============================================ */

/* The TMA banner: hidden by default, JS removes [hidden] in TMA */
.tma-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #229ED9, #0088cc);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.tma-banner[hidden] {
    display: none !important;
}
.tma-banner i { font-size: 1.1rem; }
.tma-banner span { flex: 1; }
.tma-banner button,
.tma-banner .tma-banner-close {
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    padding: 0.4rem 0.6rem !important;
    border-radius: 6px !important;
    opacity: 0.9 !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 36px !important;
    min-height: 36px !important;
    -webkit-tap-highlight-color: rgba(255,255,255,0.3) !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
}
.tma-banner button:hover,
.tma-banner .tma-banner-close:hover,
.tma-banner .tma-banner-close:active {
    opacity: 1 !important;
    background: rgba(255,255,255,0.15) !important;
}
.tma-banner .tma-banner-close i {
    pointer-events: none !important;
    font-size: 1.1rem !important;
    line-height: 1 !important;
}

/* TMA layout adjustments */
.tma-mode, .tma-mode body {
    /* Respect Telegram's reported viewport height */
    min-height: var(--tma-viewport-h, 100vh);
    /* No rubber-band overscroll inside the mini app */
    overscroll-behavior: none;
}

.tma-mode {
    /* Add safe-area padding for devices with notches while inside Telegram */
    padding-top: var(--tma-safe-top, 0px);
    padding-bottom: var(--tma-safe-bottom, 0px);
}

/* In TMA, the floating support button is redundant (Telegram has its
   own back button + native UI). Keep it but make it less intrusive and
   raise it so it doesn't collide with Telegram's bottom bar. */
.tma-mode .support-fab {
    bottom: calc(1.25rem + var(--tma-safe-bottom, 0px));
    right: 1rem;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    /* Disable the pulse animation inside Telegram to save battery */
    animation: none;
}

/* Tighter spacing in TMA — the container has less real estate */
.tma-mode .container { padding: 0 0.85rem; }
.tma-mode .hero-title { font-size: clamp(1.5rem, 6vw, 2.2rem); }
.tma-mode .hero-subtitle { font-size: 1rem; }
.tma-mode .upload-area { padding: 2rem 1rem; }

/* Disable the drag-and-drop visual hint in TMA — touch devices don't DnD */
.tma-mode .upload-area .upload-info::after {
    content: " · Tap to pick a file";
}

/* Make the in-Telegram experience a bit more "app-like" */
.tma-mode .header {
    /* Stick the header to the top of the TMA viewport */
    position: sticky;
    top: var(--tma-safe-top, 0);
    z-index: 50;
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    background-color: color-mix(in srgb, var(--bg-primary) 85%, transparent);
}
.tma-mode[data-theme="dark"] .header {
    background-color: color-mix(in srgb, var(--bg-primary) 85%, transparent);
}

