.trend-page {
  overflow: hidden;
}

.trend-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 26px 28px 24px;
  border-bottom: 1px solid var(--line);
}

.trend-head h1 {
  margin: 3px 0 8px;
}

.trend-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.trend-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  min-width: min(100%, 470px);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.trend-summary div {
  min-width: 0;
  padding: 11px 12px;
  background: var(--panel2);
}

.trend-summary div + div {
  border-left: 1px solid var(--line);
}

.trend-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.trend-summary dd {
  margin: 5px 0 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 15px;
  font-weight: 700;
}

.trend-up-text { color: #059669; }
.trend-down-text { color: #dc2626; }
html[data-theme="dark"] .trend-up-text { color: #34d399; }
html[data-theme="dark"] .trend-down-text { color: #fb7185; }

.trend-body {
  padding: 22px 28px 28px;
}

.trend-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.trend-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.trend-mode {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
}

.trend-mode button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.trend-mode button.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.trend-mode-panel[hidden] { display: none; }

.trend-volume-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -8px 0 18px;
}

.trend-volume-filter[hidden] {
  display: none;
}

.trend-volume-filter span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.trend-volume-filter button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.trend-volume-filter button.is-active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--text);
}

.trend-chart-grid,
.trend-rank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.trend-chart {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trend-chart > header,
.trend-rank > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.trend-chart > header div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.trend-chart h2,
.trend-rank h2 {
  margin: 0;
  font-size: 16px;
}

.trend-chart header span {
  font: 700 10px/1 "IBM Plex Mono", monospace;
}

.trend-chart--up header span { color: #059669; }
.trend-chart--down header span { color: #dc2626; }
.trend-chart header small,
.trend-rank header span {
  color: var(--muted);
  font-size: 11px;
}

.trend-chart ol {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.trend-chart-label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12px;
}

.trend-chart-label > span {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.trend-chart-label a {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-chart-label a:hover,
.trend-rank td a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.trend-chart-label strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.trend-bar-track {
  height: 6px;
  margin-left: 28px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--panel2);
}

.trend-bar-track i {
  display: block;
  width: var(--trend-width);
  height: 100%;
  border-radius: inherit;
}

.trend-chart--up .trend-bar-track i { background: #10b981; }
.trend-chart--down .trend-bar-track i { background: #f43f5e; }

.trend-rank-grid {
  margin-top: 18px;
}

.trend-rank {
  min-width: 0;
  padding-top: 18px;
  border-top: 3px solid var(--line);
}

.trend-rank--up { border-top-color: #10b981; }
.trend-rank--down { border-top-color: #f43f5e; }

.trend-table-wrap {
  margin-top: 10px;
  overflow: auto;
}

.trend-rank table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 11px;
}

.trend-rank th,
.trend-rank td {
  padding-left: 7px;
  padding-right: 7px;
  white-space: nowrap;
}

.trend-rank th:nth-child(1),
.trend-rank td:nth-child(1) { width: 6%; }
.trend-rank th:nth-child(2),
.trend-rank td:nth-child(2) { width: 31%; }
.trend-rank th:nth-child(n+3),
.trend-rank td:nth-child(n+3) { width: 15.75%; }

.trend-rank td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.trend-rank td a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.trend-rank td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font: 10px/1.35 "IBM Plex Mono", monospace;
}

.trend-rank--up .trend-delta { color: #059669; font-weight: 800; }
.trend-rank--down .trend-delta { color: #dc2626; font-weight: 800; }
html[data-theme="dark"] .trend-rank--up .trend-delta { color: #34d399; }
html[data-theme="dark"] .trend-rank--down .trend-delta { color: #fb7185; }

.trend-mode-panel[data-trend-mode-panel="percent"] .trend-rank--up .trend-percent { color: #059669; font-weight: 800; }
.trend-mode-panel[data-trend-mode-panel="percent"] .trend-rank--down .trend-percent { color: #dc2626; font-weight: 800; }
html[data-theme="dark"] .trend-mode-panel[data-trend-mode-panel="percent"] .trend-rank--up .trend-percent { color: #34d399; }
html[data-theme="dark"] .trend-mode-panel[data-trend-mode-panel="percent"] .trend-rank--down .trend-percent { color: #fb7185; }

.trend-empty {
  margin: 18px 0 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.trend-guide,
.trend-faq {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.trend-guide {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 36px;
}

.trend-guide h2,
.trend-faq h2 {
  margin: 5px 0 10px;
  font-size: 18px;
}

.trend-guide p,
.trend-guide dd,
.trend-faq p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.trend-guide dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.trend-guide dl div {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.trend-guide dt {
  font-size: 13px;
  font-weight: 700;
}

.trend-guide dd {
  margin: 4px 0 0;
}

.trend-faq details {
  border-top: 1px solid var(--line);
}

.trend-faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.trend-faq summary {
  padding: 14px 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.trend-faq details p {
  margin: -3px 0 16px;
}

@media (max-width: 900px) {
  .trend-head {
    align-items: stretch;
    flex-direction: column;
  }

  .trend-summary {
    min-width: 0;
    width: 100%;
  }

  .trend-chart-grid,
  .trend-rank-grid,
  .trend-guide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .trend-head,
  .trend-body {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .trend-summary div + div {
    border-left: 0;
  }

  .trend-summary div:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .trend-summary div:nth-child(n+3) {
    border-top: 1px solid var(--line);
  }

  .trend-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .trend-mode {
    width: 100%;
  }

  .trend-volume-filter {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trend-volume-filter span {
    grid-column: 1 / -1;
  }

  .trend-rank table {
    font-size: 10px;
  }

  .trend-rank th,
  .trend-rank td {
    padding-left: 5px;
    padding-right: 5px;
  }

  .trend-rank th:nth-child(1),
  .trend-rank td:nth-child(1),
  .trend-rank th:nth-child(3),
  .trend-rank td:nth-child(3) {
    display: none;
  }

  .trend-rank th:nth-child(2),
  .trend-rank td:nth-child(2) { width: 34%; }
  .trend-rank th:nth-child(4),
  .trend-rank td:nth-child(4) { width: 20%; }
  .trend-rank th:nth-child(5),
  .trend-rank td:nth-child(5) { width: 23%; }
  .trend-rank th:nth-child(6),
  .trend-rank td:nth-child(6) { width: 23%; }

  .trend-rank td small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .trend-chart-label a,
  .trend-bar-track i {
    transition: none;
  }
}
