.lottery-entry, .home-status-controls {
  --home-status-color-rgb: 244 206 103;
  --home-status-color: rgb(var(--home-status-color-rgb));
  --home-status-ball-size: 1.25rem;
  --home-status-ball-gap: 4px;
  --home-status-control-gap: 6px;
  --home-status-column-gap: 12px;
  --home-control-block-reduction: 1.5px;
  --home-control-min-height: calc(28px - 2 * var(--home-control-block-reduction));
  --home-status-block-padding: 2px;
  align-content: start;
  isolation: isolate;
}
:is(.lottery-entry, .home-status-controls)[data-status-mode="rare"] {
  --home-status-color-rgb: 117 215 255;
}
:is(.lottery-entry, .home-status-controls)[data-status-mode="focus"] {
  --home-status-color-rgb: 192 162 255;
}
:is(.lottery-entry, .home-status-controls):is([data-status-mode="rare"], [data-status-mode="focus"]) {
  --home-status-ball-size: 1.125rem;
  --home-status-ball-gap: 3px;
}
/* 彩種按鈕與 LPA Core 是同一列的兩顆按鈕，用全站共用的主要按鍵厚度（styles.css 的 --key-*）：下緣一道厚邊加較深的陰影
   讓它浮起來，按住時圖面沉進厚邊、陰影收短，放開彈回。這一列有留白，厚邊畫在按鈕外；位移只作用在圖面（transform），
   觸控範圍與列高都不動。 */
.home-action-row {
  --home-status-press-depth: var(--key-sink-primary);
  --home-status-press-scale: var(--control-press-scale);
}
button.entry-lottery {
  padding: 0;
  border: 0;
  background: transparent;
  width: 100%;
  aspect-ratio: auto;
  align-self: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 var(--key-lip-primary) 0 var(--key-lip-color), 0 calc(var(--key-lip-primary) + 2px) 7px rgb(0 0 0 / 60%);
  transition: box-shadow var(--motion-fast);
}
button.entry-lottery:active {
  box-shadow: 0 var(--key-lip-pressed) 0 var(--key-lip-color), var(--control-relief-shadow);
}
/* 圖面上緣一道柔光、下緣略暗，像一顆微凸的按鍵；疊在金框與彩種圖示之上，不擋點按。 */
button.entry-lottery > .entry-artwork::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgb(255 244 214 / 14%), transparent 44%, transparent 68%, rgb(0 0 0 / 30%));
  pointer-events: none;
  content: '';
}
button.entry-lottery > .entry-artwork, .home-action-row > [data-lottery-feature="core"] > .entry-artwork {
  transform-origin: center;
  transition: transform var(--motion-fast) ease-out, filter var(--motion-fast), box-shadow var(--motion-fast);
}
/* Move the artwork and its frame together without moving the touch target. */
button.entry-lottery:active > .entry-artwork, .home-action-row > [data-lottery-feature="core"]:active > .entry-artwork {
  transform: translateY(var(--home-status-press-depth)) scale(var(--home-status-press-scale));
}
.home-action-row > .entry {
  --home-entry-aspect: calc(var(--frame-width) / var(--frame-height));
  /* Grow and shrink in proportion to each artwork's width so both entries keep one shared height. */
  flex-grow: var(--home-entry-aspect);
  flex-shrink: 1;
  flex-basis: calc(var(--home-action-height) * var(--home-entry-aspect));
  max-width: calc(var(--home-action-max-height) * var(--home-entry-aspect));
  min-height: var(--target-size);
  height: auto;
  display: grid;
  justify-items: center;
  align-content: center;
}
.home-action-row > [data-lottery-feature="core"] {
  /* The crop values arrive inline from app.js (CORE_VISIBLE_FRAME) so the Core entry and the lottery frame share one source. */
  --home-core-visible-height: calc(var(--frame-height) - 2 * var(--home-core-crop-block));
  /* Size the entry by the gold rim so the row gap and right edge measure from the visible frame, not the canvas. */
  --home-core-visible-width: calc(var(--frame-width) - var(--home-core-crop-left) - var(--home-core-crop-right));
  --home-entry-aspect: calc(var(--home-core-visible-width) / var(--home-core-visible-height));
  background: transparent;
  /* The link box is taller than the clipped gold rim, so the key edge is a drop shadow of the visible rim rather
     than a box shadow; it has the lottery button's thickness and colour so the two keys sit on one baseline. */
  box-shadow: none;
  filter: drop-shadow(0 var(--key-lip-primary) 0 var(--key-lip-color)) drop-shadow(0 2px 3.5px rgb(0 0 0 / 60%));
  transition: filter var(--motion-fast);
}
.home-action-row > [data-lottery-feature="core"]:active {
  filter: drop-shadow(0 var(--key-lip-pressed) 0 var(--key-lip-color)) drop-shadow(0 1px 1.5px rgb(0 0 0 / 45%));
}
.home-action-row > [data-lottery-feature="core"] > .entry-artwork {
  justify-self: start;
  width: calc(100% * var(--frame-width) / var(--home-core-visible-width));
  margin-inline-start: calc(-100% * var(--home-core-crop-left) / var(--home-core-visible-width));
  /* Crop only the opaque canvas outside the gold rim, leaving the touch target intact. */
  clip-path: inset(
    calc(100% * var(--home-core-crop-block) / var(--frame-height))
    calc(100% * var(--home-core-crop-right) / var(--frame-width))
    calc(100% * var(--home-core-crop-block) / var(--frame-height))
    calc(100% * var(--home-core-crop-left) / var(--frame-width))
    round
    calc(100% * var(--home-core-crop-radius) / var(--frame-width))
    /
    calc(100% * var(--home-core-crop-radius) / var(--frame-height))
  );
}
.lottery-entry .entry-artwork { width: 100%; }
.home-status-controls {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  /* Spare screen height goes to the gaps above and below the action row and the space under the statistics frame, so
     the frame hugs its content instead of stretching. The gap down to the frame takes the largest share, setting the
     statistics apart from the two buttons. Short screens fall back to the minimum gaps. */
  --home-action-summary-share: 1.4fr;
  grid-template-rows: minmax(var(--home-draw-entries-gap), 1fr) auto minmax(var(--home-action-summary-gap), var(--home-action-summary-share)) auto minmax(0, .5fr);
  min-width: 0;
}
.home-status-controls > .home-action-row { grid-row: 2; }
.home-status-controls > .home-status-summary { grid-row: 4; }
.home-action-row {
  /* The two buttons sit closer than the statistics columns. The narrower gap's saving goes to the row's sides, so the
     buttons keep their size; once both reach their largest size the pair is centred and the sides take the rest. */
  --home-action-gap: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--home-action-gap);
  padding-inline: calc((var(--home-status-column-gap) - var(--home-action-gap)) / 2);
  min-width: 0;
}
.home-status-summary {
  --home-status-wall-dim: 20%;
  /* 統計區的選取金色比全站亮金柔和，避免在暖灰底上過於刺眼。 */
  --color-selected: #d9bf7c;
  /* Label of a selected (held-down) key in this block (styles.css --key-selected-text-mix). */
  --home-status-selected-text: color-mix(in srgb, var(--color-selected) var(--key-selected-text-mix), #000);
  /* Option keys in this block (2026-11-13). The chosen key must be the brightest one: it is pressed down onto a flat,
     matte warm-gold face (no gradient, no glow) with a gold frame, and its label keeps 5.4:1 there. The raised keys are
     quiet near-black faces with a faint top light and the soft frame; their neutral label is dimmed (about 5.1:1) so the
     chosen one stands out. */
  --home-status-raised-text: var(--key-raised-text);
  --home-status-raised-face: linear-gradient(180deg, color-mix(in srgb, var(--color-selected) 7%, var(--color-background)), color-mix(in srgb, var(--color-selected) 3%, var(--color-background)));
  --home-status-pressed-fill: color-mix(in srgb, var(--color-selected) 24%, var(--color-background));
  --home-status-pressed-frame: color-mix(in srgb, var(--color-selected) 80%, transparent);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  /* Keep results at the top while the frame absorbs the remaining screen height. */
  align-content: start;
  min-width: 0;
  padding: var(--home-group-inline);
  border: 1px solid color-mix(in srgb, var(--color-announcement-border) 85%, transparent);
  border-radius: var(--radius);
  /* Attenuate only the shared wall behind this panel, leaving controls and other regions intact. */
  background: color-mix(in srgb, var(--color-background) var(--home-status-wall-dim), transparent);
}
.home-status-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  padding-bottom: 0;
}
.home-status-results {
  --draw-ball-size: var(--home-status-ball-size);
  --draw-number-size: calc(var(--home-status-ball-size) * .5);
  min-width: 0;
  padding-block: var(--home-status-block-padding);
}
.home-status-sides {
  --frequency-columns: 5;
  --frequency-rows: 3;
  --frequency-ball-size: 24px;
  --frequency-cell-width: 28px;
  --frequency-column-gap: 4px;
  --frequency-side-space: 3px;
  --frequency-cell-padding: calc((var(--frequency-cell-width) - var(--frequency-ball-size)) / 2);
  --frequency-grid-padding: max(0px, calc(var(--frequency-side-space) - var(--frequency-cell-padding)));
  --frequency-grid-width: calc(var(--frequency-columns) * var(--frequency-cell-width) + (var(--frequency-columns) - 1) * var(--frequency-column-gap));
  --frequency-side-width: calc(var(--frequency-grid-width) + 2 * var(--frequency-grid-padding));
  /* The grid is three bands: a row of balls with the line under it, the last row's line being the block frame. Each
     count line sits this close to its line, and the band's lead above the balls takes the rest of the band. */
  --frequency-row-space: 3px;
  /* Block padding plus summary padding lie under the values; the last row reaches into them to keep its row space. */
  --frequency-frame-space: calc(var(--home-status-block-padding) + var(--home-group-inline));
  /* The gaps around the three rows add up to what they were (10px above, 4px + 7px at each separator, 10px below), so
     the block keeps its height. Since 2026-11-22 (owner) the last row has its own line too, so its marks no longer sit
     on the frame: that line and the space under it come out of the 40px, and each band takes a third of the rest. */
  --frequency-last-line-space: 4px;
  --frequency-band-gaps: calc(40px - var(--frequency-separator-width) - var(--frequency-last-line-space));
  --frequency-band-lead: calc(var(--frequency-band-gaps) / 3 - var(--frequency-row-space));
  --home-status-side-gap: 6px;
  --frequency-separator-width: 1px;
  --frequency-separator-color: color-mix(in srgb, var(--color-announcement-border) 65%, transparent);
  /* Balls with one of the three highest counts get a three-cell mark under them on their line: first rank fills three
     cells, second two, third one; unfilled cells stay faint. A warm vermilion sits with the orange balls and the gold
     frame; the alert red (--color-danger) read as pink against them. */
  --frequency-rank-color: #e2553f;
  /* Unlit cells are solid (owner 2026-11-22): a see-through cell let the row line show through and blur it, so the
     faint red is mixed into the page's near-black instead of into transparency. */
  --frequency-rank-empty: color-mix(in srgb, var(--frequency-rank-color) 36%, var(--color-background));
  --frequency-rank-stroke: 3px;
  --frequency-rank-cell-gap: 2px;
  /* The mark is centred on the 1px line, so its bottom edge lies this far below the count line. */
  --frequency-rank-reach: calc(var(--frequency-row-space) + (var(--frequency-separator-width) + var(--frequency-rank-stroke)) / 2);
  /* Rows after a separator start one band lead below it; the first row is the same lead below the kind buttons. */
  --frequency-row-lead: calc(var(--frequency-band-lead) + var(--frequency-separator-width));
  --frequency-grid-top-gap: calc(var(--frequency-band-lead) - var(--home-status-side-gap));
  --frequency-ball-count-gap: 1.5px;
  --frequency-count-size: .5rem;
  --frequency-count-line-height: 1.35;
  --frequency-count-digit-width: .7;
  --frequency-count-unit-width: 1.1;
  position: relative;
  display: grid;
  /* Spare width belongs to the left controls; the percentage only protects very narrow screens. */
  grid-template-columns: minmax(0, 1fr) minmax(0, min(var(--frequency-side-width), 57.5%));
  gap: var(--home-status-column-gap);
  align-items: stretch;
}
/* The detail panel takes whatever height the right column leaves, so its rows can share that height evenly. */
.home-status-side[data-status-side="left"] { --home-left-detail-inset: 4px; grid-template-rows: auto auto auto minmax(0, 1fr); container: home-left / inline-size; }
.home-status-side[data-status-side="right"] { position: relative; container-type: inline-size; }
.home-status-side[data-status-side="right"] .home-side-values {
  --frequency-reserved-grid-width: min(var(--frequency-grid-width), calc(100cqi - 2 * var(--frequency-grid-padding)));
  --frequency-reserved-cell-width: calc((var(--frequency-reserved-grid-width) - (var(--frequency-columns) - 1) * var(--frequency-column-gap)) / var(--frequency-columns));
  --frequency-reserved-ball-size: max(0px, min(var(--frequency-ball-size), calc(var(--frequency-reserved-cell-width) - 2 * var(--frequency-cell-padding))));
  --frequency-reserved-count-size: min(var(--frequency-count-size), calc(var(--frequency-reserved-cell-width) / (var(--frequency-count-digit-width) + var(--frequency-count-unit-width))));
  /* Empty and partial results keep the height of three bands, plus the room a last-row rank mark needs to stay unclipped. */
  --home-values-min-height: calc(var(--frequency-grid-top-gap) + var(--frequency-rows) * (var(--frequency-reserved-ball-size) + var(--frequency-ball-count-gap) + var(--frequency-reserved-count-size) * var(--frequency-count-line-height)) + (var(--frequency-rows) - 1) * (var(--frequency-row-space) + var(--frequency-row-lead)) + var(--frequency-rank-reach));
  /* The last row ends one row space, its line and the last line space above the frame, inside the paddings below; the
     leads above made up the height. The padding keeps the last row's mark inside this clipped box, and the margin takes
     it back out of the layout. */
  padding-block-end: var(--frequency-rank-reach);
  margin-block-end: calc(var(--frequency-row-space) + var(--frequency-separator-width) + var(--frequency-last-line-space) - var(--frequency-frame-space) - var(--frequency-rank-reach));
  /* Include the cells' own inset so the ball edges, rather than the grid edges, keep 3px. */
  padding-inline: var(--frequency-grid-padding);
}
.home-status-side[data-status-side="right"]::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: calc(var(--home-status-column-gap) / -2);
  width: 1px;
  background: var(--color-announcement-border);
  box-shadow: 1px 0 0 rgb(0 0 0 / 65%);
  pointer-events: none;
}
.home-status-side {
  display: grid;
  align-content: start;
  gap: var(--home-status-side-gap);
  min-width: 0;
}
/* One control height and type for the mode group, the kind buttons, the repeat heading and the detail tabs. */
.home-side-kinds button, .home-side-modes, .home-repeat-heading, .home-left-detail-tabs button {
  min-width: 0;
  min-height: var(--home-control-min-height);
  font: 600 .6875rem/1.4 var(--font-body);
}
/* The repeat heading is a label, not a control, and the two framed groups carry their own frame and surface below. */
.home-side-kinds button, .home-side-modes, .home-left-detail-tabs button { color: var(--home-status-raised-text); cursor: pointer; }
/* The kind buttons, detail tabs and result cards are option keys (styles.css --key-*): the face frame is an inset line
   and the lip is the bottom border inside the existing box. */
