#marketPage {
  max-width: 1080px;
  margin: 0 auto;
}

.market-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.market-card-heading span,
.market-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.market-card {
  margin-top: 24px;
  padding: 22px;
  border-radius: 0;
}

.market-world-section {
  margin-top: 24px;
}

.market-card-heading {
  margin-bottom: 16px;
}

.market-card-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

.market-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

.market-filter {
  padding: 5px 9px;
  border: 0.8px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .market-filter:hover {
    color: var(--ink);
    background: var(--surface-soft);
  }
}

.market-filter.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  box-shadow: inset 0 0 0 0.8px color-mix(in srgb, var(--accent) 10%, transparent);
}

.market-filter [data-market-filter-count] {
  margin-left: 2px;
  font-family: var(--font-mono);
  font-size: 0.82em;
  font-weight: 500;
  opacity: 0.75;
}

.market-position-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .market-position-toggle:hover {
    color: var(--ink);
    background: var(--surface-soft);
  }
}

.market-position-toggle[aria-pressed="true"] {
  color: var(--accent);
}

.market-position-toggle svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.market-position-toggle[aria-pressed="true"] svg {
  fill: currentColor;
}

.market-world {
  position: relative;
  width: 100%;
  aspect-ratio: 2048 / 1039;
  min-height: 400px;
  overflow: hidden;
}

.market-world-skeleton {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  border-radius: 0;
  background: var(--surface-soft);
}

.market-world-skeleton[hidden] {
  display: none;
}

.market-world-skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.3) 48%,
    transparent 76%
  );
  content: "";
  transform: translateX(-100%);
  animation: market-skeleton-shimmer 1.35s ease-in-out infinite;
}

.market-world-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.5;
}

.market-world-quotes {
  position: absolute;
  inset: 0;
}

.market-world-quote {
  position: absolute;
  display: grid;
  gap: 2px;
  min-width: 88px;
  color: var(--ink);
  line-height: 1.08;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.market-world-quote::after {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border: 0.8px solid var(--bg);
  border-radius: 0;
  background: var(--muted);
  content: "";
  transform: translateY(-50%);
}

.market-world-quote.market-world-anchor-left {
  padding-right: 12px;
  text-align: right;
  transform: translate(-100%, -50%);
}

.market-world-quote.market-world-anchor-left::after {
  right: 0;
}

.market-world-quote.market-world-anchor-right {
  padding-left: 12px;
  text-align: left;
  transform: translate(0, -50%);
}

.market-world-quote.market-world-anchor-right::after {
  left: 0;
}

.market-world-name {
  font-size: 11px;
  font-weight: 450;
  transform: translateY(var(--market-label-shift, 0));
}

.market-world-change {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 450;
  letter-spacing: -0.02em;
  transform: translateY(var(--market-label-shift, 0));
}

.market-world-quote:has(.market-positive)::after {
  background: var(--success-text);
}

.market-world-quote:has(.market-negative)::after {
  background: var(--error-text);
}

.market-table-wrap {
  overflow-x: auto;
}

.market-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.market-table th,
.market-table td {
  padding: 12px 10px;
  border-bottom: 0.8px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.market-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.market-sort-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.market-table th:first-child .market-sort-button {
  justify-content: flex-start;
}

.market-sort-button svg {
  width: 8px;
  height: 11px;
  flex: 0 0 auto;
  overflow: visible;
}

.market-sort-button path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.34;
  transition: opacity 160ms ease, transform 160ms ease;
}

.market-sort-button.active.sort-asc .sort-up,
.market-sort-button.active.sort-desc .sort-down {
  opacity: 1;
}

.market-sort-button.active.sort-asc .sort-up {
  transform: translateY(-1px);
}

.market-sort-button.active.sort-desc .sort-down {
  transform: translateY(1px);
}

.market-table th:first-child,
.market-table td:first-child {
  padding-left: 0;
  text-align: left;
}

.market-table th:last-child,
.market-table td:last-child {
  padding-right: 0;
}

.market-table tbody tr {
  cursor: pointer;
  transition: background-color 140ms ease;
}

.market-table tbody tr:focus-visible {
  outline: none;
  background: var(--surface-soft);
}
@media (hover: hover) and (pointer: fine) {
  .market-table tbody tr:hover {
    outline: none;
    background: var(--surface-soft);
  }
}

.market-table tbody tr.market-row-empty {
  cursor: default;
  pointer-events: none;
}

.market-table tbody tr.market-row-empty:focus-visible {
  background: transparent;
}
@media (hover: hover) and (pointer: fine) {
  .market-table tbody tr.market-row-empty:hover {
    background: transparent;
  }
}

.market-row-spacer {
  display: block;
  width: 24px;
  height: 24px;
}

.market-symbol,
.market-number {
  font-family: var(--font-mono);
}

.market-symbol {
  color: var(--ink);
  font-weight: 600;
  min-width: 280px;
}

.market-symbol-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.market-symbol-logo {
  position: relative;
  display: inline-flex;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--surface-soft);
}

