/* ==========================================================================
   GUID Essentials — app layer on top of the TenX design system (tenx.css).
   ========================================================================== */

:root {
    --gx-rail: 14.5rem;
    --gx-tabbar: 4rem;
    --gx-gutter: var(--tx-space-4);
}

html, body { min-height: 100%; }

body {
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

h1:focus, h1:focus-visible { outline: none; }
a { color: inherit; }

/* ---------- Shell ---------- */
.gx-app { min-height: 100vh; min-height: 100dvh; }

.gx-main {
    min-width: 0;
    padding-bottom: calc(var(--gx-tabbar) + var(--tx-inset-bottom) + var(--tx-space-6));
}

.gx-page {
    width: min(100%, 76rem);
    margin: 0 auto;
    /* Keep clear of the status bar and any cutout. */
    padding: calc(var(--tx-space-6) + var(--tx-inset-top)) calc(var(--gx-gutter) + var(--tx-inset-right))
             var(--tx-space-6) calc(var(--gx-gutter) + var(--tx-inset-left));
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--tx-space-5);
    align-content: start;
    animation: tx-fade-up var(--tx-duration-slow) var(--tx-ease);
}

.gx-page--narrow { width: min(100%, 46rem); }

.gx-rail { display: none; }

.gx-brand {
    display: flex;
    align-items: center;
    gap: var(--tx-space-3);
    padding: var(--tx-space-2);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: var(--tx-tracking-tight);
}

.gx-brand__mark {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    border-radius: 10px;
    background: var(--tx-accent);
    color: var(--tx-on-accent);
}

.gx-brand__mark--lg { width: 3rem; height: 3rem; border-radius: 14px; }
.gx-mark { width: 68%; height: 68%; display: block; }

/* Bottom tabs (phones) */
.gx-tabbar {
    position: fixed;
    z-index: 50;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--gx-tabbar) + var(--tx-inset-bottom));
    padding-bottom: var(--tx-inset-bottom);
    background: color-mix(in srgb, var(--tx-bg) 84%, transparent);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--tx-border-subtle);
}

.gx-tab {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    color: var(--tx-fg-subtle);
    text-decoration: none;
    font-size: 0.6875rem;
    font-weight: 500;
    transition: color var(--tx-duration) var(--tx-ease);
}

.gx-tab__icon {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 1.75rem;
    border-radius: var(--tx-radius-full);
    font-size: 1.25rem;
    transition: background-color var(--tx-duration) var(--tx-ease);
}

.gx-tab.active { color: var(--tx-fg); }
.gx-tab.active .gx-tab__icon { background: var(--tx-surface-active); }

@media (max-width: 899px) {
    .tx-toaster { bottom: calc(var(--gx-tabbar) + var(--tx-inset-bottom) + var(--tx-space-3)); }
}

@media (min-width: 900px) {
    :root { --gx-gutter: var(--tx-space-8); }

    .gx-app { display: grid; grid-template-columns: var(--gx-rail) minmax(0, 1fr); }
    .gx-tabbar { display: none; }
    .gx-main { padding-bottom: var(--tx-space-10); }
    .gx-page { padding-top: calc(var(--tx-space-8) + var(--tx-inset-top)); gap: var(--tx-space-6); }

    .gx-rail {
        position: sticky;
        top: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
        gap: var(--tx-space-6);
        padding: var(--tx-space-6) var(--tx-space-4);
        border-right: 1px solid var(--tx-border-subtle);
        background: var(--tx-bg-subtle);
    }

    .gx-rail__nav { display: grid; gap: 2px; }

    .gx-rail__link {
        display: flex;
        align-items: center;
        gap: var(--tx-space-3);
        height: 2.5rem;
        padding: 0 var(--tx-space-3);
        border-radius: var(--tx-radius-sm);
        color: var(--tx-fg-muted);
        text-decoration: none;
        font-size: var(--tx-text-sm);
        font-weight: 500;
        transition: background-color var(--tx-duration-fast) var(--tx-ease), color var(--tx-duration-fast) var(--tx-ease);
    }

    .gx-rail__link:hover { background: var(--tx-surface-hover); color: var(--tx-fg); }
    .gx-rail__link.active { background: var(--tx-surface); color: var(--tx-fg); box-shadow: var(--tx-shadow-xs), 0 0 0 1px var(--tx-border-subtle); }

    .gx-rail__foot {
        margin-top: auto;
        display: flex;
        gap: var(--tx-space-2);
        padding: var(--tx-space-3);
        color: var(--tx-fg-subtle);
        font-size: var(--tx-text-xs);
        line-height: var(--tx-leading-snug);
    }
}