.home-side-kinds button, .home-left-detail-tabs button, .home-left-card {
  --key-frame: var(--color-border-soft);
  border: 0 solid transparent;
  border-bottom: var(--key-lip-option) solid var(--key-lip-color);
  border-radius: var(--key-option-radius);
  background: var(--key-option-lip), var(--home-status-raised-face) padding-box;
  box-shadow: inset 0 0 0 1px var(--key-frame), var(--control-relief);
}
/* Mode buttons sit inside the framed .home-side-modes group. The raised one is an option key seated in the group (soft
   frame, lip and lit face, like the kind buttons below); the selected one is held down with the matte gold face and
   gold frame of the other selected keys. */
.home-side-mode {
  --status-focus-offset: -2px;
  --home-side-mode-radius: calc(var(--radius) - 1px);
  --key-frame: var(--color-border-soft);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--home-control-min-height);
  /* The segment had no border; its lip comes out of the block padding, half above and half below the label. */
  padding: calc(6px - var(--home-control-block-reduction) - var(--key-lip-option) / 2) 0;
  border: 0 solid transparent;
  border-bottom: var(--key-lip-option) solid var(--key-lip-color);
  border-radius: var(--home-side-mode-radius) / var(--home-side-mode-radius) var(--home-side-mode-radius) calc(var(--home-side-mode-radius) + var(--key-lip-option)) calc(var(--home-side-mode-radius) + var(--key-lip-option));
  background: var(--key-option-lip), var(--home-status-raised-face) padding-box;
  box-shadow: inset 0 0 0 1px var(--key-frame), var(--control-relief-highlight);
  color: var(--home-status-raised-text);
  font: 600 .6875rem/1.4 var(--font-body);
  cursor: pointer;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
/* The selected segment keeps the key's round corners and takes the gold frame of the other selected keys: since its
   face turned matte gold (2026-11-13) a square, unframed segment showed as a loose box inside the rounded group. */
.home-side-modes {
  grid-template-columns: repeat(2, minmax(0, 1fr)) var(--home-settings-target);
}
.home-side-modes > .home-side-mode { align-self: stretch; }
.home-side-kinds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.home-side-kinds button { padding: calc(2px - var(--home-control-block-reduction)) 6px; }
/* A selected option is a key pressed down: a thin painted lip under a sunk dark face and an inner top shadow (styles.css --key-*). */
.home-side-kinds [aria-pressed="true"], .home-side-modes [aria-pressed="true"], .home-left-detail-tabs [aria-selected="true"], .home-left-card[data-active="true"] {
  border-bottom-color: transparent;
  background: var(--key-option-lip-selected), var(--home-status-pressed-fill) padding-box;
  translate: 0 var(--key-option-selected-sink);
  color: var(--home-status-selected-text);
  box-shadow: inset 0 0 0 1px var(--key-frame), var(--key-pressed-inset);
}
.home-side-kinds [aria-pressed="true"], .home-side-modes [aria-pressed="true"], .home-left-detail-tabs [aria-selected="true"], .home-left-card[data-active="true"] { --key-frame: var(--home-status-pressed-frame); }
.home-side-values {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--home-status-ball-gap);
  min-height: var(--home-values-min-height, 32px);
  min-width: 0;
  /* Scaled ball sprites have transparent margins outside their visible footprint. */
  overflow: clip;
}
.home-left-cards {
  --left-ball-max: 1.75rem;
  --left-card-inset: 4px;
  /* The double card takes the larger share so its two balls get a 6px gap and clear side room; the single card gives up width it does not need. */
  --left-double-share: .56;
  --left-double-ball-gap: 6px;
  display: grid;
  grid-template-columns: minmax(0, 44fr) minmax(0, 56fr);
  gap: var(--home-status-ball-gap);
  min-width: 0;
  container-type: inline-size;
}
/* The card is the key face (frame, lip and selected look above); the button inside fills it and reaches over the lip. */
.home-left-card { min-width: 0; }
.home-left-choice {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  align-items: center;
  gap: var(--left-card-inset);
  width: 100%;
  min-width: 0;
  min-height: calc(var(--left-ball-max) + 1.4em + 3 * var(--left-card-inset));
  height: 100%;
  padding: var(--left-card-inset);
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--home-status-raised-text);
  font: 600 .6875rem/1.4 var(--font-body);
  cursor: pointer;
}
.home-left-choice[aria-pressed="true"] .home-left-choice-label { color: var(--home-status-selected-text); }
.home-left-choice::after { position: absolute; inset: 0 0 calc(-1 * var(--key-lip-option)); content: ''; }
/* While the card sinks or stays selected, the tap area keeps covering the strip it left at the top. */
.home-left-choice:active::after { inset-block-start: calc(-1 * var(--key-sink-option)); }
.home-left-card[data-active="true"] > .home-left-choice::after { inset-block: calc(-1 * var(--key-option-selected-sink)) calc(-1 * var(--key-lip-option-pressed)); }
.home-left-choice-values {
  /* Both cards derive the ball size from the double card's width (the pair container is the query container), so the balls stay equal. */
  --draw-ball-size: min(var(--left-ball-max), calc(((100cqi - var(--home-status-ball-gap)) * var(--left-double-share) - 2px - 2 * var(--left-card-inset) - var(--left-double-ball-gap)) / 2));
  --draw-number-size: calc(var(--draw-ball-size) * .5);
  --home-values-min-height: var(--draw-ball-size);
  width: 100%;
  flex-wrap: nowrap;
  /* The card box equals the ball size, so the scaled sprite (六合彩 ×1.478) would lose its top and bottom under a clip. */
  overflow: visible;
}
.home-left-card:last-child .home-left-choice-values { gap: var(--left-double-ball-gap); }
/* Takes the balls' place when the leading place is tied. It keeps the label's colours (a fainter one falls under
   4.5:1 on the card) and is quieter only by weight, so it does not read as a result. */
.home-left-choice-note { font-weight: 400; white-space: nowrap; }
.home-left-choice[aria-pressed="true"] .home-left-choice-note { color: var(--home-status-selected-text); }
/* Several confirmed pairs share the double card: one pair per page, swiped sideways. It sits above the button's
   tap-area overlay (::after), otherwise a finger would land on the overlay and the pages would not move. */
