:root {
  --bg: #f1f4f0;
  --surface: #ffffff;
  --surface-muted: #eef2f4;
  --text: #1d252c;
  --muted: #66727d;
  --line: #d7dee5;
  --primary: #c7263a;
  --primary-dark: #9f1e2d;
  --teal: #0c7f75;
  --amber: #b66a00;
  --gold: #d5a82f;
  --magic: #4f46a5;
  --danger: #b42318;
  --shadow: 0 18px 44px rgba(22, 27, 33, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(213, 168, 47, 0.14) 0 2px, transparent 2px 22px),
    radial-gradient(circle at 12% 10%, rgba(199, 38, 58, 0.12), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(12, 127, 117, 0.14), transparent 24%),
    var(--bg);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 16px clamp(14px, 3vw, 36px) 12px;
  background:
    linear-gradient(135deg, rgba(29, 37, 44, 0.92), rgba(65, 33, 52, 0.9)),
    var(--text);
  border-bottom: 3px solid var(--gold);
  color: #fff;
}

.site-header #open-settings {
  margin-left: auto;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #f4d675;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0;
}

.source-link {
  color: #f4d675;
  font-weight: 800;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
}

.source-link:hover {
  text-decoration: underline;
}

.chart-tooltip {
  position: fixed;
  z-index: 1200;
  max-width: min(70vw, 320px);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(29, 37, 44, 0.18);
  background: rgba(29, 37, 44, 0.94);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(22, 27, 33, 0.24);
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto 48px;
  display: grid;
  gap: 18px;
}

.controls {
  width: 100%;
}

.controls .panel-heading {
  justify-content: flex-end;
  padding: 10px 12px 0;
}

.controls .panel-heading p,
.controls .badge {
  display: none;
}

.controls .control-grid {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.controls .account-fields {
  grid-template-columns: 1fr;
  gap: 10px;
}

.controls .status {
  margin: 0 12px 12px;
}

.app-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

.app-nav a {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, rgba(213, 168, 47, 0.7), rgba(12, 127, 117, 0.5)) border-box;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.app-nav a.active,
.app-nav a:hover {
  border-color: var(--gold);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--magic));
}

.view {
  display: grid;
  gap: 18px;
}

.view[hidden] {
  display: none;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 252, 252, 0.96)),
    var(--surface);
  border: 1px solid rgba(29, 37, 44, 0.12);
  border-radius: 8px;
  box-shadow: 0 2px 0 rgba(213, 168, 47, 0.16);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 0;
}

.chart-heading {
  align-items: center;
  padding-bottom: 14px;
}

.panel-heading p,
.status,
.summary-grid span,
.empty-cell,
.muted {
  color: var(--muted);
}

.badge {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--teal);
  background: rgba(12, 127, 117, 0.1);
  border: 1px solid rgba(12, 127, 117, 0.24);
  font-size: 0.78rem;
  font-weight: 800;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 0.8fr) 110px auto auto auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
}

.account-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px 14px;
}

.settings-collapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px;
  border: 1px solid rgba(12, 127, 117, 0.28);
  border-radius: 8px;
  background: rgba(12, 127, 117, 0.08);
  padding: 12px 14px;
}

.settings-collapsed[hidden],
#settings-body[hidden] {
  display: none;
}

.settings-collapsed span {
  display: block;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.settings-collapsed strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.account-summary[hidden] {
  display: none;
}

.account-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-summary strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.account-summary p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.account-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.account-fields[hidden] {
  display: none;
}

.account-buttons {
  justify-content: flex-start;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span,
.check-field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(12, 127, 117, 0.14);
}

.field-wide {
  grid-column: span 2;
}

.compact {
  width: min(220px, 100%);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.button-row,
.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  font-weight: 800;
}

.button:hover {
  border-color: #aab4bc;
  background: var(--surface-muted);
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.button.icon-button {
  min-width: 40px;
  width: 40px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.status {
  margin: 0 18px 18px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
  padding: 8px 10px;
  font-size: 0.92rem;
}

.status.ok {
  border-color: rgba(12, 127, 117, 0.32);
  color: #075e55;
  background: rgba(12, 127, 117, 0.1);
}

.status.error {
  border-color: rgba(180, 35, 24, 0.32);
  color: var(--danger);
  background: rgba(180, 35, 24, 0.09);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-grid > div {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid rgba(213, 168, 47, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(253, 247, 229, 0.92)),
    var(--surface);
}

.summary-grid strong {
  font-size: clamp(1.2rem, 3vw, 1.7rem);
}

.hero-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: 18px;
  padding: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 20%, rgba(244, 214, 117, 0.36), transparent 28%),
    linear-gradient(135deg, rgba(29, 37, 44, 0.96), rgba(63, 36, 75, 0.94));
  color: #fff;
  border-color: rgba(213, 168, 47, 0.6);
}

.hero-profile,
.hero-bars {
  width: 100%;
  max-width: 520px;
}

.hero-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-avatar {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 4px solid rgba(244, 214, 117, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), transparent 26%),
    linear-gradient(135deg, var(--primary), var(--magic));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.hero-avatar span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  font-weight: 900;
}

.hero-avatar strong {
  margin-top: -18px;
  font-size: 2.8rem;
  line-height: 1;
}

.hero-profile h2 {
  margin: 4px 0 8px;
  color: #fff;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
}

.hero-rank-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 4px 0;
}

