:root {
    /* Color Palette */
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --border-color: #e2e8f0;
    --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);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
}

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

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 1.5rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.nav a:hover {
    color: var(--text-primary);
}

/* Main Content & Hero */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 0;
}

.hero-section {
    text-align: center;
    max-width: 800px;
    width: 100%;
    margin-bottom: 4rem;
}

.hero-badge {
    display: inline-block;
    background-color: #dbeafe;
    color: #1e40af;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.5s ease-out;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #0f172a 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Input Area */
.input-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto 2rem auto;
    box-shadow: var(--shadow-lg);
    border-radius: 1rem;
}

#signature-input {
    width: 100%;
    padding: 1.25rem 3rem 1.25rem 1.5rem;
    font-size: 1.25rem;
    border: 2px solid transparent;
    border-radius: 1rem;
    background-color: var(--surface-color);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-normal);
}

#signature-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.clear-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
}

.clear-btn.visible {
    opacity: 1;
    visibility: visible;
}

.clear-btn:hover {
    color: var(--text-primary);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background-color: var(--surface-color);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    max-width: fit-content;
    margin: 0 auto;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tool-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Color Picker */
.color-presets {
    display: flex;
    gap: 0.5rem;
}

.preset-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.preset-btn:hover {
    transform: scale(1.1);
}

.preset-btn.active {
    box-shadow: 0 0 0 2px var(--surface-color), 0 0 0 4px var(--primary-color);
}

#color-picker {
    width: 0;
    height: 0;
    opacity: 0;
    position: absolute;
}

/* Slider */
#size-slider {
    -webkit-appearance: none;
    width: 150px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}

#size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

#size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Preview Section */
.preview-section {
    width: 100%;
}

.preview-header {
    margin-bottom: 2rem;
    text-align: center;
}

.preview-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.preview-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
}

.empty-state svg {
    margin-bottom: 1rem;
    color: #94a3b8;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    display: none; /* Hidden by default until input has value */
}

/* Signature Cards */
.signature-card {
    background-color: var(--surface-color);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
}

.signature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.signature-card .font-label {
    position: absolute;
    bottom: 0.75rem;
    left: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.signature-card:hover .font-label {
    opacity: 1;
}

.signature-card .download-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
    backdrop-filter: blur(2px);
    color: var(--primary-color);
    font-weight: 600;
}

.signature-card:hover .download-overlay {
    opacity: 1;
}

.signature-card .download-overlay svg {
    margin-bottom: 0.5rem;
}

/* Dynamic Font Styling */
.signature-text {
    line-height: 1.2;
    text-align: center;
    word-break: break-word;
    /* Font family and size injected via JS */
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: auto;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

.animate-pop {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        max-width: 100%;
    }
    
    .grid-container {
        grid-template-columns: 1fr;
    }
}