.home-left-choice-pages {
  --left-page-bleed: calc(var(--draw-ball-size) * .25);
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 100%;
  min-width: 0;
  /* A scroll box clips both ways; the padding keeps the scaled ball sprite whole and the margin gives the space back. */
  padding-block: var(--left-page-bleed);
  margin-block: calc(-1 * var(--left-page-bleed));
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.home-left-choice-pages::-webkit-scrollbar { display: none; }
.home-left-choice-page {
  display: flex;
  flex: 0 0 100%;
  align-items: center;
  justify-content: center;
  gap: var(--left-double-ball-gap);
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
/* The dots only count the pairs and mark the one showing; they sit in the card's bottom inset so the card keeps its height. */
.home-left-choice-dots { position: absolute; inset-inline: 0; inset-block-end: 1px; display: flex; justify-content: center; gap: 3px; pointer-events: none; }
.home-left-choice-dots i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
.home-left-choice-dots i[data-current] { opacity: 1; }
.home-left-choice[aria-pressed="true"] .home-left-choice-dots { color: var(--home-status-selected-text); }
.home-left-detail-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--home-status-ball-gap); min-width: 0; }
.home-left-detail-tabs button { padding: 2px; overflow-wrap: anywhere; }
/* The metric list sits as far under its tabs as the frame sits under the list (block padding plus summary padding,
   2026-11-14): at 2px the space above the first row read smaller than the space under the last one. */
/* contain: size keeps a long scrolling list from stretching the column; the panel takes only what the right column leaves. */
.home-left-detail-panel { display: grid; grid-template-rows: minmax(0, 1fr); contain: size; min-width: 0; min-block-size: 0; margin-block-start: calc(var(--home-status-block-padding) + var(--home-group-inline) - var(--home-status-side-gap)); }
/* Every row has the same fixed height and stacks from the top, whether one row or three; four rows step the type and
   padding down to fit the panel, five or more scroll. */
.home-left-metrics { --home-left-metric-digits: 2; --home-left-metric-line: 1.5; --home-left-metric-size: .75rem; --home-left-metric-value-size: .875rem; --home-left-metric-row-padding: var(--home-status-block-padding); --home-left-metric-row-min: calc(var(--home-left-metric-value-size) * var(--home-left-metric-line) + 2 * var(--home-left-metric-row-padding)); display: grid; grid-auto-rows: var(--home-left-metric-row-min); align-content: start; min-block-size: 0; margin: 0; font: 500 var(--home-left-metric-size)/var(--home-left-metric-line) var(--font-body); }
/* More rows than the visible count scroll inside the panel; the fade shows that more follows. Scrollbars are hidden app-wide. */
.home-left-metrics[data-rows="4"], .home-left-metrics[data-scrollable="true"] { --home-left-metric-line: 1.4; --home-left-metric-size: .6875rem; --home-left-metric-value-size: .6875rem; --home-left-metric-row-padding: 1.5px; }
/* 版路類型 is always cut into four equal slots, one per road type (加減／合值／拖牌／複合); the listed roads fill them from
   the top and the slots below stay empty. */
.home-left-metrics[data-slots="4"] { grid-template-rows: repeat(4, minmax(0, 1fr)); }
.home-left-metrics[data-scrollable="true"] {
  /* The panel's own height caps the list. Unlike the rest of the app, this list shows a hairline scrollbar so the
     extra rows are discoverable; the 3px gutter keeps the 版 column clear of the thumb. */
  --home-left-metric-scrollbar: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-selected) 55%, transparent) transparent;
}
.home-left-metrics[data-scrollable="true"]::-webkit-scrollbar { display: block; width: var(--home-left-metric-scrollbar); height: 0; }
.home-left-metrics[data-scrollable="true"]::-webkit-scrollbar-track { background: transparent; }
.home-left-metrics[data-scrollable="true"]::-webkit-scrollbar-thumb { border-radius: 2px; background: color-mix(in srgb, var(--color-selected) 55%, transparent); }
.home-left-metrics[data-scrollable="true"]:focus-visible { outline: 2px solid var(--color-selected); outline-offset: 2px; }
/* The list spans the full column like the tabs above; each row keeps the text inset inside itself so the two road cells
   can line up with the two tabs: left cell under 版路類型, right cell under 連準次數, hairline in the tabs' gap. */
.home-left-metrics > div { display: grid; grid-template-columns: auto minmax(8px, 1fr) auto; align-items: baseline; align-content: center; gap: var(--home-status-ball-gap); min-width: 0; padding: var(--home-left-metric-row-padding) var(--home-left-detail-inset); }
.home-left-metric-leader { min-width: 8px; align-self: baseline; border-block-end: 1px dotted color-mix(in srgb, var(--color-announcement-border) 70%, transparent); transform: translateY(-.2em); }
.home-left-metrics > div + div { border-block-start: 1px solid color-mix(in srgb, var(--color-announcement-border) 45%, transparent); }
/* Road rows fill their slot, sorted left and actual order right, split by a hairline the height of the slot; each cell
   centres its line in the slot. */
.home-left-metrics > [data-detail-layout="orders"] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: stretch; align-items: stretch; gap: 0; padding: 0; }
/* A road row under a separator gives the line's 1px back below, so its text stays centred in the slot. */
.home-left-metrics > [data-detail-layout="orders"] + [data-detail-layout="orders"] { padding-block-end: 1px; }
/* One line per cell, left-aligned: road and value in the text colour, order in the status accent.
   One type size for every road cell, chosen so two full cells ("加減 順球 99 版｜加減 落球 99 版") share the 148px row on a 360px screen. */
