/* One-page deals grid (templates/deals_per_origin_grid.html). Scoped to .deals-grid-layout / .dg.
   Colours, radii and shadows are the Clarity tokens from main.css, so dark mode follows [data-theme]. */

/* The article column is 500px for prose; the grid needs room. 800px keeps clear of the
   fixed L/R sidebar ad slots on common desktop widths. */
.deals-grid-layout #article_main { max-width: 800px; }

.dg { font-family: var(--font-body); color: var(--text-hi); }

.deals-grid-layout #article_header h1 { font-weight: 800; letter-spacing: -.01em; }
.dg-h1-origin {
  font: inherit; color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 2px dashed var(--border-strong); display: inline-flex; align-items: center; gap: 2px;
}
.dg-h1-origin:hover { border-bottom-style: solid; }
.dg-h1-origin svg { flex-shrink: 0; }

.dg-from { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: -6px 0 6px; }
.dg-from-label { font-size: 13px; font-weight: 600; color: var(--text-mid); }
.dg-origin-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-hi);
  border-radius: var(--radius-sm); padding: 6px 10px; font: inherit; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow-btn);
}
.dg-origin-btn:hover { border-color: var(--primary); }
.dg-origin-code {
  font-size: 12px; font-weight: 800; letter-spacing: .03em; color: var(--badge-text);
  background: var(--badge-bg); border-radius: 6px; padding: 2px 6px;
}
.dg-origin-change { font-size: 13px; font-weight: 600; color: var(--link); }

.dg-lead { color: var(--text-mid); font-size: 14.5px; margin: 8px 0 0; }

.dg-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 4px; }
.dg-seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.dg-seg button {
  border: 0; background: transparent; color: var(--text-mid); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 6px;
}
.dg-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text-hi); box-shadow: var(--shadow-btn); }

.dg-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  border: 1px solid var(--toggle-row-border); background: var(--toggle-row-bg); color: var(--toggle-row-fg);
  border-radius: var(--radius-sm); padding: 7px 11px; font: inherit; font-size: 13px; font-weight: 600;
}
.dg-toggle[aria-checked="true"] { background: var(--toggle-on-bg); border-color: var(--toggle-on-border); color: var(--toggle-on-fg); }
.dg-switch { width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; }
.dg-toggle[aria-checked="true"] .dg-switch { background: var(--green); }
.dg-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.dg-toggle[aria-checked="true"] .dg-switch::after { transform: translateX(12px); }


.dg-grid {
  list-style: none; margin: 14px 0 24px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px;
}
.article .dg-grid li { margin-top: 0; }
.dg-ad { grid-column: 1 / -1; }

.dg-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); overflow: hidden; display: flex; flex-direction: column;
}
.dg-card[hidden] { display: none; }

