/* -----------------------------------------------------------------------------
   AI Predict page (/ai-prediction, views/pc/ai-prediction/*), design "AI Predictions".
   Loaded only by that page (registerCssFile in index.php). Everything is prefixed aip- so nothing here touches the
   rail box (.ai-panel, custom.css) or the match AI tab (.match-ai-*).

   Layout: the sections in one column over the site container and, from 1280px, the Community & AI Agent chat in a
   300px right column (.aip-aside, sticky) so it sits beside the data instead of between the sections. The left column
   has priority: the breakpoint is where it still shows the model table (840px) without sideways scrolling
   (1280 - 2 x 40 gutter - 300 - 16 gap - 2 x 16 card padding = 852). Narrower screens stack the chat under the sections.
   One card per section (#12141b, radius 12). Sizes follow the design at 1440px; two-column grids collapse under 640px.
   ----------------------------------------------------------------------------- */

.aip-page {
    --aip-card: var(--bg-box, #12141b);
    --aip-tile: #171a21;
    --aip-line: #1f2129;
    --aip-text: #eee;
    --aip-muted: #8c8c8e;
    --aip-accent: #e1243b;
    --aip-pick: #27d1fb;
    --aip-hot: #ff7a1a;
    --aip-green: #2ecc71;
    font-family: var(--font-vn, 'Be Vietnam Pro', sans-serif);
}

.aip-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
}

/* Stretches to the row height (grid default) on purpose: the sticky chat card can then follow the whole left column */
.aip-aside {
    min-width: 0;
}

/* Chat beside the sections: 300px column like the rail boxes elsewhere, the card aligned with the first section
   (under the 28px breadcrumb + 16px gap) and pinned under the sticky header while the page scrolls */
@media (min-width: 1280px) {
    .aip-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .aip-aside {
        padding-top: 44px;
    }

    .aip-aside > .aip-section {
        position: -webkit-sticky;
        position: sticky;
        top: 84px;
    }

    /* The log takes the viewport height left under the header and over the chips + input, within sane bounds */
    .aip-aside .aip-chat__log {
        height: calc(100vh - 560px);
        min-height: 220px;
        max-height: 520px;
    }

    .aip-aside .aip-chat__msg {
        max-width: 88%;
    }
}

.aip-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.aip-main > .home-breadcrumb {
    min-height: 28px;
    border-bottom: 0;
}

.aip-main > .home-breadcrumb .home-breadcrumb__item {
    color: var(--aip-muted);
    font-size: 12px;
}

/* ---- Section card -------------------------------------------------------- */

.aip-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-radius: 12px;
    background: var(--aip-card);
    box-sizing: border-box;
}

.aip-section__head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aip-section__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
}

.aip-section__desc {
    margin: 0;
    color: var(--aip-muted);
    font-size: 13px;
    line-height: 20px;
}