.home-left-metric-cell { --home-left-metric-size: .625rem; --home-left-metric-value-size: .6875rem; --home-left-metric-cell-gap: 1.5px; display: grid; grid-auto-flow: column; align-items: baseline; align-content: center; justify-content: start; gap: var(--home-left-metric-cell-gap); min-width: 0; white-space: nowrap; }
.home-left-metric-cell:first-child { padding-inline-start: var(--home-left-detail-inset); }
.home-left-metric-cell[data-lone="true"] { grid-column: 1 / -1; padding-inline-end: var(--home-left-detail-inset); }
/* The right cell ends at the same inset as the tab above it, so its right margin matches the left cell's left margin. */
.home-left-metric-cell + .home-left-metric-cell { justify-content: end; padding-inline: 3px var(--home-left-detail-inset); border-inline-start: 1px solid color-mix(in srgb, var(--color-announcement-border) 45%, transparent); }
.home-left-metrics .home-left-metric-cell dt { display: flex; flex: 0 0 auto; gap: var(--home-left-metric-cell-gap); font-size: var(--home-left-metric-size); font-weight: 500; }
.home-left-metric-road { color: var(--color-text); }
.home-left-metric-order { color: rgb(var(--home-status-color-rgb)); }
/* Selectors repeat the list class so these win over the generic metric row rules that allow wrapping. */
.home-left-metrics .home-left-metric-cell dd { flex: 0 0 auto; flex-wrap: nowrap; gap: var(--home-left-metric-cell-gap); margin: 0; color: var(--color-text); }
.home-left-metrics .home-left-metric-cell dd > span { font-size: var(--home-left-metric-size); }
/* Three-digit counts widen the shared column, so every road cell steps down one size to keep two per row. */
.home-left-metrics[data-digits="3"] .home-left-metric-cell { --home-left-metric-size: .5625rem; --home-left-metric-value-size: .625rem; }
.home-left-metrics dt { min-width: 0; max-width: 100%; color: var(--color-text); overflow-wrap: anywhere; }
.home-left-metrics dd { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 3px; max-width: 100%; margin: 0; color: var(--color-selected); font-variant-numeric: tabular-nums; }
.home-left-metrics[data-digits="3"] { --home-left-metric-digits: 3; }
/* Counts sit centred in one fixed-width column so "9" lines up under "14" and 版 keeps its place on every row. */
.home-left-metrics strong { flex-shrink: 0; min-inline-size: calc(var(--home-left-metric-digits) * 1ch); max-width: 100%; font-size: var(--home-left-metric-value-size); font-weight: 700; text-align: center; overflow-wrap: anywhere; }
/* Keep both results readable when a narrow column and larger text cannot share a row. */
@container home-left (max-width: 6rem) {
  .home-side-modes { grid-template-columns: minmax(0, 1fr) var(--home-settings-target); }
  .home-side-mode { grid-column: 1; }
  .home-side-modes > .home-settings-button { grid-column: 2; grid-row: 1 / span 2; }
  .home-left-cards, .home-left-detail-tabs { grid-template-columns: minmax(0, 1fr); }
  .home-side-mode, .home-left-detail-tabs button { padding-inline: 0; }
  .home-left-metrics strong { font-size: 1em; }
}
/* Small-print typography shared by the summary message, the feedback line and the settings-dialog error. */
.home-status-message, .home-status-feedback, .home-status-form > .status-settings-error {
  font-size: .6875rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.home-status-message { color: var(--color-secondary); }
.home-side-modes, .home-repeat-heading {
  --home-settings-gear-size: 12px;
  --home-settings-gear-padding: 1.5px;
  --home-settings-gear-border: 1px;
  --home-settings-visual-size: calc(var(--home-settings-gear-size) + 2 * var(--home-settings-gear-padding) + 2 * var(--home-settings-gear-border));
  --home-settings-target: 24px;
  --home-settings-group-end: 2px;
  --home-settings-frame-width: 1px;
  position: relative;
  /* Both setting rows are one rounded gold frame with the gear in the same last column (owner, 2026-11-22), so the
     two gears share their size, column and vertical centre. */
  display: grid;
  align-items: center;
  padding-inline-end: var(--home-settings-group-end);
  border: var(--home-settings-frame-width) solid var(--color-announcement-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
/* The repeat heading is a title, not a key. Since 2026-11-22 (owner) it shares the mode group's frame, fill and relief
   so the two setting rows match, and its gear sits in the same last column; only the gear is a control. The owner
   dropped the grey cut-corner nameplate the same night: the label 重複次數統計 is plain bold text in the announcement
   gold (the beige of the unselected keys read as one more key), centred in the column before the gear, with no frame, fill, lift, pointer or press. A short
   rule in the frame's own width and gold stands just before the gear (this row only, owner 2026-11-22). Its single row is the mode keys' height, so both rows keep
   one height and the two gears one vertical centre. */
.home-repeat-heading {
  --home-repeat-letter-space: 1px;
  grid-template-columns: minmax(0, 1fr) var(--home-settings-target);
  grid-template-rows: minmax(var(--home-control-min-height), auto);
  justify-items: center;
  color: var(--color-announcement-text);
  cursor: default;
}
/* The rule sits in the gap left of the gear's visible key, half the row high and vertically centred. */
.home-repeat-heading::before {
  content: '';
  position: absolute;
  inset-block: 25%;
  inset-inline-end: calc(var(--home-settings-group-end) + (var(--home-settings-target) + var(--home-settings-visual-size)) / 2 + 5px);
  width: var(--home-settings-frame-width);
  background: var(--color-announcement-border);
  pointer-events: none;
}
/* Larger than the key labels, but held to their line height so the heading keeps its height. Letter spacing also
   trails the last character; the negative end margin takes it back so the words stay centred. A line box centres the
   font's ascent and descent, not the characters, and phones use different fonts; trimming the line to the cap height
   and baseline and centring that keeps the characters in the vertical middle whatever the font (unsupported browsers
   keep the plain line box). */
.home-repeat-heading > span {
  margin-inline-end: calc(-1 * var(--home-repeat-letter-space));
  /* The key labels' line box, set as a fixed height too: a larger font's line box would round a fraction taller. */
  --home-repeat-line: calc(.6875rem * 1.4);
  block-size: var(--home-repeat-line);
  align-content: center;
  text-box: trim-both cap alphabetic;
  font-size: .6875rem;
  font-weight: 700;
  line-height: var(--home-repeat-line);
  letter-spacing: var(--home-repeat-letter-space);
  white-space: nowrap;
}
/* The gears are option keys too: the former border is the inset frame, the lip is the bottom border, and the face gives
   up the rest of the lip's height from its block padding so the icon stays centred and whole. */
.home-settings-button {
  --key-frame: var(--color-announcement-border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: var(--home-settings-visual-size);
  height: var(--home-settings-visual-size);
  min-height: 0;
  padding: calc(var(--home-settings-gear-padding) + var(--home-settings-gear-border) - var(--key-lip-option) / 2) calc(var(--home-settings-gear-padding) + var(--home-settings-gear-border));
  border: 0 solid transparent;
  border-bottom: var(--key-lip-option) solid var(--key-lip-color);
  border-radius: var(--radius-sm) / var(--radius-sm) var(--radius-sm) calc(var(--radius-sm) + var(--key-lip-option)) calc(var(--radius-sm) + var(--key-lip-option));
  background: var(--key-option-lip), var(--color-background) padding-box;
  box-shadow: inset 0 0 0 1px var(--key-frame), var(--control-relief);
  color: var(--color-announcement-text);
  cursor: pointer;
}
/* The tap area stays centred on the whole key (face and lip), also while the face sinks. */
.home-settings-button::after { content: ''; position: absolute; inset-block-start: calc(50% + var(--key-lip-option) / 2); inset-inline-start: 50%; width: var(--home-settings-target); height: var(--home-settings-target); transform: translate(-50%, -50%); }
.home-settings-button:active::after { inset-block-start: calc(50% + var(--key-lip-option) / 2 - var(--key-sink-option)); }
.home-settings-button svg { width: var(--home-settings-gear-size); height: var(--home-settings-gear-size); flex: 0 0 auto; }
.home-frequency-grid {
  --frequency-number-ratio: .5;
  display: grid;
  align-self: flex-start;
  grid-template-columns: repeat(var(--frequency-columns), minmax(0, 1fr));
  gap: var(--frequency-row-space) var(--frequency-column-gap);
  width: min(100%, var(--frequency-grid-width));
  min-width: 0;
  margin: var(--frequency-grid-top-gap) 0 0;
  padding: 0;
  position: relative;
  list-style: none;
  container-type: inline-size;
}
/* The last row's line: one row space under the grid, like the separators the next rows draw above themselves, so the
   last row's marks sit on a line of their own instead of the frame. */
.home-frequency-grid::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  inset-block-end: calc(-1 * (var(--frequency-row-space) + var(--frequency-separator-width)));
  height: var(--frequency-separator-width);
  background: var(--frequency-separator-color);
  pointer-events: none;
}
.home-frequency-grid[data-lottery="六合彩"] {
  /* The original white face narrows at its slanted edges; reserve room for every numeral pair. */
  --frequency-number-ratio: .34;
  --status-ball-face-content: none;
}
.home-frequency-item {
  --frequency-cell-size: calc((100cqi - (var(--frequency-columns) - 1) * var(--frequency-column-gap)) / var(--frequency-columns));
  --draw-ball-size: min(var(--frequency-ball-size), calc(var(--frequency-cell-size) - 2 * var(--frequency-cell-padding)));
  --draw-number-size: calc(var(--draw-ball-size) * var(--frequency-number-ratio));
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--frequency-ball-count-gap);
  min-width: 0;
}
.home-frequency-item:nth-child(n + 6) { padding-block-start: var(--frequency-row-lead); }
.home-frequency-item:nth-child(5n + 6)::before { content: ''; position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 100cqi; height: var(--frequency-separator-width); background: var(--frequency-separator-color); }
/* Drawn centred on the row's line (the grid's own line for the last row) and above it, so a separator painted by the next row
   cannot cover it. The cells are three colour layers, one cell wide each, so a rank only swaps colours. */
.home-frequency-item[data-frequency-rank] {
  --frequency-rank-cell-1: var(--frequency-rank-color);
  --frequency-rank-cell-2: var(--frequency-rank-empty);
  --frequency-rank-cell-3: var(--frequency-rank-empty);
}
.home-frequency-item[data-frequency-rank="1"] { --frequency-rank-cell-2: var(--frequency-rank-color); --frequency-rank-cell-3: var(--frequency-rank-color); }
.home-frequency-item[data-frequency-rank="2"] { --frequency-rank-cell-2: var(--frequency-rank-color); }
.home-frequency-item[data-frequency-rank]::after {
  --frequency-rank-cell: calc((100% - 2 * var(--frequency-rank-cell-gap)) / 3);
  content: '';
  position: absolute;
  z-index: 1;
  inset-block-end: calc(-1 * var(--frequency-rank-reach));
  inset-inline: var(--frequency-cell-padding);
  height: var(--frequency-rank-stroke);
  background:
    linear-gradient(var(--frequency-rank-cell-1), var(--frequency-rank-cell-1)) left / var(--frequency-rank-cell) 100% no-repeat,
    linear-gradient(var(--frequency-rank-cell-2), var(--frequency-rank-cell-2)) center / var(--frequency-rank-cell) 100% no-repeat,
    linear-gradient(var(--frequency-rank-cell-3), var(--frequency-rank-cell-3)) right / var(--frequency-rank-cell) 100% no-repeat;
  pointer-events: none;
}
.home-frequency-item .draw-ball { flex: 0 0 auto; }
.home-status-summary .draw-ball[data-lottery="六合彩"] {
  --ball-optical-x: 0px;
  --ball-optical-y: 0px;
  --status-ball-face-width: 62%;
  --status-ball-face-height: 56%;
  --status-ball-face-light: #fff;
  --status-ball-face-shade: #dededb;
}
/* Every 六合彩 ball in the summary uses the original textured face and the narrower numeral ratio of the repeat grid. */
.home-left-card .draw-ball[data-lottery="六合彩"] { --status-ball-face-content: none; --draw-number-size: calc(var(--draw-ball-size) * .34); }
.home-status-summary .draw-ball[data-lottery="六合彩"]::before {
  content: var(--status-ball-face-content, '');
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: var(--status-ball-face-width);
  height: var(--status-ball-face-height);
  transform: translate(-50%, -50%);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(155deg, var(--status-ball-face-light), var(--status-ball-face-shade));
  pointer-events: none;
}
.home-status-summary .draw-ball[data-lottery="六合彩"] .draw-ball-value { z-index: 2; }
.home-frequency-count {
  --frequency-count-em-width: calc(var(--frequency-count-digits, 3) * var(--frequency-count-digit-width) + var(--frequency-count-unit-width));
  max-width: 100%;
  color: var(--color-announcement-text);
  font: 600 min(var(--frequency-count-size), calc(var(--frequency-cell-size) / var(--frequency-count-em-width)))/var(--frequency-count-line-height) var(--font-body);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.home-status-feedback {
  grid-column: 1 / -1;
  color: var(--color-announcement-text);
}
.home-status-feedback:empty {
  display: none;
}
/* Scoped density tokens keep settings controls independent of page navigation. */
.home-status-dialog {
  --status-panel: var(--color-background);
  --status-control: var(--color-background);
  --status-control-hover: color-mix(in srgb, var(--status-control) 88%, var(--status-accent));
  --status-accent: var(--color-announcement-text);
  --status-text: var(--color-text);
  --status-muted: var(--color-secondary);
  --status-border: var(--color-announcement-border);
  --status-divider: var(--color-border-soft);
  --status-section-border: 1px solid var(--status-divider);
  --status-selected: var(--color-announcement-text);
  --status-selected-border: var(--status-selected);
  --status-on-selected: var(--color-background);
  --status-selected-text: var(--status-on-selected);
  /* Both settings dialogs end with the same pair: save is the one gold action, matching the confirmation it opens, so
     it cannot be mistaken for an option (亮度壓低，避免在深色視窗裡過於刺眼); cancel is the dark key with the soft gold frame. */
  --status-submit-fill: linear-gradient(135deg, var(--gold-action-bright), var(--gold-action));
  --status-submit-border: var(--color-gold);
  --status-submit-text: var(--status-on-selected);
  --status-cancel-fill: transparent;
  --status-cancel-border: var(--color-border-soft);
  --status-cancel-text: var(--color-text);
  --page-divider: var(--color-border-soft);
  --status-dialog-padding: 10px;
  --status-dialog-width: 272px;
  --status-dialog-inline-space: 48px;
  --status-dialog-edge-gap: 12px;
  --status-dialog-rise: min(24px, 3dvh);
  --status-footer-gap: 4px;
  --status-footer-padding: 22px;
  --status-footer-button-gap: 6px;
  --status-footer-columns: minmax(0, 1fr) minmax(0, .75fr) minmax(0, 1fr);
  --status-footer-reset-align: start;
  --status-control-radius: var(--radius-sm);
  --repeat-control-height: 24px;
  --repeat-muted: var(--color-secondary);
  --repeat-control: color-mix(in srgb, var(--status-control) 90%, var(--color-surface));
  --repeat-selected-text: color-mix(in srgb, var(--status-accent) 88%, var(--status-muted));
  --repeat-selected-fill: color-mix(in srgb, var(--status-control) 92%, var(--status-accent));
  --repeat-selected-border: color-mix(in srgb, var(--status-accent) 55%, var(--status-control));
  --repeat-option-border: color-mix(in srgb, var(--status-border) 65%, var(--status-control));
  width: var(--status-dialog-width);
  max-width: calc(100vw - var(--status-dialog-inline-space) - var(--safe-inline-start) - var(--safe-inline-end));
  inset-block-start: calc(env(safe-area-inset-top, 0px) + var(--status-dialog-edge-gap));
  inset-block-end: calc(env(safe-area-inset-bottom, 0px) + var(--status-dialog-edge-gap) + 2 * var(--status-dialog-rise));
  max-height: calc(100vh - 2 * var(--status-dialog-edge-gap) - 2 * var(--status-dialog-rise) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 2 * var(--status-dialog-edge-gap) - 2 * var(--status-dialog-rise) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--status-text);
  box-shadow: 0 18px 60px rgb(0 0 0 / 55%);
  font-family: var(--font-body);
}
.home-status-dialog[open] {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.home-status-form {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 8px var(--status-dialog-padding);
  min-width: 0;
}
.status-settings-content { min-width: 0; container-type: var(--status-content-containment, inline-size); }
.status-lottery-tabs {
  display: grid;
  grid-template-columns: repeat(var(--status-tab-count, 3), minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  padding: 0;
  /* The selected tab's own underline is the only line under the lottery row. */
  border: 0;
  border-radius: 0;
  background: transparent;
}
.home-status-form button {
  min-width: 0;
  min-height: var(--repeat-control-height);
  padding: 2px;
  border: 1px solid var(--status-divider);
  border-radius: var(--status-control-radius);
  background: var(--status-control);
  color: var(--status-text);
  font: 500 var(--status-form-font-size, .6875rem)/var(--status-form-line-height, 1.4) var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: none;
  overflow-wrap: anywhere;
  transition: background-color var(--motion-fast), border-color var(--motion-fast);
}
.home-status-form .status-lottery-tabs button {
  /* Entry rows (lottery, step, help): a short underline drawn as a pseudo-element, sitting close under the label. */
  --status-tab-underline-inset: 8px;
  --status-tab-underline-gap: 2px;
  position: relative;
  min-height: 22px;
  padding: 1px 2px calc(2px + var(--status-tab-underline-gap));
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--repeat-muted);
  font-weight: 600;
}
.home-status-form .status-lottery-tabs button::after {
  content: '';
  position: absolute;
  inset-inline: var(--status-tab-underline-inset);
  inset-block-end: 0;
  height: 2px;
  border-radius: 1px;
  background: transparent;
  pointer-events: none;
}
.home-status-form .status-lottery-tabs [data-settings-lottery] { font-size: .8125rem; }
.home-status-form .status-lottery-tabs [data-repeat-lottery] { font-size: .875rem; }
.home-status-form .status-lottery-tabs [aria-selected="true"] { color: var(--repeat-selected-text); }
.home-status-form .status-lottery-tabs [aria-selected="true"]::after { background: var(--repeat-selected-border); }
.home-status-form [aria-pressed="true"] {
  color: var(--status-selected-text);
  border-color: var(--status-selected-border);
  background: var(--status-selected);
}
.status-rule-selectors { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--rule-selector-row-gap) var(--rule-field-gap); min-width: 0; margin-block-start: var(--rule-selector-top-gap); }
.status-rule-selector-group { display: flex; flex: 1 1 auto; flex-direction: column; align-items: center; gap: var(--rule-selector-label-gap); min-width: 0; max-width: 100%; margin: 0; padding: var(--rule-selector-frame-inset); border: 1px solid var(--status-divider); border-radius: var(--status-control-radius); }
.status-rule-selector-label { max-width: 100%; color: var(--rule-selector-label-color); font: 600 var(--rule-label-size)/1.4 var(--font-body); text-align: center; overflow-wrap: anywhere; }
.status-rule-selector-options { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--rule-field-gap); min-width: 0; width: 100%; max-width: 100%; }
.status-rule-option { display: grid; position: relative; flex: 1 1 auto; min-width: 0; cursor: pointer; touch-action: manipulation; }
/* One quiet frame for every condition-dialog control: the selector labels, the comparison and streak dropdowns and the
   branch / road / order choices. The shared selected rule (next to the popup options) and the locked rules override it. */
.status-rule-option-label, .status-rule-branch-choice, .status-rule-road-choice, .status-rule-order-choice,
.home-rule-dialog :is(.status-rule-comparison-select, .status-rule-streak-select) {
  border: 1px solid var(--repeat-option-border);
  border-radius: var(--status-control-radius);
  background: var(--repeat-control);
  color: var(--repeat-muted);
}
.status-rule-option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--rule-selector-control-height);
  padding: var(--rule-selector-block-inset) var(--rule-selector-inline-inset);
  font: 600 var(--rule-control-font-size)/var(--rule-control-line-height) var(--font-body);
  text-align: center;
  overflow-wrap: anywhere;
  transition: background-color var(--motion-fast), border-color var(--motion-fast);
}
.status-rule-option input:focus-visible + .status-rule-option-label { outline: 2px solid var(--color-selected); outline-offset: 1px; }
.status-rule-option:active .status-rule-option-label { filter: brightness(.85); }
/* A mode the plan cannot customize: the same locked language as the editor's other locked choices (dashed outline,
   struck-through text), and no hover or press feedback, so it is not mistaken for an unselected mode. */
