:root {
    /* Slate Blue Palette */
    --bg-app: #0D1117;
    /* Deep GitHub Dark */
    --bg-panel: rgba(22, 27, 34, 0.75);
    --bg-input: rgba(1, 4, 9, 0.5);

    --primary: #636E72;
    /* Slate Gray */
    --secondary: #B2BEC3;
    /* Silver Light Gray */
    --accent: #6C5CE7;
    /* Vibrant Indigo/Violet */
    --accent-hover: #5849C6;

    --border: rgba(178, 190, 195, 0.15);
    --border-focus: rgba(108, 92, 231, 0.5);

    --text-main: #F4F5F6;
    --text-muted: #8B949E;

    --radius: 12px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    /* Subtle ambient glow */
    background-image: radial-gradient(circle at 100% 0%, rgba(108, 92, 231, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 0% 100%, rgba(108, 92, 231, 0.05) 0%, transparent 40%);
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hidden {
    display: none !important;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.full-width {
    width: 100%;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 340px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.logo-group {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(108, 92, 231, 0.1);
    color: var(--accent);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Inputs */
.form-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.form-input:focus {
    border-color: var(--border-focus);
    background: rgba(0, 0, 0, 0.6);
}

.text-area {
    resize: vertical;
    min-height: 80px;
    font-family: 'Inter', sans-serif;
}

.val-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Range */
.form-range {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(108, 92, 231, 0.5);
}

.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--bg-input);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.segmented-control input {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    text-transform: capitalize;
    letter-spacing: 0;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
}

.segmented-control input:checked+label {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Font List */
.font-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.search-wrapper {
    position: relative;
    margin-bottom: 0.5rem;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    padding-left: 2.25rem;
}

.font-list {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.loading-fonts {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.font-item {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.font-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.font-item.active {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
    border-left: 3px solid var(--accent);
    font-weight: 500;
}

.font-item.active::after {
    content: '✓';
    font-size: 0.8rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: var(--transition);
}

.primary-btn {
    background: var(--accent);
    color: white;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.outline-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.outline-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.sn-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Main Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    background: transparent;
    min-width: 0;
    /* allows pre to shrink */
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
}

.font-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    font-size: 0.95rem;
}

.output-container {
    flex: 1;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#ascii-output {
    margin: 0;
    padding: 2rem;
    flex: 1;
    overflow: auto;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    /* Standard rendering size */
    line-height: 1.2;
    color: var(--text-main);
    background: var(--bg-input);
    white-space: pre;
    /* absolute must for ASCII art */
}

/* Loading Overlay for output */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--accent);
    font-weight: 500;
    z-index: 5;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(108, 92, 231, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 50vh;
        border-bottom: 1px solid var(--border);
    }

    .workspace {
        height: 50vh;
        padding: 1rem;
    }
}