:root {
  --paper: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fd;
  --ink: #182238;
  --ink-soft: #667087;
  --line: #e1e5ef;
  --line-strong: #cbd2e1;
  --primary: #263b7a;
  --primary-2: #3f5fc4;
  --tint: #e9edfb;
  --accent: #e96f51;
  --positive: #177c5b;
  --negative: #c2463a;
  --amber: #b17a24;
  --shadow: 0 20px 60px rgba(38, 59, 122, 0.09);
  --radius-lg: 24px;
  --radius-md: 15px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 88% 5%, rgba(233, 111, 81, 0.14), transparent 25rem),
    radial-gradient(circle at 8% 18%, rgba(63, 95, 196, 0.08), transparent 22rem),
    var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--primary);
  color: white;
  padding: 10px 14px;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  position: relative;
  z-index: 5;
  border-bottom: 1px solid rgba(38, 59, 122, 0.1);
  background: rgba(244, 246, 251, 0.86);
  backdrop-filter: blur(18px);
}

.header-inner {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-content {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding: 8px;
  border-radius: 11px;
  background: var(--primary);
}

.brand-mark i {
  display: block;
  width: 4px;
  border-radius: 4px;
  background: white;
}

.brand-mark i:nth-child(1) { height: 9px; opacity: 0.65; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 12px; opacity: 0.8; }

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.03em;
}

.brand small {
  margin-top: 1px;
  color: var(--ink-soft);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.header-description {
  max-width: 620px;
  margin: 0;
  padding-left: 26px;
  border-left: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.data-health {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(177, 122, 36, 0.12);
}

.data-health.ready .health-dot {
  background: var(--positive);
  box-shadow: 0 0 0 4px rgba(23, 124, 91, 0.12);
}

.data-health.stale .health-dot,
.data-health.error .health-dot {
  background: var(--negative);
  box-shadow: 0 0 0 4px rgba(194, 70, 58, 0.12);
}

.section-kicker {
  margin: 0 0 10px;
  color: var(--primary-2);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.2em;
}

.workspace {
  margin-top: 28px;
  padding: clamp(22px, 4vw, 44px);
  border: 1px solid rgba(38, 59, 122, 0.13);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace-head,
.summary-head,
.asset-heading,
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.workspace-head h2,
.summary-head h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 31px);
  letter-spacing: -0.035em;
}

.workspace-head p:not(.section-kicker),
.summary-head > p,
.asset-heading p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.secondary-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: 160ms ease;
}

.secondary-button:hover {
  border-color: var(--primary-2);
  color: var(--primary-2);
}

.secondary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secondary-button.loading .reload-icon {
  animation: spin 0.8s linear infinite;
}

.control-panel {
  margin-top: 30px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.control-label,
.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.range-presets {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
}

.range-presets button {
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.range-presets button:hover {
  background: var(--tint);
  color: var(--primary);
}

.range-presets button.active {
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(145px, 0.8fr) auto minmax(145px, 0.8fr) minmax(220px, 1.25fr);
  align-items: end;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: white;
  color: var(--ink);
  font-size: 13px;
  transition: 150ms ease;
}

.field input:focus,
.field select:focus,
button:focus-visible {
  outline: 3px solid rgba(63, 95, 196, 0.17);
  border-color: var(--primary-2);
}

.date-separator {
  padding-bottom: 10px;
  color: #9aa49f;
}

.asset-heading {
  margin-top: 28px;
}

.asset-heading h3 {
  margin: 0;
  font-size: 15px;
}

.asset-actions {
  display: flex;
  gap: 6px;
}

.asset-actions button {
  padding: 5px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--primary-2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.asset-actions button:hover {
  background: var(--tint);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.asset-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 58px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.asset-option:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.asset-option.active {
  border-color: color-mix(in srgb, var(--asset-color) 55%, white);
  background: color-mix(in srgb, var(--asset-color) 7%, white);
}

.asset-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.asset-check {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: white;
  color: transparent;
  font-size: 12px;
  font-weight: 800;
}

.asset-option.active .asset-check {
  border-color: var(--asset-color);
  background: var(--asset-color);
  color: white;
}

.asset-line {
  width: 16px;
  height: 3px;
  flex: 0 0 16px;
  border-radius: 999px;
  background: var(--asset-color);
}

.asset-name {
  min-width: 0;
}

.asset-name strong,
.asset-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-name strong {
  font-size: 12px;
}

.asset-name small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 10px;
}

.chart-toolbar {
  margin-top: 30px;
  padding: 0 3px 10px;
}

.chart-period {
  font-size: 13px;
  font-weight: 700;
}

.chart-note {
  color: var(--ink-soft);
  font-size: 11px;
}

.chart-wrap {
  position: relative;
  height: 520px;
  padding: 18px 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fff, #fbfcfb);
}

.chart-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-soft);
  font-size: 12px;
}

.chart-loading.hidden {
  display: none;
}

.chart-loading p {
  margin: 0;
}

.loader {
  width: 24px;
  height: 24px;
  border: 2px solid var(--tint);
  border-top-color: var(--primary-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 11px;
}

.status.error { color: var(--negative); }
.status.warning { color: var(--amber); }

.summary-section {
  padding: 68px 0 58px;
}

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

.ranking-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  min-height: 82px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.68);
}