.status-rule-option:has(> input:disabled) { cursor: not-allowed; }
.home-rule-dialog .status-rule-option:has(> input:disabled) .status-rule-option-label {
  border-style: dashed;
  border-color: var(--rule-disabled-border);
  background: var(--rule-disabled-fill);
  color: var(--rule-disabled-text);
  text-decoration: line-through;
  text-decoration-color: var(--rule-disabled-border);
  text-decoration-thickness: 1px;
  filter: none;
  scale: 1;
}
.home-rule-dialog .status-rule-comparison-select { display: flex; align-items: center; justify-content: center; flex: 1 1 auto; min-height: var(--rule-selector-control-height); max-width: 100%; gap: var(--rule-control-gap); padding: var(--rule-selector-block-inset) var(--rule-selector-inline-inset); font-weight: 600; }
.status-rule-comparison-select > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.status-rule-panel { position: relative; display: grid; gap: var(--rule-step-content-gap); margin-block-start: var(--rule-panel-top-gap); min-width: 0; }
.status-rule-panel::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: calc(var(--rule-panel-top-gap) / -2); border-block-start: var(--status-section-border); pointer-events: none; }
.status-settings-help {
  --rule-help-text: color-mix(in srgb, var(--repeat-selected-text) 60%, var(--status-muted));
  --dialog-paragraph-color: var(--rule-help-text);
  --dialog-paragraph-font-size: var(--rule-help-font-size);
  --dialog-paragraph-line-height: 1.7;
  --status-form-font-size: var(--rule-help-font-size);
  --status-form-line-height: 1.7;
  --status-control-hover: transparent;
  /* Help text must wrap within the control-defined width, not widen the dialog. */
  contain: inline-size;
  min-width: 0;
  margin-block-start: var(--rule-help-top-gap);
  padding-block-start: var(--rule-help-block-gap);
  border-block-start: var(--status-section-border);
  color: var(--rule-help-text);
  font: 400 var(--rule-help-font-size)/1.7 var(--font-body);
  overflow-wrap: anywhere;
}
.home-status-form .status-help-toggles button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--rule-help-text-gap);
  min-height: var(--rule-help-entry-height);
}
.home-status-form .status-help-toggles [aria-expanded="true"] { color: var(--repeat-selected-text); }
.home-status-form .status-help-toggles [aria-expanded="true"]::after { background: var(--repeat-selected-border); }
.status-help-toggles { --status-tab-count: 4; }
.status-help-toggles button > span:first-child { min-width: 0; }
.status-help-toggles button > .status-triangle { flex: 0 0 auto; opacity: .7; transform: rotate(-90deg); }
.status-help-toggles [aria-expanded="true"] > .status-triangle { transform: rotate(0deg); }
/* Every help page keeps the same distance from the entry row to its first line, independent of list or tab content. */
/* Smooth expand: the body is a one-track grid whose row goes 0fr → 1fr (220ms out, 180ms in) while the text fades; the
   height always follows the content, so nothing is clipped. `hidden` is only applied once the collapse has finished. */
.status-settings-help-body { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 180ms ease-in-out, opacity 150ms ease-in; }
.status-settings-help-body[data-open="true"] { grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows 220ms ease-out, opacity 220ms ease-out; }
/* The inset collapses with the track, so the block really reaches zero height before it is hidden. */
.status-settings-help-content { display: grid; gap: var(--rule-help-block-gap); min-height: 0; overflow: hidden; padding: 0 var(--rule-field-gap); transition: padding-block 180ms ease-in-out; }
.status-settings-help-body[data-open="true"] .status-settings-help-content { padding: var(--rule-help-body-gap) var(--rule-field-gap); transition-duration: 220ms; transition-timing-function: ease-out; }
.status-settings-help-body :is(p, ol, ul) { margin: 0; }
.status-settings-help-body :is(ol, ul) { display: grid; gap: var(--rule-help-block-gap); padding-inline-start: 1.5em; }
.status-help-separator { margin-inline: var(--rule-help-slash-gap); }
.status-settings-help-note .status-help-indicators { display: inline-grid; width: max-content; margin-inline: var(--rule-help-text-gap); vertical-align: middle; }
.status-settings-help-panel { min-width: 0; }
/* The note block sits a full body gap below the numbered steps so the two read as separate groups. */
.status-settings-help-note { --dialog-paragraph-color: var(--status-muted); display: grid; gap: var(--rule-help-block-gap); margin-block-start: calc(var(--rule-help-body-gap) - var(--rule-help-block-gap)); padding-inline-start: var(--rule-help-block-gap); border-inline-start: var(--status-section-border); color: var(--status-muted); }
.home-status-form > .status-settings-error {
  margin: 6px 0 0;
  color: #ffb3ab;
}
.status-settings-actions {
  position: relative;
  display: var(--status-footer-display, grid);
  grid-template-columns: var(--status-footer-columns);
  align-items: center;
  gap: var(--status-footer-button-gap);
  margin-top: var(--status-footer-gap);
  padding-top: max(var(--status-footer-padding), var(--status-footer-feedback-space, 0px));
  border-top: var(--status-section-border);
  flex-shrink: 0;
}
.status-settings-status {
  --dialog-paragraph-color: var(--status-accent);
  --dialog-paragraph-font-size: var(--rule-help-font-size);
  --dialog-paragraph-line-height: 1.5;
  position: absolute;
  inset-block-start: var(--status-footer-feedback-inset, 0px);
  inset-inline: 0;
}
.home-status-form .status-settings-actions button { min-height: var(--status-footer-control-height, 26px); padding: var(--status-footer-control-block-inset, 2px) var(--status-footer-control-inline-inset, 2px); }
.home-status-form .status-settings-actions :is([data-reset-settings], [data-clear-settings]) { justify-self: var(--status-footer-reset-align); padding-inline: 5px; border-color: var(--status-divider); color: var(--status-muted); background: transparent; }
.home-status-form .status-settings-actions [type="submit"] { --key-frame: var(--status-submit-border); background: var(--status-submit-fill) padding-box; color: var(--status-submit-text); font-weight: 700; }
/* Cancel keeps its see-through face: the lip shows it is a key, but no drop shadow lifts it off the dialog like save. */
.home-status-form .status-settings-actions [data-cancel-settings] { --key-frame: var(--status-cancel-border); --key-drop: 0 0 transparent; --key-drop-pressed: 0 0 transparent; background: var(--status-cancel-fill) padding-box; color: var(--status-cancel-text); }
/* Cancel and save are the footer's pair of primary keys (styles.css --key-*). Both frames are the app gold (cancel's at
   20% opacity), so both take the gold lip: mixing the translucent frame itself toward black would vanish into the dark
   dialog. The lip comes out of the existing height, so the footer row and the dialog keep their size. */
