:root, [data-theme="latte"] {
    --base: #eff1f5;
    --mantle: #e6e9ef;
    --crust: #dce0e8;
    --surface0: #ccd0da;
    --surface1: #bcc0cc;
    --surface2: #acb0be;
    --overlay0: #9ca0b0;
    --overlay1: #8c8fa1;
    --text: #4c4f69;
    --subtext0: #6c6f85;
    --subtext1: #5c5f77;
    --blue: #1e66f5;
    --lavender: #7287fd;
    --sapphire: #209fb5;
    --teal: #179299;
    --green: #40a02b;
    --mauve: #8839ef;
    --peach: #fe640b;
    --red: #d20f39;
    --rosewater: #dc8a78;
    --blue-dim: rgba(30, 102, 245, 0.1);
    --mauve-dim: rgba(136, 57, 239, 0.08);
    --shadow: rgba(76, 79, 105, 0.06);
    --green-glow: rgba(64, 160, 43, 0.35);
    --blue-focus: rgba(30, 102, 245, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --font: 'JetBrains Mono', monospace;
    color-scheme: light;
}

[data-theme="frappe"] {
    --base: #303446;
    --mantle: #292c3c;
    --crust: #232634;
    --surface0: #414559;
    --surface1: #51576d;
    --surface2: #626880;
    --overlay0: #737994;
    --overlay1: #838ba7;
    --text: #c6d0f5;
    --subtext0: #a5adce;
    --subtext1: #b5bfe2;
    --blue: #8caaee;
    --lavender: #babbf1;
    --sapphire: #85c1dc;
    --teal: #81c8be;
    --green: #a6d189;
    --mauve: #ca9ee6;
    --peach: #ef9f76;
    --red: #e78284;
    --rosewater: #f2d5cf;
    --blue-dim: rgba(140, 170, 238, 0.1);
    --mauve-dim: rgba(202, 158, 230, 0.1);
    --shadow: rgba(0, 0, 0, 0.25);
    --green-glow: rgba(166, 209, 137, 0.3);
    --blue-focus: rgba(140, 170, 238, 0.12);
    color-scheme: dark;
}

[data-theme="macchiato"] {
    --base: #24273a;
    --mantle: #1e2030;
    --crust: #181926;
    --surface0: #363a4f;
    --surface1: #494d64;
    --surface2: #5b6078;
    --overlay0: #6e738d;
    --overlay1: #8087a2;
    --text: #cad3f5;
    --subtext0: #a5adcb;
    --subtext1: #b8c0e0;
    --blue: #8aadf4;
    --lavender: #b7bdf8;
    --sapphire: #7dc4e4;
    --teal: #8bd5ca;
    --green: #a6da95;
    --mauve: #c6a0f6;
    --peach: #f5a97f;
    --red: #ed8796;
    --rosewater: #f4dbd6;
    --blue-dim: rgba(138, 173, 244, 0.1);
    --mauve-dim: rgba(198, 160, 246, 0.1);
    --shadow: rgba(0, 0, 0, 0.3);
    --green-glow: rgba(166, 218, 149, 0.3);
    --blue-focus: rgba(138, 173, 244, 0.12);
    color-scheme: dark;
}

[data-theme="mocha"] {
    --base: #1e1e2e;
    --mantle: #181825;
    --crust: #11111b;
    --surface0: #313244;
    --surface1: #45475a;
    --surface2: #585b70;
    --overlay0: #6c7086;
    --overlay1: #7f849c;
    --text: #cdd6f4;
    --subtext0: #a6adc8;
    --subtext1: #bac2de;
    --blue: #89b4fa;
    --lavender: #b4befe;
    --sapphire: #74c7ec;
    --teal: #94e2d5;
    --green: #a6e3a1;
    --mauve: #cba6f7;
    --peach: #fab387;
    --red: #f38ba8;
    --rosewater: #f5e0dc;
    --blue-dim: rgba(137, 180, 250, 0.1);
    --mauve-dim: rgba(203, 166, 247, 0.1);
    --shadow: rgba(0, 0, 0, 0.3);
    --green-glow: rgba(166, 227, 161, 0.3);
    --blue-focus: rgba(137, 180, 250, 0.12);
    color-scheme: dark;
}

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

body {
    font-family: var(--font);
    background-color: var(--base);
    background-image: radial-gradient(circle, var(--surface0) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text);
    min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface2);
}

