:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.05);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Changed from center to prevent top cut-off on mobile */
    padding: 3rem 1rem 10rem 1rem;
    /* Substantial bottom padding so ad banner doesn't cover content */
    overflow-x: hidden;
    overflow-y: auto;
    /* Fix: Allow scrolling */
}

.background-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.5;
    animation: move 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: #6366f1;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: #ec4899;
    animation-delay: -5s;
}

@keyframes move {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(60px, 60px) scale(1.15);
    }
}

.converter-card {
    position: relative;
    z-index: 1;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--glass-shadow);
    transform: translateY(20px);
    opacity: 0;
    animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

p.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 300;
}

.input-group {
    margin-bottom: 1.5rem;
    position: relative;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.control-wrapper {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.control-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

input[type="number"] {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    outline: none;
    width: 100%;
    padding: 0.5rem;
}

input[type="number"]::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

select {
    appearance: none;
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 2rem 0.5rem 1rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    transition: background 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
}

select:hover {
    background-color: var(--accent-hover);
}

.swap-btn-container {
    display: flex;
    justify-content: center;
    margin: -1.2rem 0;
    position: relative;
    z-index: 2;
}

.swap-btn {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.swap-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(180deg);
}

.result-container {
    margin-top: 2rem;
    text-align: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.rate-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.final-amount {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.is-loading .loading-spinner {
    display: inline-block;
}

.is-loading .result-value {
    display: none;
}

/* --- Search Bar --- */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-container input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
}

.search-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* --- Mock Charts --- */
.chart-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.time-toggles {
    display: flex;
    gap: 0.3rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px;
    border-radius: 6px;
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.time-btn.active {
    background: var(--card-border);
    color: var(--text-primary);
}

.mock-chart {
    height: 60px;
    width: 100%;
    position: relative;
}

.mock-chart svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

#trend-line {
    transition: all 0.5s ease;
}

.chart-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
}

.chart-col {
    flex: 1;
    height: 100%;
    position: relative;
    cursor: crosshair;
}

.chart-col:hover,
.chart-col.active-touch {
    background: rgba(255, 255, 255, 0.05);
}

.chart-col:hover::before,
.chart-col.active-touch::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.chart-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    font-size: 0.7rem;
    color: white;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.chart-col:hover .chart-tooltip,
.chart-col.active-touch .chart-tooltip {
    opacity: 1;
}

/* --- AI Prediction Panel --- */
.ai-prediction-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 12px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.ai-prediction-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    to {
        left: 200%;
    }
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fbcfe8;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

#ai-text {
    font-size: 0.95rem;
    font-weight: 300;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.confidence-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: #ec4899;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-disclaimer {
    display: block;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.8rem;
    text-align: right;
}

/* --- Ad Banner --- */
.ad-banner {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 90%;
    max-width: 600px;
    text-align: center;
    gap: 1rem;
    z-index: 20;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.ad-banner strong {
    color: var(--accent);
}

#close-ad-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

#close-ad-btn:hover {
    color: white;
}

.ad-banner.dismissed {
    display: none !important;
}

/* --- State Toggles --- */
/* Completely logged out views */
body.is-free.is-logged-out .profile-content.auth-only {
    display: none !important;
}

/* Logged in views (hides login form) */
body.is-logged-in .profile-content.free-only {
    display: none !important;
}

body.is-free .pro-only {
    display: none !important;
}

body.is-pro .free-only {
    display: none !important;
}

/* --- Profile Section Styles Updates --- */
.top-bar {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10;
}

.profile-btn {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.profile-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Sidebar */
.profile-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    /* Hidden by default */
    width: 100%;
    max-width: 350px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    /* Darker blur for overlay contrast */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid var(--card-border);
    z-index: 100;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.profile-sidebar.open {
    right: 0;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
}

.close-btn:hover {
    color: white;
}

.profile-content {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    overflow-y: auto;
}

/* Pricing Cards */
.pricing-cards {
    display: flex;
    gap: 0.8rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

.plan-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.plan-card.pro {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.plan-card h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.plan-card .price {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.plan-card .price span {
    font-size: 0.7rem;
    font-weight: 400;
}

.features {
    list-style: none;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: left;
    padding-left: 0.5rem;
}

.plan-card.pro .features {
    color: var(--text-primary);
}

.features li {
    margin-bottom: 0.25rem;
    position: relative;
}

.features li::before {
    content: '•';
    color: var(--accent);
    position: absolute;
    left: -10px;
}

/* Login Form */
.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: auto;
}

.login-form input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.8rem;
    color: white;
    outline: none;
}

.login-form input:focus {
    border-color: var(--accent);
}

/* Settings Toggle */
.settings-group {
    width: 100%;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-info strong {
    font-size: 0.9rem;
    display: block;
}

.setting-info p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* Toggle Switch CSS */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.avatar-container {
    margin-bottom: 1rem;
    position: relative;
    cursor: pointer;
}

.avatar-hover-icon {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    color: white;
}

.avatar-container:hover .avatar-hover-icon {
    opacity: 1;
}

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
    color: white;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.pro-badge {
    background: rgba(236, 72, 153, 0.2);
    color: #fbcfe8;
    border: 1px solid rgba(236, 72, 153, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 2rem;
}

.profile-stats {
    display: flex;
    width: 100%;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn {
    width: 100%;
    padding: 0.85rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.action-btn.btn-sm {
    padding: 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0;
    margin-top: 1rem;
}

.action-btn.outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.action-btn.outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.action-btn.logout {
    margin-top: auto;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid transparent;
}

.action-btn.logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Background Overlay when sidebar is open */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}