.home-status-form .status-settings-actions :is([data-cancel-settings], [type="submit"]) {
  /* The 1px side frame is now drawn inside, so the side padding gives that pixel back to keep the width. */
  padding: calc(var(--status-footer-control-block-inset, 2px) - (var(--key-lip-primary) - 2px) / 2) calc(var(--status-footer-control-inline-inset, 2px) + 1px);
  border: 0 solid transparent;
  border-bottom: var(--key-lip-primary) solid var(--key-lip-color);
  border-radius: var(--status-control-radius) / var(--status-control-radius) var(--status-control-radius) calc(var(--status-control-radius) + var(--key-lip-primary)) calc(var(--status-control-radius) + var(--key-lip-primary));
  box-shadow: inset 0 0 0 1px var(--key-frame), var(--key-drop, var(--key-primary-shadow));
}
.home-rule-dialog :is(.status-settings-utility-actions, .status-settings-primary-actions) { display: flex; align-items: center; gap: var(--status-footer-button-gap); min-width: 0; }
.home-rule-dialog .status-settings-utility-actions { margin-inline-end: auto; }
.home-rule-dialog .status-settings-primary-actions { --status-footer-control-height: 28px; --status-footer-control-block-inset: 4px; --status-footer-control-inline-inset: 10px; }
.home-repeat-dialog {
  --repeat-control-gap: 4px;
  --repeat-select-block-inset: 2px;
  --repeat-select-label-size: .75rem;
  --repeat-select-label-line-height: .875rem;
  --repeat-streak-word-space: 1.5px;
  --repeat-row-gap: 26px;
  --repeat-section-gap: 26px;
  /* 區塊標題與下方按鈕靠近一些，區塊之間仍保持原本距離。 */
  --repeat-section-content-gap: 9px;
  /* Section labels match the option text size so they read without leaning in on a phone. */
  --repeat-section-title-size: .6875rem;
  /* 納入統計是會點的控制項，比區塊標題再大一號。 */
  --repeat-include-label-size: .8125rem;
  --repeat-include-check-size: 13px;
  /* 儲存設定前留出一段距離，分隔線不貼著最後一排選項。 */
  --status-footer-gap: 14px;
  --repeat-algorithm-end-inset: 4px;
  --repeat-indicator-gap: 4px;
  --repeat-indicator-size: 4px;
}
.home-rule-dialog {
  --status-control: #10171d;
  --status-accent: #b6a17e;
  --status-muted: #a7adb2;
  --status-border: #4c555d;
  --status-divider: #333c44;
  --status-focus-ring: var(--status-accent);
  --repeat-muted: var(--status-muted);
  --repeat-control: var(--status-control);
  --repeat-option-border: var(--status-border);
  --repeat-selected-text: #f4ead7;
  --repeat-selected-fill: #293d49;
  --repeat-selected-border: #748b9a;
  --rule-step-selected-fill: #263947;
  --rule-step-selected-border: #667e8e;
  --rule-revalidation-control: #342d22;
  --rule-revalidation-text: #d2c4ac;
  --rule-revalidation-border: #887454;
  --rule-revalidation-selected-fill: #624d2f;
  --rule-revalidation-selected-border: #c1a06b;
  --rule-revalidation-disabled-fill: #29251f;
  --rule-revalidation-disabled-text: #a59b8b;
  --rule-revalidation-disabled-border: #5f5545;
  --rule-disabled-fill: #090f14;
  --rule-disabled-text: #77828c;
  --rule-disabled-border: #39434b;
  --repeat-streak-word-space: 1px;
  --status-dialog-width: max-content;
  --status-dialog-inline-space: calc(2 * var(--status-dialog-edge-gap));
  /* Size containment would hide the controls' intrinsic width from this dialog. */
  --status-content-containment: normal;
  --status-footer-display: flex;
  --status-form-font-size: var(--rule-control-font-size);
  --status-form-line-height: var(--rule-control-line-height);
  --status-popup-font-size: var(--rule-control-font-size);
  --status-popup-line-height: var(--rule-control-line-height);
  --status-selected: var(--repeat-selected-fill);
  --status-selected-border: var(--repeat-selected-border);
  --status-selected-text: var(--repeat-selected-text);
  --rule-panel-top-gap: 24px;
  --rule-step-content-gap: 16px;
  --rule-help-top-gap: 16px;
  --rule-help-font-size: .75rem;
  --rule-help-entry-height: 22px;
  --rule-help-block-gap: 6px;
  --rule-help-body-gap: 12px;
  --rule-help-text-gap: 4px;
  --rule-help-slash-gap: 2px;
  --status-footer-feedback-inset: var(--rule-help-block-gap);
  --status-footer-feedback-space: calc(var(--rule-help-font-size) * 1.5 + 2 * var(--status-footer-feedback-inset));
  --rule-field-gap: 4px;
  --rule-column-gap-increase: 4px;
  --rule-control-gap: 3px;
  --rule-road-content-gap: calc(var(--rule-control-gap) + 5px);
  --rule-order-content-gap: 1px;
  --rule-source-content-gap: 5px;
  --rule-split-inline-inset: 5px;
  --rule-control-block-inset: 3px;
  --rule-control-font-size: .6875rem;
  --rule-control-line-height: 1.2;
  --rule-control-height: calc(var(--rule-control-font-size) * var(--rule-control-line-height) + 2 * var(--rule-control-block-inset) + 2px);
  --rule-label-size: .625rem;
  --rule-selector-label-color: color-mix(in srgb, var(--status-text) 80%, var(--status-muted));
  --rule-selector-top-gap: 24px;
  --rule-selector-label-gap: 3px;
  --rule-selector-block-inset: 2px;
  --rule-selector-control-height: 22px;
  --rule-selector-inline-inset: 4px;
  --rule-selector-frame-inset: 4px;
  --rule-selector-row-gap: 10px;
  --rule-choice-gap: 5px;
  --rule-row-count: 3;
  --rule-checkbox-size: 10px;
  --rule-indicator-size: 4px;
  --rule-indicator-dot-size: 3px;
  --rule-indicator-stack-gap: 1.5px;
  --rule-order-indicator-width: calc(3 * var(--rule-indicator-dot-size) + 2 * var(--rule-indicator-stack-gap));
  --rule-dropdown-arrow-width: 6px;
  --rule-enabled-indicator: #e6c277;
  --status-popup-padding: 2px;
  --status-popup-row-gap: 2px;
  --status-popup-row-inset: 0px;
  --status-popup-option-gap: 4px;
  --status-popup-option-height: 28px;
  --status-popup-indicator-size: 8px;
  --status-popup-border: var(--repeat-option-border);
  --status-popup-surface: var(--status-control);
}
.status-rule-tabs { --status-tab-count: 4; }
.status-rule-steps { --repeat-selected-fill: var(--rule-step-selected-fill); --repeat-selected-border: var(--rule-step-selected-border); display: grid; min-width: 0; }
.status-rule-step { display: grid; min-width: 0; }
.status-rule-step[data-has-revalidation="true"] { --rule-row-count: 4; }
.status-rule-fields { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--rule-field-gap); min-width: 0; }
.status-rule-source-column { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(var(--rule-row-count), minmax(var(--rule-control-height), 1fr)); row-gap: var(--rule-choice-gap); flex: 0 1 auto; width: max-content; min-width: 0; max-width: 100%; }
/* Preserve the intrinsic tracks so extra column spacing cannot shrink the road labels. */
.status-rule-dependent-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(var(--rule-row-count), minmax(var(--rule-control-height), 1fr)); align-items: stretch; gap: var(--rule-choice-gap) var(--rule-field-gap); flex: 1 1 max-content; min-width: 0; max-width: 100%; }
.status-rule-field { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--rule-choice-gap); min-width: 0; max-width: 100%; }
/* Equal tracks keep the source and dependent rows aligned when their labels grow. */
.status-rule-source-column > .status-rule-field, .status-rule-dependent-fields > .status-rule-field { grid-row: 1 / span var(--rule-row-count); grid-template-rows: subgrid; }
/* The shorter order labels provide the extra gutter before the streak field. */
.status-rule-field[data-rule-field="roads"] { margin-inline: var(--rule-column-gap-increase) calc(-1 * var(--rule-column-gap-increase)); }
.status-rule-field[data-rule-field="orders"] { margin-inline: calc(2 * var(--rule-column-gap-increase)) 0; }
.status-rule-field[data-rule-field="streaks"] { margin-inline-start: var(--rule-column-gap-increase); }
.status-rule-field[data-rule-field="sources"] { width: 100%; }
.status-rule-field[data-rule-field="orders"] > [data-rule-revalidation="true"]:has(> [data-rule-order-toggle="sorted"]),
.status-rule-field[data-rule-field="streaks"] > [data-rule-revalidation="true"] { grid-row: 3; }
.home-rule-dialog [data-rule-revalidation="true"] {
  --repeat-control: var(--rule-revalidation-control);
  --repeat-muted: var(--rule-revalidation-text);
  --repeat-option-border: var(--rule-revalidation-border);
  --repeat-selected-fill: var(--rule-revalidation-selected-fill);
  --repeat-selected-border: var(--rule-revalidation-selected-border);
  --rule-disabled-fill: var(--rule-revalidation-disabled-fill);
  --rule-disabled-text: var(--rule-revalidation-disabled-text);
  --rule-disabled-border: var(--rule-revalidation-disabled-border);
}
.status-rule-value { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.status-rule-branch-choice, .status-rule-road-choice, .status-rule-order-choice {
  display: grid;
  column-gap: var(--rule-choice-content-gap, var(--rule-control-gap));
  align-items: stretch;
  min-width: 0;
  min-height: var(--rule-control-height);
  width: 100%;
  max-width: 100%;
  font: 500 var(--rule-control-font-size)/var(--rule-control-line-height) var(--font-body);
}
.home-rule-dialog :is(.status-rule-edit, .status-rule-road-edit, .status-rule-order-edit)[aria-current="true"]:not(:disabled) .status-triangle { color: var(--status-accent); }
.status-rule-branch-choice { grid-template-columns: var(--rule-checkbox-size) minmax(0, max-content); justify-content: center; column-gap: var(--rule-source-content-gap); padding-inline: var(--rule-control-gap); }
.status-rule-check { display: grid; place-items: center; cursor: pointer; }
.status-rule-check input { width: var(--rule-checkbox-size); height: var(--rule-checkbox-size); margin: 0; accent-color: var(--repeat-selected-text); color-scheme: dark; cursor: inherit; }
.home-rule-dialog :is(.status-rule-edit, .status-rule-road-toggle, .status-rule-road-edit, .status-rule-order-toggle, .status-rule-order-edit) {
  align-items: center;
  gap: var(--rule-choice-content-gap, var(--rule-control-gap));
  min-height: 0;
  padding: var(--rule-control-block-inset) 0;
  border: 0;
  border-radius: var(--status-control-radius);
  background: transparent;
  color: inherit;
  font-size: var(--rule-control-font-size);
  line-height: var(--rule-control-line-height);
}
.home-rule-dialog :is(.status-rule-edit, .status-rule-road-edit, .status-rule-order-edit) { display: flex; justify-content: center; }
.home-rule-dialog :is(.status-rule-road-toggle, .status-rule-order-toggle) { display: grid; grid-template-columns: var(--rule-leading-indicator-width, var(--rule-indicator-size)) minmax(0, 1fr); }
.home-rule-dialog :is(.status-rule-edit, .status-rule-road-toggle, .status-rule-order-toggle) .status-rule-value { text-align: center; }
.home-rule-dialog :is(.status-rule-road-toggle, .status-rule-order-toggle) .status-rule-value { grid-column: 2; }
.home-rule-dialog .status-rule-edit { gap: var(--rule-source-content-gap); }
.status-rule-road-indicators, .status-rule-order-indicators { display: grid; justify-items: center; align-content: center; gap: var(--rule-indicator-stack-gap); width: var(--rule-leading-indicator-width, var(--rule-indicator-size)); }
.status-rule-order-indicators { grid-template-columns: repeat(3, var(--rule-indicator-dot-size)); }
.status-rule-indicator-spacer { width: var(--rule-leading-indicator-width, var(--rule-indicator-size)); pointer-events: none; }
.status-rule-road-indicator, .status-rule-order-indicator { width: var(--rule-indicator-dot-size); height: var(--rule-indicator-dot-size); border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1px var(--repeat-option-border); }
.status-rule-road-indicator[data-enabled="true"], .status-rule-order-indicator[data-enabled="true"] { background: var(--rule-enabled-indicator); box-shadow: none; }
.home-rule-dialog :is([data-rule-source-enable], [data-rule-source-edit], [data-rule-road-toggle], [data-rule-road-edit], [data-rule-order-toggle], [data-rule-order-edit], [data-rule-streak-select]):disabled { color: var(--rule-disabled-text); cursor: not-allowed; opacity: 1; }
.status-rule-check:has(:disabled) { cursor: not-allowed; }
.status-rule-road-name { display: flex; flex-wrap: wrap; justify-content: center; }
.status-rule-road-name > span { min-width: 0; overflow-wrap: anywhere; }
.status-rule-road-choice, .status-rule-order-choice { grid-template-columns: minmax(0, 1fr) var(--rule-indicator-size); padding-inline: var(--rule-split-inline-inset); }
.status-rule-road-choice { --rule-choice-content-gap: var(--rule-road-content-gap); }
.status-rule-order-choice { --rule-choice-content-gap: var(--rule-order-content-gap); --rule-leading-indicator-width: var(--rule-order-indicator-width); }
.home-rule-dialog .status-triangle-right { border: 0; border-block: 3px solid transparent; border-inline-start: 4px solid currentColor; }
/* The dialog's button font already resolves to the rule-control size and line height here. */
.home-rule-dialog .status-rule-streak-select { display: grid; grid-template-columns: minmax(0, 1fr) var(--rule-dropdown-arrow-width); align-items: center; gap: 0; min-height: var(--rule-control-height); width: 100%; max-width: 100%; margin: 0; padding: var(--rule-control-block-inset) var(--rule-split-inline-inset); }
/* A disabled view arrow alone must not make an available choice look locked. Locked choices use the same language as
   locked streak options: dashed outline plus struck-through text, so they cannot be mistaken for merely unselected ones. */
.home-rule-dialog :is(.status-rule-branch-choice:has(> .status-rule-check > input:disabled), .status-rule-road-choice:has(> .status-rule-road-toggle:disabled), .status-rule-order-choice:has(> .status-rule-order-toggle:disabled), .status-rule-streak-select:disabled) {
  border-style: dashed;
  border-color: var(--rule-disabled-border);
  background: var(--rule-disabled-fill);
  color: var(--rule-disabled-text);
}
.home-rule-dialog :is(.status-rule-branch-choice:has(> .status-rule-check > input:disabled) .status-rule-edit, .status-rule-road-toggle:disabled, .status-rule-order-toggle:disabled, .status-rule-streak-select:disabled .status-rule-select-label) {
  text-decoration: line-through;
  text-decoration-color: var(--rule-disabled-border);
  text-decoration-thickness: 1px;
}
.status-rule-select-label { display: grid; grid-column: 1; min-width: 0; padding-inline: var(--rule-control-gap); text-align: center; }
.status-rule-streak-select > .status-triangle { grid-column: 2; justify-self: center; }
.status-rule-select-label > span { grid-area: 1 / 1; overflow-wrap: anywhere; }
.status-rule-count { margin-inline: var(--repeat-streak-word-space); }
/* Reserve the longest option so the shared popup can keep the trigger's width. */
.status-rule-select-sizer { visibility: hidden; pointer-events: none; }
.status-repeat-content { display: grid; gap: 0; }
.status-repeat-section { display: grid; gap: var(--repeat-section-content-gap); min-width: 0; margin-top: var(--repeat-row-gap); }
.status-repeat-section + .status-repeat-section { margin-top: var(--repeat-section-gap); }
.status-repeat-section h3 { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--status-muted); font-size: var(--repeat-section-title-size); font-weight: 500; line-height: 1.4; letter-spacing: .04em; }
.status-repeat-section h3::after { content: ''; flex: 1; min-width: 0; height: 1px; background: var(--status-divider); }
.status-repeat-source-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status-repeat-source-title h3 { flex: 1; min-width: 0; }
.status-repeat-include { display: inline-flex; align-items: center; gap: 6px; color: var(--status-muted); font-size: var(--repeat-include-label-size, var(--repeat-section-title-size)); line-height: 1.4; cursor: pointer; }
.status-repeat-include input { width: var(--repeat-include-check-size); height: var(--repeat-include-check-size); margin: 0; accent-color: var(--status-accent); cursor: pointer; }
/* 複驗 without a plan that includes it: the box cannot be ticked, so it does not invite a click. */
.status-repeat-include[data-locked="true"], .status-repeat-include[data-locked="true"] input { cursor: default; }
.status-repeat-source-row, .status-repeat-roads, .status-repeat-streaks {
  display: grid;
  gap: var(--repeat-control-gap);
  min-width: 0;
}
.status-repeat-source-row { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.2fr); }
.status-repeat-roads { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, .92fr); }
/* Streak buttons size to their label (auto tracks) and share the leftover space equally, so wider labels get wider buttons instead of tighter padding. */
.status-repeat-streaks { grid-template-columns: repeat(3, auto); }
.status-repeat-streak-word { margin-inline-end: var(--repeat-streak-word-space); }
.status-repeat-streak-word[data-word="進"] { margin-inline-start: var(--repeat-streak-word-space); }
/* Four options sit on one row; five split two over three (對映／聯析 double and 複驗); six keep three per row. */
.status-repeat-streaks[data-count="4"] { grid-template-columns: repeat(4, auto); }
/* Two over three keeps equal widths: with spanning cells, auto tracks would make the two top buttons unequal. */
.status-repeat-streaks[data-count="5"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.status-repeat-streaks[data-count="5"] > button { grid-column: span 2; }
.status-repeat-streaks[data-count="5"] > button:nth-child(-n + 2) { grid-column: span 3; }
.home-repeat-dialog .home-status-form .status-repeat-choice { color: var(--repeat-muted); background: var(--repeat-control); border-color: var(--repeat-option-border); }
.home-repeat-dialog .home-status-form .status-repeat-algorithm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - var(--repeat-algorithm-end-inset));
  justify-self: start;
  padding-inline: 0;
  border-color: transparent;
  border-bottom-width: 2px;
  border-radius: var(--status-control-radius) var(--status-control-radius) 0 0;
  background: transparent;
  color: var(--repeat-muted);
  font-size: .75rem;
}
.home-repeat-dialog .home-status-form .status-repeat-algorithm[aria-pressed="true"] { color: var(--repeat-selected-text); border-bottom-color: var(--repeat-selected-border); background: var(--repeat-selected-fill); }
.status-repeat-algorithm-name { position: relative; max-width: 100%; }
/* The inclusion marker must not shift the label or resize its selection frame. */
.status-repeat-algorithm-name::after {
  content: '';
  position: absolute;
  inset-inline-start: calc(100% + var(--repeat-indicator-gap));
  top: 50%;
  width: var(--repeat-indicator-size);
  height: var(--repeat-indicator-size);
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--repeat-selected-text);
  opacity: 0;
  pointer-events: none;
}
.status-repeat-algorithm[data-included="true"] .status-repeat-algorithm-name::after { opacity: .8; }
.home-status-form .status-repeat-select {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-block: var(--repeat-select-block-inset);
  border-color: var(--repeat-option-border);
  background: var(--repeat-control);
  color: var(--repeat-muted);
  font-size: .625rem;
}
/* Keep the original line box so larger labels cannot resize the dropdowns. */
.status-repeat-select > span:first-child { min-width: 0; font-size: var(--repeat-select-label-size); line-height: var(--repeat-select-label-line-height); }
.status-triangle {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-inline: 3px solid transparent;
  border-top: 4px solid currentColor;
}
.status-multiselect-popup {
  position: fixed;
  inset: auto;
  z-index: 100;
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
  padding: var(--status-popup-padding, 2px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--status-popup-border, var(--status-border, var(--color-border)));
  border-radius: var(--status-control-radius, var(--radius));
  background: var(--status-popup-surface, var(--status-panel, var(--color-surface)));
  color: var(--status-text, var(--color-text));
  box-shadow: 0 5px 20px rgb(0 0 0 / 65%);
}
.status-multiselect-popup:popover-open, .status-multiselect-popup:not([popover]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--status-popup-row-gap, 2px);
}
.status-multiselect-popup[data-columns="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.status-multiselect-popup button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--status-popup-option-gap, 2px);
  min-width: 0;
  min-height: var(--status-popup-option-height, var(--repeat-control-height));
  padding: 3px var(--status-popup-row-inset, 0px);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--status-muted, var(--color-secondary));
  font: 500 var(--status-popup-font-size, .625rem)/var(--status-popup-line-height, 1.4) var(--font-body);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.status-multiselect-label { min-width: 0; }
