:root {
    color-scheme: light dark;
}

html,
body {
    background: rgb(var(--paper));
    color: rgb(var(--text));
    font-family: var(--font-body);
    font-size: var(--text-md);
}

/* Layout: sticky footer */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1 0 auto;
}

.site-footer {
    margin-top: auto;
    border-top: 1px solid rgb(var(--border));
    text-align: center;
}

.site-footer .container {
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
}

/* Headings use brand serif by default */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-head);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: rgb(var(--text));
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-4);
}

.card {
    background: rgb(var(--bg));
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    padding: var(--space-4);
    overflow: hidden;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius-sm);
    padding: calc(var(--space-2) + 1px) var(--space-3);
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--c-brand);
    color: rgb(255 255 255);
    box-shadow: var(--shadow-1);
}

.btn-primary:hover {
    background: var(--c-brand-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--c-brand-strong);
    border-color: rgb(var(--border));
}

.btn-ghost:hover {
    background: rgb(var(--brand-soft) / 0.25);
}

/* Inputs */
.input {
    width: 100%;
    background: rgb(var(--bg));
    color: var(--c-text);
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    box-sizing: border-box;
    /* <-- key fix */
    display: block;
    max-width: 100%;
}

.input:focus {
    outline: 2px solid var(--c-brand);
    outline-offset: 1px;
    box-shadow: 0 0 0 3px rgb(var(--brand-soft) / 0.6);
}

/* Tags / badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: var(--text-xs);
    background: rgb(var(--brand-soft) / 0.35);
    color: var(--c-brand-strong);
}

/* “Ink” dividers or strokes — use sparingly for that sketch vibe */
.ink-stroke {
    border-bottom: 2px solid rgb(var(--ink));
    filter: contrast(0.98) saturate(0.9);
}

/* Align Bootstrap variants to your tokens */
.btn-info,
.btn-secondary {
    color: #fff;
    border-color: transparent;
}

.btn-info {
    background: var(--c-accent);
}

.btn-info:hover {
    background: var(--c-accent-strong);
}

.btn-secondary {
    background: rgb(var(--muted));
}

.btn-secondary:hover {
    background: rgb(80 88 100);
}

.btn-danger {
    background: rgb(var(--red-700));
    border-color: transparent;
}

.btn-danger:hover {
    background: rgb(var(--red-800));
}

/* -----------------------------
   Data table (token-driven)
   ----------------------------- */
.tablex-wrap {
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-md);
    background: rgb(var(--bg));
    box-shadow: var(--shadow-1);
    overflow: hidden;
    /* clip sticky header corners */
}

.tablex-scroller {
    overflow: auto;
    max-width: 100%;
}

.tablex {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-body);
    color: var(--c-text);
}

.tablex thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--c-muted);
    background: rgb(var(--paper));
    border-bottom: 1px solid rgb(var(--border));
}

.tablex th,
.tablex td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid rgb(var(--border));
    vertical-align: middle;
    white-space: nowrap;
}

/* Compact density option if needed */
.tablex.compact th,
.tablex.compact td {
    padding: var(--space-2) var(--space-3);
}

/* Alignment helpers */
.cell-right {
    text-align: right;
}

.cell-center {
    text-align: center;
}

.cell-mono {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-body);
}

/* Zebra + hover */
.tablex tbody tr:nth-child(even) td {
    background: rgb(var(--paper));
}

.tablex tbody tr:hover td {
    background: rgb(var(--brand-soft) / 0.18);
}

/* Selected row (optional) */
.tablex tr.is-selected td {
    background: rgb(var(--brand-soft) / 0.35);
}

/* Inline row actions */
.row-actions {
    display: inline-flex;
    gap: .5rem;
}

.btn-ghost-sm {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    padding: .25rem .5rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgb(var(--border));
    background: transparent;
    color: var(--c-text);
}

.btn-ghost-sm:hover {
    background: rgb(var(--paper));
}

/* Sort indicators (visual only; hooks for JS later) */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable .dir {
    opacity: .45;
    margin-left: .25rem;
}

.sortable.asc .dir::before {
    content: "▲";
}

.sortable.desc .dir::before {
    content: "▼";
}

/* ===========================
   Responsive tweaks (mobile)
   =========================== */
@media (max-width: 640px) {

    /* Reduce padding and allow first column to wrap */
    .tablex th,
    .tablex td {
        padding: var(--space-2) var(--space-3);
    }

    .tablex td:first-child,
    .tablex th:first-child {
        white-space: normal;
    }

    /* Stack rows into cards with inline labels */
    .tablex-wrap {
        overflow: visible;
    }

    .tablex-scroller {
        overflow: visible;
    }

    .tablex thead {
        display: none;
    }

    .tablex tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: .25rem .75rem;
        padding: var(--space-3);
        border-bottom: 1px solid rgb(var(--border));
        background: rgb(var(--bg));
    }

    .tablex td {
        padding: .25rem 0;
        white-space: normal;
        border: 0;
    }

    .tablex td::before {
        content: attr(data-th);
        font-size: var(--text-xs);
        color: var(--c-muted);
        text-transform: uppercase;
        letter-spacing: .06em;
        margin-right: .5rem;
        display: inline-block;
        min-width: 92px;
    }

    .tablex td[data-th="Label"] {
        grid-column: 1 / -1;
        font-weight: 600;
    }

    .tablex td[data-th="Label"]::before {
        content: "";
        display: none;
    }

    .tablex td[data-th="Actions"] {
        grid-column: 2;
        justify-self: end;
        align-self: center;
    }

    /* --- XS fixes for very narrow screens (<420px) --- */
    @media (max-width: 420px) {
        .tablex tbody tr {
            grid-template-columns: 1fr;
            padding: var(--space-2) var(--space-2);
        }

        .tablex td::before {
            min-width: 64px;
            font-size: var(--text-xs);
        }

        .tablex td[data-th="Actions"] {
            grid-column: 1 / -1;
            justify-self: start;
            margin-top: .25rem;
        }

        .row-actions {
            width: 100%;
            flex-wrap: wrap;
            gap: .375rem;
        }

        .btn-ghost-sm {
            font-size: var(--text-xs);
            padding: .2rem .4rem;
        }
    }
}

