:root {
  --bg: #000;
  --fg: #e8e8ea;
  --muted: #8a8a93;
  --accent: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.28);
  --panel-bg-hover: rgba(255, 255, 255, 0.10);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

main {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4vmin;
}

.chart {
  width: min(86vmin, 960px);
  aspect-ratio: 1 / 1;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.chart .grid-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.10);
  stroke-width: 1;
}

.chart .grid-ring--outer {
  stroke: rgba(255, 255, 255, 0.22);
}

.chart .spoke {
  stroke: rgba(255, 255, 255, 0.10);
  stroke-width: 1;
}

.chart .axis-label {
  fill: #e8e8ea;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.chart .series {
  fill: var(--series-color);
  fill-opacity: 0.08;
  stroke: var(--series-color);
  stroke-width: 3.25;
  stroke-linejoin: round;
  transition: opacity 160ms var(--ease);
}

.chart .series.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Memo (top-left) ---------- */

.memo {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 10;
  max-width: 430px;
  padding: 16px 18px;
  background: var(--panel-bg);
  border-radius: 12px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 220ms var(--ease),
    transform 220ms var(--ease),
    border-color 220ms var(--ease);
}

.memo.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.memo__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--memo-color, var(--fg));
}

.memo__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--memo-color, var(--fg));
  box-shadow: 0 0 10px -2px var(--memo-color, var(--fg));
  flex-shrink: 0;
}

.memo__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  opacity: 0.82;
}

/* ---------- Filters aside ---------- */

.filters {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 10;

  display: flex;
  align-items: stretch;

  width: 56px;                    /* collapsed */
  height: 240px;
  padding: 0;

  background: var(--panel-bg);
  border-right: none;
  border-radius: 14px 0 0 14px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);

  cursor: pointer;
  outline: none;
  overflow: hidden;
  transition:
    width 360ms var(--ease),
    height 360ms var(--ease),
    background 240ms var(--ease),
    border-color 240ms var(--ease);
}

.filters:hover,
.filters:focus-within,
.filters.filters--initial {
  width: 360px;
  height: 380px;
  background: var(--panel-bg-hover);
  border-color: rgba(255, 255, 255, 0.2);
  cursor: default;
}

.filters__label {
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  user-select: none;
  transition: color 240ms var(--ease);
}

.filters:hover .filters__label,
.filters:focus-within .filters__label,
.filters.filters--initial .filters__label {
  color: var(--accent);
}

.filters__panel {
  flex: 1 1 auto;
  min-width: 0;
  padding: 22px 22px 22px 6px;
  opacity: 0;
  transform: translateX(8px);
  transition:
    opacity 260ms var(--ease) 80ms,
    transform 260ms var(--ease) 80ms;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.filters:hover .filters__panel,
.filters:focus-within .filters__panel,
.filters.filters--initial .filters__panel {
  opacity: 1;
  transform: translateX(0);
}

.filters__section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filters__section-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.filters__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filters__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 6px 2px;
  border-radius: 6px;
  transition: background 160ms var(--ease);
}

.filters__row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.filters__check {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
}

.filters__check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--series-color);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.filters__check input[type="checkbox"]:checked {
  background: var(--series-color);
  box-shadow: 0 0 10px -2px var(--series-color);
}

.filters__check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--series-color);
  outline-offset: 2px;
}

.filters__check-label {
  font-size: 15px;
  color: var(--fg);
  white-space: nowrap;
  user-select: none;
}

.filters__only {
  appearance: none;
  background: none;
  border: none;
  padding: 2px 6px;
  margin: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transform: translateX(4px);
  transition:
    opacity 160ms var(--ease),
    transform 160ms var(--ease),
    color 160ms var(--ease);
}

.filters__row:hover .filters__only,
.filters__row:focus-within .filters__only {
  opacity: 1;
  transform: translateX(0);
}

.filters__only:hover,
.filters__only:focus-visible {
  color: var(--accent);
  outline: none;
}

/* ---------- Mobile / touch ---------- */

@media (hover: none), (max-width: 760px) {
  main {
    padding: 2vmin 2vmin 78px 2vmin; /* leave room for bottom filter pill */
  }

  .chart {
    width: min(94vmin, 96vw);
  }

  .chart .axis-label {
    font-size: 15px;
  }

  /* Memo: top strip, full-width minus margins */
  .memo {
    top: 10px;
    left: 10px;
    right: 10px;
    max-width: none;
    padding: 12px 14px;
  }

  .memo__title {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .memo__body {
    font-size: 12px;
    line-height: 1.45;
  }

  /* Filters: bottom drawer, opens upward on tap */
  .filters {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    transform: none;
    width: auto;
    height: 52px;
    flex-direction: column;
    border-radius: 14px 14px 0 0;
    border: 1px solid var(--panel-border);
    border-bottom: none;
    transition:
      height 320ms var(--ease),
      background 240ms var(--ease),
      border-color 240ms var(--ease);
  }

  .filters:hover,
  .filters:focus-within,
  .filters.filters--initial,
  .filters.filters--open {
    width: auto;
    height: auto;
    max-height: 78vh;
  }

  .filters__label {
    flex: 0 0 52px;
    width: 100%;
    height: 52px;
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 13px;
    letter-spacing: 0.22em;
  }

  .filters__panel {
    padding: 4px 22px 22px 22px;
    transform: translateY(8px);
    transition:
      opacity 260ms var(--ease) 80ms,
      transform 260ms var(--ease) 80ms;
  }

  .filters:hover .filters__panel,
  .filters:focus-within .filters__panel,
  .filters.filters--initial .filters__panel,
  .filters.filters--open .filters__panel {
    transform: translateY(0);
  }

  /* "only" tag has no hover state on touch — always visible */
  .filters__only {
    opacity: 1;
    transform: translateX(0);
  }

  /* Bump tap targets */
  .filters__row {
    padding: 10px 6px;
  }

  .filters__check input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }
}