.status-multiselect-popup button::before {
  content: '';
  flex: 0 0 var(--status-popup-indicator-size, 7px);
  width: var(--status-popup-indicator-size, 7px);
  height: var(--status-popup-indicator-size, 7px);
  border: 1px solid currentColor;
  border-radius: 2px;
}
.status-multiselect-popup:is(.status-repeat-order-popup, .status-repeat-kind-popup) { --status-popup-option-height: var(--status-popup-trigger-height, var(--repeat-control-height)); --status-popup-indicator-size: 8px; --status-popup-option-gap: 6px; }
.status-multiselect-popup:is(.status-repeat-order-popup, .status-repeat-kind-popup) button { padding-block: var(--repeat-select-block-inset); font-size: var(--repeat-select-label-size); line-height: var(--repeat-select-label-line-height); }
.status-multiselect-popup:is(.status-repeat-order-popup, .status-repeat-kind-popup) button::before { box-sizing: border-box; }
/* One selected treatment for every settings-dialog control: condition selectors, branch / road / order choices, the
   streak dropdown, repeat-dialog choices and dropdowns, and popup options. Each selector keeps its own specificity, so
   the locked (dashed) and disabled rules still win. */
.status-rule-option input:checked + .status-rule-option-label,
.status-rule-branch-choice[data-selected="true"], .status-rule-road-choice[data-selected="true"], .status-rule-order-choice[data-selected="true"],
.home-rule-dialog .status-rule-streak-select[data-selected="true"],
.home-repeat-dialog .home-status-form .status-repeat-choice[aria-pressed="true"],
.home-status-form .status-repeat-select[data-selected="true"],
.status-multiselect-popup :is([aria-pressed="true"], [aria-selected="true"]) {
  color: var(--repeat-selected-text);
  background: var(--repeat-selected-fill);
  border-color: var(--repeat-selected-border);
}
.status-multiselect-popup :is([aria-pressed="true"], [aria-selected="true"])::before {
  background: currentColor;
  box-shadow: inset 0 0 0 1px var(--repeat-selected-fill);
}
.status-multiselect-popup button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
.status-multiselect-popup[role="listbox"] button::before { border-radius: 50%; }
.status-rule-streak-popup {
  --rule-streak-number-width: 2ch;
  --status-popup-surface: var(--repeat-control);
  --status-popup-padding: 0px;
  --status-popup-row-inset: var(--rule-split-inline-inset);
  --status-popup-row-gap: var(--rule-choice-gap);
  --status-popup-option-gap: var(--rule-source-content-gap);
  --status-popup-option-height: var(--rule-control-height);
  --status-focus-offset: -2px;
  --repeat-selected-fill: var(--rule-step-selected-fill);
  --repeat-selected-border: var(--rule-step-selected-border);
  border: 0;
}
.status-rule-streak-popup button { display: grid; grid-template-columns: var(--status-popup-indicator-size) minmax(0, 1fr); justify-content: stretch; border: 0; border-radius: 0; color: var(--repeat-muted); }
/* Unavailable streaks must read as struck out, not merely dimmer, because the hover reason never shows on touch. */
.status-rule-streak-popup button:disabled { background: var(--rule-disabled-fill); color: var(--rule-disabled-text); opacity: 1; }
.status-rule-streak-popup button:disabled::before { border-style: dashed; border-color: var(--rule-disabled-border); background: transparent; box-shadow: none; }
.status-rule-streak-popup button:disabled .status-multiselect-label { text-decoration: line-through; text-decoration-color: var(--rule-disabled-border); text-decoration-thickness: 1px; }
.status-rule-streak-popup .status-multiselect-label { display: flex; align-items: center; justify-content: center; width: 100%; text-align: center; }
/* Keep the measuring text before the scroll origin so it cannot widen a narrow popup. */
.status-rule-streak-reference { position: absolute; inset-block-start: 0; inset-inline-end: 100%; visibility: hidden; pointer-events: none; width: max-content; font: 500 var(--status-popup-font-size)/var(--status-popup-line-height) var(--font-body); }
.status-rule-streak-text { display: inline-grid; grid-template-columns: max-content var(--rule-streak-number-width) max-content var(--rule-streak-number-width); flex: 0 0 auto; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.status-rule-comparison-popup { --status-popup-option-height: var(--rule-selector-control-height); }
.status-rule-comparison-popup button { position: relative; justify-content: center; padding: var(--rule-selector-block-inset) var(--status-popup-row-inset); font-weight: 600; }
.status-rule-comparison-popup button::before { position: absolute; inset-inline-start: 0; width: 2px; height: 60%; border: 0; border-radius: 0; background: transparent; }
.status-rule-comparison-popup [aria-selected="true"]::before { background: var(--repeat-selected-text); box-shadow: none; }
.home-status-dialog button:focus-visible, .home-status-side button:focus-visible, .status-multiselect-popup button:focus-visible, .status-repeat-include input:focus-visible, .status-rule-check input:focus-visible {
  outline: 2px solid var(--status-focus-ring, var(--color-selected));
  outline-offset: var(--status-focus-offset, 1px);
}
@media (hover: hover) {
  .status-rule-option:hover .status-rule-option-label { filter: brightness(1.15); }
  .home-status-side button:hover { filter: brightness(1.15); }
  /* The selected face is a flat colour layer, so a hover colour would replace the matte gold. */
  .home-status-side button:not([aria-pressed="true"], [aria-selected="true"]):hover { background-color: var(--color-hover); }
  .home-status-dialog button:not(:disabled):hover { filter: brightness(1.15); }
  .home-status-dialog button:not(:disabled):not([aria-selected="true"]):not([aria-pressed="true"]):not([type="submit"]):hover { background-color: var(--status-control-hover); }
}
.home-status-dialog button:not(:disabled):active, .home-status-side button:active {
  filter: brightness(.85);
}
@media (prefers-reduced-motion: reduce) {
  .home-left-choice-pages { scroll-behavior: auto; }
  .home-action-row {
  --home-status-press-scale: 1;
}
}
@media (forced-colors: active) {
  .home-rule-dialog {
    --rule-revalidation-disabled-fill: Canvas;
    --rule-revalidation-disabled-text: GrayText;
    --rule-revalidation-disabled-border: GrayText;
    --rule-disabled-fill: Canvas;
    --rule-disabled-text: GrayText;
    --rule-disabled-border: GrayText;
  }
  .home-status-dialog legend {
  color: CanvasText;
}
  .home-settings-button, .home-side-modes, .home-repeat-heading, .home-status-form button, .status-multiselect-popup {
  border: 1px solid ButtonText;
}
  /* Forced colours repaint backgrounds, so the rule before the gear takes the frame's system colour too. */
  .home-repeat-heading::before { background: ButtonText; }
  /* Keys draw a plain system frame instead of the lip and inset lines. */
  .home-side-kinds button, .home-left-detail-tabs button, .home-left-card, .home-status-form .status-settings-actions :is([data-cancel-settings], [type="submit"]) { border: 1px solid ButtonText; }
  .home-side-mode:not([aria-pressed="true"]) { border: 1px solid ButtonText; }
  .home-side-mode[aria-pressed="true"] { border-bottom-width: 0; }
  .home-side-modes [aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .status-multiselect-popup [aria-pressed="true"]:not(:disabled), .home-status-form [aria-pressed="true"]:not(:disabled), .home-status-form [aria-selected="true"]:not(:disabled) {
  outline: 2px solid Highlight;
}
}

/* Raised controls and unified press feedback (2026-11-10): top-edge light plus soft bottom shadow on the home selector
   groups and dialog radios (the home keys carry their own, above); every option button scales to 98% while held and
   springs back without bouncing. Scaling never affects layout, so neighbouring controls stay put. */
.home-side-modes, .home-repeat-heading,
.status-rule-option-label, .home-status-form .status-settings-actions :is([data-reset-settings], [data-clear-settings]) { box-shadow: var(--control-relief); }
.home-side-mode, .home-side-kinds button, .home-left-card, .home-left-detail-tabs button, .home-settings-button,
.home-status-dialog button, .status-multiselect-popup button, .status-rule-option-label {
  /* The key lip's bottom border switches at once: fading it would leave a faint line under a key that has just sunk. */
  transition: scale var(--control-press-duration) ease-out, filter var(--motion-fast), background-color var(--motion-fast), border-top-color var(--motion-fast), border-inline-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast);
}
:is(.home-side-mode, .home-side-kinds button, .home-left-detail-tabs button, .home-settings-button, .home-status-dialog button, .status-multiselect-popup button):not(:disabled):active,
.home-left-card:has(> .home-left-choice:active), .status-rule-option:active .status-rule-option-label { scale: var(--control-press-scale); }
/* Save, clear, reset and cancel answer with a firmer press. */
.home-status-form .status-settings-actions button:not(:disabled):active { scale: var(--control-press-strong-scale); filter: brightness(.8); }
/* Keys (2026-11-12): while held, a raised key sinks into its lip and the box never changes. An option moves down by its
   sink over its own painted lip, which shortens by the same amount (styles.css --key-option-lip), so a raised option
   held down looks like a selected one; a footer key's transparent top border takes the height its lip gives up. A
   selected option is already down and only scales. */
:is(.home-side-mode, .home-side-kinds button, .home-left-detail-tabs button, .home-settings-button):not([aria-pressed="true"], [aria-selected="true"], :disabled):active,
.home-left-card:not([data-active="true"]):has(> .home-left-choice:active) {
  border-bottom-color: transparent;
  /* Two layers: the painted lip shortens, the lit face (--home-status-raised-face) keeps its own size. */
  background-position: left 0 bottom var(--key-sink-option), 0 0;
  background-size: 100% calc(var(--key-lip-option) - var(--key-sink-option)), auto;
  translate: 0 var(--key-sink-option);
  box-shadow: inset 0 0 0 1px var(--key-frame);
}
.home-status-form .status-settings-actions :is([data-cancel-settings], [type="submit"]):not(:disabled):active {
  border-top-width: var(--key-sink-primary);
  border-bottom-width: calc(var(--key-lip-primary) - var(--key-sink-primary));
  box-shadow: inset 0 0 0 1px var(--key-frame), var(--key-drop-pressed, var(--key-primary-pressed-shadow));
}
/* A disabled key lies flat: same face, no lip (border or painted), no shadow. The repeat gear is one for guests. */
:is(.home-side-mode, .home-side-kinds button, .home-left-detail-tabs button, .home-settings-button):disabled {
  border-bottom-color: transparent;
  background-size: 0 0, auto;
  translate: none;
  box-shadow: inset 0 0 0 1px var(--key-frame);
}
.home-status-form .status-settings-actions :is([data-cancel-settings], [type="submit"]):disabled {
  border-bottom-color: transparent;
  box-shadow: inset 0 0 0 1px var(--key-frame);
}
@media (prefers-reduced-motion: reduce) {
  :is(.home-side-mode, .home-side-kinds button, .home-left-detail-tabs button, .home-settings-button, .home-status-dialog button, .status-multiselect-popup button, .entry-utility):active,
  .home-left-card:has(> .home-left-choice:active), .status-rule-option:active .status-rule-option-label { scale: 1; }
}