/* =========================================
   Landing / marketing components (token-driven)
   ========================================= */

/* Branded nav (logo + wordmark) */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
}

.navbar-brand img {
    display: block;
    width: 48px;
    height: 48px;
}

.navbar-brand .word {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: -0.01em;
    color: var(--c-text);
}

.site-header {
    padding-inline: clamp(1rem, 5vw, 2rem);
}

/* Hero */
.hero {
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 120% at 10% 10%, rgb(var(--paper)) 0%, rgb(var(--bg)) 60%),
        rgb(var(--bg));
    box-shadow: var(--shadow-2);
    padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: clamp(1rem, 4vw, 2rem);
    align-items: center;
}

.hero h1 {
    font-family: var(--font-head);
    font-weight: 800;
    letter-spacing: -0.015em;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    margin: 0;
}

.hero p.lead {
    font-family: var(--font-body);
    font-size: 1.125rem;
    color: var(--c-muted);
    margin: .5rem 0 1rem 0;
}

.hero .cta-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: end;
    margin-top: .75rem;
}

.hero .cta-row .input {
    min-width: 14rem;
}

.hero .chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .375rem .6rem;
    border-radius: 999px;
    font-size: var(--text-xs);
    background: rgb(var(--brand-soft) / .35);
    color: var(--c-brand-strong);
    border: 1px solid rgb(var(--border));
}

.hero .lockup {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.hero .lockup img {
    width: 80px;
    height: 80px;
}

/* Features */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.feature-card {
    background: rgb(var(--bg));
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-1);
}

.feature-card h3 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.125rem;
    margin: 0 0 .25rem 0;
}

.feature-card p {
    margin: 0;
    color: var(--c-muted);
}

.logo-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

.logo-row .mark {
    width: 24px;
    height: 24px;
}

/* Footer note */
.footer-note {
    color: var(--c-muted);
    font-size: var(--text-sm);
}

/* How it works (vertical steps with illustrations) */
.how-it-works {
    margin-top: var(--space-4);
}

.how-it-works__header {
    margin-bottom: var(--space-3);
}

.how-it-works__tagline {
    margin: .25rem 0 0 0;
    color: var(--c-muted);
    font-size: var(--text-md);
}

.how-it-works__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.how-it-works__item {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    align-items: flex-start;
}

.how-it-works__media {
    flex: 0 0 auto;
    align-self: center;
}

.how-it-works__media img {
    display: block;
    width: 96px;
    height: 96px;
    border-radius: 999px;
    margin-bottom: var(--space-2);
}

.how-it-works__content {
    flex: 1 1 auto;
}

.how-it-works__heading {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: var(--space-1);
}

.how-it-works__step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: rgb(var(--brand-soft) / 0.4);
    color: var(--c-brand-strong);
    font-weight: 600;
    font-size: var(--text-sm);
}

.how-it-works__content h3 {
    margin-top: 0;
}

.how-it-works__content p {
    font-size: var(--text-sm);
}

.how-it-works__example {
    margin-top: .5rem;
    font-size: var(--text-xs);
    color: var(--c-muted);
    word-break: break-all;
}

.how-it-works__example span {
    font-weight: 600;
    margin-right: .25rem;
}

.how-it-works__note {
    margin-top: .5rem;
    font-size: var(--text-xs);
    color: var(--c-muted);
}

/* Make the example URL clickable but still look like inline code */
.how-it-works__example code a {
    color: inherit;
    /* use the code color */
    text-decoration: none;
    /* kill the default underline */
}

.how-it-works__example code a:visited {
    color: inherit;
    /* no weird visited color */
}

.how-it-works__example code a:hover,
.how-it-works__example code a:focus-visible {
    text-decoration: underline;
    /* optional: show underline on hover/focus */
}

/* On wider screens, keep one step per row but lay out image + text horizontally */
@media (min-width: 640px) {
    .how-it-works__item {
        flex-direction: row;
        align-items: center;
    }

    .how-it-works__media {
        align-self: flex-start;
    }

    .how-it-works__media img {
        width: 80px;
        height: 80px;
        margin-bottom: 0;
    }
}

/* Section spacing helper */
.section {
    margin: var(--space-4) 0;
}

@media (max-width: 860px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .hero .lockup img {
        width: 32px;
        height: 32px;
    }
}

/* Mobile tweaks for How It Works section */
@media (max-width: 639px) {
    .how-it-works__item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .how-it-works__media {
        margin-bottom: var(--space-3);
    }

    .how-it-works__content {
        width: 100%;
    }
}