:root {
    /* Colors */
    --primary: #3b82f6; /* Blue 500 */
    --primary-hover: #2563eb; /* Blue 600 */
    --primary-bg: #eff6ff; /* Blue 50 */
    
    --bg-body: #f8fafc; /* Slate 50 */
    --bg-card: #ffffff;
    
    --text-main: #0f172a; /* Slate 900 */
    --text-muted: #64748b; /* Slate 500 */
    --text-light: #94a3b8; /* Slate 400 */
    
    --border: #e2e8f0; /* Slate 200 */
    
    --success: #10b981;
    --error: #ef4444;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    
    /* Spacing & Layout */
    --radius: 12px;
    --container-width: 1200px;
    --header-height: 70px;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Focus Ring */
    --ring-offset: 2px;
    --ring-color: rgba(59, 130, 246, 0.5);
}

[data-theme="dark"] {
    --primary: #60a5fa; /* Blue 400 */
    --primary-hover: #3b82f6;
    --primary-bg: rgba(59, 130, 246, 0.1);
    
    --bg-body: #0f172a; /* Slate 900 */
    --bg-card: #1e293b; /* Slate 800 */
    
    --text-main: #f1f5f9; /* Slate 100 */
    --text-muted: #94a3b8; /* Slate 400 */
    --text-light: #64748b;
    
    --border: #334155; /* Slate 700 */
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Accessibility Utilities */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px;
    z-index: 100;
    transition: top 0.2s;
    text-decoration: none;
    font-weight: bold;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: var(--ring-offset);
}

/* Layout */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    height: auto;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    backdrop-filter: blur(8px);
    background: rgba(var(--bg-card), 0.8); /* Requires RGB var, strictly simplifying here */
}

.nav-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 1rem 0;
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.logo span {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.2rem;
}

/* Navigation */
nav ul {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 99px;
    transition: var(--transition);
}

nav a:hover, nav a.active, nav a[aria-current="page"] {
    color: var(--primary);
    background: var(--primary-bg);
}

#theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    color: var(--text-main);
    margin-left: 0.5rem;
}

#theme-toggle:hover {
    background: var(--bg-body);
    border-color: var(--text-muted);
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Fallback for text fill */
[data-theme="dark"] .hero h1 {
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin-bottom: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    font-size: 1rem;
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

/* Tool Cards */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

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

.card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    color: var(--text-main);
}

.card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

/* Tool Interface Area */
.tool-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-sm);
}

/* Inputs & Forms */
.input-group {
    margin-bottom: 2rem;
}

label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

textarea, input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    transition: var(--transition);
}

textarea:focus, input:focus, select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

textarea {
    min-height: 180px;
    line-height: 1.5;
}

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* Output Area */
.output-area {
    background: var(--bg-body);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
    min-height: 100px;
}

.output-area pre {
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.9rem;
    color: var(--text-main);
    max-height: 500px;
    overflow-y: auto;
    padding-right: 2rem; /* Space for copy btn */
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 2rem;
    gap: 2rem;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 0;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.2s;
    font-size: 1rem;
}

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

.tab-btn.active, .tab-btn[aria-selected="true"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

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

/* Copy Button */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    z-index: 10;
}

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

.copy-feedback {
    position: absolute;
    top: -30px;
    right: 0;
    background: var(--text-main);
    color: var(--bg-card);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.copy-feedback.show {
    opacity: 1;
    top: 10px; 
}

/* Symbol Grid */
.symbol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.75rem;
}

.symbol-item {
    background: var(--bg-body);
    border: 1px solid var(--border);
    padding: 0.75rem 0;
    text-align: center;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1.5rem;
    font-family: var(--font-sans); /* Some symbols render better in sans */
    transition: var(--transition);
    user-select: none;
}

.symbol-item:hover, .symbol-item:focus {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.1);
}

/* ASCII Table */
.ascii-table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.ascii-cell {
    border: 1px solid var(--border);
    padding: 0.75rem;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-body);
}

.ascii-cell:hover, .ascii-cell:focus {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.ascii-cell .char {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: block;
    margin-bottom: 0.25rem;
}

.ascii-cell .code {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.ascii-cell:hover .code {
    color: rgba(255,255,255,0.9);
}

/* Footer */
footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 4rem 0 2rem;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-links h4 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    color: var(--text-main);
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* SEO Content */
.seo-content {
    max-width: 800px;
    margin: 3rem auto;
    color: var(--text-muted);
}

.seo-content h2, .seo-content h3 {
    color: var(--text-main);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.seo-content p, .seo-content li {
    margin-bottom: 1rem;
    line-height: 1.7;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .nav-flex {
        flex-direction: column;
        gap: 1rem;
        padding-bottom: 0;
    }

    nav ul {
        justify-content: center;
        gap: 0.5rem;
        padding-bottom: 1rem;
    }

    nav a {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    .hero h1 {
        font-size: 2.25rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn, .btn-outline {
        width: 100%;
    }
    
    .tabs {
        padding-bottom: 0.5rem;
    }
}
