:root {
    --header-top: 8px;
    --header-gap: 8px;
    --gap: 8px;
    --radius: 2px;

    /* Hyprland / Catppuccin Latte */
    --md-sys-color-primary: #1e66f5;
    --md-sys-color-on-primary: #eff1f5;
    --md-sys-color-primary-container: #dce0e8;
    --md-sys-color-on-primary-container: #4c4f69;
    --md-sys-color-surface: #dce0e8;
    --md-sys-color-surface-container-low: #e6e9ef;
    --md-sys-color-surface-container: #eff1f5;
    --md-sys-color-surface-container-high: #ccd0da;
    --md-sys-color-on-surface: #4c4f69;
    --md-sys-color-on-surface-variant: #6c6f85;
    --md-sys-color-outline: #9ca0b0;
    --md-sys-color-outline-variant: #bcc0cc;
    --focus-border: #1e66f5;
    --wallpaper: #dce0e8;

    --search-border-color: var(--md-sys-color-outline);
    --search-bg: var(--md-sys-color-surface-container);
    --search-text: var(--md-sys-color-on-surface);
    --search-placeholder: var(--md-sys-color-on-surface-variant);

    --md-sys-shape-corner-extra-large: 2px;
    --md-sys-shape-corner-large: 2px;
    --md-sys-shape-corner-medium: 2px;

    --status-green: #40a02b;
    --status-yellow: #df8e1d;
    --status-red: #d20f39;
}

[data-theme="dark"] {
    /* Hyprland / Catppuccin Mocha */
    --md-sys-color-primary: #89b4fa;
    --md-sys-color-on-primary: #11111b;
    --md-sys-color-primary-container: #313244;
    --md-sys-color-on-primary-container: #cdd6f4;
    --md-sys-color-surface: #11111b;
    --md-sys-color-surface-container-low: #181825;
    --md-sys-color-surface-container: #1e1e2e;
    --md-sys-color-surface-container-high: #313244;
    --md-sys-color-on-surface: #cdd6f4;
    --md-sys-color-on-surface-variant: #a6adc8;
    --md-sys-color-outline: #6c7086;
    --md-sys-color-outline-variant: #45475a;
    --focus-border: #89b4fa;
    --wallpaper: #11111b;

    --status-green: #a6e3a1;
    --status-yellow: #f9e2af;
    --status-red: #f38ba8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background-color: var(--wallpaper);
    color: var(--md-sys-color-on-surface);
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    overflow: hidden;
}

#loader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--wallpaper);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loader-flower {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 2px solid var(--focus-border);
    border-radius: var(--radius);
    animation: hypr-pulse 1.1s infinite ease-in-out;
}

@keyframes hypr-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.72); opacity: 0.45; }
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--gap);
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.35s ease;
    box-sizing: border-box;
}

.container.loaded {
    opacity: 1;
}

.unified-organism {
    display: block;
    height: 100%;
    background: var(--md-sys-color-surface-container);
    border-radius: var(--radius);
    border: 2px solid var(--focus-border);
    overflow-y: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--md-sys-color-outline) transparent;
}

.unified-organism::-webkit-scrollbar { width: 8px; }
.unified-organism::-webkit-scrollbar-track { background: transparent; }
.unified-organism::-webkit-scrollbar-thumb {
    background-color: var(--md-sys-color-outline-variant);
    border-radius: var(--radius);
    border: 2px solid var(--md-sys-color-surface-container);
}

.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    background-color: color-mix(in srgb, var(--md-sys-color-surface-container-low), transparent 12%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 10px 10px 10px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.toolbar-top { display: flex; justify-content: space-between; align-items: center; width: 100%; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
    font-size: 18px; color: var(--md-sys-color-on-primary);
    background: var(--md-sys-color-primary);
    padding: 6px;
    border-radius: var(--radius);
}
.brand-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.brand-name {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--md-sys-color-primary);
}
.brand-subname { font-size: 0.75rem; font-weight: 400; color: var(--md-sys-color-on-surface-variant); }
.brand-desc { font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); max-width: 450px; line-height: 1.4; margin: 0; }

#appVersion {
    font-size: 0.7rem;
    opacity: 0.55;
    margin-left: 8px;
    font-weight: 400;
    align-self: center;
}

.toolbar-actions { display: flex; align-items: center; gap: 8px; }

.control-group { display: flex; gap: 6px; align-items: center; }

.hero-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gap);
    width: 100%;
}

