:where(.gl-term) {
    appearance: none;
    position: relative;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    text-align: inherit;
    line-height: inherit;
}

:where(.gl-term--cell) { width: 100%; }

.gl-term,
.gl-term--cell .gl-term__label {
    text-decoration: underline dotted var(--color-text-muted);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

.gl-term { cursor: pointer; }

.gl-term::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100%, 44px);
    height: max(100%, 44px);
    transform: translate(-50%, -50%);
}

.gl-term--inline::after {
    height: 100%;
    padding: var(--space-1) 0;
}

.gl-term:hover,
.gl-term--cell:hover .gl-term__label {
    text-decoration: underline solid var(--color-text);
    text-decoration-thickness: 1px;
}

.gl-term:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.gl-term--heading {
    text-decoration-thickness: 2px;
    border-radius: var(--radius-sm);
}

.gl-term--cell,
.gl-term--cell:hover { text-decoration: none; }

.gl-info {
    appearance: none;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 100%;
    min-height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
}
.gl-info__ring { stroke-dasharray: 1.7 1.7; }
.gl-info:hover { color: var(--color-text); }
.gl-info:hover .gl-info__ring { stroke-dasharray: none; }
.gl-info:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -4px; }

@media (pointer: coarse) {
    .gl-info { width: 44px; min-height: 44px; }
}

.gl-card {
    width: 320px;
    max-width: calc(100vw - 32px);
    margin: 6px 0;
    padding: var(--space-3) var(--space-4) 6px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    font-family: var(--font-sans);
    text-align: left;
    overflow: visible;
}

.gl-card__name {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1.4;
}

.gl-card__def {
    margin: var(--space-1) 0 0;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    text-wrap: pretty;
}

.gl-card__cover {
    margin: var(--space-2) 0 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    line-height: 1.5;
    color: var(--color-text-muted);
}

.gl-card__link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    margin-top: var(--space-1);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-link);
    text-decoration: none;
}
.gl-card__link:hover { color: var(--color-link-hover); text-decoration: underline; }

.gl-card__close {
    appearance: none;
    position: absolute;
    top: 2px;
    right: 2px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
}

html[data-theme="dark"] .gl-card { background: var(--bg-tint); }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .gl-card { background: var(--bg-tint); }
}

@supports (position-area: bottom) {
    .gl-card {
        position: fixed;
        inset: auto;
        position-area: bottom span-right;
        position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
    }
    .gl-card::backdrop { background: transparent; }

    @media (max-width: 767px) {
        .gl-card {
            width: auto;
            max-width: none;
            margin: 6px var(--space-4);
            position-area: bottom span-all;
            position-try-fallbacks: flip-block;
        }
        .gl-card__def { font-size: var(--font-size-base); }
        .gl-card__link { min-height: 44px; font-size: var(--font-size-sm); }
    }
}

@supports not (position-area: bottom) {
    .gl-card {
        position: fixed;
        inset: 0;
        width: 360px;
        height: fit-content;
        margin: auto;
        padding-right: 44px;
    }
    .gl-card::backdrop { background: rgba(0, 0, 0, 0.28); }
    .gl-card__close { display: inline-flex; }

    @media (max-width: 767px) {
        .gl-card {
            inset: auto 0 0 0;
            width: 100%;
            max-width: none;
            max-height: 40vh;
            margin: 0;
            padding: var(--space-4) var(--space-4) calc(8px + env(safe-area-inset-bottom, 0px));
            border-width: 1px 0 0;
            border-radius: var(--radius-lg) var(--radius-lg) 0 0;
            overflow-y: auto;
        }
        .gl-card__name { padding-right: 36px; font-size: var(--font-size-base); }
        .gl-card__def { font-size: var(--font-size-base); }
        .gl-card__link { min-height: 44px; font-size: var(--font-size-sm); }
    }

    html[data-theme="dark"] .gl-card::backdrop { background: rgba(0, 0, 0, 0.55); }
    @media (prefers-color-scheme: dark) {
        html:not([data-theme="light"]) .gl-card::backdrop { background: rgba(0, 0, 0, 0.55); }
    }
}

@supports not selector(:popover-open) {
    .gl-card { display: none; }
    .gl-term { text-decoration: none; cursor: inherit; }
    .gl-info { display: none; }
}