.hero-side-badges {
  display: grid;
  gap: 10px;
  align-content: center;
}

.hero-rank-row > span:last-child {
  color: rgba(255, 255, 255, 0.74);
  font-weight: 800;
}

#hero-exp-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 8px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#hero-type-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid rgba(12, 127, 117, 0.5);
  background: rgba(12, 127, 117, 0.18);
  color: #e6fffb;
  padding: 8px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hero-exp-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
}

.hero-exp-count {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--gold), #ffe58f);
  color: #3b2c00;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.hero-type-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(230, 255, 251, 0.9);
}

.hero-type-value {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
}

.hero-score-orb {
  width: 176px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  border: 5px solid rgba(255, 255, 255, 0.5);
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, rgba(40, 51, 63, 0.92), rgba(28, 35, 46, 0.92));
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.28),
    inset 0 2px 10px rgba(255, 255, 255, 0.16);
  padding: 14px;
}

.hero-rank-caption {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.1;
}

.hero-rank-value {
  color: #fff;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.hero-score-orb.rank-ss {
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, #6d28d9, #f59e0b);
}

.hero-score-orb.rank-s {
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, var(--primary), #f59e0b);
}

.hero-score-orb.rank-a {
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, var(--teal), #4ad2c2);
}

.hero-score-orb.rank-b {
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, var(--magic), #7f77d7);
}

.hero-score-orb.rank-c {
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, #64748b, #94a3b8);
}