.sort-header {
    display: flex; align-items: center; padding: 8px 10px;
    background-color: color-mix(in srgb, var(--md-sys-color-surface-container-low), transparent 12%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    position: sticky;
    top: var(--header-height, 0);
    z-index: 990;
}

.grid-container {
    display: flex;
    flex-direction: column;
    background: transparent;
}

.sort-col {
    display: flex; align-items: center; gap: 6px; font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; color: var(--md-sys-color-on-surface-variant);
    cursor: pointer; user-select: none; transition: color 0.15s, background-color 0.15s, border-color 0.15s;
    position: relative;
    padding: 4px 6px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    min-width: 0;
}
.sort-col:hover { background: var(--md-sys-color-surface-container-high); }
.sort-col.active {
    color: var(--md-sys-color-primary);
    border-color: var(--focus-border);
}
.sort-col .header-icon { font-size: 16px; display: inline-block; flex-shrink: 0; }

.col-status span#txtSortStatus {
    display: none !important;
}

.sort-col span:not(.material-symbols-outlined):not(.sort-arrows span) {
    white-space: normal;
    line-height: 1.1;
    word-break: break-word;
    flex-shrink: 1;
}

.sort-arrows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 2px;
}
.sort-arrows .material-symbols-outlined {
    font-size: 14px !important;
    line-height: 0.4;
    opacity: 0.15;
    transition: opacity 0.15s, color 0.15s;
}

.sort-col.active.asc .up { opacity: 1; color: var(--md-sys-color-primary); }
.sort-col.active.desc .down { opacity: 1; color: var(--md-sys-color-primary); }

.col-status, .cell-status { flex: 0 0 70px; display: flex; justify-content: center; }
.col-category, .cell-category { flex: 0 0 140px; display: flex; align-items: center; gap: 8px; }
.col-google, .cell-google { flex: 1; min-width: 0; }
.col-arrow, .cell-arrow { flex: 0 0 40px; display: flex; justify-content: center; align-items: center; }
.col-alt, .cell-alt { flex: 1; min-width: 0; }

.md3-card {
    background: transparent;
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex; align-items: center;
    transition: background-color 0.15s ease;
    position: relative;
}

.md3-card:hover {
    background: var(--md-sys-color-surface-container-high);
}

.md3-card.status-green { background-color: color-mix(in srgb, transparent, var(--status-green) 7%); }
.md3-card.status-yellow { background-color: color-mix(in srgb, transparent, var(--status-yellow) 7%); }
.md3-card.status-red { background-color: color-mix(in srgb, transparent, var(--status-red) 7%); }

.md3-card.status-green:hover { background-color: color-mix(in srgb, var(--md-sys-color-surface-container-high), var(--status-green) 10%); }
.md3-card.status-yellow:hover { background-color: color-mix(in srgb, var(--md-sys-color-surface-container-high), var(--status-yellow) 10%); }
.md3-card.status-red:hover { background-color: color-mix(in srgb, var(--md-sys-color-surface-container-high), var(--status-red) 10%); }

.status-indicator { width: 8px; height: 8px; border-radius: 0; cursor: help; }
.status-green .status-indicator { background: var(--status-green); }
.status-yellow .status-indicator { background: var(--status-yellow); }
.status-red .status-indicator { background: var(--status-red); }

.cell-category {
    font-size: 0.7rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
}
.cell-category .material-symbols-outlined { font-size: 18px; }

.service-row { display: flex; align-items: center; width: 100%; }
.badge {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    background: transparent;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius); flex: 1; min-width: 0; font-size: 0.8rem; font-weight: 500;
    text-decoration: none; color: inherit; transition: background-color 0.15s ease, border-color 0.15s ease;
}
.badge:hover { background: color-mix(in srgb, var(--md-sys-color-primary), transparent 90%); border-color: var(--focus-border); }

.badge span:not(.open-icon) {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    flex-grow: 1;
    min-width: 0;
    line-height: 1.2;
}

.badge.alt { background: transparent; border-color: var(--md-sys-color-primary); border-width: 1px; color: var(--md-sys-color-on-surface); }
.badge.alt:hover { background: color-mix(in srgb, var(--md-sys-color-primary), transparent 90%); border-color: var(--focus-border); }

.favicon { width: 16px; height: 16px; border-radius: 0; flex-shrink: 0; }

.open-icon {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.5;
    font-size: 16px !important;
    flex-shrink: 0;
    margin-left: auto;
}

