@font-face {
  font-family: "Inter";
  src: url("fonts/inter/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "LINE Seed JP";
  src: url("fonts/LINESeedJP-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "LINE Seed JP";
  src: url("fonts/LINESeedJP-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

html[data-theme=dark] {
  color-scheme: dark;
  --canvas: #121519;
  --surface: #191d22;
  --field: #252a31;
  --hover: #292f35;
  --line: #30363d;
  --outline: #515a62;
  --text: #e7ebee;
  --muted: #aab3bc;
  --accent: #9ddac7;
  --tinted: #25413a;
  --pico-font-family: "LINE Seed JP", sans-serif;
  --pico-font-size: 100%;
  --pico-border-radius: 6px;
  --pico-spacing: .75rem;
  --pico-form-element-spacing-vertical: .45rem;
  --pico-form-element-spacing-horizontal: .65rem;
  --pico-background-color: var(--canvas);
  --pico-color: var(--text);
  --pico-primary: var(--accent);
  --pico-form-element-background-color: var(--field);
  --pico-form-element-selected-background-color: var(--tinted);
  --pico-form-element-border-color: var(--outline);
  --pico-form-element-active-border-color: var(--accent);
  --pico-form-element-focus-color: transparent;
  --pico-form-element-color: var(--text);
  --pico-form-element-placeholder-color: var(--muted);
  --pico-box-shadow: none;
}
body { background: var(--canvas); color: var(--text); font-variant-numeric: tabular-nums; }
.mast {
  display: flex; align-items: stretch; gap: 48px; padding: 0 3vw;
  background: #171b20; border-bottom: 1px solid var(--line);
}
.mast b { display: flex; align-items: center; gap: 11px; font-size: 23px; letter-spacing: -.8px; line-height: 62px; }
.mast i {
  display: block; width: 25px; height: 21px; background: var(--accent);
  clip-path: polygon(0 100%,36% 0,56% 0,20% 100%,32% 100%,63% 14%,100% 100%,76% 100%,62% 61%,48% 100%);
}
.mast nav { gap: 6px; align-items: stretch; }
.mast button, .song, #columnHeaders button {
  margin: 0; background: transparent; color: inherit; border: 0; box-shadow: none;
}
.mast button { position: relative; padding: 0 14px; font-size: 14px; color: var(--muted); border-radius: 0; }
.mast button:hover { color: var(--text); background: var(--surface); }
.mast button[aria-pressed=true] { color: var(--accent); }
.mast button[aria-pressed=true]::after {
  content: ""; position: absolute; bottom: 0; height: 3px; left: 14px; right: 14px;
  background: var(--accent); border-radius: 3px 3px 0 0;
}
body > main { max-width: 1680px; margin: auto; padding: 22px 3vw; }
.workspace { display: grid; grid-template-columns: 228px minmax(0,1fr); gap: 24px; align-items: start; }
.filterbox { padding: 16px; background: var(--surface); border-radius: 10px; }
.filterbox summary { color: var(--text); font-weight: 700; }
.filterbox[open] > summary { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.filters { display: grid; gap: 15px; }
.filters [hidden] { display: none; }
label, legend { color: var(--muted); font-size: 13px; font-weight: 400; }
label, fieldset, select, input:not([type=checkbox]), legend { margin-bottom: 0 !important; }
input, select { font-size: 14px !important; }
.filters legend { margin-bottom: 5px !important; }
.choices, #chips, .tools, .pager, .dialogActions, .limits, .sortlabel { display: flex; align-items: center; gap: 8px; }
.choices, #chips { flex-wrap: wrap; gap: 5px; }
.choices button, #chips button, .pager button, .dialogActions button, #reset {
  margin: 0; padding: 5px 8px; background: transparent; border: 1px solid var(--outline);
  border-radius: 7px; color: var(--text); font-size: 13px; box-shadow: none;
}
.choices button:hover, .pager button:enabled:hover, .dialogActions button:enabled:hover, #reset:hover { background: var(--hover); }
.choices button[aria-pressed=true], #chips button, #detail #close {
  color: var(--accent); background: var(--tinted); border-color: var(--tinted);
}
.levels { display: grid; grid-template-columns: repeat(4,1fr); }
.limits input { min-width: 0; }
.check input { margin: 0 5px 0 0; }
.records { min-width: 0; }
.tools { justify-content: space-between; gap: 14px; flex-wrap: wrap; padding-bottom: 16px; }
.lookup { flex: 1; min-width: 180px; }
.lookup input { background-color: var(--field); border-color: transparent; border-radius: 24px; }
#results { font-size: 14px; color: var(--muted); white-space: nowrap; font-weight: 400; }
.sortlabel { white-space: nowrap; }
.sortlabel select { width: auto; margin: 0; }
#chips:not(:empty) { padding-bottom: 12px; }
.scroll { overflow: auto; background: var(--surface); border-radius: 8px; }
.records table { min-width: 805px; }
.records table, dialog table { font-size: 14px; margin: 0; }
.records th, .records td, dialog th, dialog td {
  padding: 10px; border-bottom: 1px solid var(--line); background: transparent; color: inherit;
}
.records th, dialog th { font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--field); color: var(--muted); }
.records tbody tr:hover, .records tbody tr:focus-within { background: var(--hover); }
#columnHeaders button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 0; font: inherit; }
#columnHeaders button::after { content: "↕"; font-family: sans-serif; }
#columnHeaders [aria-sort] button, .song:hover { color: var(--accent); }
#columnHeaders [aria-sort=ascending] button::after { content: "↑"; }
#columnHeaders [aria-sort=descending] button::after { content: "↓"; }
.song { font-size: 15px; font-weight: 700; padding: 2px 0; text-align: left; line-height: 1.35; }
.artist { display: block; font-size: 12px; color: var(--muted); }
.badge { display: inline-block; font: 650 13px/1.4 var(--pico-font-family); white-space: nowrap; }
.rate, .numeric, .border-score {
  font-family: "Inter", var(--pico-font-family);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: normal;
  white-space: nowrap;
}
.rate { font-weight: 600; }
.numeric { font-weight: 500; }
.pager, .dialogActions { justify-content: flex-end; margin-top: 14px; }
.pager span { font-size: 13px; color: var(--muted); }
button:disabled { opacity: .4; }
dialog::backdrop { background: #05070bbb; }
dialog article { width: min(760px,95vw); max-width: 95vw; padding: 24px; background: var(--surface); border: 1px solid var(--outline); border-radius: 14px; box-shadow: none; }
dialog h2 { margin: 8px 0 2px; }
dialog p { color: var(--muted); }
dialog .best td { font-weight: bold; color: var(--accent); background: var(--tinted); }
.detailTop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#detail #close { min-height: 44px; padding: 6px 14px; margin: 0; font-size: 14px; }
.score-row { cursor: pointer; }
.empty { text-align: center; padding: 32px !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:where(button,input,select,summary):focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 2px; }

@media (max-width:850px) {
  .workspace { grid-template-columns: 1fr; gap: 6px; }
  .filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mast { gap: 18px; }
  .lookup { flex-basis: 100%; }
  .records th, .records td { padding: 8px; }
  .records table { min-width: 760px; }
  .filters select { width: 100%; }
}
@media (max-width:500px) {
  body > main { padding: 12px 3vw; }
  .mast { justify-content: space-between; }
  .mast b { font-size: 19px; line-height: 54px; }
  .mast button { padding: 0 7px; font-size: 13px; }
  .tools { gap: 8px; }
  .records td:first-child { min-width: 145px; }
  dialog article { padding: 14px; }
  dialog td, dialog th { padding: 5px; font-size: 12px; }
  .pager { justify-content: center; }
}
#diff { display: flex; flex-wrap: wrap; }
#diff button { padding-inline: 7px; }


/* Atlas controls using the official Astryx Neutral theme tokens. */
html[data-astryx-theme=neutral] {
  --canvas: var(--color-background-body);
  --surface: var(--color-background-surface);
  --field: var(--color-background-muted);
  --hover: var(--color-overlay-hover);
  --line: var(--color-border);
  --outline: var(--color-border-emphasized);
  --text: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --accent: var(--color-text-accent);
  --tinted: var(--color-accent-muted);
  --pico-border-radius: var(--radius-element);
  --font-family-body: var(--pico-font-family);
  --font-family-heading: var(--pico-font-family);
}
[data-astryx-theme=neutral] .mast { background: var(--surface); }
[data-astryx-theme=neutral] .mast nav { align-items: center; }
[data-astryx-theme=neutral] .mast button { padding: 7px 12px; border-radius: var(--radius-element); }
[data-astryx-theme=neutral] .mast button[aria-pressed=true],
[data-astryx-theme=neutral] .choices button[aria-pressed=true],
[data-astryx-theme=neutral] #detail #close {
  background: var(--color-accent);
  color: var(--color-on-accent);
}
[data-astryx-theme=neutral] .mast button::after { display: none; }
[data-astryx-theme=neutral] .filterbox,
[data-astryx-theme=neutral] .scroll { border: 1px solid var(--line); border-radius: var(--radius-container); }
[data-astryx-theme=neutral] .lookup input { background-color: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius-element); }
[data-astryx-theme=neutral] .records td { padding-block: 7px; }