.hero-exp,
.quest-progress,
.rpg-gauge {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.hero-exp {
  margin: 12px auto 0;
  max-width: 460px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.hero-exp span,
.quest-progress span,
.rpg-gauge span {
  display: block;
  width: calc(var(--value) * 1%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd45f, #fff0a7 55%, #ffffff);
  box-shadow: 0 0 10px rgba(255, 232, 153, 0.55);
}

.hero-bars {
  display: grid;
  gap: 10px;
}

.rpg-stat {
  display: grid;
  gap: 5px;
}

.rpg-stat > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.86rem;
  font-weight: 900;
}

.rpg-gauge {
  background: rgba(255, 255, 255, 0.14);
}

.rpg-gauge span {
  background: linear-gradient(90deg, var(--teal), #69d7c9);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.rank-ss {
  background: linear-gradient(135deg, #7c3aed, #f59e0b);
}

.rank-s {
  background: linear-gradient(135deg, var(--primary), #f59e0b);
}

.rank-a {
  background: var(--teal);
}

.rank-b {
  background: var(--magic);
}

.rank-c {
  background: #64748b;
}

.summary-grid span {
  font-size: 0.78rem;
  font-weight: 800;
}

.table-heading {
  align-items: center;
  padding-bottom: 14px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.analysis-grid .chart-panel-wide {
  grid-column: 1 / -1;
}

.chart-panel {
  min-width: 0;
}

.chart-canvas {
  display: block;
  width: calc(100% - 36px);
  height: auto;
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.square-chart {
  max-width: 620px;
  margin-inline: auto;
}

.insight-panel {
  overflow: hidden;
}

.insight-list,
.card-grid,
.rank-list,
.achievement-grid {
  padding: 18px;
}

.insight-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.insight-item,
.analysis-card,
.achievement-card {
  border: 1px solid rgba(29, 37, 44, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fff, #fbfcfd),
    var(--surface);
  padding: 14px;
}

.quest-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(213, 168, 47, 0.36);
}

.quest-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 92% 0%, rgba(213, 168, 47, 0.22), transparent 28%);
}

.quest-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.quest-status {
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 900;
}

.quest-progress {
  height: 10px;
  margin-top: 12px;
  background: var(--surface-muted);
}

.quest-progress span {
  background: linear-gradient(90deg, var(--primary), var(--gold));
}

.insight-item strong,
.analysis-card h3,
.achievement-card h3,
.rank-item h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.insight-item p,
.analysis-card p,
.achievement-card p,
.rank-item p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.card-metrics strong {
  color: var(--text);
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.rank-item:last-child {
  border-bottom: 0;
}

.rank-item > strong {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.achievement-card {
  opacity: 0.58;
  position: relative;
}

.achievement-card.unlocked {
  border-color: rgba(12, 127, 117, 0.35);
  background:
    radial-gradient(circle at 90% 10%, rgba(213, 168, 47, 0.2), transparent 28%),
    rgba(12, 127, 117, 0.08);
  opacity: 1;
}

.achievement-card span {
  display: inline-block;
  margin-bottom: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 800;
}

.achievement-card.unlocked span {
  background: rgba(12, 127, 117, 0.14);
  color: var(--teal);
}

.empty-note {
  color: var(--muted);
}

.howto-body {
  padding: 0 18px 18px;
}

.howto-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 12px;
}

.howto-steps li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.howto-steps h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.howto-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #39424a;
  background: #f0f3f5;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #faf1f2;
}

.song-cell {
  font-weight: 900;
}

.score-cell {
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 900;
  white-space: nowrap;
}

.empty-cell {
  height: 120px;
  text-align: center;
}

.detail-dialog {
  width: min(900px, calc(100% - 24px));
  max-height: min(820px, calc(100vh - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(16, 20, 24, 0.45);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 28% 22%, rgba(199, 38, 58, 0.18), transparent 28%),
    radial-gradient(circle at 75% 76%, rgba(12, 127, 117, 0.18), transparent 30%),
    rgba(20, 24, 28, 0.48);
  padding: 20px;
  backdrop-filter: blur(5px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-card {
  width: min(360px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
  animation: loading-pop 280ms ease-out both;
}

.loading-stage {
  position: relative;
  width: 132px;
  height: 120px;
  margin: 0 auto 12px;
}

.mic {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 54px;
  height: 88px;
  transform: translateX(-50%);
  animation: mic-bounce 980ms ease-in-out infinite;
}

.mic-head {
  width: 54px;
  height: 54px;
  border: 4px solid var(--primary);
  border-radius: 50%;
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, rgba(199, 38, 58, 0.14) 8px 12px),
    #fff8f9;
}

.mic-body {
  width: 18px;
  height: 34px;
  margin: -2px auto 0;
  border-radius: 10px;
  background: var(--teal);
}

.mic-stand {
  width: 64px;
  height: 5px;
  margin: 0 auto;
  border-radius: 999px;
  background: #1d252c;
}

.note {
  position: absolute;
  color: var(--primary);
  font-size: 1.6rem;
  font-weight: 900;
  animation: note-float 1400ms ease-in-out infinite;
}

.note-a {
  left: 8px;
  top: 34px;
}

.note-b {
  right: 2px;
  top: 18px;
  color: var(--teal);
  animation-delay: 180ms;
}

.note-c {
  left: 32px;
  top: 0;
  color: var(--amber);
  animation-delay: 360ms;
}

.loading-card strong {
  display: block;
  font-size: 1.2rem;
}

.loading-card p {
  margin-top: 6px;
  color: var(--muted);
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  animation: dot-pulse 880ms ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  background: var(--teal);
  animation-delay: 140ms;
}

.loading-dots span:nth-child(3) {
  background: var(--amber);
  animation-delay: 280ms;
}

.is-loading {
  overflow: hidden;
}

@keyframes loading-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes mic-bounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateX(-50%) translateY(-8px) rotate(4deg);
  }
}

@keyframes note-float {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg);
    opacity: 0.62;
  }
  50% {
    transform: translateY(-12px) rotate(8deg);
    opacity: 1;
  }
}

@keyframes dot-pulse {
  0%,
  100% {
    transform: translateY(0) scale(0.86);
    opacity: 0.45;
  }
  50% {
    transform: translateY(-6px) scale(1.08);
    opacity: 1;
  }
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

#detail-content {
  padding: 24px;
}

.detail-header {
  padding-right: 44px;
}

.detail-header h3 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 8px;
  color: var(--muted);
}

.detail-score {
  color: var(--primary);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  line-height: 1;
  margin: 20px 0;
}

.result-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.result-score strong {
  color: var(--primary);
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-section-wide {
  grid-column: 1 / -1;
}

.detail-section h4 {
  margin: 0 0 12px;
  font-size: 0.94rem;
}

.detail-mini-chart {
  margin-top: 14px;
}

.detail-mini-chart h5 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.mini-summary {
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.mini-legend {
  display: flex;
  gap: 10px;
  margin: 0 0 6px;
}

.mini-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 800;
}

.mini-legend span::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend-add::before {
  background: var(--teal);
}

.legend-deduct::before {
  background: var(--amber);
}

.mini-axis-layout {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.mini-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
  padding: 10px 0;
}

.mini-plot-wrap {
  min-width: 0;
}

.section-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8px, 1fr));
  align-items: end;
  gap: 4px;
  height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 10px;
}

.section-bars span {
  display: block;
  min-height: 4px;
  height: calc(var(--value) * 1%);
  border-radius: 4px 4px 0 0;
  background: rgba(199, 38, 58, 0.45);
}

.compare-bars {
  grid-template-columns: repeat(auto-fit, minmax(12px, 1fr));
}

.compare-bars .compare-cell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 2px;
  min-height: 100%;
}

