/* osu!PersonalTracker — dark-first, because osu! is and this sits next to the game. */
:root {
  /* Without this the browser paints native chrome for a light page: a pale scrollbar
     down every screen and a white menu when the sort dropdown opens. */
  color-scheme: dark;

  --bg:      #131019;
  --panel:   #1C1826;
  --panel-2: #241F31;
  /* The untouched share of every bar and ring. It used to be --panel-2, which is a
     surface colour: at 1.09:1 against the panel the largest number in the app was
     drawn as nothing at all. */
  --untouched: #4A4266;
  --untouched-edge: #6B6188;
  --line:    #322B42;
  --ink:     #EDE9F5;
  --muted:   #948CA8;

  --osu:    #F0559C;
  --taiko:  #F2764B;
  --fruits: #9BD64A;
  --mania:  #7B8CF5;

  --good: #3FB57A;
  --warn: #E3A93C;
  --crit: #EC6478;

  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--osu);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Page headings take tabindex="-1" so FocusOnNavigate can move focus to them on every
   route change. That focus is programmatic, never a user's tab stop, so it draws nothing. */
.mode-title:focus,
.mode-title:focus-visible { outline: none; }

.shell { max-width: 1180px; margin: 0 auto; padding: 0 24px 80px; }

/* ---------- nav ---------- */
.appnav {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 16px 0 14px; margin-bottom: 24px; border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--display); font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.brand span { color: var(--osu); }
.appnav nav { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.appnav nav a.active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--osu); padding-bottom: 3px; }
.appnav .spacer { flex: 1; }
.syncbadge { font-family: var(--mono); font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--good); flex: none; }
.pulse.stale { background: var(--warn); }
.pulse.failed { background: var(--crit); }
.pulse.unknown { background: var(--muted); }
a.syncbadge:hover { color: var(--ink); }

.live { color: var(--good); }
.refresh { margin-left: 10px; letter-spacing: 0; text-transform: none; }

/* ---------- stat strip ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin-bottom: 22px;
}
.stat { background: var(--panel); padding: 14px 16px; }
.stat .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stat .v { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); font-family: var(--body); }

/* ---------- dashboard: one panel per mode ---------- */
/* The ring, the bar and the legend used to live in two stacked sections sorted by
   different keys, so every mode appeared twice and the two orders could disagree. */
/* Two up on a wide screen: four modes should be one glance, not a scroll. */
.mode-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 14px; margin-bottom: 22px; }

.mode-panel { position: relative; overflow: hidden; }
.mode-panel::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--mc); }
.mode-panel .panel-title h2 a { color: var(--ink); }
.mode-panel .panel-title h2 a:hover { color: var(--mc); }

.mp-body { display: flex; align-items: center; gap: 18px; }
.mp-bars { flex: 1; min-width: 0; }
.mp-bars .seg-legend { margin-top: 11px; }

.ring { flex: none; }
.ring circle { fill: none; stroke-linecap: round; }
.ring .track { stroke: var(--untouched); }
.ring .fill { stroke: var(--mc); transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.6s ease; }
.ring text { font-family: var(--display); font-weight: 700; font-size: 15px; fill: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- ladder ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 17px; margin-bottom: 14px; }
.panel-title {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-title b { color: var(--ink); font-weight: 600; letter-spacing: 0.05em; }
.panel-title h2 { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; margin: 0; }
.bar {
  height: 13px; border-radius: 4px; background: var(--untouched); overflow: hidden; display: flex;
  /* Inset rather than a border so the bar keeps its height. Carries the bar's extent at
     3.06:1 — the fill alone cannot reach that without washing the whole panel out. */
  box-shadow: inset 0 0 0 1px var(--untouched-edge);
}
.bar i { display: block; height: 100%; transition: width 0.6s ease; }
.seg-legend { display: flex; flex-wrap: wrap; gap: 16px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 12px; }
.seg-legend span { display: inline-flex; align-items: center; gap: 7px; }
.seg-legend i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.seg-legend .qual { color: var(--muted); opacity: 0.8; }

/* The caveat that used to live in a title attribute, where touch and keyboard users
   never saw it. */
.footnote {
  font-size: 12px; line-height: 1.6; color: var(--muted);
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  max-width: 76ch;
}
.footnote b { color: var(--ink); font-weight: 600; }
/* The untouched swatch is the one legend marker with no hue to carry it. */
.seg-legend i.untouched { background: var(--untouched); box-shadow: inset 0 0 0 1px var(--untouched-edge); }

.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 0 7px 7px 0;
  background: var(--panel); padding: 14px 17px; margin-bottom: 20px; font-size: 13px; color: var(--muted);
}
.notice b { color: var(--ink); font-weight: 600; }

