/* ============ Display section (.d-) — tags, badges, stats, tables, charts ============ */

#display .preview { font-size: 14px; }
#display svg text { font-family: var(--font-sans); }

.d-col { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.d-col.left { align-items: stretch; }
.d-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* ---- 1. Tags ---- */
.d-tag {
  display: inline-flex; align-items: center;
  padding: 2px 6px; border-radius: var(--radius-4);
  font-size: 12px; line-height: 16px; font-weight: 600;
}
.d-tag.pink   { background: var(--tag-pink-bg);   color: var(--tag-pink-fg); }
.d-tag.blue   { background: var(--tag-blue-bg);   color: var(--tag-blue-fg); }
.d-tag.cyan   { background: var(--tag-cyan-bg);   color: var(--tag-cyan-fg); }
.d-tag.purple { background: var(--tag-purple-bg); color: var(--tag-purple-fg); }
.d-tag.orange { background: var(--tag-orange-bg); color: var(--tag-orange-fg); }
.d-tag.gold   { background: var(--tag-gold-bg);   color: var(--tag-gold-fg); }
.d-tag.bull { background: color-mix(in srgb, var(--data-green) 10%, transparent); color: var(--data-green); font-weight: 700; }
.d-tag.bear { background: color-mix(in srgb, var(--data-red) 10%, transparent);   color: var(--data-red);   font-weight: 700; }
.d-tag.base { background: var(--tag-neutral-bg); color: var(--tag-neutral-fg); font-weight: 700; }

/* ---- 2. Plan badges & gradient chips ---- */
.d-plan {
  position: relative; display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: var(--radius-full);
  font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .02em;
  background: var(--pg);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.d-plan::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--pg);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.d-plan.free { --pg: var(--gradient-g5); }
.d-plan.plus { --pg: var(--gradient-plus); }
.d-plan.pro  { --pg: var(--gradient-pro); }
.d-plan.max  { --pg: var(--gradient-max); }

.d-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--radius-full);
  font-size: 10px; line-height: 12px; font-weight: 700; letter-spacing: .06em;
  color: #ffffff;
}
.d-chip.hot { background: linear-gradient(135deg, #fc3bb2 0%, #f7906e 100%); }
.d-chip.newfn { background: var(--gradient-new-function); }

/* ---- 3. KPI stat tiles ---- */
.d-stats { display: flex; gap: 10px; width: 100%; justify-content: center; }
.d-stat {
  flex: 1; min-width: 0; max-width: 118px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-8);
  padding: 12px 10px; display: flex; flex-direction: column; gap: 4px;
}
.d-stat .lbl { font-size: 12px; line-height: 16px; color: var(--fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-stat .val { font-size: 20px; line-height: 28px; font-weight: 900; color: var(--fg-base); }
.d-stat .delta { font-size: 12px; line-height: 16px; font-weight: 600; }
.d-up,   .d-table td.d-up   { color: var(--data-green); }
.d-down, .d-table td.d-down { color: var(--data-red); }

/* ---- 4. Token table ---- */
.d-tablewrap { width: 100%; overflow-x: auto; }
.d-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.d-table th {
  height: 36px; padding: 0 10px; text-align: left;
  font-size: 12px; line-height: 16px; font-weight: 700; color: var(--fg-subtle);
}
.d-table td {
  height: 52px; padding: 0 10px;
  border-top: 1px solid var(--border-base);
  font-size: 12px; line-height: 16px; font-weight: 700; color: var(--fg-base);
}
.d-table tbody tr { transition: background .12s; }
.d-table tbody tr:hover { background: var(--bg-subtle); }
.d-table .num, .d-table th.num { text-align: right; }
.d-table .rank { color: var(--fg-muted); font-weight: 700; }
.d-coin { display: flex; align-items: center; gap: 8px; }
.d-coin-dot {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 900; color: #ffffff;
  box-shadow: inset 0 0 0 1px var(--border-base);
}
.d-coin-meta { display: flex; flex-direction: column; gap: 1px; }
.d-coin-meta .sym { font-size: 12px; line-height: 16px; font-weight: 700; color: var(--fg-base); }
.d-coin-meta .name { font-size: 10px; line-height: 12px; font-weight: 400; color: var(--fg-subtle); }
.d-spark { display: inline-block; vertical-align: middle; }
.d-table th.spark, .d-table td.spark { width: 76px; padding-left: 0; }
.d-table th.vol, .d-table td.vol { width: 84px; }

/* ---- 5. Heat cells ---- */
.d-heat { display: grid; grid-template-columns: repeat(4, 62px); gap: 4px; }
.d-heat-cell {
  height: 40px; border-radius: var(--radius-4);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--fg-base);
}
.d-heat-scale { display: grid; grid-template-columns: repeat(4, 62px); gap: 4px; margin-top: 6px; }
.d-heat-scale span { text-align: center; font-size: 10px; color: var(--fg-muted); }
.d-heat-cell.g10 { background: color-mix(in srgb, var(--data-green) 10%, transparent); }
.d-heat-cell.g24 { background: color-mix(in srgb, var(--data-green) 24%, transparent); }
.d-heat-cell.g40 { background: color-mix(in srgb, var(--data-green) 40%, transparent); }
.d-heat-cell.g60 { background: color-mix(in srgb, var(--data-green) 60%, transparent); }
.d-heat-cell.r10 { background: color-mix(in srgb, var(--data-red) 10%, transparent); }
.d-heat-cell.r24 { background: color-mix(in srgb, var(--data-red) 24%, transparent); }
.d-heat-cell.r40 { background: color-mix(in srgb, var(--data-red) 40%, transparent); }
.d-heat-cell.r60 { background: color-mix(in srgb, var(--data-red) 60%, transparent); }

/* ---- 6. Line chart ---- */
.d-chart { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.d-chart-head { display: flex; align-items: center; gap: 8px; }
.d-chart-head .logo {
  width: 20px; height: 20px; border-radius: 50%; background: #0e2e2a;
  color: #97fce4; font-size: 9px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.d-chart-head .tick { font-size: 16px; font-weight: 700; color: var(--fg-subtle); }
.d-chart-head .vdiv { width: 1px; height: 16px; background: var(--border-strong); }
.d-chart-head .title { font-size: 16px; font-weight: 700; color: var(--fg-base); }
.d-chart-val { display: flex; align-items: baseline; gap: 8px; }
.d-chart-val .big { font-size: 22px; line-height: 32px; font-weight: 900; color: var(--fg-base); }
.d-chart-val .chg { font-size: 14px; font-weight: 600; color: var(--data-green); }
.d-chart-val .per { font-size: 12px; color: var(--fg-muted); }
.d-chart svg { width: 100%; height: auto; display: block; }
.d-chart-plot { position: relative; width: 100%; }
.d-tip {
  position: absolute; top: 0; left: 0; z-index: 3;
  pointer-events: none; opacity: 0;
  transform: translate(-50%, 0);
  transition: opacity .12s ease;
  background: var(--bg-menu);
  border: 1px solid var(--border-base);
  border-radius: 9.4px;
  box-shadow: var(--shadow-drop);
  padding: 8px 10px; white-space: nowrap;
}
.d-tip.on { opacity: 1; }
.d-tip-time { font-size: 10px; color: var(--fg-muted); margin-bottom: 5px; }
.d-tip-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--fg-subtle); }
.d-tip-row b { color: var(--fg-base); font-weight: 700; margin-left: 10px; }
.d-tip-dot { width: 6px; height: 6px; border-radius: 50%; background: #1db699; flex: none; }

/* ---- 8. Stacked bars legend ---- */
.d-legend { display: flex; align-items: center; justify-content: center; gap: 14px; }
.d-legend .item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--fg-subtle); }
.d-legend .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }

/* ---- 9/10. Gauges ---- */
.d-gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.d-gauge .readout { font-size: 24px; line-height: 28px; font-weight: 900; color: var(--fg-base); margin-top: -34px; }
.d-gauge .state { font-size: 14px; font-weight: 700; color: var(--data-green); }
.d-ring { position: relative; display: flex; align-items: center; justify-content: center; }
.d-ring .score {
  position: absolute; font-size: 28px; font-weight: 800; color: var(--fg-base);
}
.d-ring-legend { display: flex; gap: 12px; }
.d-ring-legend .item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--fg-muted); }
.d-ring-legend .v { font-weight: 700; }

/* ---- 11. Grades ---- */
.d-grades { display: flex; align-items: baseline; gap: 20px; }
.d-grade {
  font-family: "DM Sans", var(--font-sans);
  font-size: 32px; line-height: 40px; font-weight: 900;
  background: var(--gg);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18));
}
.d-grade.s, .d-grade.a { --gg: var(--gradient-max); }
.d-grade.b { --gg: var(--gradient-silver); }
.d-grade.c { --gg: var(--gradient-grade-c); }
.d-grade.d { --gg: var(--gradient-grade-d); }

/* ---- 13. Skeleton / loading ---- */
.d-skel-stack { width: 100%; max-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.d-skel {
  height: 12px; border-radius: 6px;
  background: var(--bg-subtle);
  position: relative; overflow: hidden;
}
.d-skel.w80 { width: 80%; }
.d-skel.w55 { width: 55%; }
.d-skel.block { height: 48px; border-radius: var(--radius-8); }
.d-skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: translateX(-100%);
  animation: d-shimmer 1.6s ease-in-out infinite;
}
@keyframes d-shimmer { to { transform: translateX(100%); } }
:root[data-theme="dark"] .d-skel::after, .dark .d-skel::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .12), transparent);
}
.d-load { display: flex; align-items: center; gap: 9px; }
.d-breathe {
  color: var(--fg-subtle); flex: none;
  transform-origin: center;
  animation: d-breathe 2s ease-in-out infinite;
}
.d-load span { font-size: 12px; color: var(--fg-muted); }
@keyframes d-breathe {
  0%, 100% { transform: scale(.9); opacity: .45; }
  50% { transform: scale(1.06); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .d-breathe { animation: none; } }

/* ---- 14. Dividers ---- */
.d-divs { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 20px; }
.d-div-item { display: flex; flex-direction: column; gap: 8px; }
.d-div-item .cap { font-size: 11px; color: var(--fg-muted); }
.d-div-line { height: 1px; background: var(--border-strong); }
.d-div-dots {
  height: 2px;
  background: radial-gradient(circle, var(--fg-muted) 0 .9px, transparent 1px) left center / 6px 2px repeat-x;
}

/* ---- 15. Wallet rows ---- */
.d-wallet { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.d-balance {
  background: var(--bg-subtle); border-radius: var(--radius-16);
  padding: 16px; display: flex; align-items: center; gap: 12px;
}
.d-balance .avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: #fac4da; color: #a20a4a;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900;
}
.d-balance .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.d-balance .name { font-size: 14px; font-weight: 600; color: var(--fg-base); }
.d-balance .addr {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-numeric); font-size: 12px; color: var(--fg-subtle);
}
.d-balance .addr svg { color: var(--fg-muted); cursor: pointer; }
.d-balance .addr svg:hover { color: var(--fg-base); }
.d-balance .sum { font-size: 18px; font-weight: 900; color: var(--fg-base); }
.d-tx {
  height: 68px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border-base); padding-right: 4px;
}
.d-tx-icon { position: relative; flex: none; }
.d-tx-icon .circle {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-subtle-hover);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-base);
}
.d-tx-icon .net {
  position: absolute; right: -2px; bottom: -2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #627eea; color: #ffffff;
  border: 2px solid var(--bg-base-opaque);
  display: flex; align-items: center; justify-content: center;
}
.d-tx .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.d-tx .type { font-size: 14px; font-weight: 600; color: var(--fg-base); }
.d-tx .sub { font-size: 12px; color: var(--fg-subtle); white-space: nowrap; }
.d-tx .amounts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.d-tx .in  { font-size: 13px; font-weight: 600; color: var(--data-green); }
.d-tx .out { font-size: 12px; color: var(--data-red); }