/* ---------- Header ---------- */
.gx-header { display: flex; align-items: flex-start; gap: var(--tx-space-4); }
.gx-header__titles { display: grid; gap: 2px; min-width: 0; }

.gx-header__title {
    margin: 0;
    font-size: var(--tx-text-2xl);
    font-weight: 600;
    letter-spacing: var(--tx-tracking-tight);
    line-height: var(--tx-leading-tight);
}

.gx-header__subtitle { margin: 0; font-size: var(--tx-text-sm); color: var(--tx-fg-muted); }
.gx-header__actions { margin-left: auto; display: flex; gap: var(--tx-space-2); flex: none; }

/* ---------- Panels & layout ---------- */
.gx-panel {
    display: grid;
    gap: var(--tx-space-5);
    padding: var(--tx-space-5);
    background: var(--tx-surface);
    border: 1px solid var(--tx-border);
    border-radius: var(--tx-radius-xl);
}

.gx-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--tx-space-5); align-items: start; }

@media (min-width: 1000px) {
    .gx-layout { grid-template-columns: 23rem minmax(0, 1fr); gap: var(--tx-space-6); }
    .gx-options { position: sticky; top: var(--tx-space-8); }
}

.gx-group { display: grid; gap: var(--tx-space-3); margin: 0; padding: 0; border: 0; min-width: 0; }

.gx-legend, .gx-group-block__title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--tx-space-3);
    width: 100%;
    margin: 0 0 var(--tx-space-1);
    padding: 0;
    font-size: var(--tx-text-sm);
    font-weight: 600;
}

.gx-group-block { display: grid; gap: var(--tx-space-2); }

.gx-group-block__title {
    font-size: var(--tx-text-xs);
    letter-spacing: var(--tx-tracking-wide);
    text-transform: uppercase;
    color: var(--tx-fg-subtle);
    padding: 0 var(--tx-space-1);
}

.gx-form { display: grid; gap: var(--tx-space-4); }

/* ---------- Type picker ---------- */
.gx-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: var(--tx-space-2); }

.gx-kind {
    all: unset;
    box-sizing: border-box;
    display: grid;
    gap: 2px;
    padding: var(--tx-space-3);
    border: 1px solid var(--tx-border);
    border-radius: var(--tx-radius-md);
    background: var(--tx-surface);
    cursor: pointer;
    transition: border-color var(--tx-duration) var(--tx-ease), box-shadow var(--tx-duration) var(--tx-ease), background-color var(--tx-duration) var(--tx-ease);
}

.gx-kind:hover { border-color: var(--tx-border-strong); }
.gx-kind:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: 2px; }
.gx-kind.is-selected { border-color: var(--tx-fg); box-shadow: 0 0 0 1px var(--tx-fg); }
.gx-kind__name { font-weight: 600; font-size: var(--tx-text-sm); }
.gx-kind__blurb { font-size: var(--tx-text-xs); color: var(--tx-fg-subtle); line-height: var(--tx-leading-snug); }

/* ---------- Chips, toggles, segmented ---------- */
.gx-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tx-space-2); }
.gx-chips__label { font-size: var(--tx-text-xs); color: var(--tx-fg-subtle); }

.gx-chip {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 2rem;
    padding: 0 var(--tx-space-3);
    border: 1px solid var(--tx-border);
    border-radius: var(--tx-radius-full);
    background: var(--tx-surface);
    color: var(--tx-fg-muted);
    font-size: var(--tx-text-xs);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color var(--tx-duration) var(--tx-ease), color var(--tx-duration) var(--tx-ease), border-color var(--tx-duration) var(--tx-ease);
}

.gx-chip:hover:not(:disabled) { color: var(--tx-fg); border-color: var(--tx-border-strong); }
.gx-chip:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: 2px; }
.gx-chip.is-selected { background: var(--tx-accent); border-color: var(--tx-accent); color: var(--tx-on-accent); }
.gx-chip:disabled { opacity: 0.4; cursor: not-allowed; }

.gx-count { display: grid; gap: var(--tx-space-3); }
.gx-count__field { max-width: 9rem; }

.gx-segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: var(--tx-radius-md);
    background: var(--tx-surface-sunken);
}

