/* Modern layer over app.css: theme-aware surfaces, sticky header, phone tab bar. */

/* The sidebar and hero banners are dark in both themes; their text keeps fixed light colours. */
.sidebar { background: #0f2620; border-right: 1px solid #ffffff10; }
.sidebar .brand-sub, .sidebar .nav-caption { color: #8fa89c; }
.sidebar .nav-link { color: #a9c0b5; border-radius: 12px; }
.sidebar .nav-link:hover { background: #ffffff10; color: #ffffff; }
.sidebar .nav-link.active, .brand-mark { color: #143a2d; }
.sidebar .nav-link.active { background: var(--lime); box-shadow: 0 6px 18px #c8f58b26; }
.sidebar .nav-link.active .nav-count { background: #143a2d1a; }
.sidebar .nav-count { background: #ffffff12; color: inherit; }
.sidebar-tip { background: #ffffff08; border-color: #ffffff14; border-radius: 16px; }
.sidebar-tip p, .local-status { color: #9fb4a8; }

/* Surfaces: softer corners, quiet shadows, borders that follow the theme. */
body { background: var(--canvas); color: var(--ink); }
.summary-item, .forecast-panel, .report-section, .league-card, .live-card, .top-picks, .match-section, .band-card {
  border-radius: var(--radius); border-color: var(--line); box-shadow: var(--shadow);
}
.summary-item, .forecast-panel, .report-section, .live-card, .top-picks { background: var(--surface); }
.summary-item strong { letter-spacing: -0.5px; }
.matchday-banner, .live-hero { border-radius: 20px; }
.notice { border-radius: 12px; }
.match-dialog, .slip-dialog { background: var(--surface); color: var(--ink); }
.dialog-header { background: var(--header-bg); border-color: var(--line); }
.match-dialog::backdrop { background: rgba(5, 12, 20, .55); }

/* Controls */
input, select, textarea { background: var(--surface); color: var(--ink); border-color: var(--line); }
.search-field, .select-field select, .slip-leg-body select, .slip-odds input, .slip-stake input { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.button.secondary:hover { background: var(--surface-2); }
.icon-button { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-button:hover { background: var(--surface-2); }
.segmented { background: var(--surface-2); border-radius: 12px; }
.segmented button { border-radius: 9px; color: var(--muted); }
.segmented button.selected { background: var(--surface); color: var(--green); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented button:hover { background: var(--surface-3); }

/* Fixture table: roomier rows and a clear leading probability. */
.forecast-table tbody tr { transition: background .15s; }
.forecast-table tbody tr:hover { background: var(--surface-2); }
.probability.leading { background: var(--accent-soft); color: var(--green); border-radius: 8px; padding: 3px 8px; }
.team-avatar { background: var(--surface-3); color: var(--ink); }
.team-avatar.away { background: var(--info-soft); color: var(--info); }

/* Sticky, translucent header with the theme switch. */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--header-bg); backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--line); }
.topbar-brand { display: none; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: .5px; color: var(--ink); }
.topbar-brand .brand-mark { width: 30px; height: 32px; font-size: 24px; border-radius: 10px 10px 3px 10px; padding-bottom: 4px; }
.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .when-light { display: none; }

/* Phone tab bar (hidden on wide screens). */
.tabbar { display: none; }
.more-sheet { display: none; }

@media (max-width: 900px) {
  :root { font-size: 15px; }
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .topbar { height: 58px; padding: 0 14px; gap: 10px; }
  .topbar-brand { display: inline-flex; }
  .topbar .breadcrumb, .topbar .date-label { display: none; }
  .topbar .account-area { margin-left: auto; }
  main { padding: 18px 14px 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--header-bg); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: 12px; font-size: 11px;
    font-weight: 600; color: var(--muted); background: none; }
  .tab svg { width: 21px; height: 21px; }
  .tab.active { color: var(--green); }
  .tab.active svg { background: var(--accent-soft); border-radius: 10px; padding: 3px 10px; width: 41px; height: 27px; }
  .more-sheet { position: fixed; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 41; min-width: 220px; padding: 8px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
  .more-sheet.open { display: grid; }
  .more-sheet a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; font-size: 14px; color: var(--ink); }
  .more-sheet a:hover, .more-sheet a.active { background: var(--surface-2); color: var(--green); }
  .slip-fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(146px + env(safe-area-inset-bottom)); z-index: 45; }  /* Above the tab bar and the accumulator button. */
  footer { padding-bottom: 12px; }
}

/* Hero banner text stays light on its dark green in both themes. */
.banner-copy p { color: #cfe3d6; }
.next-match-footer button { background: var(--lime); color: #143a2d; }
.next-match-footer button:hover { background: #ffffff; color: #143a2d; }

@media (max-width: 900px) {
  /* Header grows to a second row for the account buttons instead of overlapping the page. */
  .topbar { height: auto; min-height: 58px; flex-wrap: wrap; row-gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .topbar .account-area { order: 5; width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin: 0; }
  .topbar .account-area:empty { display: none; }
  .topbar .theme-toggle { margin-left: auto; }
  /* Matches first: drop desktop-only strips and shorten the banner on phones. */
  .live-entry, .heading-actions, .ai-engine-status { display: none !important; }
  .page-heading { margin-bottom: 14px; }
  .page-heading h1 { font-size: 30px; }
  .matchday-banner { min-height: 0; }
  .banner-copy h2 { font-size: 26px; }
  .banner-copy p, .banner-copy .banner-link { display: none; }
}

/* Speed on phones: blurred, see-through bars are repainted on every scroll frame and stutter on
   low-end devices, so touch screens and narrow windows get solid bars instead. */
@media (max-width: 900px), (hover: none) {
  .topbar, .tabbar, .dialog-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
}

/* Claude: the match preview and Ask Dalt. */
.ai-preview { border: 1px solid var(--accent-line); background: var(--accent-soft); }
.ai-preview h3 { display: flex; align-items: center; gap: 8px; }
.ai-preview h3 svg { width: 17px; height: 17px; color: var(--accent); }
.ai-preview-text p { margin: 0 0 10px; line-height: 1.65; }
.ai-preview-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: 12px; }
.ask-card h2 svg { width: 18px; height: 18px; margin-right: 6px; vertical-align: -3px; color: var(--accent); }
.ask-dialog { width: min(560px, calc(100vw - 24px)); }
.ask-dialog h2 { margin: 4px 0 10px; }
.ask-log { display: flex; flex-direction: column; gap: 10px; max-height: min(52vh, 460px); min-height: 140px; overflow-y: auto; padding: 4px 2px; overscroll-behavior: contain; }
.ask-bubble { max-width: 88%; padding: 10px 13px; border-radius: 14px; line-height: 1.55; font-size: 14px; overflow-wrap: anywhere; }
.ask-bubble p { margin: 0 0 8px; } .ask-bubble p:last-child { margin: 0; }
.ask-bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ask-bubble.assistant { align-self: flex-start; background: var(--surface-2, var(--accent-soft)); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ask-bubble.thinking { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.ask-bubble.thinking svg { width: 16px; height: 16px; animation: spin 1s linear infinite; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ask-chip { border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.ask-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.ask-form textarea { flex: 1; min-width: 0; resize: none; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.ask-foot { font-size: 12px; margin: 8px 0 0; }
.ask-locked { text-align: center; padding: 18px 8px; }
.ask-locked svg { width: 26px; height: 26px; color: var(--accent); }
.ask-locked p { margin: 6px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ask-bubble.thinking svg { animation: none; } }
.ask-dialog > h2, .ask-dialog .ask-log, .ask-dialog .ask-foot { padding-left: 22px; padding-right: 22px; }
.ask-dialog .ask-foot { padding-bottom: 18px; }
.ask-dialog { max-width: none; }
.ask-dialog .ask-form { display: flex; padding: 12px 22px 0; }

/* Older phones: repeated cards below the screen are not laid out or painted until scrolled near.
   Browsers without content-visibility simply ignore it. */
.live-card, .home-card, .saved-slip, .event-card, .league-card, .page-results, .history-item, .game-card {
  content-visibility: auto; contain-intrinsic-size: auto 260px;
}

/* Touch screens have no hover: colour transitions only cost work there. */
@media (hover: none) { button, a, .forecast-table tbody tr { transition: none; } }
/* Low-end phones (theme.js adds .lite): the cheapest drawing that still looks the same. */
html.lite *, html.lite *::before, html.lite *::after { transition: none !important; }  /* Spinners keep turning: they are cheap and show the app is working. */
html.lite .topbar, html.lite .tabbar, html.lite .dialog-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
html.lite .match-dialog, html.lite .slip-dialog, html.lite .home-card, html.lite .live-card, html.lite .event-card, html.lite .card { box-shadow: none; }
html.lite .match-dialog::backdrop { background: rgba(5, 12, 20, .6); }

/* Your call vs the crowd, divisions and the weekly recap (progress.js). */
.crowd-section h3 { display: flex; align-items: center; gap: 8px; }
.crowd-section h3 svg { width: 17px; height: 17px; color: var(--accent); }
.crowd-section .pick-row { margin: 6px 0 4px; }
.crowd-hint { font-size: 12px; margin: 0 0 10px; }
.crowd-row { display: grid; grid-template-columns: minmax(96px, 30%) 1fr auto; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.crowd-row .crowd-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line); }
.crowd-row .crowd-bar span { display: block; height: 100%; }
.crowd-row .crowd-bar .home { background: var(--accent); } .crowd-row .crowd-bar .draw { background: #9aa8a2; } .crowd-row .crowd-bar .away { background: #e0a43a; }
.crowd-nums { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 480px) { .crowd-row { grid-template-columns: 1fr auto; } .crowd-row .crowd-bar { grid-column: 1 / -1; grid-row: 2; } }
.division-head { display: flex; gap: 10px; align-items: center; }
.division-head svg { width: 26px; height: 26px; flex: none; }
.division.bronze .division-head svg { color: #b0763f; } .division.silver .division-head svg { color: #8f9aa3; }
.division.gold .division-head svg { color: #d4a017; } .division.diamond .division-head svg { color: #3fa9d6; }
.division-head small { display: block; }
.division-zone { font-size: 13px; margin: 8px 0; display: flex; gap: 6px; align-items: center; }
.division-zone svg { width: 15px; height: 15px; }
.division-zone.up { color: var(--accent); } .division-zone.down { color: #c2410c; }
.recap-line { margin: 0 0 6px; }

.lang-pick select { font: inherit; font-size: 12px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
/* The date filter row scrolls sideways on narrow phones instead of widening the page. */
.table-toolbar { min-width: 0; }
.table-toolbar .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.table-toolbar .segmented::-webkit-scrollbar { display: none; }
.table-toolbar .segmented button { flex: none; }

/* Event pages (events-pro.js): fight cards, questions, profiles, pool chart, receipts. */
.link-title { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.link-title:hover { color: var(--accent); text-decoration: underline; }
.card-faces { display: flex; gap: 6px; margin: 8px 0; }
.card-faces .event-face { width: 42px; height: 42px; }
.card-bouts { margin: 4px 0 10px; padding-left: 18px; font-size: 13px; }
.event-dialog { width: min(760px, calc(100vw - 24px)); }
.event-dialog #event-body { padding: 0 22px 22px; }
.event-dialog .event-cover { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 12px; }
.event-dialog h3 { margin: 22px 0 8px; font-size: 16px; }
.event-proof { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); margin: 10px 0; font-size: 14px; }
.event-proof svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.event-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bout { border-top: 1px solid var(--line); margin-top: 14px; }
.event-question { padding: 10px 0; }
.event-question h4 { margin: 0; font-size: 15px; }
.event-question .event-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.profile { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.profile img, .profile .event-face { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.profile small { display: block; }
.profile p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; }
.pool-chart { width: 100%; height: auto; max-height: 160px; background: var(--surface-2); border-radius: 10px; }
.pool-chart .grid { stroke: var(--line); stroke-dasharray: 4 4; }
.pool-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin-top: 6px; }
.pool-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.event-recent, .event-news { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.event-recent li, .event-news li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.event-news p { margin: 2px 0 0; }
.receipt-result { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.receipt-result svg { width: 18px; height: 18px; color: var(--accent); }
.receipt-rows > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.receipt-timeline { padding-left: 20px; font-size: 13px; }
.receipt-timeline li { margin: 5px 0; }
.stake-estimate small { display: block; margin-top: 4px; }
.stake-done { text-align: center; padding: 10px 4px; }
.stake-done > svg { width: 40px; height: 40px; color: var(--accent); }
.stake-done .form-actions { justify-content: center; }

/* Live predictions on every live match (live.js). */
.live-markets { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; margin-top: 8px; color: var(--muted); }
.live-markets strong { color: var(--ink); }
.live-markets svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.live-basis { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.live-basis .text-button svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
.live-trend { margin-top: 6px; }
.live-trend-chart { width: 100%; height: auto; max-height: 110px; background: var(--surface-2); border-radius: 8px; }
.live-trend-chart path { fill: none; stroke-width: 2; stroke-linejoin: round; }
.live-trend-chart .home { stroke: var(--accent); } .live-trend-chart .draw { stroke: #9aa8a2; } .live-trend-chart .away { stroke: #e0a43a; }
.live-trend-chart .goal-mark { stroke: var(--line-strong); stroke-dasharray: 3 3; }

.slip-clear { display: flex; justify-content: flex-end; margin: 0 0 6px; }
.slip-clear .text-button { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); }
.slip-clear svg { width: 14px; height: 14px; }

/* Slip builder: remove-weakest and smart slip (slip.js). */
:root[data-theme="dark"] :root[data-theme="dark"] .slip-tip { flex-wrap: wrap; }
.slip-tip .button { margin-left: auto; }
.slip-target { margin-top: 10px; font-size: 13px; }
.slip-target summary { cursor: pointer; color: var(--muted); }
