:root {
    --kp-bg: rgba(255, 255, 255, 0.82);
    --kp-bg-strong: rgba(255, 255, 255, 0.96);
    --kp-ink: #111827;
    --kp-muted: #6b7280;
    --kp-line: rgba(148, 163, 184, 0.34);
    --kp-hover: rgba(15, 118, 110, 0.08);
    --kp-selected: rgba(37, 99, 235, 0.11);
    --kp-selected-line: rgba(37, 99, 235, 0.34);
    --kp-search-sheen: rgba(255, 255, 255, 0.34);
    --kp-shadow: 0 30px 90px rgba(15, 23, 42, 0.28), 0 10px 28px rgba(15, 23, 42, 0.16);
    --kp-radius: 22px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --kp-bg: rgba(17, 24, 39, 0.82);
        --kp-bg-strong: rgba(17, 24, 39, 0.97);
        --kp-ink: #f9fafb;
        --kp-muted: #a7b0c0;
        --kp-line: rgba(148, 163, 184, 0.22);
        --kp-hover: rgba(45, 212, 191, 0.10);
        --kp-selected: rgba(96, 165, 250, 0.18);
        --kp-selected-line: rgba(96, 165, 250, 0.42);
        --kp-search-sheen: rgba(255, 255, 255, 0.05);
        --kp-shadow: 0 30px 90px rgba(0, 0, 0, 0.46), 0 10px 28px rgba(0, 0, 0, 0.32);
    }
}

.global-command-palette {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 7vh 18px 18px;
    color: var(--kp-ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.global-command-palette.is-open {
    display: flex;
}

.global-command-palette__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    -webkit-backdrop-filter: blur(14px) saturate(1.05);
    backdrop-filter: blur(14px) saturate(1.05);
    opacity: 0;
    transition: opacity 150ms ease-out;
}

.global-command-palette.is-visible .global-command-palette__overlay {
    opacity: 1;
}

.global-command-palette__dialog {
    position: relative;
    width: min(820px, 100%);
    max-height: min(78vh, 820px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--kp-line);
    border-radius: var(--kp-radius);
    background: var(--kp-bg);
    -webkit-backdrop-filter: blur(24px) saturate(1.25);
    backdrop-filter: blur(24px) saturate(1.25);
    box-shadow: var(--kp-shadow);
    opacity: 0;
    transform: translateY(10px) scale(0.975);
    transition: opacity 150ms ease-out, transform 170ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.global-command-palette.is-visible .global-command-palette__dialog {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.global-command-palette__search {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--kp-line);
    background: linear-gradient(180deg, var(--kp-search-sheen), transparent);
}

.global-command-palette__search-icon,
.global-command-palette__clear,
.global-command-palette__spinner {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    color: var(--kp-muted);
}

.global-command-palette__input {
    min-width: 0;
    flex: 1 1 auto;
    height: 44px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--kp-ink);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0;
}

.global-command-palette__input::placeholder {
    color: var(--kp-muted);
    font-weight: 500;
    opacity: 0.76;
}

.global-command-palette__hint {
    flex: 0 0 auto;
    min-width: 54px;
    padding: 5px 9px;
    border: 1px solid var(--kp-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.42);
    color: var(--kp-muted);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}

.global-command-palette__clear {
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.global-command-palette__clear:hover,
.global-command-palette__clear:focus-visible {
    background: var(--kp-hover);
    color: var(--kp-ink);
    outline: 0;
}

.global-command-palette__clear:active {
    transform: scale(0.94);
}

.global-command-palette__spinner {
    display: none;
}

.global-command-palette.is-loading .global-command-palette__spinner {
    display: grid;
}

.global-command-palette.is-loading .global-command-palette__clear {
    display: none;
}

.global-command-palette__spinner::before {
    width: 18px;
    height: 18px;
    content: "";
    border: 2px solid rgba(148, 163, 184, 0.36);
    border-top-color: #2563eb;
    border-radius: 999px;
    animation: kp-spin 700ms linear infinite;
}

.global-command-palette__body {
    overflow: auto;
    padding: 10px;
    scroll-padding-block: 12px;
}

.global-command-palette__section {
    padding: 8px 0 2px;
    animation: kp-rise 170ms ease-out both;
}

.global-command-palette__section-title {
    padding: 8px 12px 7px;
    color: var(--kp-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.global-command-palette__item {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 68px;
    margin: 1px 0;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--kp-ink);
    text-align: left;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.global-command-palette__item:hover {
    background: var(--kp-hover);
}

.global-command-palette__item.is-selected,
.global-command-palette__item:focus-visible {
    border-color: var(--kp-selected-line);
    background: var(--kp-selected);
    outline: 0;
    transform: translateY(-1px);
}

.global-command-palette__icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--kp-line);
    border-radius: 12px;
    background: var(--kp-bg-strong);
    color: #2563eb;
}

.global-command-palette__main {
    min-width: 0;
}

.global-command-palette__title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.global-command-palette__title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0;
}

.global-command-palette__subtitle {
    min-width: 0;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--kp-muted);
    font-size: 12px;
    font-weight: 500;
}