.gx-segmented__item {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tx-space-2);
    padding: var(--tx-space-2) var(--tx-space-2);
    border-radius: var(--tx-radius-sm);
    color: var(--tx-fg-muted);
    font-size: var(--tx-text-xs);
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background-color var(--tx-duration) var(--tx-ease), color var(--tx-duration) var(--tx-ease), box-shadow var(--tx-duration) var(--tx-ease);
}

.gx-segmented__item:hover:not(:disabled) { color: var(--tx-fg); }
.gx-segmented__item:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: 1px; }
.gx-segmented__item.is-selected { background: var(--tx-surface-raised); color: var(--tx-fg); box-shadow: var(--tx-shadow-sm); }
.gx-segmented__item:disabled { opacity: 0.4; cursor: not-allowed; }

.gx-range { width: 100%; accent-color: var(--tx-accent); cursor: pointer; }

/* ---------- Results ---------- */
.gx-results {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--tx-space-3);
    align-content: start;
    min-width: 0;
}

.gx-results__bar { display: flex; align-items: center; gap: var(--tx-space-3); flex-wrap: wrap; min-width: 0; }
.gx-results__count { font-size: var(--tx-text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.gx-results__actions { margin-left: auto; display: flex; gap: var(--tx-space-2); flex-wrap: wrap; }

.gx-ids {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    margin: 0;
    padding: var(--tx-space-1);
    list-style: none;
    border: 1px solid var(--tx-border);
    border-radius: var(--tx-radius-lg);
    background: var(--tx-surface);
}

.gx-ids--virtual { display: block; max-height: min(70vh, 40rem); overflow: auto; }

.gx-id { min-width: 0; }

.gx-id__button {
    all: unset;
    box-sizing: border-box;
    display: flex;
    min-width: 0;
    align-items: center;
    gap: var(--tx-space-3);
    width: 100%;
    height: 2.625rem;
    padding: 0 var(--tx-space-3);
    border-radius: var(--tx-radius-sm);
    cursor: pointer;
    transition: background-color var(--tx-duration-fast) var(--tx-ease);
}

.gx-id__button:hover { background: var(--tx-surface-hover); }
.gx-id__button:active { background: var(--tx-surface-active); }
.gx-id__button:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: -2px; }

.gx-id__index {
    flex: none;
    width: 2.25rem;
    color: var(--tx-fg-disabled);
    font-size: var(--tx-text-xs);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.gx-id__value {
    flex: 1;
    min-width: 0;
    font-family: var(--tx-font-mono);
    font-size: var(--tx-text-sm);
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-user-select: text;
    user-select: text;
}

.gx-id__icon { flex: none; color: var(--tx-fg-disabled); font-size: 1rem; }
.gx-id__button:hover .gx-id__icon { color: var(--tx-fg-muted); }

.gx-save { display: grid; gap: var(--tx-space-2); }

/* ---------- Inspector ---------- */
.gx-verdict { display: grid; gap: var(--tx-space-2); justify-items: start; }

.gx-verdict__badge {
    display: inline-flex;
    align-items: center;
    padding: var(--tx-space-1) var(--tx-space-3);
    border-radius: var(--tx-radius-full);
    background: var(--tx-accent);
    color: var(--tx-on-accent);
    font-size: var(--tx-text-sm);
    font-weight: 600;
}

.gx-verdict__note { margin: 0; color: var(--tx-fg-muted); font-size: var(--tx-text-sm); text-wrap: pretty; }

.gx-fields {
    display: grid;
    margin: 0;
    border: 1px solid var(--tx-border-subtle);
    border-radius: var(--tx-radius-md);
    background: var(--tx-bg-subtle);
}

.gx-field {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    gap: var(--tx-space-3);
    padding: var(--tx-space-3) var(--tx-space-4);
    border-top: 1px solid var(--tx-border-subtle);
}

.gx-field:first-child { border-top: 0; }
.gx-field dt { color: var(--tx-fg-subtle); font-size: var(--tx-text-sm); }
.gx-field dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 420px) {
    .gx-field { grid-template-columns: 1fr; gap: 2px; }
}

.gx-variants { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0; padding: 0; list-style: none; }

.gx-variant {
    all: unset;
    box-sizing: border-box;
    display: flex;
    min-width: 0;
    align-items: center;
    gap: var(--tx-space-3);
    width: 100%;
    padding: var(--tx-space-2) var(--tx-space-3);
    border-radius: var(--tx-radius-sm);
    cursor: pointer;
    transition: background-color var(--tx-duration-fast) var(--tx-ease);
}

.gx-variant:hover { background: var(--tx-surface-hover); }
.gx-variant:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: -2px; }
.gx-variant__label { flex: none; width: 8.5rem; font-size: var(--tx-text-xs); color: var(--tx-fg-subtle); }