.compare-bars .compare-cell .bar {
  display: block;
  min-height: 4px;
  height: calc(var(--value) * 1%);
  border-radius: 3px 3px 0 0;
}

.compare-bars .compare-cell .bar.add {
  background: var(--teal);
}

.compare-bars .compare-cell .bar.deduct {
  background: var(--amber);
}

.teal-bars span {
  background: var(--teal);
}

.amber-bars span {
  background: var(--amber);
}

.mini-x-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 4px;
}

.mini-axis-label {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.metric-list {
  display: grid;
  gap: 10px;
}

.metric-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 10px;
}

.meter {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.meter span {
  display: block;
  width: calc(var(--value) * 1%);
  height: 100%;
  background: var(--teal);
}

.raw-grid,
.pretty-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  font-size: 0.86rem;
}

.raw-grid dt,
.pretty-grid dt {
  color: var(--muted);
  font-weight: 800;
}

.raw-grid dd,
.pretty-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .controls {
    position: static;
    width: 100%;
  }

  .controls .panel-heading p,
  .controls .badge {
    display: block;
  }

  .controls .control-grid {
    grid-template-columns: 1fr 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-bars {
    grid-column: 1 / -1;
  }

  .analysis-grid,
  .insight-list,
  .card-grid,
  .achievement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-fields {
    grid-template-columns: 1fr 1fr;
  }

  .field-wide {
    grid-column: span 2;
  }

  .button-row {
    grid-column: span 2;
    justify-content: flex-start;
  }

  .summary-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .site-header,
  .panel-heading,
  .table-heading,
  .account-summary,
  .settings-collapsed {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    width: min(100% - 20px, 1240px);
    margin-top: 12px;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-avatar {
    margin-inline: auto;
  }

  .control-grid,
  .account-fields,
  .summary-grid,
  .detail-grid,
  .raw-grid,
  .analysis-grid,
  .insight-list,
  .card-grid,
  .achievement-grid {
    grid-template-columns: 1fr;
  }

  .chart-heading {
    align-items: stretch;
  }

  .chart-heading .button {
    width: 100%;
  }

  .chart-heading .button.icon-button {
    width: 40px;
  }

  .chart-canvas {
    width: calc(100% - 24px);
    margin-inline: 12px;
  }

  .field-wide,
  .button-row {
    grid-column: span 1;
  }

  .button-row,
  .table-tools {
    justify-content: stretch;
  }

  .button,
  .compact {
    width: 100%;
  }

  .button.icon-button {
    width: 40px;
  }

  #detail-content {
    padding: 18px;
  }

  .metric-row {
    grid-template-columns: 96px minmax(0, 1fr) 48px;
  }
}