.dg-postcard { display: flex; align-items: center; justify-content: center; color: #fff; }
.dg-iata { font-weight: 800; letter-spacing: .04em; }
/* Wider screens: the destination's colour and code as a tile beside the name and the line under it, as on phones. */
@media (min-width: 521px) {
  .dg-card { position: relative; }
  .dg-postcard { position: absolute; top: 12px; left: 12px; width: 42px; height: 42px; border-radius: 9px; }
  .dg-iata { font-size: 12px; }
  #article_main .dg-card .dg-dest, .dg-card .dg-dest + * { margin-left: 54px; }
  #article_main .dg-card .dg-dest { min-height: 22px; }
  .dg-card .dg-dest + * { min-height: 20px; margin-top: 0; }
  .dg-card .dg-dest + .dg-dateline { margin-bottom: 6px; }
}
/* Destination colours: 13 hues evenly round the colour wheel at the same strength, each dark enough for white
   text (4.5:1 at the dark end, 3:1 at the light end). deal_postcard_tone() picks one per airport code. */
.dg-tone-0, .dgm-tone-0 { --tone-a: #3F74AB; --tone-b: #6A97C8; }
.dg-tone-1, .dgm-tone-1 { --tone-a: #3F42AB; --tone-b: #6A6CC8; }
.dg-tone-2, .dgm-tone-2 { --tone-a: #6F3FAB; --tone-b: #936AC8; }
.dg-tone-3, .dgm-tone-3 { --tone-a: #A13FAB; --tone-b: #BF6AC8; }
.dg-tone-4, .dgm-tone-4 { --tone-a: #AB3F84; --tone-b: #C86AA6; }
.dg-tone-5, .dgm-tone-5 { --tone-a: #AB3F52; --tone-b: #C86A7B; }
.dg-tone-6, .dgm-tone-6 { --tone-a: #AB5E3F; --tone-b: #C78368; }
.dg-tone-7, .dgm-tone-7 { --tone-a: #8A7433; --tone-b: #AD9240; }
.dg-tone-8, .dgm-tone-8 { --tone-a: #6C7D2E; --tone-b: #889C3A; }
.dg-tone-9, .dgm-tone-9 { --tone-a: #4C8431; --tone-b: #5FA43D; }
.dg-tone-10, .dgm-tone-10 { --tone-a: #32863D; --tone-b: #3FA94D; }
.dg-tone-11, .dgm-tone-11 { --tone-a: #318462; --tone-b: #3DA67B; }
.dg-tone-12, .dgm-tone-12 { --tone-a: #328186; --tone-b: #3EA2A8; }
.dg-postcard { background: linear-gradient(135deg, var(--tone-a), var(--tone-b)); }

.dg-body { padding: 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
#article_main .dg-dest { font-size: 16px; font-weight: 700; line-height: 1.2; margin: 0; }
.dg-dest a { color: var(--text-hi); text-decoration: none; }
.dg-dest a:hover { color: var(--link); text-decoration: underline; }
.dg-country { font-size: 12.5px; color: var(--text-lo); }
.dg-dateline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 7px; margin-top: 8px; }
.dg-dates { font-size: 14.5px; font-weight: 700; }
.dg-nights { font-size: 12px; color: var(--text-lo); }
.dg-priceline { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.dg-price { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dg-trip { font-size: 13px; font-weight: 600; color: var(--text-lo); }
.dg-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dg-chip {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; background: var(--surface-alt); color: var(--text-mid); border: 1px solid var(--border);
}
.dg-chip-direct { background: var(--toggle-on-bg); color: var(--toggle-on-fg); border-color: var(--toggle-on-border); }
.dg-seen { font-size: 11px; color: var(--text-lo); margin-top: 6px; }

.dg-actions { display: flex; gap: 8px; padding: 0 12px 12px; }
.dg-btn {
  font: inherit; font-weight: 700; font-size: 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; padding: 11px 12px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
}
.dg-book { flex: 1 1 auto; white-space: nowrap; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn); }
.dg-book:hover { background: var(--primary-hover); }
.dg-predict { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; background: var(--surface); color: var(--primary); border-color: var(--border-strong); }
.dg-predict:hover { background: var(--surface-alt); }

.dg-empty { color: var(--text-mid); text-align: center; padding: 24px 0; }

/* Origin picker */
.dg-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 1050; }
.dg-sheet {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1051;
  width: min(440px, calc(100% - 32px)); max-height: min(72vh, 560px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 16px;
}
.dg-scrim[hidden], .dg-sheet[hidden] { display: none; }
.dg-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#article_main .dg-sheet-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.dg-sheet-close { border: 0; background: transparent; color: var(--text-mid); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.dg-search {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface-alt); color: var(--text-hi);
  border-radius: var(--radius-sm); padding: 10px 12px; font: inherit; font-size: 16px;
}
.dg-sheet-status { font-size: 13px; color: var(--text-lo); margin: 10px 0 0; }
.dg-sheet-status:empty { display: none; }
.dg-origins { list-style: none; margin: 8px 0 0; padding: 0; }
.article .dg-origins li { margin-top: 0; }
.dg-origins a {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm);
  color: var(--text-hi); text-decoration: none;
}
.dg-origins a:hover, .dg-origins a:focus-visible { background: var(--surface-alt); }
.dg-origins .dg-origin-code { min-width: 44px; text-align: center; }
.dg-origin-name { font-weight: 600; }
.dg-origin-airport { font-size: 12px; color: var(--text-lo); }
.dg-origin-current { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--toggle-on-fg); }

/* Phones: a compact list. A row shows city, dates and price; tapping it opens country, airline,
   Book and Predict (deals-grid.js toggles .is-open). Still a one-column grid so the ad's CSS order works. */
.dg-row-toggle, .dg-chev { display: none; }
/* "All months" (route page) and "December dates" (month page): the card's footer on desktop, inside the open row on
   phones. Real links: the crawl path from origin to route and month pages. */
.dg-links { display: flex; border-top: 1px solid var(--border); }
.dg-more {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 8px;
  font-size: 13px; font-weight: 700; line-height: 1.25; text-align: center; color: var(--primary); text-decoration: none;
}
.dg-more + .dg-more { border-left: 1px solid var(--border); }
.dg-more::after {
  content: ""; flex-shrink: 0; width: 6px; height: 6px; border-right: 2px solid currentColor; border-top: 2px solid currentColor; transform: rotate(45deg);
}
.dg-more:hover { background: var(--surface-alt); text-decoration: none; }
@media (max-width: 520px) {
  .dg-grid {
    grid-template-columns: minmax(0, 1fr); gap: 0; background: var(--surface);
    border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden;
  }
  /* Each row's line is the divider; the last one closes the list (the list itself has no bottom border). */
  .dg-card, .dg-ad {
    border-bottom: 1px solid var(--border-strong);
    border-bottom-color: color-mix(in srgb, var(--border-strong), var(--text-lo) 30%);
  }
  .dg-ad { padding: 8px 0; }
  .dg-card {
    position: relative; display: grid; column-gap: 12px; padding: 10px 12px 10px 14px;
    grid-template-columns: 36px minmax(0, 1fr) auto 12px;
    grid-template-areas:
      "tile name  price chev"
      "tile dates price chev"
      ".    ctry  ctry  ctry"
      ".    meta  meta  meta"
      ".    seen  seen  seen"
      "acts acts  acts  acts"
      "more more  more  more";
    border-radius: 0; box-shadow: none; border-left: 0; border-right: 0; border-top: 0; overflow: visible;
  }
  .dg-card[hidden] { display: none; }
  .dg-row-toggle {
    display: block; position: absolute; left: 0; right: 0; top: 0; height: 58px; z-index: 1;
    padding: 0; border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .dg-row-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
  .dg-body { display: contents; }
  .dg-postcard {
    grid-area: tile; align-self: center; width: 36px; height: 36px; padding: 0; border-radius: 8px;
    align-items: center; justify-content: center;
  }
  .dg-iata { font-size: 11px; }
  #article_main .dg-dest { grid-area: name; align-self: end; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dg-dateline { grid-area: dates; align-self: start; margin: 1px 0 0; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
  .dg-dates { font-size: 12.5px; font-weight: 600; }
  .dg-nights { font-size: 12.5px; color: var(--text-mid); }
  .dg-priceline { grid-area: price; flex-direction: column; align-items: flex-end; justify-content: center; gap: 0; margin: 0; }
  .dg-price { font-size: 18px; line-height: 1.15; }
  .dg-trip { font-size: 11px; }
  .dg-priceline .dg-chip-best { display: none; }
  .dg-chev {
    display: block; grid-area: chev; align-self: center; width: 8px; height: 8px; margin-top: -4px;
    border-right: 2px solid var(--text-lo); border-bottom: 2px solid var(--text-lo); transform: rotate(45deg);
  }
  .dg-card.is-open .dg-chev { transform: rotate(-135deg); margin-top: 4px; }
  .dg-country, .dg-meta, .dg-seen, .dg-actions, .dg-links { display: none; }
  .dg-card.is-open .dg-country { display: block; grid-area: ctry; margin-top: 8px; }
  .dg-card.is-open .dg-meta { display: flex; grid-area: meta; margin-top: 6px; }
  .dg-card.is-open .dg-seen { display: block; grid-area: seen; margin-top: 4px; }
  .dg-card.is-open .dg-actions { display: flex; grid-area: acts; padding: 12px 0 0; }
  .dg-card.is-open .dg-links { display: flex; grid-area: more; margin-top: 10px; border-top: 0; }
  .dg-card.is-open .dg-more { padding: 4px 0; font-size: 13px; font-weight: 600; color: var(--link); }
  .dg-card.is-open .dg-more:hover { background: none; }
}

.dg :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .dg * { transition: none !important; } }

/* ---- Route and month pages in the grid design (deals_per_route_grid.html, month_deals_grid.html) ---- */

/* Trip type there is two pages, so the segmented control holds links, not filter buttons. */
.dg-seg a {
  color: var(--text-mid); font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 6px; text-decoration: none;
}
.dg-seg a:hover { color: var(--text-hi); text-decoration: none; }
.dg-seg a.is-on { background: var(--surface); color: var(--text-hi); box-shadow: var(--shadow-btn); }
.dg-lead strong { color: var(--text-hi); }
.dg-back { font-size: 13px; font-weight: 600; margin: 6px 0 0; }
.dg-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 12px; font-size: 13px; font-weight: 600; color: var(--text-lo); }
.dg-crumbs a { color: var(--primary); }
.dg-crumbs [aria-current] { color: var(--text-hi); }
.dg-chip-best { background: var(--badge-bg); color: var(--badge-text); border-color: transparent; font-weight: 700; }
.dg-priceline .dg-chip-best { align-self: center; margin-left: 2px; }

/* Month tiles on origin pages (name + deal count). */
.dgm-month-name { font-size: 13px; font-weight: 800; }
.dgm-month-price { font-size: 12px; color: var(--text-mid); white-space: nowrap; }

/* Month pages: the fare table, drawn as cards. The markup and its text are month_deals.html's; the band,
   big price, "Book" and "Cheapest" come from data-* attributes. */

.dgm-table-wrap { margin: 14px 0 24px; }
.dgm .dgm-table { display: block; width: 100%; border: 0; margin: 0; }
.dgm .dgm-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dgm .dgm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

.dgm .dgm-card {
  display: grid; column-gap: 8px;
  grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "date date date" "price best best" "air air air" "book book pred";
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); overflow: hidden; padding: 5px 0 0;
  /* Every card on a month page goes to the same place, so no postcard band: a thin strip in the destination's colour. */
  background: linear-gradient(90deg, var(--tone-a), var(--tone-b)) top / 100% 5px no-repeat, var(--surface);
}
.dgm .dgm-card[hidden] { display: none; }
.dgm .dgm-card::after {
  content: attr(data-price); grid-area: price; padding: 6px 0 0 12px;
  font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--text-hi);
}
.dgm .dgm-card > td { display: block; border: 0; padding: 0 12px; background: none; }
.dgm .dgm-card > td.deal-listing-dates { grid-area: date; padding-top: 14px; font-size: 18px; font-weight: 800; line-height: 1.25; letter-spacing: -.005em; }
.dgm .dgm-card .deal-listing-dates-text,
.dgm .dgm-card .deal-listing-dates-text--return .deal-listing-date-line { display: inline; }
.dgm .dgm-card .deal-listing-date-line + .deal-listing-date-line::before { content: " – "; }
.dgm .dgm-card > td.deal-listing-airline {
  grid-area: air; display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 6px; padding-top: 6px;
}
.dgm .dgm-card .deal-listing-meta { display: contents; }
.dgm .dgm-card .deal-listing-airline-name,
.dgm .dgm-card .deal-direct-badge {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; line-height: 1.4; padding: 2px 7px;
  border-radius: 999px; background: var(--surface-alt); color: var(--text-mid); border: 1px solid var(--border);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
/* "Cheapest" sits on the price line, just after the price (phones use ::before for the date tile). */
@media (min-width: 521px) {
  .dgm .dgm-card[data-cheapest]::before {
    content: attr(data-cheapest); grid-area: best; justify-self: start; align-self: center; margin-top: 6px;
    display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700; line-height: 1.4; padding: 2px 7px;
    border-radius: 999px; background: var(--badge-bg); color: var(--badge-text); white-space: nowrap;
  }
}
.dgm .dgm-card .deal-direct-badge { order: 2; background: var(--toggle-on-bg); color: var(--toggle-on-fg); border-color: var(--toggle-on-border); }
.dgm .dgm-card > td.deal-listing-price { grid-area: book; padding: 12px 0 12px 12px; text-align: left; width: auto; white-space: nowrap; }
.dgm .dgm-card > td.dgm-predict-cell { grid-area: pred; padding: 12px 12px 12px 0; }
.dgm .dgm-card .dg-btn { width: 100%; }
.dgm .dgm-card .dg-book.btn {
  background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-btn);
  font-size: 14px; font-weight: 700; line-height: 1.2; padding: 11px 12px; border-radius: var(--radius-sm); white-space: nowrap;
}
.dgm .dgm-card .dg-book.btn:hover { background: var(--primary-hover); }
.dgm .dgm-card .dg-book::before { content: attr(data-book-label); }

.dgm .dg-ad { display: block; }
.dgm .dg-ad > td { display: block; padding: 0; border: 0; }

@media (max-width: 520px) {
  .dgm .dgm-grid {
    grid-template-columns: minmax(0, 1fr); gap: 0; background: var(--surface);
    border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden;
  }
  .dgm .dgm-card {
    position: relative; column-gap: 12px; padding: 10px 12px 10px 14px; border: 0; border-radius: 0; box-shadow: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border-strong);
    border-bottom-color: color-mix(in srgb, var(--border-strong), var(--text-lo) 30%);
    grid-template-columns: 36px minmax(0, 1fr) auto 12px; grid-template-rows: auto;
    grid-template-areas: "tile date price chev" "tile air price chev";
  }
  .dgm .dgm-card.is-open { grid-template-areas: "tile date price chev" "tile air price chev" "acts acts acts acts"; }
  .dgm .dgm-card::before {
    content: attr(data-tile); grid-area: tile; align-self: center; width: 36px; height: 36px; padding: 0;
    display: flex; color: #fff; font-weight: 800;
    border-radius: 8px; justify-content: center; align-items: center; text-align: center;
    white-space: pre; font-size: 10px; line-height: 1.15; letter-spacing: .03em;
    background: linear-gradient(135deg, var(--tone-a), var(--tone-b));
  }
  .dgm .dgm-card::after { grid-area: price; align-self: center; justify-self: end; padding: 0; font-size: 18px; line-height: 1.15; }
  .dgm .dgm-card > td { padding: 0; }
  .dgm .dgm-card > td.deal-listing-dates { align-self: end; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dgm .dgm-card > td.deal-listing-airline {
    display: block; align-self: start; padding: 1px 0 0; font-size: 12.5px; color: var(--text-mid);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .dgm .dgm-card .deal-listing-airline-name,
  .dgm .dgm-card .deal-direct-badge {
    display: inline; padding: 0; border: 0; background: none; border-radius: 0; font-size: 12.5px;
  }
  .dgm .dgm-card .deal-listing-airline-name { color: var(--text-hi); }
  .dgm .dgm-card .deal-direct-badge::before { content: " · "; color: var(--text-mid); }
  .dgm .dgm-card > td.deal-listing-price,
  .dgm .dgm-card > td.dgm-predict-cell { display: none; }
  /* Book and Predict share the full-width row (about 60/40, like the cards), so the price column keeps its width. */
  .dgm .dgm-card.is-open > td.deal-listing-price { display: block; grid-area: acts; justify-self: start; width: calc(60% - 4px); padding: 12px 0 2px; }
  .dgm .dgm-card.is-open > td.dgm-predict-cell { display: block; grid-area: acts; justify-self: end; width: calc(40% - 4px); padding: 12px 0 2px; }
  .dgm .dgm-card .dg-row-toggle::after {
    content: ""; position: absolute; right: 14px; top: 24px; width: 8px; height: 8px;
    border-right: 2px solid var(--text-lo); border-bottom: 2px solid var(--text-lo); transform: rotate(45deg);
  }
  .dgm .dgm-card.is-open .dg-row-toggle::after { transform: rotate(-135deg); top: 28px; }
  .dgm .dg-ad { padding: 8px 0; border-bottom: 1px solid var(--border-strong); }
}

/* Origin pages, "Soonest first": month headings between the cards (added by deals-grid.js). */
.article .dg-grid li.dg-month-head,
.dg-month-head {
  grid-column: 1 / -1; list-style: none; margin: 8px 0 -4px; font-size: 15px; font-weight: 800; color: var(--text-hi);
}
.dg-grid > .dg-month-head:first-child { margin-top: 0; }
@media (max-width: 520px) {
  .article .dg-grid li.dg-month-head,
  .dg-month-head {
    margin: 0; padding: 8px 14px; font-size: 13px; background: var(--surface-alt);
    border-bottom: 1px solid color-mix(in srgb, var(--border-strong), var(--text-lo) 30%);
  }
}

/* Origin pages: month bar, the same tiles as the month page's month links, with a deal count under each month. */
.dg-months { display: flex; gap: 8px; overflow-x: auto; margin: 12px 0 0; padding-bottom: 2px; scrollbar-width: none; }
.dg-months[hidden] { display: none; }
.dg-months::-webkit-scrollbar { display: none; }
.dg-months button {
  flex-shrink: 0; min-width: 64px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-hi);
  font: inherit; text-align: left; cursor: pointer;
}
.dg-months button:hover { border-color: var(--primary); }
.dg-months button[aria-pressed="true"] { border: 1.5px solid var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.dg-months button[aria-pressed="true"] .dgm-month-price { color: var(--badge-text); font-weight: 600; }

/* Phones: the list is drawn row by row, so the ad sits between two pieces of the list on the page background
   instead of as a blank row inside it (deals-grid.js marks each piece's first and last row). */
@media (max-width: 520px) {
  .dg .dg-grid, .dgm .dgm-grid { background: none; border: 0; box-shadow: none; overflow: visible; border-radius: 0; }
  .dg .dg-grid > .dg-card, .dg .dg-grid > .dg-month-head,
  .dgm .dgm-grid > .dgm-card {
    background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  }
  .dg .dg-grid > .dg-month-head { background: var(--surface-alt); }
  .dg .dg-grid > .is-seg-first, .dgm .dgm-grid > .is-seg-first {
    border-top: 1px solid var(--border); border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
  }
  .dg .dg-grid > .is-seg-last, .dgm .dgm-grid > .is-seg-last {
    border-bottom: 1px solid var(--border); border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius);
  }
  .dg .dg-grid > .dg-ad, .dgm .dgm-grid > .dg-ad { padding: 12px 0; border: 0; background: none; }

  /* Opened row: Book and Predict about 60/40, like the cards. */
  .dg-card .dg-actions .dg-book { flex: 3 1 0; }
  .dg-card .dg-actions .dg-predict { flex: 2 1 0; }
}