/* Recording editions, adapted from the official title artwork for dark surfaces. */
.version-28 { color: #9de0df; }
.version-29 { color: #ffad78; }
.version-30 { color: #97bcff; }
.version-31 { color: #e7ec70; }
.version-32 { color: #ff9ad7; }
.version-33 { color: #b0ec72; }
.version-34 { color: #dfa5ff; }
select option { background: var(--field); color: var(--text); }
#diff button { color: var(--difficulty); }
#diff button[aria-pressed=true] { background: var(--field); border-color: var(--difficulty); }
.BEGINNER, [data-value="BEGINNER"] { --difficulty: #8bdc9e; }
.NORMAL, [data-value="NORMAL"] { --difficulty: #90c9ff; }
.HYPER, [data-value="HYPER"] { --difficulty: #f6d16c; }
.ANOTHER, [data-value="ANOTHER"] { --difficulty: #ff949a; }
.LEGGENDARIA, [data-value="LEGGENDARIA"] { --difficulty: #d7a7ff; }
.badge { color: var(--difficulty); }
.grade-AAA { color: #ffe08a; }
.grade-AA { color: #b8dbff; }
.grade-A { color: #a2e3bd; }
.grade-B { color: #9edbdf; }
.grade-C { color: #c0b7eb; }
.grade-D { color: #e6b49e; }
.grade-E { color: #f6a9b3; }
.grade-F { color: #f19494; }
.records .lamp { display: block; font-size: 12px; }
.lamp { color: var(--muted); }
.lamp-failed { color: #ff939b; }
.lamp-assist-clear { color: #d6a0ff; }
.lamp-easy-clear { color: #88eaa3; }
.lamp-clear { color: #91bcff; }
.lamp-hard-clear { color: #f0f1f3; }
.lamp-ex-hard-clear { color: #ffca75; }
.lamp-fullcombo-clear { color: #9cecea; }

.border-score { color: var(--muted); font-size: 14px; font-weight: 500; line-height: 1.45; }
td > .border-score { display: block; }

.score-label { display: none; }

/* Reflow the same score records on narrow screens. The sort menu stays available. */
@media (max-width: 760px) {
  .records table, #detailBody table { display: block; width: 100%; min-width: 0; }
  .records thead, #detailBody thead { display: none; }
  .records tbody, #detailBody tbody { display: block; }
  .records tbody tr, #detailBody tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 3px 10px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }
  .records tbody tr { grid-template-areas: "song rate" "chart score" "edition status" "gap status"; }
  .records tbody td, [data-astryx-theme=neutral] .records tbody td, #detailBody tbody td {
    min-width: 0; padding: 0; border: 0;
  }
  .records tbody td:nth-child(1) { grid-area: song; }
  .records tbody td:nth-child(2) { grid-area: chart; }
  .records tbody td:nth-child(3) { grid-area: score; text-align: right; }
  .records tbody td:nth-child(4) { grid-area: rate; text-align: right; }
  .records tbody td:nth-child(5) { grid-area: status; text-align: right; }
  .records tbody td:nth-child(6) { grid-area: edition; }
  .records tbody td:nth-child(7) { grid-area: gap; color: var(--muted); }
  .records tbody td.empty { grid-column: 1 / -1; }
  .score-row { position: relative; isolation: isolate; }
  .score-row .song::after { content: ""; position: absolute; inset: 0; z-index: 1; touch-action: manipulation; }
  .song { font-size: 16px; overflow-wrap: anywhere; }
  .records .artist, #detailBody h2, #detailBody p { overflow-wrap: anywhere; }
  .records .rate { font-size: 18px; }
  .records td.numeric { font-size: 14px; }
  .records td:nth-child(6) { font-size: 13px; }
  .numeric .score-label {
    display: inline; margin-inline-end: .35em; color: var(--muted);
  }
  /* Pico vertically centers inline elements. Text runs in score rows share a baseline. */
  .records td :is(span,button), #detailBody :is(td,strong) span {
    vertical-align: baseline;
  }
  .records .lamp { display: block; }
  .tools select, .dialogActions button, .pager button { min-height: 40px; }
  .sortlabel select { max-width: 58vw; }

  #detailBody tbody tr {
    grid-template-areas: "edition rate" "ex rate" "grade lamp";
    padding: 9px 4px;
  }
  #detailBody td:nth-child(1) { grid-area: edition; font-size: 14px; }
  #detailBody td:nth-child(2) { grid-area: ex; }
  #detailBody td:nth-child(3) { grid-area: rate; text-align: right; }
  #detailBody td:nth-child(4) { grid-area: grade; }
  #detailBody td:nth-child(5) { grid-area: lamp; text-align: right; }
  #detailBody tr.best { background: var(--tinted); }
  #detailBody tr.best td { background: transparent; }
  #detail article {
    display: flex; flex-direction: column; overflow: hidden;
    max-height: 92dvh; margin: 0; padding: 0;
  }
  .detailTop { padding: 6px 14px; border-bottom: 1px solid var(--line); }
  #detailScroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px; }
  .detailTop { flex: none; }
  .dialogActions {
    justify-content: space-between; margin-top: 8px; padding-bottom: env(safe-area-inset-bottom);
  }
  .dialogActions button { min-height: 44px; border: 0; background: transparent; }
}

.profile-controls { margin-left: auto; align-self: center; display: flex; gap: 6px; }
.profile-controls select { width: auto; margin: 0; }
.profile-controls #playStyle { width: 64px; }
.version-27 { color: #9abaff; }
@media (max-width: 700px) {
  .mast { flex-wrap: wrap; }
  .mast nav { margin-left: auto; }
  .profile-controls { width: 100%; justify-content: flex-end; padding-bottom: 8px; }
}
.mast [hidden] { display: none; }
@media (max-width: 500px) {
  .mast { gap: 4px; }
  .mast nav { gap: 0; }
  [data-astryx-theme=neutral] .mast button { padding-inline: 6px; }
}

.mast #themeToggle { padding: 5px 10px; border: 1px solid var(--outline); border-radius: 7px; }
.mast #themeToggle::after { display: none; }
.profile-controls { flex-wrap: wrap; }
@media (max-width: 700px) {
  .profile-controls #player { flex: 1; min-width: 0; }
}

#buildRevision { color: var(--muted); font: 500 12px/1.4 "Inter",sans-serif; letter-spacing: 0; text-decoration: none; }
#buildRevision:hover, #buildRevision:focus-visible { color: var(--accent); text-decoration: underline; }

.score-trend { --axis-width: 3.1rem; margin: 16px 0 20px; padding: 12px 0 0; border-block: 1px solid var(--line); }
.score-trend figcaption { padding: 0; color: var(--text); font-size: 14px; font-weight: 700; }
.trend-plot { position: relative; height: 128px; margin: 17px 0 0 var(--axis-width); cursor: pointer; }
.trend-gridline { position: absolute; width: 100%; border-top: 1px solid var(--line); }
.trend-gridline span { position: absolute; right: calc(100% + 7px); transform: translateY(-50%); color: var(--muted); font: 12px/1.2 Inter,sans-serif; font-variant-numeric: tabular-nums; }
.trend-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trend-plot path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.trend-point { position: absolute; transform: translate(-50%,-50%); height: 6px; width: 6px; border-radius: 50%; background: var(--accent); }
.trend-point.peak { height: 10px; width: 10px; border: 2px solid var(--accent); background: var(--surface); }
.trend-editions { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); margin-left: var(--axis-width); }
.trend-editions button { padding: 4px 0; margin: 0; min-height: 36px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font: 13px Inter,sans-serif; box-shadow: none; }
.trend-editions button[aria-pressed=true] { color: var(--text); text-decoration: underline; text-underline-offset: 4px; font-weight: 700; }
.trend-readout { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.trend-readout small { color: var(--muted); }

@media (display-mode: standalone), (display-mode: fullscreen) {
  html { scroll-padding-top: 68px; }
  .mast { position: sticky; top: 0; z-index: 2; }

  @media (max-width: 700px) {
    html { scroll-padding-top: 52px; }
    .mast { display: contents; }
    .mast b, .mast nav, .profile-controls {
      padding-inline: 3vw;
      background: var(--surface);
    }
    .mast nav {
      position: sticky; top: 0; z-index: 2;
      justify-content: flex-start; height: 44px;
      border-bottom: 1px solid var(--line);
    }
    .mast nav button { height: 100%; }
    .profile-controls { padding-block: 8px; }
  }
}
