/* ---------- Load states ---------- */

.state-panel {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  max-width: 720px;
  margin: 80px auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.state-panel strong {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
}

.state-panel p {
  margin: 0;
  color: var(--ink-2);
}

.loading-pulse,
.error-mark {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 11px;
}

/* The brand's rising bars, breathing while history is aggregated. */
.loading-pulse {
  padding: 10px 0;
  background:
    linear-gradient(#fff, #fff) 12px 100% / 4px 40% no-repeat content-box,
    linear-gradient(#fff, #fff) 18px 100% / 4px 65% no-repeat content-box,
    linear-gradient(var(--event), var(--event)) 24px 100% / 4px 95% no-repeat content-box,
    var(--ink);
  animation: loading-bars 1.2s ease-in-out infinite;
}

@keyframes loading-bars {
  0%,
  100% { background-size: 4px 40%, 4px 65%, 4px 95%; }
  33% { background-size: 4px 75%, 4px 40%, 4px 60%; }
  66% { background-size: 4px 55%, 4px 95%, 4px 40%; }
}

.error-mark {
  color: #fff;
  background: #d6404a;
  font-size: 22px;
  font-weight: 800;
}

.error-panel { border-color: rgba(214, 64, 74, 0.3); }

.error-help {
  margin-top: 7px !important;
  font-size: var(--fs-body);
}

/* ---------- Panels ---------- */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px 12px;
}

/* Japanese title first; the English kicker trails as a quiet index label. */
.panel-header > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 10px;
  min-width: 0;
}

.panel-header h2 {
  order: -1;
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.data-basis,
.panel-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
  background: var(--surface-2);
  font-size: var(--fs-meta);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-tooltip {
  position: absolute;
  z-index: 8;
  min-width: 118px;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(21, 27, 36, 0.95);
  box-shadow: 0 10px 24px rgba(21, 27, 36, 0.24);
  pointer-events: none;
  font-size: var(--fs-meta);
  line-height: 1.5;
}

.chart-tooltip strong,
.chart-tooltip span { display: block; }

.chart-tooltip strong {
  font-family: var(--font-num);
  font-size: var(--fs-control);
  font-weight: 600;
}

.chart-tooltip span { color: rgba(255, 255, 255, 0.74); }

.tooltip-score-update { color: #ffb37a !important; font-weight: 800; }
.tooltip-lamp-update { color: #d2bcff !important; font-weight: 800; }
.tooltip-bp-update { color: #9fe3e8 !important; font-weight: 800; }

.chart-empty {
  position: absolute;
  inset: 18px 20px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  color: var(--ink-3);
  background: rgba(246, 247, 249, 0.72);
  font-size: var(--fs-control);
  font-weight: 700;
}

.level-empty,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  color: var(--ink-3);
  text-align: center;
}

.level-empty strong,
.empty-state strong { color: var(--ink-2); }

.level-empty span,
.empty-state span {
  margin-top: 4px;
  font-size: var(--fs-control);
}

/* ---------- Period summary band ---------- */

/* One surface: four period metrics and a subordinate data-quality cell. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(250px, 0.9fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.kpi-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  min-width: 0;
  padding: 14px 20px 13px;
}

.kpi-card + .kpi-card { border-left: 1px solid var(--line); }

.kpi-topline {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 18px;
}

/* Activity metrics need no mark; the two achievement metrics reuse their in-list symbols. */
.kpi-icon { display: none; }

.kpi-score .kpi-icon,
.kpi-lamp .kpi-icon {
  display: block;
  flex: 0 0 auto;
  font-size: 0;
}

.kpi-score .kpi-icon {
  width: 9px;
  height: 8px;
  background: var(--event);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.kpi-lamp .kpi-icon {
  width: 16px;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(90deg, #389b47 0 25%, #2a82d2 25% 50%, #d6404a 50% 75%, #e2a500 75%);
}

.kpi-label {
  color: var(--ink-2);
  font-size: var(--fs-control);
  font-weight: 700;
}

.kpi-value {
  display: block;
  margin: 8px 0 6px;
  font-family: var(--font-num);
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Activity is context; the two achievement counts lead by one ink step. */
.kpi-play .kpi-value,
.kpi-keys .kpi-value { color: var(--ink-2); }

.kpi-value small {
  margin-left: 5px;
  color: var(--ink-3);
  font-family: var(--font-ui);
  font-size: var(--fs-control);
  font-weight: 700;
  letter-spacing: 0;
}

.kpi-compare {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
  color: var(--ink-2);
  font-size: var(--fs-meta);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-compare::before {
  content: "−";
  display: grid;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-3);
  background: var(--surface-3);
  font-size: var(--fs-micro);
  font-weight: 800;
}

/* No previous period: a quiet scope caption, not a "no change" trend. */
.kpi-compare[data-trend="none"] {
  color: var(--ink-3);
  font-weight: 500;
}

.kpi-compare[data-trend="none"]::before { content: none; }
.kpi-compare[data-trend="up"]::before { content: "↑"; color: #1d7a4e; background: #e3f4ea; }
.kpi-compare[data-trend="down"]::before { content: "↓"; color: var(--ink-2); background: var(--surface-3); }

/* Daily keystroke goal reached (直近の取り組み / 日): a small lit HUD tag at the card's upper
   right and a thin goal-coloured edge light. The celebration plays once on top of this
   state: the figure's characters ripple, then a restrained spark burst. */
.kpi-goal-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 0 8px;
  border: 1px solid #fff0f1;
  border-radius: 3px;
  color: #ffffff;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, #ff7a86, #e0424f 55%, #b92338);
  box-shadow:
    0 0 0 1px rgba(184, 35, 56, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 0 9px rgba(240, 70, 90, 0.45);
  font-size: var(--fs-meta);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 0 6px rgba(255, 220, 225, 0.8), 0 1px 1px rgba(90, 0, 15, 0.35);
  white-space: nowrap;
}

.kpi-goal-badge[hidden] { display: none; }

.kpi-keys.is-goal-achieved .kpi-value { color: var(--ink); }

.kpi-keys.is-goal-achieved::before {
  content: "";
  position: absolute;
  top: 0;
  right: 14px;
  left: 14px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, transparent, #e0424f 22%, #ff9a3c 78%, transparent);
  box-shadow: 0 0 8px rgba(240, 70, 90, 0.5);
  pointer-events: none;
}

.kpi-keys .kpi-value { position: relative; }

.goal-wave > span { display: inline-block; }

.kpi-keys.is-goal-celebrating .goal-wave > span {
  animation: goal-char-wave 440ms cubic-bezier(0.2, 0.8, 0.2, 1) calc(var(--i) * 34ms) both;
}

.goal-burst {
  position: absolute;
  top: 45%;
  left: calc(var(--n, 6) * 0.29em);
  width: 0;
  height: 0;
  pointer-events: none;
}

.goal-burst i {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 28%, #ffb52e 52%, rgba(255, 181, 46, 0) 74%);
  box-shadow: 0 0 5px rgba(255, 170, 60, 0.55);
  opacity: 0;
}

.goal-burst i:nth-child(3n) { background: radial-gradient(circle, #ffffff 0 30%, #ff5d6c 55%, rgba(255, 93, 108, 0) 72%); }

.kpi-keys.is-goal-celebrating .goal-burst i {
  animation: goal-particle 640ms cubic-bezier(0.15, 0.7, 0.3, 1) calc(360ms + var(--k) * 9ms) both;
}

.kpi-keys.is-goal-celebrating .kpi-goal-badge {
  animation: goal-badge-snap 380ms cubic-bezier(0.3, 1.5, 0.5, 1) 380ms both;
}

@keyframes goal-char-wave {
  0% { transform: none; }
  38% { transform: translateY(-7px) scale(1.1); color: #e0424f; text-shadow: 0 0 12px rgba(255, 130, 100, 0.65); }
  72% { transform: translateY(1px); }
  100% { transform: none; }
}

@keyframes goal-particle {
  0% { opacity: 0; transform: rotate(var(--a)) translateX(6px) scale(0.7); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(calc(var(--d) + 14px)) scale(0.4); }
}

@keyframes goal-badge-snap {
  0% { opacity: 0; transform: translate(8px, -3px) scale(0.55); filter: brightness(1.6); }
  60% { opacity: 1; transform: scale(1.08); filter: brightness(1.3); }
  100% { opacity: 1; transform: none; filter: none; }
}

/* Result/detection ratio is data-quality context, so it reads quieter than the outcomes. */
.kpi-capture {
  grid-template-rows: auto auto auto auto;
  gap: 6px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background: var(--surface-2);
}

.capture-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.capture-copy span {
  color: var(--ink-3);
  font-size: var(--fs-meta);
  font-weight: 700;
}

.capture-copy strong {
  color: var(--ink-2);
  font-family: var(--font-num);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.capture-track {
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-3);
}

.capture-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--ink-4);
  transition: width 400ms var(--ease);
}

.capture-card small {
  color: var(--ink-3);
  font-size: var(--fs-meta);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-notice {
  position: static;
  margin: 0;
}

.data-notice summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: var(--fs-meta);
  font-weight: 700;
  list-style: none;
}

.data-notice summary::-webkit-details-marker { display: none; }

.data-notice summary:hover span:last-child {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.notice-mark {
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 1px solid var(--ink-4);
  border-radius: 50%;
  color: var(--ink-2);
  font-family: var(--font-num);
  font-size: var(--fs-micro);
  font-weight: 700;
}

.data-notice p {
  position: absolute;
  z-index: 15;
  top: calc(100% + 6px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-control);
  line-height: 1.65;
}

/* ---------- Personal bests ---------- */

.updates-panel,
.songs-panel { margin-top: 12px; }

.updates-heading { align-items: center; }

.updates-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.updates-reset {
  min-height: 28px;
  padding: 0 10px;
  font-size: var(--fs-meta);
}

.updates-speed-toggle,
.speed-results-heading label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: var(--fs-meta);
  font-weight: 700;
  white-space: nowrap;
}

.updates-speed-toggle input,
.speed-results-heading input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.achievement-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

/* The column is the positioning box for its filter toggle, which sits inside the header
   row: a closed filter costs no row of its own. */
.achievement-column {
  position: relative;
  min-width: 0;
}

.achievement-column + .achievement-column { border-left: 1px solid var(--line); }

.achievement-column-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 104px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.achievement-column-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink-2);
  font-family: var(--font-num);
  font-size: var(--fs-control);
  font-weight: 700;
  letter-spacing: 0.14em;
}

/* The column symbols repeat the KPI marks: ▲ for scores, the lit lamp spectrum for lamps. */
.achievement-column-header h3 span {
  display: block;
  width: 9px;
  height: 8px;
  font-size: 0;
  background: var(--event);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.lamp-achievements .achievement-column-header h3 span {
  width: 16px;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(90deg, #2fa345 0 25%, #168fff 25% 50%, #e03a4a 50% 75%, #f2b400 75%);
  box-shadow: 0 0 6px rgba(155, 123, 255, 0.45);
  clip-path: none;
}

.achievement-column-header strong {
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.achievement-filter-details { background: var(--surface); }

.achievement-filter-details[open] { border-bottom: 1px solid var(--line); }

.achievement-filter-details > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 16px;
  color: var(--ink-3);
  cursor: pointer;
  font-size: var(--fs-meta);
  font-weight: 700;
  list-style: none;
  user-select: none;
  transition: color 140ms var(--ease), background-color 140ms var(--ease);
}

/* The toggle rides on the column header (absolute within .achievement-column). */
.achievement-filter-details > summary {
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 8px;
  height: 26px;
  min-height: 0;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 7px;
}

.achievement-filter-details > summary:hover,
.achievement-filter-details[open] > summary {
  border-color: var(--line-2);
  background: var(--surface);
}

.achievement-filter-details > summary::-webkit-details-marker { display: none; }

.achievement-filter-details > summary::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms var(--ease);
}

.achievement-filter-details[open] > summary::before { transform: rotate(45deg); }

/* A fold that is closing (app.js keeps [open] until its motion ends) already shows the closed
   toggle, so the control answers the click at once. */
.achievement-filter-details[open][data-fold="closing"] > summary::before { transform: rotate(-45deg); }

/* While a fold moves (app.js sets the class for the length of the motion) the records panel
   below it rides its own compositor layer, so the per-frame shift moves the layer instead of
   repainting its rows. */
.is-fold-moving .songs-panel { will-change: transform; }

.achievement-filter-details > summary:hover { color: var(--ink); }

.achievement-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 14px 9px;
  background: var(--surface-2);
}

.achievement-filterbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  color: var(--ink-3);
  font-size: var(--fs-meta);
  font-weight: 700;
  white-space: nowrap;
}

.achievement-filterbar select {
  min-width: 0;
  max-width: 150px;
  height: 28px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  color: var(--ink);
  font-size: var(--fs-meta);
  font-weight: 700;
}

.achievement-filterbar input[type="number"] {
  width: 56px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--font-num);
  font-size: var(--fs-control);
}

.achievement-filter-check input {
  width: 14px;
  height: 14px;
  margin: 0;
}

/* Twelve dense rows fit before the list scrolls. */
.achievement-list {
  max-height: 556px;
  overflow: auto;
}

.achievement-columns.show-all .achievement-list {
  max-height: none;
  overflow: visible;
}

.achievement-empty {
  display: grid;
  min-height: 96px;
  place-content: center;
  color: var(--ink-3);
  font-size: var(--fs-control);
  text-align: center;
}

/* Identity column | title & when | what changed. */
.achievement-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 4px 14px 4px 16px;
  border-bottom: 1px solid var(--line);
  /* Keep app.js LIVE_MOTION_CONTAINERS in sync with this paint-contained row. */
  content-visibility: auto;
  contain-intrinsic-size: auto 46px;
  transition: background-color 120ms var(--ease);
}

.achievement-row:last-child { border-bottom: 0; }

/* Row window: stand-ins for rows outside the viewport (heights are set inline). A spacer is
   never a scroll anchor, or resizing it would pull the scroll position with it. */
.row-window-spacer,
.row-window-spacer > td { padding: 0; border: 0; background: none; overflow-anchor: none; }
/* Collapsed rows still size the columns but take no height and are not interactive. */
.songs-table tbody.row-window-sizers > tr { visibility: collapse; }
.songs-table tbody tr.row-window-spacer > td,
.songs-table tbody tr.row-window-spacer:hover > td { position: static; padding: 0; border: 0; background: none; }

.achievement-row:hover { background-color: var(--surface-2); }

/* An achievement row (and a lamp-history card) takes the light of what it reached: a lamp
   strip on its left edge (the song-bar lamp of a music select screen) and a wash spilling
   from its lit label on the right. The weight classes set in app.js decide how strong both
   are. */
:is(.achievement-row, .lamp-update-event).is-weighted::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--light);
  box-shadow: 0 0 6px color-mix(in srgb, var(--light) 70%, transparent);
}

:is(.achievement-row, .lamp-update-event).weight-1::before {
  opacity: 0.5;
  box-shadow: none;
}

:is(.achievement-row, .lamp-update-event).weight-2 {
  background-image: linear-gradient(90deg, transparent 55%, color-mix(in srgb, var(--light) 9%, transparent));
}

:is(.achievement-row, .lamp-update-event).weight-3 {
  background-image:
    linear-gradient(90deg, color-mix(in srgb, var(--light) 7%, transparent), transparent 22%),
    linear-gradient(90deg, transparent 45%, color-mix(in srgb, var(--light) 15%, transparent));
}

:is(.achievement-row, .lamp-update-event).weight-3::before,
:is(.achievement-row, .lamp-update-event).weight-4::before,
:is(.achievement-row, .lamp-update-event).weight-5::before {
  width: 4px;
  box-shadow: 0 0 10px color-mix(in srgb, var(--light) 80%, transparent);
}

:is(.achievement-row, .lamp-update-event).weight-4 {
  background-image:
    linear-gradient(90deg, color-mix(in srgb, var(--light) 10%, transparent), transparent 26%),
    linear-gradient(90deg, transparent 38%, color-mix(in srgb, var(--light) 19%, transparent));
}

/* FULL COMBO and MAX light in the spectrum; PERFECT in gold. */
:is(.achievement-row, .lamp-update-event).lamp-fullcombo.is-weighted::before,
:is(.achievement-row, .lamp-update-event).rank-max.is-weighted::before {
  background: linear-gradient(180deg, #ff8fa2, #ffd45e 30%, #8fe07a 52%, #6fcaf5 74%, #b39bff);
}

:is(.achievement-row, .lamp-update-event).lamp-fullcombo.weight-4,
:is(.achievement-row, .lamp-update-event).rank-max.weight-5 {
  background-image:
    linear-gradient(90deg, rgba(255, 143, 162, 0.1), transparent 24%),
    linear-gradient(90deg, transparent 36%, rgba(255, 212, 94, 0.1) 55%, rgba(111, 202, 245, 0.14) 78%, rgba(179, 155, 255, 0.2));
}

:is(.achievement-row, .lamp-update-event).lamp-perfect.weight-5 {
  background-image:
    linear-gradient(90deg, rgba(242, 176, 0, 0.14), transparent 26%),
    linear-gradient(90deg, transparent 34%, rgba(255, 214, 90, 0.2) 70%, rgba(255, 196, 30, 0.3));
}

:is(.achievement-row, .lamp-update-event).lamp-perfect.weight-5::before {
  width: 5px;
  background: linear-gradient(180deg, #fff3b0, #f6c21a 45%, #e8a800);
  box-shadow: 0 0 12px rgba(255, 194, 26, 0.85);
}

:is(.achievement-row, .lamp-update-event).rank-max.weight-5::before {
  width: 5px;
  box-shadow: 0 0 12px rgba(169, 139, 255, 0.8);
}

.achievement-level {
  display: grid;
  justify-items: start;
  gap: 2px;
  color: var(--difficulty, var(--ink));
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.achievement-level small {
  color: var(--ink-3);
  font-size: var(--fs-micro);
  font-weight: 700;
  white-space: nowrap;
}

.achievement-main { min-width: 0; }

.achievement-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.song-title-button {
  max-width: 420px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--ink);
  background: transparent;
  font-size: var(--fs-body);
  font-weight: 700;
  text-align: left;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 140ms var(--ease);
}

.song-title-button:hover {
  text-decoration: underline;
  text-decoration-color: var(--ink-4);
}

/* The title stays ink; its chart code (SPA, SPH, SPL …) carries the difficulty colour so a
   chart is recognised at a glance in dense lists. */
.song-title-button em {
  color: var(--difficulty-text, var(--difficulty, var(--ink-3)));
  font-size: var(--fs-micro);
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.song-title-button b {
  color: var(--ink-2);
  font-family: var(--font-num);
  font-size: var(--fs-micro);
  font-weight: 600;
}

/* Only the title text truncates; the chart code (SPA, DPH …) always stays visible. */
.achievement-title-line .song-title-button {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: baseline;
  gap: 0.35em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.achievement-title-line .song-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-title-line .song-title-button em { flex: 0 0 auto; }

/* When and how is supporting metadata: one quiet line under the title. */
.achievement-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: var(--fs-meta);
  line-height: 1.3;
  white-space: nowrap;
}

.achievement-meta time {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.achievement-value { text-align: right; }

.score-achievement-value {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 190px;
  min-height: 30px;
  white-space: nowrap;
}

/* Score update: old → new on one baseline, the gain above the arrow, and the new score's
   rate/rank delta on its own line underneath (never overlapping the old score). */
.score-transition {
  display: grid;
  grid-template-columns: minmax(44px, max-content) 40px minmax(52px, max-content);
  align-items: end;
  justify-content: end;
  padding-bottom: 12px;
  color: var(--ink);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.score-transition b { font: inherit; }

.score-transition > .score-before {
  padding-bottom: 1px;
  color: var(--ink-3);
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  text-align: right;
}

.score-arrow {
  display: grid;
  grid-template-rows: 11px 10px;
  place-items: center;
  width: 40px;
  padding-bottom: 2px;
}

.achievement-value .score-arrow small {
  color: var(--event-ink);
  font-family: var(--font-num);
  font-size: var(--fs-meta);
  font-weight: 700;
  line-height: 1;
}

.score-arrow i {
  color: var(--ink-4);
  font-size: var(--fs-meta);
  font-style: normal;
  line-height: 1;
}

.score-transition > .detail-score-stack {
  position: relative;
  display: block;
  min-width: 52px;
}

.score-transition > .detail-score-stack > strong {
  display: block;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  text-align: right;
}

.score-transition > .detail-score-stack > .score-secondary {
  position: absolute;
  top: calc(100% + 1px);
  right: 0;
}

.score-transition > .detail-score-stack > .score-secondary > * { font-size: var(--fs-unit); }

/* A MAX score is printed in the spectrum it earned. */
.achievement-row.rank-max.weight-5 .score-transition > .detail-score-stack > strong {
  color: transparent;
  background: linear-gradient(100deg, #e8456e, #e5a100 30%, #2fb35e 52%, #1f9bd8 74%, #7a55e6);
  -webkit-background-clip: text;
  background-clip: text;
}

.lamp-achievement-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 250px;
  white-space: nowrap;
}

.lamp-achievement-metrics > small {
  color: var(--ink-3);
  font-size: var(--fs-micro);
}

.lamp-achievement-metrics .speed-update-note { order: -3; }

/* Unlit earlier state → lit new state; both labels share one width so arrows align down the list. */
.lamp-achievement-metrics > strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-4);
  font-weight: 400;
}

.lamp-achievement-metrics > strong > .lamp-pill { min-width: 84px; }

.speed-update-note {
  order: -2;
  color: var(--ink-3);
}


/* Optional provider progress: counted fractions only, otherwise a moving marker or an unfilled track. */
.load-progress { min-width: 320px; }
.state-panel .load-progress-stage { color: var(--ink); }
.state-panel .load-progress-elapsed { font-variant-numeric: tabular-nums; }
.load-progress-bar { height: 5px; margin-top: 10px; overflow: hidden; background: var(--line-2); border-radius: 3px; }
.load-progress-bar span { display: block; height: 100%; background: var(--ink); }
.load-progress-bar.is-indeterminate span { width: 28%; animation: load-progress-slide 1.8s linear infinite; }
@keyframes load-progress-slide { from { transform: translateX(-100%); } to { transform: translateX(358%); } }
@media (prefers-reduced-motion: reduce) { .load-progress-bar.is-indeterminate span { display: none; width: 0; animation: none; } }

/* ---------- Achievement share (X) ---------- */

/* A quiet action in the 更新成果 bar: same weight as its neighbours, never a call-to-action colour. */
.share-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink-2);
  background: var(--surface);
  font-size: var(--fs-meta);
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}
.share-button svg { width: 13px; height: 13px; flex: none; }
.share-button:hover:not(:disabled) { border-color: var(--ink-4); color: var(--ink); background: var(--surface-2); }
.share-button:disabled { opacity: 0.5; cursor: default; }
.share-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* The production rows a share card reads its colours from: laid out, never seen. */
.share-row-holder { position: fixed; top: 0; left: -10000px; width: 560px; visibility: hidden; pointer-events: none; }

.share-dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.share-dialog[open] { display: flex; flex-direction: column; }
.share-dialog::backdrop { background: rgba(21, 27, 36, 0.28); }
.share-dialog > header { display: flex; flex: none; align-items: center; justify-content: space-between; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.share-dialog > header > div { display: grid; gap: 2px; }
.share-dialog h2 { margin: 0; font-size: 17px; }
.share-close { width: 32px; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink-2); background: var(--surface); font-size: 18px; line-height: 1; }
.share-close:hover { color: var(--ink); background: var(--surface-2); }
.share-body { display: grid; gap: 12px; min-height: 0; padding: 14px 16px; overflow: auto; overscroll-behavior: contain; }
.share-preview { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.share-status { min-height: 1.5em; margin: 0; color: var(--ink-2); font-size: var(--fs-body); font-weight: 700; line-height: 1.5; }
.share-status[data-tone="ok"] { color: #1d6b2b; }
.share-status[data-tone="warn"] { color: var(--event-ink); }
.share-text-field { display: grid; gap: 4px; color: var(--ink-3); font-size: var(--fs-meta); font-weight: 700; }
.share-text-field textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; resize: vertical; border: 1px solid var(--line-2); border-radius: var(--radius-sm); color: var(--ink); background: var(--surface); font: 500 var(--fs-body)/1.55 var(--font-ui); }
/* The whole post text stays readable when the tags wrap on a phone; rows="5" where unsupported. */
@supports (field-sizing: content) {
  .share-text-field textarea { field-sizing: content; min-height: calc(4lh + 18px); max-height: calc(9lh + 18px); }
}
.share-steps { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: var(--fs-body); line-height: 1.7; }
.share-note { margin: 0; color: var(--ink-3); font-size: var(--fs-meta); }
.share-dialog > footer { display: flex; flex: none; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.share-secondary, .share-primary { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 8px; font-size: var(--fs-control); font-weight: 700; text-decoration: none; white-space: nowrap; }
.share-secondary { color: var(--ink-2); background: var(--surface); }
.share-secondary:hover { color: var(--ink); border-color: var(--ink-4); }
.share-primary { border-color: var(--ink); color: #fff; background: var(--ink); }
.share-primary:hover { background: #283241; }
:is(.share-secondary, .share-primary, .share-close):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 520px) {
  .share-dialog > footer { justify-content: stretch; }
  .share-dialog > footer > * { flex: 1 1 100%; }
}
