/* /rates: 30-day trend on each tile, and the full chart in a dialog. Builds on main.css tokens. */
:root { --t-buy: #2a64a6; --t-sell: #a98128; }

/* ---------- Tiles: the whole tile opens the chart ---------- */
.tile__trend { display: block; width: 100%; margin: 12px 0 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.tile__trend::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* stretch the button over the tile */
.tile__trend:focus-visible { outline: none; }
.tile__trend:focus-visible::after { box-shadow: 0 0 0 3px var(--gold-deep); }
.spark { position: relative; display: block; height: 34px; }
.spark svg { display: block; width: 100%; height: 34px; overflow: visible; }
.spark path { fill: none; stroke: var(--t-sell); stroke-width: 1.75px; stroke-linejoin: round; stroke-linecap: round; }
.spark i { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--t-sell); box-shadow: 0 0 0 2px var(--paper); }
.tile:hover .spark i { box-shadow: 0 0 0 2px #fff; }
.tile__chg { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; font-size: .74rem; color: var(--fg-muted); }
.tile__chg b { font-weight: 700; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.tile--feat .spark path { stroke: var(--gold); }
.tile--feat .spark i { background: var(--gold); box-shadow: 0 0 0 2px var(--night); }
.tile--feat:hover .spark i { box-shadow: 0 0 0 2px var(--night-2); }
.tile--feat .tile__chg { color: #9a917f; }
.tile--feat .tile__chg b { color: #e9e1cf; }
.trend-hint { display: flex; align-items: center; gap: 8px; margin: 0 8px 14px; font-size: .85rem; color: var(--fg-muted); }
.trend-hint .ico { width: 15px; height: 15px; color: var(--gold-deep); }

/* ---------- Dialog ---------- */
.trend { width: min(780px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: clamp(18px, 3vw, 30px); border: 0; border-radius: var(--r-card); background: var(--card); color: var(--fg); box-shadow: 0 40px 80px -30px rgba(15, 13, 10, .55); overflow-y: auto; overscroll-behavior: contain; }
.trend::backdrop { background: rgba(15, 13, 10, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.trend[open] { animation: trend-in .45s var(--ease); }
@keyframes trend-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.trend__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.trend__id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.trend__id img { width: 40px; height: 30px; border-radius: 5px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.trend__id img:not([src]), .trend__id img[src=""] { visibility: hidden; }
.trend__id h2 { font-family: var(--font-display); font-size: clamp(1.4rem, 2.6vw, 1.9rem); font-weight: 500; letter-spacing: -.02em; margin: 2px 0 0; line-height: 1.15; }
.trend__id small { display: block; color: var(--fg-muted); font-size: .85rem; }
.trend__tools { display: flex; align-items: center; gap: 8px; }
.trend__pick select { height: 40px; max-width: 220px; padding: 0 34px 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2394742f' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center; font: inherit; font-size: .88rem; font-weight: 600; color: var(--fg); appearance: none; -webkit-appearance: none; cursor: pointer; }
.trend__pick select:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(212,178,94,.35); }
.trend__close { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--paper); cursor: pointer; color: var(--fg); }
.trend__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.trend__close:hover { background: #fff; }
.trend__close:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(212,178,94,.45); }

.trend__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.trend__stat { padding: 14px 16px; border-radius: 14px; background: var(--paper); }
.trend__stat small { display: flex; align-items: center; gap: 7px; font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-muted); }
.trend__stat small i { width: 14px; height: 2px; border-radius: 2px; }
.trend__stat b { display: block; margin-top: 4px; font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.trend__stat span { display: block; margin-top: 2px; font-size: .8rem; color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* ---------- Chart ---------- */
.trend__chart { position: relative; touch-action: pan-y; border-radius: 12px; }
.trend__chart:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(212,178,94,.45); }
.trend__chart svg { display: block; width: 100%; overflow: visible; font-family: var(--font-body); }
.t-grid { stroke: var(--line); stroke-width: 1; }
.t-tick { fill: var(--fg-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.t-title { fill: var(--fg-2); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.t-line { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.t-line--buy { stroke: var(--t-buy); }
.t-line--sell { stroke: var(--t-sell); }
.t-end { stroke: var(--card); stroke-width: 2px; }
.t-end--buy { fill: var(--t-buy); }
.t-end--sell { fill: var(--t-sell); }
.t-cross { stroke: var(--fg-2); stroke-width: 1; stroke-dasharray: 3 3; }
.t-dot { stroke: var(--card); stroke-width: 2px; }
.t-hit { fill: transparent; cursor: crosshair; }
.trend__tip { position: absolute; top: 0; z-index: 2; min-width: 150px; padding: 10px 12px; border-radius: 12px; background: var(--night); color: #f3ede0; font-size: .8rem; pointer-events: none; box-shadow: 0 14px 30px -14px rgba(0,0,0,.6); white-space: nowrap; }
.trend__tip[hidden] { display: none; }
.trend__tip p { margin: 0 0 6px; color: #9a917f; font-size: .72rem; font-weight: 600; }
.trend__tip div { display: flex; align-items: center; gap: 8px; }
.trend__tip div + div { margin-top: 3px; }
.trend__tip i { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.trend__tip b { font-size: .95rem; font-variant-numeric: tabular-nums; min-width: 4.5em; }
.trend__tip span { color: #cfc6b4; }

.trend__note { margin: 14px 0 0; font-size: .8rem; color: var(--fg-muted); max-width: 60em; }
.trend__table { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.trend__table summary { cursor: pointer; font-size: .85rem; font-weight: 700; color: var(--gold-deep); width: max-content; }
.trend__table table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.trend__table th, .trend__table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.trend__table th:first-child, .trend__table td:first-child { text-align: left; }
.trend__table th { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-muted); font-weight: 700; }
.trend__table td.is-new::after { content: "•"; margin-left: 6px; color: var(--gold-deep); }

@media (max-width: 640px) {
  .trend { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .trend[open] { animation-name: trend-up; }
  @keyframes trend-up { from { transform: translateY(40px); opacity: 0; } }
  .trend__tools { width: 100%; }
  .trend__pick { flex: 1; }
  .trend__pick select { width: 100%; max-width: none; }
  .trend__head { gap: 12px; }
  .trend__stats { grid-template-columns: 1fr 1fr; }
  .trend__stat:last-child { grid-column: 1 / -1; }
  .trend__stat { padding: 12px 14px; }
  .trend__stat b { font-size: 1.2rem; }
  .spark, .spark svg { height: 26px; }
  .tile__chg { font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) { .trend[open] { animation: none; } }
@media (forced-colors: active) { .t-line, .spark path { stroke: CanvasText; } .t-line--buy { stroke-dasharray: 5 3; } }
