:root {
    --bg-dark: #0f1115;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-glow: rgba(56, 189, 248, 0.15);
    --glass-bg: rgba(255, 255, 255, 0.02);
    /* More transparent for gloss */
    --glass-border: rgba(255, 255, 255, 0.12);
    /* Brighter border */
    --btn-primary-bg: rgba(255, 255, 255, 0.1);
    --btn-hover: rgba(255, 255, 255, 0.2);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 50%, rgba(30, 41, 59, 0.5) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(51, 65, 85, 0.5) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(15, 23, 42, 1) 0%, transparent 100%);
    filter: blur(60px);
}

.navbar {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 1px;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem 2rem;
    overflow: hidden;
    min-height: 0;
    gap: 1.5rem;
}

.actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-shrink: 0;
    margin-top: auto;
    width: 100%;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
}

.vote-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.2rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 44px;
    /* Fixed width matching slightly larger than buttons */
}

.vote-stack .btn-icon {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* Ensure no margin interferes */
}

.vote-stack .btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

.vote-stack .btn-icon svg {
    width: 22px;
    height: 22px;
}

.score-display {
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    width: 100%;
    display: flex;
    /* Flexbox for perfect centering */
    justify-content: center;
    align-items: center;
    padding: 0.2rem 0;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced V3 Glass Card */
.glass-card {
    width: 100%;
    max-width: 1000px;
    height: 100%;
    max-height: 700px;
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    /* Highlights */
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.6),
        inset 0 0 60px rgba(255, 255, 255, 0.03);
    /* Deep inner glow */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.content-split {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.image-section {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

.image-container {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    /* Brighter inner border */
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
    /* Depth */
}

.placeholder-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    opacity: 0.6;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

#joke-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.5s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.text-section {
    flex: 1;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.01), transparent);
}

.joke-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.8rem;
    margin-bottom: 2rem;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.joke-content::-webkit-scrollbar {
    width: 6px;
}

.joke-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.joke-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.joke-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.joke-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 1.2rem 0;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.1));
}

.joke-body {
    font-size: 1.15rem;
    line-height: 1.7;
    color: #cbd5e1;
    /* Brighter secondary text */
    margin: 0;
    font-weight: 300;
}



.btn {
    border: none;
    outline: none;
    padding: 1rem 1.8rem;
    border-radius: 100px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn.primary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn.primary:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255, 255, 255, 0.1), transparent);
    pointer-events: none;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
}

.auth-controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.btn:active {
    transform: translateY(0);
}

/* Footer Social Icons - Floating Glass */
.footer-social {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    padding: 1.5rem;
    flex-shrink: 0;
}

.social-icon {
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    text-decoration: none;
    backdrop-filter: blur(5px);
}

.social-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

.btn-icon.large {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.08);
}

.btn-icon.large svg {
    width: 26px;
    height: 26px;
}

/* Search Bar - Glossy Input */
.search-container {
    display: flex;
    gap: 0.5rem;
}

.search-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    padding: 0.7rem 1.4rem;
    color: white;
    font-family: var(--font-main);
    font-size: 0.9rem;
    width: 240px;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.search-input:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.search-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }

    .container {
        height: auto;
        overflow: visible;
        padding: 1rem;
    }

    .content-split {
        flex-direction: column;
    }

    .glass-card {
        border-radius: 25px;
        height: auto;
        max-height: none;
    }

    .image-section {
        min-height: 250px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .text-section {
        height: auto;
        overflow: visible;
        padding: 1.5rem;
    }

    .joke-content {
        max-height: 400px;
    }

    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .search-input {
        width: 100%;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    /* Upper left corner */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: auto;
    max-width: 400px;
}

.toast {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    /* Base state: invisible and slight offset */
    opacity: 0;
    transform: translateY(-20px);

    /* Default transition (for appearing and recovering): Fast */
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    pointer-events: auto;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.fading {
    opacity: 0;
    /* When fading out, use a slow linear transition */
    transition: opacity 3s linear;
}

/* Traveling Glow Effect */
.toast.glow {
    position: relative;
    overflow: hidden;
    /* Ensure glow doesn't spill if mask fails */
}

.toast.glow::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    /* Match toast border-radius */
    padding: 2px;
    /* Width of the traveling border */
    background: linear-gradient(60deg, transparent 20%, rgba(56, 189, 248, 0.8) 50%, transparent 80%);
    background-size: 200% 200%;

    /* Create the border mask */
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;

    /* Animation */
    animation: shineBorder 2s linear infinite;
    pointer-events: none;
}

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

    100% {
        background-position: 100% 50%;
    }
}

/* Remove old blink */
.toast.error {
    background: rgba(40, 0, 0, 0.6);
    /* Darker background for readable slightly red text */
    border-color: rgba(220, 38, 38, 0.3);
    color: #ffcccc;
    /* Slightly tilted to red */
}

/* --- Auth Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.glass-modal {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
    position: relative;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .glass-modal {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: white;
}

.auth-header {
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.accent-text {
    display: table;
    /* Ensures gradient applies to text block */
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-style: italic;
    margin: 0 auto;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.row-group {
    display: flex;
    gap: 1rem;
}

.input-group {
    position: relative;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    opacity: 0.7;
    pointer-events: none;
}

.glass-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    /* Space for icon */
    color: white;
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.glass-input:not([type="date"]):not([type="time"]) {
    /* Normal inputs */
}

/* Handle inputs without icons if any */
.input-group input:not([type="date"])+.glass-input {
    /* If we used sibling selector, but structure keeps icon inside group */
}

/* Logic for "no icon" inputs if exists */
.input-group:not(:has(.input-icon)) .glass-input {
    padding-left: 1rem;
}

.glass-textarea {
    min-height: 80px;
    resize: vertical;
    padding-left: 1rem;
    /* Textarea usually no icon or top aligned */
}

.glass-input:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(56, 189, 248, 0.5);
    /* Light blue focus */
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
}

.auth-btn {
    margin-top: 1rem;
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    border: none;
    border-radius: 100px;
    padding: 1rem;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(56, 189, 248, 0.4);
}

.auth-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.auth-footer a {
    color: #38bdf8;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: #7dd3fc;
    text-decoration: underline;
}

/* Date input specific styling to match theme */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(0.6);
    cursor: pointer;
}

.toast.success {
    background: rgba(22, 163, 74, 0.2);
    border-color: rgba(22, 163, 74, 0.3);
    color: #bbf7d0;
}