/* Messages: the WhatsApp and email parts of the account page and the Messages tab (msg-), the bell in the top bar
   (bell-, js/bell.js) and the player's Messages page (chat-, views/messages.js). Linked in index.html after kit.css;
   the back office's own sheets load after it the first time the back office opens (views/admin.js). Colours are the
   tokens from styles.css only. */

/* Staff screen */
.msg-screen { display: grid; min-width: 0; }
.msg-slot { min-width: 0; }
.msg-filters { display: inline-flex; flex-wrap: wrap; gap: 4px; max-width: 100%; margin-top: 12px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.msg-seg { min-height: 44px; min-width: 72px; padding: 0 16px; border-radius: 999px; font-size: calc(15px * var(--type)); font-weight: 600; color: var(--muted); transition: color .15s, background-color .15s; }
.msg-seg:hover { color: var(--text); }
.msg-seg.is-active { color: var(--block-ink); background: var(--block); }
/* In the dark theme the chosen filter wears the chosen chip's ring as well (styles.css, after .seg). */
:root:not([data-theme="light"]) .msg-seg.is-active { box-shadow: inset 0 0 0 2px var(--switch-on); }

.msg-body { margin: 0; font-size: calc(15px * var(--type)); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-replies { display: grid; gap: 10px; padding-left: 12px; border-left: 2px solid var(--line-strong); }
.msg-reply { display: grid; gap: 4px; min-width: 0; }
.msg-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; min-width: 0; font-size: calc(13px * var(--type)); color: var(--muted); }

.msg-form { display: grid; gap: 10px; min-width: 0; margin-top: 4px; }
.msg-form textarea { width: 100%; min-height: 84px; padding: 10px 12px; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-inner); outline: 0; font: inherit; font-size: calc(16px * var(--type)); color: var(--text); resize: vertical; }
.msg-form textarea:focus { border-color: var(--text); }
.msg-count { margin: 0; font-size: calc(13px * var(--type)); color: var(--muted); text-align: right; }
.msg-footer { margin: 0; font-size: calc(13px * var(--type)); color: var(--muted); overflow-wrap: anywhere; }
.msg-error { font-size: calc(14px * var(--type)); color: var(--loss); overflow-wrap: anywhere; }
.msg-problem { margin: 0; min-height: 20px; font-size: calc(14px * var(--type)); color: var(--loss); overflow-wrap: anywhere; }
.msg-fieldset { display: grid; gap: 10px; min-width: 0; margin: 4px 0 0; padding: 0; border: 0; }
.msg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.msg-result { margin: 0; min-height: 20px; font-size: calc(15px * var(--type)); overflow-wrap: anywhere; }

.msg-detail { display: grid; gap: 4px; min-width: 0; }
/* A player's thread from the app in the staff inbox: each message under who wrote it and when, a reply set in under a
   rule as a WhatsApp reply is, and a Ref to the player's page. */
.msg-thread { display: grid; gap: 12px; min-width: 0; }
.msg-said { display: grid; gap: 4px; min-width: 0; }
.msg-said.is-staff { padding-left: 12px; border-left: 2px solid var(--line-strong); }
.msg-said .msg-meta b { font-weight: 600; color: var(--text); }
.msg-ref { display: inline-flex; border-radius: 999px; }
.msg-new { margin-top: 8px; }

/* Player screen (account page) */
.msg-number { margin: 0; font-size: calc(20px * var(--type)); font-weight: 600; overflow-wrap: anywhere; }
.msg-check { min-height: 44px; align-items: center; }
/* Which messages come on which channel: a row for each kind, a column for each channel, a switch in each cell. The
   channel heads are icons, named for screen readers and in a tooltip. A switch for a channel not set up is greyed. */