.global-command-palette__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 8px;
    color: var(--kp-muted);
    font-size: 11px;
}

.global-command-palette__meta span {
    min-width: 0;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-command-palette__badge {
    display: inline-flex;
    align-items: center;
    max-width: 120px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.12);
    color: var(--kp-muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.global-command-palette__badge--success {
    background: rgba(5, 150, 105, 0.14);
    color: #047857;
}

.global-command-palette__badge--warning {
    background: rgba(217, 119, 6, 0.16);
    color: #a16207;
}

.global-command-palette__badge--danger {
    background: rgba(220, 38, 38, 0.14);
    color: #b91c1c;
}

.global-command-palette__badge--muted {
    background: rgba(100, 116, 139, 0.11);
    color: var(--kp-muted);
}

.global-command-palette mark {
    padding: 0 1px;
    border-radius: 3px;
    background: rgba(250, 204, 21, 0.45);
    color: inherit;
}

.global-command-palette__empty,
.global-command-palette__welcome {
    display: grid;
    place-items: center;
    min-height: 250px;
    padding: 28px;
    text-align: center;
}

.global-command-palette__empty-icon {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    border: 1px solid var(--kp-line);
    border-radius: 18px;
    background: var(--kp-bg-strong);
    color: #0f766e;
}

.global-command-palette__empty-title {
    margin: 0 0 5px;
    font-size: 16px;
    font-weight: 800;
}

.global-command-palette__empty-copy {
    margin: 0;
    color: var(--kp-muted);
    font-size: 13px;
}

.global-command-palette__footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--kp-line);
    color: var(--kp-muted);
    font-size: 11px;
    font-weight: 700;
}

.global-command-palette__footer span {
    white-space: nowrap;
}

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

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

@media (max-width: 640px) {
    .global-command-palette {
        align-items: stretch;
        padding: 8px;
    }

    .global-command-palette__dialog {
        width: 100%;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
    }

    .global-command-palette__search {
        gap: 8px;
        padding: 14px 12px 12px;
    }

    .global-command-palette__input {
        height: 42px;
        font-size: 17px;
    }

    .global-command-palette__hint {
        display: none;
    }

    .global-command-palette__item {
        grid-template-columns: 38px minmax(0, 1fr);
        min-height: 64px;
        padding: 10px;
    }

    .global-command-palette__icon {
        width: 38px;
        height: 38px;
    }

    .global-command-palette__badges {
        display: none;
    }

    .global-command-palette__meta span {
        max-width: 130px;
    }

    .global-command-palette__footer {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .global-command-palette__overlay,
    .global-command-palette__dialog,
    .global-command-palette__item,
    .global-command-palette__section {
        animation: none;
        transition: none;
    }
}
