Spaces:
Running
Running
import gradio as gr | |
# Custom CSS for enhanced UI | |
custom_title_css = """ | |
/* Target the HTML component specifically */ | |
.gradio-html .main-title { | |
font-size: 48px !important; | |
font-weight: 800 !important; | |
color: #0077B5 !important; | |
text-align: center !important; | |
margin: 20px 0 10px 0 !important; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; | |
text-shadow: 2px 2px 4px rgba(0,0,0,0.1) !important; | |
} | |
.gradio-html .main-subtitle { | |
font-size: 18px !important; | |
color: #666666 !important; | |
text-align: center !important; | |
margin: 0 0 30px 0 !important; | |
font-weight: 400 !important; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; | |
} | |
.gradio-html .title-container { | |
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important; | |
border-radius: 15px !important; | |
padding: 40px 20px !important; | |
margin: 20px 0 !important; | |
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important; | |
border: 2px solid #e2e8f0 !important; | |
} | |
.gradio-html .emoji-icon { | |
font-size: 40px !important; | |
margin-right: 10px !important; | |
vertical-align: middle !important; | |
} | |
/* Alternative approach - target by element directly */ | |
div[data-testid="HTML"] .main-title, | |
.gr-html .main-title { | |
font-size: 48px !important; | |
font-weight: 800 !important; | |
color: #0077B5 !important; | |
text-align: center !important; | |
margin: 20px 0 10px 0 !important; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; | |
} | |
div[data-testid="HTML"] .main-subtitle, | |
.gr-html .main-subtitle { | |
font-size: 18px !important; | |
color: #666666 !important; | |
text-align: center !important; | |
margin: 0 0 30px 0 !important; | |
font-weight: 400 !important; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; | |
} | |
div[data-testid="HTML"] .title-container, | |
.gr-html .title-container { | |
background: #f8fafc !important; | |
border-radius: 15px !important; | |
padding: 40px 20px !important; | |
margin: 20px 0 !important; | |
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important; | |
border: 2px solid #e2e8f0 !important; | |
} | |
""" | |
# Create the interface | |
custom_css = """ | |
/* Global App Styling */ | |
.gradio-container { | |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; | |
min-height: 100vh; | |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important; | |
} | |
/* Main content area */ | |
.main > .wrap { | |
background: rgba(255, 255, 255, 0.05) !important; | |
backdrop-filter: blur(20px) !important; | |
border: 1px solid rgba(255, 255, 255, 0.1) !important; | |
border-radius: 20px !important; | |
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important; | |
margin: 20px !important; | |
padding: 30px !important; | |
} | |
/* Title Styling */ | |
.main-title { | |
background: linear-gradient(135deg, #667eea, #764ba2, #f093fb) !important; | |
-webkit-background-clip: text !important; | |
-webkit-text-fill-color: transparent !important; | |
background-clip: text !important; | |
font-size: 3rem !important; | |
font-weight: 800 !important; | |
text-align: center !important; | |
margin: 0 0 30px 0 !important; | |
text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important; | |
letter-spacing: -0.02em !important; | |
} | |
/* Subtitle styling */ | |
.main-subtitle { | |
color: rgba(255, 255, 255, 0.8) !important; | |
text-align: center !important; | |
font-size: 1.2rem !important; | |
font-weight: 400 !important; | |
margin-bottom: 40px !important; | |
opacity: 0.9 !important; | |
} | |
/* Tab container styling */ | |
.tab-nav > .tab-nav-item { | |
background: rgba(255, 255, 255, 0.1) !important; | |
border: 1px solid rgba(255, 255, 255, 0.2) !important; | |
border-radius: 15px !important; | |
margin-right: 8px !important; | |
padding: 12px 24px !important; | |
color: rgba(255, 255, 255, 0.8) !important; | |
font-weight: 600 !important; | |
transition: all 0.3s ease !important; | |
backdrop-filter: blur(10px) !important; | |
font-size: 1rem !important; | |
} | |
.tab-nav > .tab-nav-item:hover { | |
background: rgba(255, 255, 255, 0.2) !important; | |
transform: translateY(-2px) !important; | |
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1) !important; | |
} | |
.tab-nav > .tab-nav-item.selected { | |
background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.2)) !important; | |
color: white !important; | |
border-color: rgba(255, 255, 255, 0.4) !important; | |
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important; | |
transform: translateY(-2px) !important; | |
} | |
/* Tab content area */ | |
.tabitem { | |
background: rgba(255, 255, 255, 0.02) !important; | |
border-radius: 20px !important; | |
padding: 30px !important; | |
margin-top: 20px !important; | |
border: 1px solid rgba(255, 255, 255, 0.1) !important; | |
backdrop-filter: blur(10px) !important; | |
} | |
/* Form elements styling */ | |
.gradio-textbox, .gradio-dropdown, .gradio-slider { | |
background: rgba(255, 255, 255, 0.1) !important; | |
border: 1px solid rgba(255, 255, 255, 0.2) !important; | |
border-radius: 12px !important; | |
color: white !important; | |
backdrop-filter: blur(10px) !important; | |
} | |
.gradio-textbox input, .gradio-dropdown select { | |
background: transparent !important; | |
color: white !important; | |
border: none !important; | |
} | |
.gradio-textbox input::placeholder { | |
color: rgba(255, 255, 255, 0.5) !important; | |
} | |
/* Button styling */ | |
button { | |
background: linear-gradient(135deg, #667eea, #764ba2) !important; | |
border: none !important; | |
border-radius: 12px !important; | |
color: white !important; | |
font-weight: 600 !important; | |
padding: 12px 24px !important; | |
transition: all 0.3s ease !important; | |
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important; | |
} | |
button:hover { | |
transform: translateY(-2px) !important; | |
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4) !important; | |
} | |
/* Status box styling */ | |
.gradio-textbox.status-box { | |
background: rgba(255, 107, 107, 0.1) !important; | |
border-color: rgba(255, 107, 107, 0.3) !important; | |
} | |
/* Plot containers */ | |
.plot-container { | |
background: rgba(255, 255, 255, 0.05) !important; | |
border-radius: 15px !important; | |
padding: 20px !important; | |
margin: 15px 0 !important; | |
border: 1px solid rgba(255, 255, 255, 0.1) !important; | |
backdrop-filter: blur(10px) !important; | |
} | |
/* Card-like components */ | |
.info-card { | |
background: rgba(255, 255, 255, 0.08) !important; | |
border-radius: 16px !important; | |
padding: 24px !important; | |
margin: 16px 0 !important; | |
border: 1px solid rgba(255, 255, 255, 0.12) !important; | |
backdrop-filter: blur(15px) !important; | |
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1) !important; | |
} | |
/* Markdown content styling */ | |
.prose { | |
color: rgba(255, 255, 255, 0.9) !important; | |
} | |
.prose h1, .prose h2, .prose h3 { | |
color: white !important; | |
font-weight: 700 !important; | |
} | |
.prose p { | |
color: rgba(255, 255, 255, 0.8) !important; | |
line-height: 1.6 !important; | |
} | |
/* Loading states */ | |
.loading { | |
background: linear-gradient(90deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 100%) !important; | |
background-size: 200% 100% !important; | |
animation: loading 1.5s infinite !important; | |
} | |
@keyframes loading { | |
0% { background-position: 200% 0; } | |
100% { background-position: -200% 0; } | |
} | |
/* Responsive design */ | |
@media (max-width: 768px) { | |
.main-title { | |
font-size: 2rem !important; | |
} | |
.tab-nav > .tab-nav-item { | |
padding: 8px 16px !important; | |
font-size: 0.9rem !important; | |
} | |
.main > .wrap { | |
margin: 10px !important; | |
padding: 20px !important; | |
} | |
} | |
/* Floating action elements */ | |
.floating-element { | |
position: relative !important; | |
z-index: 10 !important; | |
} | |
.floating-element::before { | |
content: '' !important; | |
position: absolute !important; | |
top: -2px !important; | |
left: -2px !important; | |
right: -2px !important; | |
bottom: -2px !important; | |
background: linear-gradient(45deg, #667eea, #764ba2, #f093fb) !important; | |
border-radius: inherit !important; | |
z-index: -1 !important; | |
opacity: 0 !important; | |
transition: opacity 0.3s ease !important; | |
} | |
.floating-element:hover::before { | |
opacity: 1 !important; | |
} | |
/* Enhanced home tab cards */ | |
.home-card { | |
background: rgba(255, 255, 255, 0.1) !important; | |
border: 1px solid rgba(255, 255, 255, 0.2) !important; | |
border-radius: 20px !important; | |
padding: 30px !important; | |
margin: 15px !important; | |
backdrop-filter: blur(15px) !important; | |
transition: all 0.3s ease !important; | |
cursor: pointer !important; | |
} | |
.home-card:hover { | |
transform: translateY(-5px) !important; | |
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2) !important; | |
background: rgba(255, 255, 255, 0.15) !important; | |
} | |
.home-card-icon { | |
font-size: 3rem !important; | |
margin-bottom: 20px !important; | |
display: block !important; | |
text-align: center !important; | |
} | |
.home-card-title { | |
font-size: 1.5rem !important; | |
font-weight: 700 !important; | |
color: white !important; | |
margin-bottom: 10px !important; | |
text-align: center !important; | |
} | |
.home-card-description { | |
color: rgba(255, 255, 255, 0.7) !important; | |
text-align: center !important; | |
line-height: 1.5 !important; | |
} | |
""" | |
# Custom theme with enhanced colors | |
custom_theme = gr.themes.Soft( | |
primary_hue="blue", | |
secondary_hue="purple", | |
neutral_hue="slate" | |
).set( | |
body_background_fill="*primary_50", | |
body_background_fill_dark="*primary_900", | |
button_primary_background_fill="linear-gradient(135deg, *primary_500, *secondary_600)", | |
button_primary_background_fill_hover="linear-gradient(135deg, *primary_600, *secondary_700)", | |
block_background_fill="rgba(255, 255, 255, 0.05)", | |
block_border_color="rgba(255, 255, 255, 0.1)", | |
input_background_fill="rgba(255, 255, 255, 0.1)", | |
input_border_color="rgba(255, 255, 255, 0.2)" | |
) |