.loading { color: var(--muted); font-family: var(--mono); font-size: 13px; padding: 40px 0; }

#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  background: #C93A50; color: #fff; padding: 12px 16px; font-size: 13px;
}
#blazor-error-ui a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- browse ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 16px; }
.f-gap { width: 10px; }

.f {
  font-family: var(--mono); font-size: 11px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 5px;
  color: var(--muted); background: var(--panel); cursor: pointer; white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.f:hover:not(:disabled) { color: var(--ink); border-color: var(--mc, var(--muted)); }
.f:disabled { opacity: 0.4; cursor: default; }
.f.on { color: var(--bg); background: var(--mc, var(--ink)); border-color: var(--mc, var(--ink)); font-weight: 700; }
.f-search { flex: 1; min-width: 180px; text-align: left; cursor: text; }
select.f { cursor: pointer; }

.result-line { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.result-line .hint { color: var(--fruits); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }

.dt { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 780px; }
.dt th {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); text-align: left; padding: 12px 14px; font-weight: 500;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.dt td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dt tbody tr:last-child td { border-bottom: none; }
.dt tbody tr:hover { background: var(--panel-2); }
.dt .r { text-align: right; }
.dt .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt .dim { color: var(--muted); }

/* Announced, never shown: for columns whose visible label is a symbol. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.dt .empty { text-align: center; color: var(--muted); padding: 40px; font-family: var(--mono); font-size: 12px; }

.t-title { font-weight: 600; color: var(--ink); }
.t-title:hover { color: var(--osu); text-decoration: underline; }
.t-artist { font-size: 11px; color: var(--muted); margin-top: 2px; }

.chip {
  display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 3px; white-space: nowrap; border: 1px solid;
}
.chip.passed    { color: var(--good);  border-color: rgba(63,181,122,0.42);  background: rgba(63,181,122,0.12); }
.chip.attempted { color: var(--warn);  border-color: rgba(227,169,60,0.42);  background: rgba(227,169,60,0.12); }
.chip.prerank   { color: var(--crit);  border-color: rgba(236,100,120,0.42); background: rgba(236,100,120,0.12); }
.chip.untouched { color: var(--muted); border-color: var(--line);            background: transparent; }

.grade { font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: -0.02em; }
.g-x, .g-xh { color: #E9D27A; }
.g-s, .g-sh { color: #7FD8E8; }
.g-a { color: var(--good); }
.g-b { color: #A78BE0; }
.g-c { color: #E0A05A; }
.g-d { color: var(--crit); }

.mods { font-size: 11px; }
.mod, .mod-nf { display: inline-block; margin-right: 5px; }
.mod { color: var(--muted); }
.mod-nf { color: var(--warn); font-weight: 700; }

.pager { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: 11px; color: var(--muted); }
.pager-jump { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; margin: 0 6px; }
.pager-input {
  width: 74px; text-align: center; color: var(--ink);
  font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums;
}
.pager-input:focus { border-color: var(--osu); }
.result-line .range { color: var(--ink); }

/* ---------- mode detail ---------- */
.mode-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.mode-title { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -0.025em; margin: 0; }
.mode-sub { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
a.f { text-decoration: none; display: inline-block; }

.histo { display: flex; align-items: flex-end; gap: 8px; height: 165px; }
.histo-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; min-width: 0; }
.histo-pct { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; }
.histo-stack {
  display: flex; flex-direction: column-reverse; border-radius: 3px 3px 0 0; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--untouched-edge);
}
.histo-stack i { display: block; }
.histo-x { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.pace-big { font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: -0.025em; }
.pace-big span { font-size: 12px; font-weight: 500; color: var(--muted); font-family: var(--body); margin-left: 6px; }
.pace-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.7; }
.pace-none { font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.6; }

.nearly { display: flex; flex-direction: column; }
.nearly-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.nearly-row:last-child { border-bottom: none; }
.nearly-row:hover .nearly-title { color: var(--osu); }
.nearly-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nearly-count { font-family: var(--mono); font-size: 11px; color: var(--muted); flex: none; }

/* ---------- sync ---------- */
.budget { display: flex; gap: 3px; }
.budget i { flex: 1; height: 22px; border-radius: 2px; background: var(--untouched); display: block; }
.budget i.used { background: var(--good); }

.job {
  display: grid; grid-template-columns: minmax(130px, 1.4fr) 110px minmax(140px, 2fr) minmax(80px, 0.6fr);
  gap: 16px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line);
}
.job:last-child { border-bottom: none; }
.job-name { font-family: var(--mono); font-size: 12px; }
.job-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.job-prog { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.job-err { color: var(--crit); }
.job-when { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }

@media (max-width: 700px) {
  .job { grid-template-columns: 1fr auto; }
  .job > :nth-child(3), .job > :nth-child(4) { grid-column: 1 / -1; text-align: left; }
}

.cmds {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.9; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 14px 16px; margin: 0; overflow-x: auto;
}

/* ---------- badge builder ---------- */
.badge-stage {
  border: 1px solid var(--line); border-radius: 10px; padding: 22px;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.018) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.018) 75%) 0 0 / 18px 18px,
    var(--bg);
  display: flex; justify-content: center; overflow-x: auto;
}
/* The light badge is invisible against a light stage, so the stage flips with it. */
.badge-stage.on-light { background: #EFECF4; }
.badge-preview { display: block; max-width: 100%; height: auto; border-radius: 12px; }

/* Below the badge's own width, show it at 1:1 and let the stage scroll — shrunk to
   245px its labels are unreadable, which defeats the point of a preview. */
@media (max-width: 940px) {
  .badge-stage { justify-content: flex-start; }
  .badge-preview { max-width: none; }
}

.badge-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 14px; }
.badge-note { font-size: 12px; color: var(--muted); line-height: 1.65; margin-top: 12px; }
.badge-note b { color: var(--ink); font-weight: 600; }
.badge-note code { font-family: var(--mono); font-size: 11px; color: var(--ink); }