/* Sections rendered with placeholder rows until their data source exists */
.aip-badge-sample {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 100px;
    color: var(--aip-muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.aip-empty {
    margin: 0;
    padding: 24px 8px;
    color: var(--aip-muted);
    font-size: 13px;
    text-align: center;
}

/* ---- Market filter chips (Top 10 Hot Picks) ------------------------------ */

.aip-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aip-filter {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 100px;
    background: transparent;
    color: var(--aip-muted);
    font: 500 12px/1 var(--font-vn, 'Be Vietnam Pro', sans-serif);
    cursor: pointer;
}

.aip-filter:hover {
    color: #fff;
}

.aip-filter.is-active {
    border-color: var(--aip-accent);
    background: rgba(225, 36, 59, .12);
    color: #fff;
}

/* ---- Hot pick cards ------------------------------------------------------ */

.aip-picks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.aip-pick {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px 14px;
    border: 1px solid var(--aip-line);
    border-radius: 12px;
    background: var(--aip-tile);
    color: var(--aip-text);
    text-decoration: none;
    box-sizing: border-box;
}

.aip-picks[hidden],
.aip-pick[hidden] {
    display: none;
}

.aip-pick:hover {
    border-color: #2a2c36;
}

.aip-pick__rank {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 24px;
    border-radius: 11px 0 10px 0;
    background: rgba(85, 85, 100, .18);
    color: var(--aip-muted);
    font-size: 12px;
    font-weight: 500;
}

.aip-pick__league {
    overflow: hidden;
    color: var(--aip-muted);
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

a.aip-pick__league:hover,
a.aip-popular__league:hover {
    color: #fff;
}

/* Body of a card = link to the match AI page (the league line above it is its own link) */
.aip-pick__body,
.aip-popular__body {
    color: inherit;
    text-decoration: none;
}

.aip-pick__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aip-pick__teams {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.aip-pick__team {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.aip-pick__team--away {
    justify-content: flex-start;
}

.aip-pick__name {
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aip-pick__crest {
    display: block;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.aip-pick__center,
.aip-popular__when {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    color: var(--aip-muted);
    font-size: 11px;
    line-height: 14px;
    white-space: nowrap;
}

/* Card content is regular weight (design); emphasis comes from colour, not weight */
.aip-pick__time {
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
}

.aip-pick__live {
    color: #f14851;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
}

.aip-pick__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Stat chip: two stacked lines (label / value or value / label) */
.aip-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 56px;
    padding: 5px 8px;
    border: 1px solid var(--aip-line);
    border-radius: 6px;
    background: rgba(85, 85, 100, .1);
    color: var(--aip-muted);
    font-size: 11px;
    line-height: 14px;
    box-sizing: border-box;
}

.aip-chip small {
    font-size: 11px;
}

.aip-chip__value {
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
}

.aip-chip__value--up,
.aip-chip__value--down,
.aip-chip__value--neutral {
    color: var(--aip-pick);
}

.aip-chip__value--rate {
    color: var(--aip-pick);
}

/* Ring gauge: circle r=15.9155 has a circumference of 100, so stroke-dasharray="N 100" fills N% */
.aip-gauge {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
}

.aip-gauge > svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.aip-gauge__track,
.aip-gauge__value {
    fill: none;
    stroke-width: 2.6;
}

.aip-gauge__track {
    stroke: rgba(255, 255, 255, .1);
}

.aip-gauge__value {
    stroke: var(--aip-hot);
    stroke-linecap: round;
}

.aip-gauge__label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    color: var(--aip-hot);
    font-size: 11px;
    font-weight: 500;
}

.aip-gauge--sm {
    width: 34px;
    height: 34px;
}

.aip-gauge--sm .aip-gauge__label {
    font-size: 10px;
}

/* ---- Most popular match -------------------------------------------------- */

.aip-popular {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.aip-popular__card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--aip-line);
    border-radius: 12px;
    background: var(--aip-tile);
    color: var(--aip-text);
    text-decoration: none;
}

.aip-popular__card:hover {
    border-color: #2a2c36;
}

.aip-popular__league {
    overflow: hidden;
    color: var(--aip-muted);
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

.aip-popular__body {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.aip-popular__teams {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.aip-popular__team {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
}

.aip-popular__team span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Model colours (shared by the table, the model cards and the article badges) */

/* Brand colours; Grok's mark is black on white, so its dot is near-black with a light ring instead */
.aip-model--true { --aip-model: #e1243b; }
.aip-model--openai { --aip-model: #10a37f; }
.aip-model--claude { --aip-model: #d97757; }
.aip-model--grok { --aip-model: #1b1b1f; --aip-model-ring: rgba(255, 255, 255, .35); --aip-model-text: #cfcfd4; }
.aip-model--deepseek { --aip-model: #4d6bfe; }

.aip-model__dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--aip-model, #555);
    box-shadow: 0 0 0 1px var(--aip-model-ring, transparent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Brand mark inside the dot: white SVG scaled to 60% of the dot whatever its size */
.aip-model__dot img {
    display: block;
    width: 60%;
    height: 60%;
    object-fit: contain;
}

/* ---- AI Model Assessment Table ------------------------------------------- */

.aip-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 840px: the narrowest the 7 columns read well at, and what fits beside the chat column at 1280px (see the header) */
.aip-table {
    width: 100%;
    min-width: 840px;
    border-collapse: separate;
    border-spacing: 0 8px;
    color: var(--aip-text);
    font-size: 12px;
    line-height: 16px;
}

.aip-table th {
    padding: 0 8px 4px;
    color: var(--aip-muted);
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.aip-table th.aip-table__bet {
    text-align: left;
}

.aip-table__model {
    vertical-align: bottom;
}

/* Dot above the name, both centred; the dot keeps its flex display so the mark sits in its middle */
.aip-table__model > span {
    display: block;
    margin: 0 auto 4px;
}

.aip-table__model > .aip-model__dot {
    display: flex;
    width: 24px;
    height: 24px;
}

.aip-table__model > span + span {
    margin-bottom: 0;
}

.aip-table td {
    padding: 10px 8px;
    background: var(--aip-tile);
    text-align: center;
    vertical-align: middle;
}

.aip-table td:first-child {
    border-radius: 10px 0 0 10px;
}

.aip-table td:last-child {
    border-radius: 0 10px 10px 0;
}

.aip-table__bet {
    min-width: 280px;
}

.aip-table td.aip-table__bet {
    text-align: left;
}

/* The match block exists twice in the markup: one cell for wide screens, two narrow cells for phones (see the 767px
   media query); only one of the two sets is displayed */
.aip-table__narrow {
    display: none;
}

/* Match block: team pair on one line, the market chip centred under it (design); the whole block links to the match */
.aip-table__match {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: inherit;
    font-weight: 400;
    text-decoration: none;
}

.aip-table__match:hover .aip-table__team {
    color: var(--aip-pick);
}

.aip-table__teams {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* Team names and kick-off time are regular weight in the design; only the live minute stands out (colour) */
.aip-table__team {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    color: #fff;
    font-weight: 400;
}

.aip-table__team > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aip-table__crest {
    display: block;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.aip-table__team--away {
    justify-content: flex-start;
}

.aip-table__when {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--aip-muted);
    font-size: 11px;
    white-space: nowrap;
}

.aip-table__when b {
    color: #fff;
    font-size: 12px;
    font-weight: 400;
}

.aip-table__live {
    color: #f14851;
}

.aip-table__market {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(39, 209, 251, .1);
    color: var(--aip-pick);
    font-size: 11px;
    font-weight: 600;
}

/* Pick text in the model colour, regular weight like the design; a dark model colour (Grok) names a lighter text colour */
.aip-table__pick {
    color: var(--aip-model-text, var(--aip-model, #fff));
    font-weight: 400;
}

.aip-consensus {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 88px;
    padding: 6px 10px;
    border: 1px solid var(--aip-consensus, var(--aip-line));
    border-radius: 8px;
    color: var(--aip-consensus, #fff);
    box-sizing: border-box;
}

.aip-consensus b {
    font-size: 13px;
    font-weight: 500;
}

.aip-consensus small {
    font-size: 11px;
}

/* Model cell while its assessment is being fetched / when the gateway had none; a model off the consensus pick is dimmed */
.aip-table__pick--pending,
.aip-table__pick--none {
    color: var(--aip-muted);
}

.aip-table__pick--off {
    opacity: .7;
}

.aip-consensus--pending,
.aip-consensus--none {
    --aip-consensus: var(--aip-muted);
}

.aip-consensus--excellent { --aip-consensus: #2ecc71; }
.aip-consensus--high { --aip-consensus: #19c37d; }
.aip-consensus--moderate { --aip-consensus: #e1243b; }
.aip-consensus--low { --aip-consensus: #ff7a1a; }
.aip-consensus--very-low { --aip-consensus: #e1243b; }

/* ---- Community & AI Agent ------------------------------------------------ */

.aip-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aip-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--aip-muted);
    font: 500 12px/1 var(--font-vn, 'Be Vietnam Pro', sans-serif);
    cursor: pointer;
}

.aip-tab img {
    filter: brightness(0) invert(1);
    opacity: .7;
}

.aip-tab.is-active {
    background: #1d8fff;
    color: #fff;
}

.aip-tab.is-active img {
    opacity: 1;
}

.aip-chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--aip-line);
    border-radius: 12px;
    background: var(--aip-tile);
}

.aip-chat[hidden] {
    display: none;
}

.aip-chat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.aip-chat__agent {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--aip-muted);
    font-size: 12px;
}

.aip-chat__status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--aip-green);
    font-size: 11px;
}

.aip-chat__status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.aip-chat__clear {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--aip-muted);
    font: 400 11px/1 var(--font-vn, 'Be Vietnam Pro', sans-serif);
    cursor: pointer;
}

.aip-chat__clear:hover {
    color: #fff;
}

.aip-chat__placeholder {
    margin: 0;
    padding: 24px 8px;
    color: var(--aip-muted);
    font-size: 13px;
    text-align: center;
}

/* Grows with the conversation up to a cap, then scrolls inside the card (scrollTop is kept at the bottom by JS) */
.aip-chat__log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.aip-chat__msg {
    max-width: 75%;
    margin: 0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 18px;
}

.aip-chat__msg--agent {
    align-self: flex-start;
    background: rgba(255, 255, 255, .06);
    color: var(--aip-text);
}

.aip-chat__msg--user {
    align-self: flex-end;
    background: #1d8fff;
    color: #fff;
}

.aip-chat__msg--typing {
    color: var(--aip-muted);
    font-style: italic;
}

.aip-chat__msg--error {
    border: 1px solid rgba(225, 36, 59, .4);
    color: #f14851;
}

.aip-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aip-chat__suggestion {
    height: 28px;
    padding: 0 12px;
    border: 1px solid var(--aip-line);
    border-radius: 6px;
    background: rgba(255, 255, 255, .04);
    color: var(--aip-text);
    font: 400 12px/1 var(--font-vn, 'Be Vietnam Pro', sans-serif);
    cursor: pointer;
}

.aip-chat__suggestion:hover {
    border-color: #2a2c36;
    background: rgba(255, 255, 255, .08);
}

.aip-chat.is-pending .aip-chat__suggestion {
    opacity: .5;
    pointer-events: none;
}

.aip-chat__form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--aip-line);
    border-radius: 8px;
    background: rgba(0, 0, 0, .2);
}

.aip-chat__input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #fff;
    font: 400 12px/32px var(--font-vn, 'Be Vietnam Pro', sans-serif);
    outline: 0;
}

.aip-chat__input::placeholder {
    color: var(--aip-muted);
}

.aip-chat__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--aip-muted);
    cursor: pointer;
}

.aip-chat__send:hover {
    color: #fff;
}

.aip-chat__send:disabled {
    opacity: .5;
    cursor: default;
}

.aip-chat__form:focus-within {
    border-color: #2a2c36;
}

/* ---- Key Insights from AI Models ----------------------------------------- */

/* Five model cards (True AI + the four consensus models); each one is also the feed filter (button) */
.aip-models {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.aip-model-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 14px 8px;
    border: 1px solid var(--aip-line);
    border-radius: 12px;
    background: var(--aip-tile);
    color: inherit;
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.aip-model-card:hover:not(:disabled) {
    border-color: #2a2c36;
}

.aip-model-card:disabled {
    opacity: .55;
    cursor: default;
}

/* Selected filter: the card takes its model colour; the others step back while a filter is on */
.aip-model-card.is-active {
    border-color: var(--aip-model-text, var(--aip-model)); /* Grok's colour is near-black: its lighter text colour */
    background: color-mix(in srgb, var(--aip-model) 12%, var(--aip-tile));
}

.aip-section.is-filtered .aip-model-card:not(.is-active) {
    opacity: .6;
}

.aip-model-card .aip-model__dot {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
    font-size: 13px;
}

.aip-model-card__name {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

/* Model id ("claude-haiku-5.5", "deepseek-v4.1-flash-1017"): one line, cut when long (full id in the title) */
.aip-model-card__role {
    max-width: 100%;
    overflow: hidden;
    color: var(--aip-muted);
    font-size: 11px;
    line-height: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aip-model-card__stats {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.aip-model-card__stats .aip-chip {
    min-width: 48px;
    padding: 5px 6px;
}

/* A model's insight that goes against the consensus pick */
.aip-article__tag {
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 122, 26, .12);
    color: var(--aip-hot);
    font-size: 10px;
    line-height: 14px;
    white-space: nowrap;
}

.aip-more {
    align-self: center;
    height: 32px;
    padding: 0 18px;
    border: 1px solid var(--aip-line);
    border-radius: 100px;
    background: transparent;
    color: var(--aip-text);
    font: 400 12px/1 var(--font-vn, 'Be Vietnam Pro', sans-serif);
    cursor: pointer;
}

.aip-more:hover {
    border-color: #2a2c36;
    color: #fff;
}

.aip-more[hidden],
.aip-article[hidden] {
    display: none;
}

.aip-articles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.aip-article {
    display: flex;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--aip-line);
    border-radius: 12px;
    background: var(--aip-tile);
    color: inherit;
    text-decoration: none;
}

.aip-article:hover {
    border-color: #2a2c36;
}

.aip-article__thumb {
    flex: 0 0 auto;
    overflow: hidden;
    width: 96px;
    height: 72px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2b2e3a 0%, #1a1c24 100%);
}

.aip-article__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Insight thumbnail: the two crests on a split red / blue background (design) */
.aip-article__thumb--crests {
    display: flex;
}

.aip-article__half {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
}

.aip-article__half img {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.aip-article__half--home {
    background: linear-gradient(160deg, #8f1f2e 0%, #5b1420 100%);
}

.aip-article__half--away {
    background: linear-gradient(200deg, #1f3f8f 0%, #14285b 100%);
}

.aip-article__time {
    margin-left: 6px;
    padding-left: 6px;
    border-left: 1px solid var(--aip-line);
    color: var(--aip-muted);
    white-space: nowrap;
}

.aip-article__body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* Model, optional "Against consensus" tag, kick-off: wraps as whole items on narrow cards instead of breaking the date */
.aip-article__model {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    color: var(--aip-muted);
    font-size: 11px;
}

.aip-article__model .aip-model__dot {
    width: 16px;
    height: 16px;
    font-size: 9px;
}

.aip-article__title {
    display: -webkit-box;
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Two lines: for the models it is their reasoning, the point of the card (the whole sentence is the card's tooltip) */
.aip-article__brief {
    display: -webkit-box;
    overflow: hidden;
    color: var(--aip-muted);
    font-size: 11px;
    line-height: 16px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ---- Narrower screens ---------------------------------------------------- */

/* Narrower than the five cards need: one row that scrolls sideways, the filter stays a single strip */
@media (max-width: 1100px) {
    .aip-models {
        grid-template-columns: repeat(5, minmax(128px, 1fr));
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .aip-models::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 767px) {
    .aip-section {
        padding: 12px;
    }

    /* Model table on phones: the Bet Type block becomes two narrow columns (kick-off + market chip, then the two teams
       one above the other) so the table needs much less width before the model columns; it still scrolls sideways */
    .aip-table {
        min-width: 620px;
    }

    .aip-table td {
        padding: 8px 6px;
    }

    .aip-table__wide {
        display: none;
    }

    .aip-table__narrow {
        display: table-cell;
    }

    .aip-table__bet {
        min-width: 0;
    }

    .aip-table td.aip-table__slot {
        width: 76px;
        padding-right: 0;
        text-align: center;
    }

    /* "AH H -0.5" is the longest chip: it must not break into two lines inside the narrow cell */
    .aip-table__slot .aip-table__market {
        white-space: nowrap;
    }

    .aip-table td.aip-table__pair {
        width: 140px;
    }

    .aip-table__pair .aip-table__match {
        align-items: flex-start;
        gap: 4px;
    }

    .aip-table__pair .aip-table__team {
        justify-content: flex-start;
        max-width: 140px;
    }

    .aip-table__pair .aip-table__crest {
        width: 18px;
        height: 18px;
    }

    /* Model cells: side over percentage in every column, whatever the column width */
    .aip-table__side,
    .aip-table__pct {
        display: block;
        white-space: nowrap;
    }

    .aip-section__title {
        font-size: 16px;
        line-height: 24px;
    }

    .aip-popular {
        grid-template-columns: minmax(0, 1fr);
    }

    .aip-chat__msg {
        max-width: 90%;
    }
}

@media (max-width: 639px) {
    .aip-picks,
    .aip-articles {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The five market chips stay on one row on phones: equal widths instead of wrapping ALL / AH / 1x2 / O/U / BTTS */
    .aip-filters {
        flex-wrap: nowrap;
        gap: 6px;
    }

    .aip-filter {
        flex: 1 1 0;
        justify-content: center;
        min-width: 0;
        padding: 0 6px;
    }

    .aip-pick {
        padding: 12px 12px 14px;
    }
}

/* ---- Loading states (model table cells, consensus box, Key Insights cards) --- */

/* Three pulsing dots in a model cell / "Posted" chip while the assessment is fetched */
.aip-loading {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 16px;
    vertical-align: middle;
}

.aip-loading i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: .35;
    animation: aip-pulse 1.2s ease-in-out infinite;
}

.aip-loading i:nth-child(2) { animation-delay: .2s; }
.aip-loading i:nth-child(3) { animation-delay: .4s; }

@keyframes aip-pulse {
    0%, 80%, 100% { opacity: .35; transform: scale(.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Ring spinner: consensus box and the status lines */
.aip-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    animation: aip-spin .8s linear infinite;
}

.aip-consensus--pending b {
    display: flex;
    justify-content: center;
    height: 18px;
}

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

/* Progress line under the model table / in Key Insights: how many bets are still being assessed */
.aip-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
    padding: 8px 12px;
    border: 1px dashed var(--aip-line);
    border-radius: 8px;
    color: var(--aip-muted);
    font-size: 12px;
    line-height: 16px;
}

.aip-status--done .aip-spinner {
    display: none;
}

#aip-insights .aip-status {
    margin: 0 0 12px;
}

@media (prefers-reduced-motion: reduce) {
    .aip-loading i,
    .aip-spinner {
        animation: none;
    }

    .aip-loading i {
        opacity: .7;
    }
}