.market-symbol-logo img {
  position: absolute;
  inset: 2px;
  z-index: 1;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  border-radius: 0;
  object-fit: contain;
}

.market-symbol-badge {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 650;
}

.market-symbol-logo.has-image .market-symbol-badge {
  visibility: hidden;
}

.market-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.market-pager[hidden] {
  display: none;
}

.market-pager button {
  padding: 5px 8px;
  border: 0;
  border-radius: 0;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font: inherit;
  font-size: 10px;
  font-weight: 550;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .market-pager button:hover:not(:disabled) {
    color: var(--ink);
    background: var(--hover);
  }
}

.market-pager button:disabled {
  opacity: 0.35;
  cursor: default;
}

.market-pager span {
  min-width: 38px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

.market-symbol-ticker {
  min-width: 46px;
}

.market-symbol-name {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  opacity: 0.72;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-positive {
  color: var(--success-text);
}

.market-negative {
  color: var(--error-text);
}

.market-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 32px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .market-detail-back:hover {
    color: var(--ink);
  }
}

.market-detail-back svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.market-detail-header {
  max-width: 760px;
  margin: 0 auto 36px;
  text-align: center;
}

.market-detail-category {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.market-detail-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 7vw, 72px);
  font-weight: 300;
  letter-spacing: -0.04em;
}

.market-detail-header h1 + p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.market-chart-section {
  margin-bottom: 34px;
}

.market-chart-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.market-chart-toolbar h2 {
  display: inline;
  margin: 0 8px 0 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 350;
}

.market-chart-toolbar span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.market-chart-periods {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 0;
  background: var(--surface-soft);
}

.market-chart-period {
  min-width: 42px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .market-chart-period:hover {
    color: var(--ink);
  }
}

.market-chart-period.active {
  color: var(--ink);
  background: var(--card);
}

.market-chart-frame {
  position: relative;
  height: 480px;
  overflow: hidden;
  border-top: 0.8px solid var(--line);
  border-bottom: 0.8px solid var(--line);
  background: var(--bg);
  touch-action: pan-y;
}

.market-chart-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.market-chart-tooltip {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  padding: 6px 8px;
  border: 0.8px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
  pointer-events: none;
}

.market-chart-state {
  position: absolute;
  inset: 50% auto auto 50%;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  transform: translate(-50%, -50%);
}

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

.market-detail-column {
  display: grid;
  align-content: start;
  gap: 28px;
}

.market-detail-section h2 {
  margin: 0 0 5px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
}

.market-detail-grid {
  display: block;
  border-top: 0.8px solid var(--line);
}

.market-detail-metric {
  display: flex;
  min-height: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 0.8px solid var(--line);
}

.market-detail-metric span {
  display: inline;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  letter-spacing: 0;
  text-transform: none;
}

.market-detail-metric strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  text-align: right;
  overflow-wrap: anywhere;
}

.market-news-section {
  margin-top: 48px;
}

.market-news-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.market-news-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 350;
}

.market-news-heading span,
.market-news-state {
  color: var(--muted);
  font-size: 11px;
}

.market-news-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 52px;
}