.rank-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tint);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.rank-asset {
  min-width: 0;
}

.rank-asset strong,
.rank-asset small {
  display: block;
}

.rank-asset strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-asset small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 10px;
}

.rank-value {
  text-align: right;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.rank-value.positive { color: var(--positive); }
.rank-value.negative { color: var(--negative); }

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-bottom: 76px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--line);
}

.about-grid article {
  padding: 32px;
  background: var(--surface-soft);
}

.about-number {
  color: var(--primary-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.about-grid h2 {
  margin: 16px 0 10px;
  font-size: 17px;
}

.about-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.site-footer {
  padding: 36px 0;
  background: var(--primary);
  color: white;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 30px;
}

.footer-inner strong {
  font-size: 15px;
}

.footer-inner p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
}

.footer-copyright {
  margin-top: 13px !important;
}

.footer-copyright a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration-color: rgba(255, 255, 255, 0.46);
  text-underline-offset: 3px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.footer-copyright a:hover,
.footer-copyright a:focus-visible {
  color: white;
  text-decoration-color: white;
}

.footer-note {
  text-align: right;
}

@media (max-width: 900px) {
  .header-description {
    max-width: 460px;
  }

  .range-presets {
    grid-template-columns: repeat(5, 1fr);
  }

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

  .chart-wrap {
    height: 450px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 24px, 1180px);
  }

  .header-inner {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 12px 0;
  }

  .header-content { display: block; }
  .brand strong { font-size: 13px; }
  .brand-mark { width: 34px; height: 34px; }
  .data-health span:last-child { display: none; }

  .header-description {
    max-width: 100%;
    margin-top: 8px;
    padding: 0;
    border: 0;
    font-size: 10.5px;
    line-height: 1.55;
  }

  .workspace {
    margin-top: 14px;
    padding: 20px 14px;
    border-radius: 18px;
  }

  .workspace-head {
    align-items: flex-start;
  }

  .secondary-button {
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .secondary-button span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .control-panel {
    padding: 14px;
  }

  .range-presets {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .mode-field {
    grid-column: 1 / -1;
  }

  .asset-grid {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .asset-option {
    min-height: 56px;
    padding: 9px;
    gap: 7px;
  }

  .asset-line { display: none; }
  .asset-heading { align-items: end; }
  .asset-heading p { display: none; }

  .chart-note { display: none; }
  .chart-wrap { height: 380px; padding-inline: 2px; }

  .summary-section {
    padding: 48px 0;
  }

  .summary-head {
    align-items: end;
  }

  .summary-head > p {
    max-width: 140px;
    text-align: right;
    font-size: 10px;
  }

  .ranking-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .about-grid {
    grid-template-columns: 1fr;
    margin-bottom: 54px;
  }

  .about-grid article {
    padding: 24px;
  }

  .footer-inner {
    display: block;
  }

  .footer-note {
    margin-top: 20px;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