/* Header */
header {
    position: relative;
    padding: 2rem 1.5rem 1rem;
    text-align: center;
}

.header-terminal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 1.25rem;
}

.header-terminal .prompt {
    color: var(--blue);
    font-size: 2rem;
    font-weight: 700;
    opacity: 0.5;
}

.header-terminal h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

.header-terminal .dot {
    color: var(--blue);
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 1.8rem;
    background: var(--blue);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Theme switcher */
.theme-switcher {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
}

.theme-toggle {
    width: 34px;
    height: 34px;
    border: 1px solid var(--surface0);
    border-radius: var(--radius);
    background: var(--mantle);
    color: var(--subtext0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: border-color 0.2s, color 0.2s;
}

.theme-toggle:hover {
    border-color: var(--surface1);
    color: var(--text);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: var(--radius);
    padding: 4px;
    z-index: 100;
    min-width: 150px;
    box-shadow: 0 8px 24px var(--shadow);
}

.theme-menu.open {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--subtext0);
    font-family: var(--font);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}

.theme-option:hover {
    background: var(--surface0);
    color: var(--text);
}

.theme-option.active {
    color: var(--blue);
}

.theme-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--surface1);
    flex-shrink: 0;
}

.theme-option.active .theme-swatch {
    border-color: var(--blue);
}

/* Search */
.search-wrapper {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--overlay0);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#search::placeholder {
    color: var(--overlay0);
}

#search:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-focus);
}

/* Host metrics bar */
.host-bar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.55rem 1.5rem;
    max-width: 1400px;
    margin: 0.75rem auto 0;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: var(--radius);
    font-size: 0.72rem;
    color: var(--subtext0);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green-glow);
    flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.host-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.host-label {
    color: var(--overlay0);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.host-value {
    color: var(--text);
    font-weight: 500;
}

.host-detail {
    color: var(--overlay0);
    font-weight: 400;
}

.host-divider {
    width: 1px;
    height: 18px;
    background: var(--surface0);
    flex-shrink: 0;
}

.progress-track {
    width: 80px;
    height: 4px;
    background: var(--surface0);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    border-radius: 2px;
    transition: width 0.8s ease;
}

/* Category pills */
.categories {
    display: flex;
    gap: 0.4rem;
    padding: 1rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.categories::-webkit-scrollbar {
    display: none;
}

.cat-pill {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--surface0);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--subtext0);
    font-family: var(--font);
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.cat-pill:hover {
    border-color: var(--surface1);
    color: var(--text);
    background: var(--mantle);
}

.cat-pill.active {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--crust);
    font-weight: 600;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
    padding: 0.5rem 1.5rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
    align-items: stretch;
}

/* Cards */
.card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem 1rem 1.5rem;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--lavender);
    opacity: 0.3;
    transition: opacity 0.2s;
}

.card:hover {
    border-color: var(--surface1);
    background: var(--crust);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.card:hover::before {
    opacity: 1;
}

.card.hidden {
    display: none;
}

/* Card icon */
.card-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon img {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.icon-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--blue-dim);
    color: var(--blue);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Card body */
.card-body {
    flex: 1;
    min-width: 0;
}

.card-body h2 {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-url {
    display: block;
    font-size: 0.68rem;
    color: var(--overlay0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
    overflow: hidden;
}

.card-category {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.58rem;
    border-radius: 3px;
    background: var(--mauve-dim);
    color: var(--mauve);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(14ch + 0.9rem);
}

.card-metrics {
    font-size: 0.6rem;
    color: var(--overlay0);
    letter-spacing: 0.01em;
    margin-left: auto;
}

.metric-dot {
    margin: 0 0.15rem;
    opacity: 0.5;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--overlay0);
    font-size: 0.85rem;
}

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

    .header-terminal h1 {
        font-size: 1.6rem;
    }

    .header-terminal .prompt {
        font-size: 1.6rem;
    }

    .cursor {
        height: 1.4rem;
    }

    .theme-switcher {
        top: 1rem;
        right: 1rem;
    }

    .host-bar {
        flex-wrap: wrap;
        gap: 0.6rem;
        padding: 0.5rem 1rem;
        margin: 0.5rem 1rem 0;
    }

    .host-divider {
        display: none;
    }

    .grid {
        grid-template-columns: 1fr;
        padding: 0.5rem 1rem 2rem;
    }

    .categories {
        padding: 0.75rem 1rem;
    }
}