.market-news-item {
  display: block;
  padding: 15px 0;
  border-top: 0.8px solid var(--line);
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .market-news-item:hover .market-news-title {
    color: var(--accent-button);
  }
}

.market-news-title {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 450;
  line-height: 1.35;
  transition: color 150ms ease;
}

.market-news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.market-news-meta span + span::before {
  margin-right: 5px;
  content: "·";
}

.market-news-state {
  margin: 14px 0 0;
}

.market-news-state[hidden] {
  display: none;
}

.market-skeleton {
  position: relative;
  height: 410px;
  overflow: hidden;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      var(--surface-soft) 0,
      var(--surface-soft) 39px,
      var(--line) 40px
    );
}

.market-skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.3) 48%,
    transparent 76%
  );
  content: "";
  transform: translateX(-100%);
  animation: market-skeleton-shimmer 1.35s ease-in-out infinite;
}

@keyframes market-skeleton-shimmer {
  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .market-world-skeleton::after,
  .market-skeleton::after {
    animation: none;
  }
}

@media (max-width: 620px) {
  .market-world {
    min-height: 0;
    aspect-ratio: 2048 / 1039;
  }

  .market-world-name {
    font-size: 7px;
    transform: translateY(var(--market-label-shift-mobile, 0));
  }

  .market-world-change {
    font-size: 9px;
    font-weight: 400;
    transform: translateY(var(--market-label-shift-mobile, 0));
  }

  .market-world-quote {
    min-width: 48px;
  }

  .market-world-quote::after {
    width: 4px;
    height: 4px;
  }

  .market-world-quote.market-world-mobile-anchor-top {
    padding: 0 0 8px;
    text-align: center;
    transform: translate(-50%, -100%);
  }

  .market-world-quote.market-world-mobile-anchor-top::after {
    top: auto;
    right: auto;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .market-card {
    padding: 16px 8px;
  }

  .market-card-heading {
    gap: 8px;
  }

  .market-card-heading h2 {
    flex: 0 0 auto;
    font-size: 22px;
  }

  .market-filters {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    gap: 2px;
    padding: 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .market-filters::-webkit-scrollbar {
    display: none;
  }

  .market-filter {
    flex: 0 0 auto;
    padding: 6px 8px;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .market-filter > span {
    font-size: inherit;
  }

  .market-table {
    min-width: 560px;
    font-size: 13px;
  }

  .market-table th,
  .market-table td {
    padding: 11px 6px;
  }

  .market-table th {
    font-size: 10px;
    letter-spacing: 0.025em;
  }

  .market-table th:first-child,
  .market-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    padding-right: 5px;
    background: var(--card);
  }

  .market-symbol {
    width: 104px;
    min-width: 104px;
  }

  .market-position-toggle {
    width: 22px;
    height: 22px;
  }

  .market-symbol-ticker {
    min-width: 0;
  }

  .market-symbol-wrap {
    gap: 6px;
  }

  .market-symbol-logo,
  .market-row-spacer {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .market-symbol-badge {
    font-size: 10px;
  }

  .market-pager button,
  .market-pager span {
    font-size: 12px;
  }

  .market-symbol-name {
    display: none;
  }

  .market-detail-back {
    margin-bottom: 22px;
  }

  .market-detail-header {
    margin-bottom: 26px;
  }

  .market-chart-toolbar {
    display: block;
  }

  .market-chart-periods {
    width: 100%;
    margin-top: 10px;
  }

  .market-chart-period {
    flex: 1;
    min-width: 0;
  }

  .market-chart-frame {
    height: 380px;
    margin-right: -14px;
    margin-left: -14px;
  }

  .market-detail-sections {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .market-news-section {
    margin-top: 38px;
  }

  .market-news-list {
    grid-template-columns: 1fr;
  }

  .market-news-title {
    font-size: 15px;
  }

  .market-detail-metric {
    min-height: 0;
    padding: 8px 0;
  }

  .market-detail-metric strong {
    font-size: 13px;
  }
}

.market-flash-up { color: var(--positive, var(--dm-success-ink, #16844a)); }
.market-flash-down { color: var(--negative, var(--dm-danger-ink, #d84040)); }