.gx-variant__value {
    flex: 1;
    min-width: 0;
    font-family: var(--tx-font-mono);
    font-size: var(--tx-text-sm);
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .gx-variant { flex-wrap: wrap; gap: 2px var(--tx-space-3); }
    .gx-variant__label { width: auto; }
    .gx-variant__value { flex-basis: 100%; }
}

/* ---------- Guide ---------- */
.gx-prose { gap: var(--tx-space-4); line-height: var(--tx-leading-normal); }
.gx-prose h2 { margin: var(--tx-space-2) 0 0; font-size: var(--tx-text-lg); font-weight: 600; letter-spacing: var(--tx-tracking-tight); }
.gx-prose h2:first-child { margin-top: 0; }
.gx-prose p { margin: 0; color: var(--tx-fg-muted); text-wrap: pretty; }
.gx-prose strong { color: var(--tx-fg); font-weight: 600; }
.gx-prose code { font-family: var(--tx-font-mono); font-size: 0.9em; padding: 0.1em 0.35em; border-radius: var(--tx-radius-xs); background: var(--tx-surface-sunken); }

.gx-table-wrap { overflow-x: auto; }

.gx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--tx-text-sm);
}

.gx-table th, .gx-table td {
    padding: var(--tx-space-3);
    text-align: left;
    border-bottom: 1px solid var(--tx-border-subtle);
    vertical-align: top;
}

.gx-table th { font-weight: 600; color: var(--tx-fg); white-space: nowrap; }
.gx-table td { color: var(--tx-fg-muted); }
.gx-table tbody tr:last-child td { border-bottom: 0; }
.gx-table td:first-child { font-family: var(--tx-font-mono); color: var(--tx-fg); }

/* ---------- Settings ---------- */
.gx-setting { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tx-space-4); }
.gx-setting__text { display: grid; gap: 2px; flex: 1; min-width: 10rem; }
.gx-setting__label { font-weight: 500; }
.gx-setting__desc { font-size: var(--tx-text-sm); color: var(--tx-fg-muted); }

.gx-about { display: flex; align-items: flex-start; gap: var(--tx-space-4); }
.gx-about p { margin: 0 0 var(--tx-space-1); }
.gx-about__name { font-weight: 600; }

/* ---------- Brand link ---------- */
.gx-tenx {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: var(--tx-space-2);
    margin-top: var(--tx-space-3);
    padding: var(--tx-space-2) var(--tx-space-4);
    border: 1px solid var(--tx-border);
    border-radius: var(--tx-radius-full);
    background: var(--tx-surface);
    color: var(--tx-fg);
    font-size: var(--tx-text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--tx-duration) var(--tx-ease), border-color var(--tx-duration) var(--tx-ease), transform var(--tx-duration-fast) var(--tx-ease);
}

.gx-tenx:hover { background: var(--tx-surface-hover); border-color: var(--tx-border-strong); }
.gx-tenx:active { transform: scale(0.98); }
.gx-tenx:focus-visible { outline: 2px solid var(--tx-ring); outline-offset: 2px; }
.gx-tenx__go { font-size: 0.9em; color: var(--tx-fg-subtle); }

/* ---------- Blazor plumbing ---------- */
#blazor-error-ui {
    color-scheme: light only;
    position: fixed;
    z-index: 3000;
    left: 0;
    bottom: 0;
    display: none;
    width: 100%;
    padding: 0.75rem 1.25rem calc(0.75rem + var(--tx-inset-bottom));
    background: var(--tx-danger-soft);
    color: var(--tx-danger);
    box-shadow: 0 -1px 2px rgb(0 0 0 / 0.2);
    font-size: var(--tx-text-sm);
}

#blazor-error-ui .dismiss { position: absolute; right: 0.75rem; top: 0.5rem; cursor: pointer; }

.blazor-error-boundary {
    padding: var(--tx-space-4);
    border-radius: var(--tx-radius-md);
    background: var(--tx-danger-soft);
    color: var(--tx-danger);
}

.blazor-error-boundary::after { content: "Something went wrong on this screen."; }

.status-bar-safe-area { display: none; }

@supports (-webkit-touch-callout: none) {
    .status-bar-safe-area {
        display: flex;
        position: sticky;
        top: 0;
        height: var(--tx-inset-top);
        background-color: var(--tx-bg);
        width: 100%;
        z-index: 55;
    }
}
