:root {
    --bg: #1e1e2e;
    --bg-card: #282840;
    --bg-input: #313150;
    --text: #cdd6f4;
    --text-muted: #9399b2;
    --accent: #89b4fa;
    --accent-dim: #45475a;
    --border: #45475a;
    --star: #f9e2af;
    --success: #a6e3a1;
    --font-mono: "Cascadia Mono", "Fira Code", "JetBrains Mono", "Consolas", "Courier New", monospace;
}

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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Loading screen */
.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    gap: 1.5rem;
}

.loading-ascii {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 1rem;
    line-height: 1.2;
    text-align: left;
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

header .tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
}

header nav {
    margin-left: auto;
    display: flex;
    gap: 1rem;
}

header nav a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

header nav a svg {
    opacity: 0.85;
}

header nav a:hover {
    text-decoration: underline;
}

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* Input area */
.input-area {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 1rem 0 0.75rem;
}

.text-input {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 1.2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    font-family: inherit;
}

.text-input:focus {
    border-color: var(--accent);
}

.text-input::placeholder {
    color: var(--text-muted);
}

/* Options bar */
.options-bar {
    position: sticky;
    top: 52px;
    z-index: 9;
    background: var(--bg);
    padding: 0.5rem 0 1rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.options-bar input[type="text"] {
    width: 180px;
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    font-family: inherit;
}

.options-bar input[type="text"]:focus {
    border-color: var(--accent);
}

.options-bar input[type="text"]::placeholder {
    color: var(--text-muted);
}

.options-bar select {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    cursor: pointer;
}

.options-bar label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.options-bar label:hover {
    color: var(--text);
}

.options-bar input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.fav-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.fav-toggle:hover {
    border-color: var(--star);
    color: var(--star);
}

.fav-toggle.active {
    border-color: var(--star);
    color: var(--star);
    background: rgba(249, 226, 175, 0.1);
}

.font-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
    white-space: nowrap;
}

/* Section headers */
.section-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--star);
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.section-header:first-of-type {
    margin-top: 0;
}

.shortlist-header {
    color: var(--accent);
}

.section-hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Font cards */
.font-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.font-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.font-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.font-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
}

.font-height {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.font-card-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.star-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--accent-dim);
    padding: 0.1rem 0.4rem;
    line-height: 1;
    transition: color 0.15s;
}

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

.star-btn.starred {
    color: var(--star);
}

.pin-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.1rem 0.3rem;
    line-height: 1;
    opacity: 0.3;
    transition: opacity 0.15s;
    filter: grayscale(1);
}

.pin-btn:hover {
    opacity: 0.7;
    filter: none;
}

.pin-btn.pinned {
    opacity: 1;
    filter: none;
}

.card-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    transition: all 0.15s;
}

.card-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.card-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(137, 180, 250, 0.1);
}

.card-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

.font-card pre {
    padding: 0.6rem 0.75rem;
    overflow-x: auto;
    font-size: 0.7rem;
    line-height: 1.15;
    color: var(--text);
    margin: 0;
}

/* Source panel */
.source-panel {
    border-top: 1px solid var(--border);
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.15);
}

.source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0.5rem;
}

.source-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    transition: all 0.15s;
}

.source-tab:first-child {
    border-radius: 4px 0 0 4px;
}

.source-tab:last-child {
    border-radius: 0 4px 4px 0;
}

.source-tab:not(:first-child) {
    border-left: none;
}

.source-tab.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.source-code {
    position: relative;
}

.source-code pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    line-height: 1.4;
    overflow-x: auto;
}

.source-copy-btn {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
}

.source-copy-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.source-copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

/* Error UI */
#blazor-error-ui {
    background: #6c1a1a;
    color: white;
    padding: 0.5rem 1rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    display: none;
}

#blazor-error-ui .reload, #blazor-error-ui .dismiss {
    color: white;
    margin-left: 1rem;
}

/* Responsive */
@media (max-width: 640px) {
    header {
        padding: 0.75rem 1rem;
    }

    main {
        padding: 1rem;
    }

    .options-bar {
        gap: 0.5rem;
    }

    .options-bar input[type="text"] {
        width: 100%;
    }

    .font-count {
        margin-left: 0;
        width: 100%;
    }
}