.arrow-divider { color: var(--md-sys-color-outline); opacity: 0.7; }

.alternatives-grid { display: flex; flex-direction: column; gap: 4px; width: 100%; }

.md3-icon-button {
    width: 28px; height: 28px; border-radius: var(--radius); border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface-variant); cursor: pointer; display: flex; align-items: center; justify-content: center;
    text-decoration: none; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.md3-icon-button:hover {
    background: var(--md-sys-color-surface-container-high);
    border-color: var(--focus-border);
    color: var(--md-sys-color-primary);
}
.md3-icon-button svg { width: 16px; height: 16px; }
.md3-icon-button .material-symbols-outlined {
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* Theme toggle styles removed, using md3-switch */

.md3-switch {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 0;
}

.md3-switch-track {
    height: 28px;
    background-color: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius);
    position: relative;
    transition: border-color 0.15s ease;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

.md3-switch-thumb {
    display: none;
}

.md3-switch-icons {
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    width: auto;
    height: 100%;
    padding: 0;
    position: relative;
    z-index: 3;
    pointer-events: none;
}

.switch-icon {
    transition: background-color 0.15s, color 0.15s, opacity 0.15s;
    opacity: 0.45;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 26px;
    font-weight: 600;
    font-size: 10px;
}

.md3-switch:not(.active) .left-icon,
.md3-switch.active .right-icon {
    opacity: 1;
    color: var(--md-sys-color-on-primary);
    background: var(--md-sys-color-primary);
}

[data-theme="dark"] .switch-icon {
    color: var(--md-sys-color-on-surface-variant);
}
[data-theme="dark"] .md3-switch:not(.active) .left-icon,
[data-theme="dark"] .md3-switch.active .right-icon {
    color: var(--md-sys-color-on-primary);
}

.md3-switch:hover .md3-switch-track {
    border-color: var(--focus-border);
}

#dot-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.28;
}

@media (max-width: 768px) {
    #dot-canvas { display: none; }
}

@keyframes fadeInUp { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 768px) {
    .container {
        padding: 0;
    }

    .unified-organism {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-width: 0;
        border-top: 2px solid var(--focus-border);
        border-bottom: 2px solid var(--focus-border);
    }

    .sort-header {
        padding: 8px 8px;
    }

    .col-status, .cell-status { flex: 0 0 45px; display: flex; justify-content: flex-start; padding-left: 8px; }
    .col-category, .cell-category { flex: 0 0 45px; display: flex; justify-content: flex-start; }
    .col-arrow, .cell-arrow { flex: 0 0 30px; }

    .cell-category .cat-name { display: none; }

    .col-category span#txtSortCategory {
        display: none !important;
    }

    .col-google span#txtSortGoogle,
    .col-alt span#txtSortAlt {
        display: inline-block !important;
    }

    .sort-col .header-icon { display: inline-block; font-size: 16px; }
    .col-category::after { display: none; }

    .sort-col { font-size: 0.58rem; justify-content: flex-start; gap: 4px; padding: 4px; }
    .sort-arrows { margin-left: 0; }
    .sort-arrows .material-symbols-outlined { font-size: 10px !important; }

    .md3-card { padding: 8px 8px; gap: 6px; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
    .md3-card:last-child { border-bottom: none; }

    .cell-google, .cell-alt { flex: 1; min-width: 0; }
    .badge { padding: 4px 6px; gap: 4px; font-size: 0.72rem; min-height: 32px; }
    .badge img.favicon { margin-top: 2px; }
    .badge span.open-icon { margin-top: 2px; font-size: 14px !important; margin-left: 2px; flex-shrink: 0; }
    .favicon { width: 14px; height: 14px; flex-shrink: 0; }

    .alternatives-grid {
        flex-direction: column;
    }

    .toolbar-top { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
    .toolbar-actions { width: auto; justify-content: flex-end; }
}

.search-container {
    position: relative;
    min-width: 200px;
    flex: 0 1 280px;
}

.search-prefix {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-primary);
    font-size: 13px;
    pointer-events: none;
    font-weight: 600;
}

#searchInput {
    width: 100%;
    padding: 7px 10px 7px 26px;
    border: 1px solid var(--search-border-color);
    border-radius: var(--radius);
    background: var(--search-bg);
    color: var(--search-text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

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

#searchInput:focus {
    border-color: var(--focus-border);
    outline: none;
}