.msg-choices { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.msg-choices th, .msg-choices td { padding: 0; vertical-align: middle; }
.msg-choices thead th { width: 56px; height: 36px; text-align: center; font-weight: 500; color: var(--muted); }
.msg-choice-head { display: inline-grid; place-items: center; width: 36px; height: 36px; }
.msg-choices tbody th { padding: 6px 8px 6px 0; text-align: left; font-size: calc(15px * var(--type)); font-weight: 500; overflow-wrap: anywhere; }
.msg-choices tbody td { text-align: center; }
.msg-choices tbody :is(th, td) { border-top: 1px solid var(--line); }
.msg-choice { justify-content: center; width: 100%; }
.msg-choices + .acct-row { box-shadow: inset 0 1px var(--line); }
:is(.msg-check, .msg-choice) input:disabled + .play-switch-track { opacity: .45; }
:is(.msg-check, .msg-choice):has(input:disabled) { cursor: default; }

/* The bell (js/bell.js), in the top bar on a phone as on a computer: a ghost icon button, the count not read as a gold
   pill ringed in the bar's claret (one look in both themes, as the bar has), and its panel under the bar, as the
   balance's. A notice not read sits on the second surface with a dot before its title; green goes only on the money a
   bet paid above its amount. */
.bell { position: relative; }
.bell-count { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--masthead-accent); color: var(--masthead-pill); box-shadow: 0 0 0 2px var(--masthead); font-size: calc(12px * var(--type)); font-weight: 800; line-height: 18px; text-align: center; pointer-events: none; }
.bell-panel { position: absolute; top: calc(100% + 8px); right: var(--gutter); z-index: 2; width: min(380px, calc(100vw - 2 * var(--gutter))); max-height: min(560px, calc(100vh - var(--top-h) - var(--dock-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px)); overflow-y: auto; overscroll-behavior: contain; padding: 0 0 10px; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 16px 40px rgba(0, 0, 0, .4); animation: panel-in .2s var(--ease); }
@supports (height: 100dvh) {
  .bell-panel { max-height: min(560px, calc(100dvh - var(--top-h) - var(--dock-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px)); }
}
.bell-panel :focus-visible { outline-color: var(--text); }
/* The panel sits inside the top bar: its own button takes the panel's ink, not the bar's. */
.bell-panel .icon-btn.ghost { color: var(--muted); }
.bell-panel .icon-btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
/* On a narrow phone the bar's buttons sit closer, so the bell, the balance and the install button fit beside the logo
   (each keeps its 44px target). */
@media (max-width: 420px) { .top-right:has(.bell) { gap: 0; } }
@media (min-width: 1024px) { .top:has(.bell-panel:not([hidden])) { z-index: 50; } }
.bell-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 4px 16px; background: var(--surface); }
.bell-heading { font-size: calc(17px * var(--type)); font-weight: 600; }
.bell-day { padding: 10px 16px 4px; font-size: calc(13px * var(--type)); font-weight: 600; color: var(--muted); }
.bell-list { display: grid; }
.bell-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: start; column-gap: 12px; min-height: 44px; padding: 10px 16px; color: inherit; transition: background-color .15s; }
a.bell-item:hover { background: var(--surface-2); }
.bell-item.is-unread { background: var(--surface-2); }
a.bell-item.is-unread:hover { background: var(--surface-3); }
.bell-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.bell-item.is-unread .bell-ico { background: var(--surface); color: var(--text); }
.bell-ico .ico { width: 18px; height: 18px; }
.bell-what { display: grid; gap: 2px; min-width: 0; }
.bell-name { font-size: calc(15px * var(--type)); font-weight: 600; overflow-wrap: anywhere; }
.bell-item.is-unread .bell-name { font-weight: 800; }
.bell-item.is-unread .bell-name::before { content: ''; display: inline-block; width: 8px; height: 8px; margin: 0 6px 1px 0; border-radius: 50%; background: var(--text); }
.bell-body { font-size: calc(14px * var(--type)); line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.bell-paid { font-weight: 700; color: var(--win); }
.bell-time { padding-top: 2px; font-size: calc(13px * var(--type)); color: var(--faint); white-space: nowrap; }
.bell-empty { display: grid; justify-items: center; gap: 8px; padding: 20px 16px 14px; color: var(--faint); text-align: center; }
.bell-empty .ico { width: 28px; height: 28px; }
.bell-empty p, .bell-status { font-size: calc(15px * var(--type)); color: var(--muted); }
.bell-status { padding: 12px 16px; }

/* Messages (views/messages.js): the thread, the player's own on the right on the second surface, the bookie's on the
   left under Elite Sports, each with its time, by day; the box to write in held at the foot, over the dock on a phone.
   Only the box floats, so only it has a shadow. */
.chat-page { display: grid; gap: 8px; }
.chat { display: grid; gap: 8px; padding: 4px 0 8px; }
.chat-day { justify-self: center; margin: 10px 0 2px; font-size: calc(13px * var(--type)); font-weight: 600; color: var(--muted); }
.chat-msg { display: grid; gap: 4px; max-width: min(560px, 86%); padding: 10px 14px 8px; border-radius: 18px; }
.chat-msg.is-own { justify-self: end; background: var(--surface-2); border-bottom-right-radius: 6px; }
.chat-msg.is-bookie { justify-self: start; background: var(--surface); border-bottom-left-radius: 6px; }
.chat-from { font-size: calc(13px * var(--type)); font-weight: 700; color: var(--muted); }
.chat-text { font-size: calc(15px * var(--type)); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-time { justify-self: end; font-size: calc(12px * var(--type)); color: var(--faint); }
.chat-compose { position: sticky; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 12px); z-index: 5; display: flex; align-items: flex-end; gap: 8px; margin-top: 4px; padding: 6px; border-radius: 28px; background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.chat-compose textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 40vh; padding: 11px 14px; border: 1px solid transparent; border-radius: 22px; outline: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: calc(16px * var(--type)); line-height: 1.35; resize: none; }
.chat-compose textarea:focus { border-color: var(--text); }
.chat-compose textarea::placeholder { color: var(--faint); }
.chat-compose .chat-ask-open { flex: none; }

/* Request a bet (16.11.2026): the request and the bookie's price as cards in the thread (the head with where it
   stands, the player's line, the event, the figures; the price's Accept and Decline), and the form above the box. */
.chat-msg.has-card { width: min(420px, 86%); padding: 8px 8px 6px; }
.chat-msg.has-card .chat-from, .chat-msg.has-card .chat-time { padding: 0 6px; }
.chat-card { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); }
.chat-msg.is-bookie .chat-card { background: var(--surface-2); }
.chat-card-head, .chat-ask-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; }
.chat-card-type { display: inline-flex; align-items: center; gap: 6px; font-size: calc(14px * var(--type)); font-weight: 700; }
.chat-card-type .ico { width: 18px; height: 18px; color: var(--muted); }
.chat-card-time { font-size: calc(14px * var(--type)); font-weight: 600; color: var(--muted); white-space: nowrap; }
.chat-card-ask { margin: 0; font-size: calc(16px * var(--type)); font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.chat-card-event { display: flex; align-items: center; gap: 8px; margin: 0; font-size: calc(13px * var(--type)); color: var(--muted); }
.chat-card-mark { display: inline-flex; flex: none; gap: 2px; }
.chat-card-mark .glyph .ico { width: 18px; height: 18px; }
.chat-card-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin: 0; padding-top: 8px; box-shadow: inset 0 1px var(--line); }
.chat-card-figures dt { font-size: calc(12px * var(--type)); color: var(--muted); }
.chat-card-figures dd { margin: 0; font-size: calc(16px * var(--type)); font-weight: 700; font-variant-numeric: tabular-nums; }
.chat-card-figures s { display: block; font-size: calc(12px * var(--type)); font-weight: 500; color: var(--faint); }
.chat-card-price { font-size: calc(18px * var(--type)); }
.chat-card-answer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.chat-card-answer .icon-btn { width: 64px; height: 48px; }
.chat-card-answer .icon-btn.primary { width: 100%; }
/* Decline on the bookie's card, as on My bets' stub: the cross inside the strong line, on no fill (the card is the
   second surface the button wore, so it showed no target). */
.chat-card-answer .icon-btn:not(.primary) { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.chat-card-answer .icon-btn:not(.primary):hover:not(:disabled) { background: var(--surface-3); }
a.chat-state { text-decoration: none; }
.chat-ask { display: grid; gap: 10px; padding: 14px; border-radius: 18px; background: var(--surface); }
.chat-field { display: grid; gap: 4px; min-width: 0; }
.chat-field > span { font-size: calc(13px * var(--type)); font-weight: 500; color: var(--muted); }
.chat-field select, .chat-field input { width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid transparent; border-radius: 12px; outline: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: calc(16px * var(--type)); }
.chat-field select:focus, .chat-field input:focus { border-color: var(--text); }
.chat-ask-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.chat-ask-send { width: 64px; height: 44px; }
@media (min-width: 1024px) {
  .chat-page { max-width: calc(760px * var(--type)); }
  .chat-compose { bottom: 24px; }
}