.badge-url { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.badge-url label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--muted); }
.badge-url input { flex: 1; min-width: 220px; color: var(--ink); font-family: var(--mono); }
.badge-url input:focus { border-color: var(--osu); }

.snippet {
  display: grid; grid-template-columns: 82px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.snippet:last-of-type { border-bottom: none; }
.snippet-k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.snippet-v {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sw {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line);
  cursor: pointer; padding: 0; background: var(--panel);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ink); }
.sw:first-child { width: auto; padding: 0 9px; }

@media (max-width: 640px) {
  .snippet { grid-template-columns: 1fr auto; }
  .snippet-k { grid-column: 1 / -1; }
}

/* A fine pointer keeps the dense layout; a coarse one gets targets it can hit. The nav
   grows its hit area with a pseudo-element so the underline stays against the text. */
@media (pointer: coarse) {
  .appnav nav { gap: 22px; }
  .appnav nav a { position: relative; }
  .appnav nav a::after { content: ""; position: absolute; inset: -12px -8px; }

  .f { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 14px; }
  .f-search { min-width: 100%; }

  .sw { width: 44px; height: 44px; }
  .sw:first-child { width: auto; padding: 0 14px; }

  .pager { gap: 18px; }
  .nearly-row { padding: 12px 0; }
  .snippet { gap: 12px; }
}

/* Every animation in this app is decorative — a bar sliding to its width, a ring
   sweeping to its percentage. Nothing is lost by arriving there instantly. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