/* ---- 16. Content card ---- */
.d-content {
  width: 100%; max-width: 300px;
  background: var(--bg-base-opaque);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-12);
  box-shadow: var(--shadow-card);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.d-content .title { font-size: 16px; line-height: 24px; font-weight: 700; color: var(--fg-base); }
.d-content .snippet {
  font-size: 14px; line-height: 20px; color: var(--fg-subtle);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.d-content .src { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.d-content .favicon { width: 14px; height: 14px; border-radius: 50%; background: #f8bf1e; flex: none; }

/* ---- 17. Avatar ---- */
.d-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900;
}
.d-avatar.pink   { background: #fac4da; color: #a20a4a; }
.d-avatar.grad   { background: var(--gradient-g2); color: #ffffff; }
.d-avatar.subtle { background: var(--bg-subtle); color: var(--fg-subtle); }
.d-avstack { display: flex; }
.d-avstack-coin {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: #ffffff;
  box-shadow: 0 0 0 2px var(--bg-base-opaque);
}
.d-avstack-coin + .d-avstack-coin { margin-left: -8px; }
.d-avstack-coin.more {
  background: linear-gradient(var(--bg-subtle), var(--bg-subtle)) var(--bg-base-opaque);
  color: var(--fg-subtle);
}

/* ---- 18. Kbd ---- */
.d-kbds { display: flex; align-items: flex-start; justify-content: center; gap: 24px; flex-wrap: wrap; }
.d-kbd-group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.d-kbd-group .keys { display: flex; align-items: center; gap: 4px; }
.d-kbd-group .plus, .d-kbd-group .cap { font-size: 11px; color: var(--fg-muted); }
.d-kbd {
  min-width: 22px; height: 22px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--radius-4);
  font-family: var(--font-sans); font-size: 11px; font-weight: 600; color: var(--fg-subtle);
}

/* ---- 19. Icons ---- */
.d-icons { display: grid; grid-template-columns: repeat(4, 48px); gap: 10px 12px; justify-content: center; }
.d-icon { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.d-icon .tile {
  width: 36px; height: 36px; border-radius: var(--radius-8);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-subtle);
  transition: background .12s, color .12s;
}
.d-icon:hover .tile { background: var(--bg-subtle); color: var(--fg-base); }
.d-icon .cap { font-size: 9px; line-height: 12px; color: var(--fg-muted); }

/* ---- 20. Code block ---- */
.d-code {
  width: 100%; max-width: 320px;
  background: #171717; border-radius: var(--radius-12);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.d-code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.d-code-head .dots { display: flex; gap: 5px; }
.d-code-head .dots i { width: 8px; height: 8px; border-radius: 50%; background: #464646; }
.d-code-head .path { flex: 1; font-size: 11px; color: #aaaaaa; }
.d-code-head .copy { color: #7a7a7a; cursor: pointer; flex: none; }
.d-code-head .copy:hover { color: #e7e7e7; }
.d-code-body {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 19px; color: #e7e7e7;
}
.d-code-body .k { color: #5bb5ff; }
.d-code-body .s { color: #1db699; }
.d-code-body .p { color: #7a7a7a; }

/* ---- 21. Credit meter ---- */
.d-meter { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 18px; }
.d-meter-item { display: flex; flex-direction: column; gap: 8px; }
.d-meter .row { display: flex; align-items: baseline; justify-content: space-between; }
.d-meter .lbl { font-size: 12px; color: var(--fg-subtle); }
.d-meter .val { font-size: 12px; font-weight: 700; color: var(--fg-base); }
.d-meter .track { height: 8px; border-radius: var(--radius-full); background: var(--bg-subtle); }
.d-meter .track.thin { height: 4px; }
.d-meter .fill { display: block; height: 100%; border-radius: var(--radius-full); }
.d-meter .fill.brand { background: var(--fg-brand); box-shadow: 0 0 8px rgba(255, 40, 130, .35); }
.d-meter .fill.green { background: var(--data-green); }

/* ---- 22. Empty state ---- */
.d-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.d-empty .orb {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--bg-subtle); color: var(--fg-muted);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
}
.d-empty .title { font-size: 14px; font-weight: 700; color: var(--fg-base); }
.d-empty .body { font-size: 12px; line-height: 16px; color: var(--fg-subtle); max-width: 200px; }
.d-empty-cta {
  border: 0; background: none; padding: 4px 6px; cursor: pointer;
  font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--fg-brand);
}
.d-empty-cta:hover { opacity: .8; }

/* ---- 23. Live feed ---- */
.d-feed { width: 100%; max-width: 300px; display: flex; flex-direction: column; }
.d-feed-row {
  height: 44px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-base);
  animation: d-feed-in 6s ease-in-out infinite;
}
.d-feed-row:last-child { border-bottom: 0; }
.d-feed-row:nth-child(2) { animation-delay: 2s; }
.d-feed-row:nth-child(3) { animation-delay: 4s; }
.d-feed .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.d-feed .txt { flex: 1; min-width: 0; font-size: 12px; color: var(--fg-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-feed .time { font-size: 10px; color: var(--fg-muted); flex: none; }
@keyframes d-feed-in {
  0% { opacity: .4; transform: translateY(4px); }
  8% { opacity: 1; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .d-feed-row { animation: none; } }
