/* ── Tether / Toman price terminal ─────────────────────────────────
   One instrument, one question: what is a dollar of Tether worth in
   toman right now and how did it get here.  The chart is the hero,
   every other element is a number that supports it. */

.tether-shell {
  --tt-radius: 18px;
  --tt-radius-sm: 12px;
  --tt-gap: 16px;
  --tt-chart-height: clamp(340px, 54vh, 560px);
  --tt-line: var(--border);
  display: grid;
  gap: var(--tt-gap);
  min-width: 0;
}

[data-theme-mode="light"] .tether-shell {
  --tt-line: rgba(16, 24, 40, 0.09);
}

.tether-shell h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

/* ── Price header ────────────────────────────────────────────────── */
.tt-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  padding: 22px 24px;
  overflow: hidden;
  border: 1px solid var(--tt-line);
  border-radius: var(--tt-radius);
  background:
    radial-gradient(520px 220px at 94% -40%, rgba(183, 156, 255, 0.16), transparent 68%),
    radial-gradient(420px 200px at 4% 130%, rgba(52, 211, 153, 0.07), transparent 64%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 46%),
    var(--surface);
  box-shadow: var(--shadow);
}

[data-theme-mode="light"] .tt-hero {
  background:
    radial-gradient(520px 220px at 94% -40%, rgba(96, 37, 191, 0.10), transparent 68%),
    radial-gradient(420px 200px at 4% 130%, rgba(15, 159, 110, 0.08), transparent 64%),
    var(--surface);
}

.tt-hero__main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.tt-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.tt-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border: 1px solid rgba(52, 211, 153, 0.28);
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.09);
  color: var(--up);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tt-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14);
}

.tt-live.is-off {
  border-color: rgba(251, 113, 133, 0.32);
  background: rgba(251, 113, 133, 0.10);
  color: var(--down);
}

.tt-live.is-off i {
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.14);
}

.tt-meta__sep {
  width: 1px;
  height: 12px;
  background: var(--tt-line);
}

.tt-updated {
  font-size: 12px;
  color: var(--muted);
}

.tt-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.tt-price__value {
  font-size: clamp(2.05rem, 5.4vw, 3.15rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.tt-price__unit {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

.tt-price__value.is-up { color: var(--up); }
.tt-price__value.is-down { color: var(--down); }

.tt-changes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tt-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px solid var(--tt-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

[data-theme-mode="light"] .tt-chip {
  background: rgba(16, 24, 40, 0.025);
}

.tt-chip b {
  font-weight: 800;
  color: var(--text);
  direction: ltr;
  unicode-bidi: isolate;
}

.tt-chip.is-up b { color: var(--up); }
.tt-chip.is-down b { color: var(--down); }

.tt-quotes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 2px;
}

.tt-quote {
  display: grid;
  gap: 1px;
  min-width: 84px;
}

.tt-quote span {
  font-size: 11px;
  color: var(--muted);
}

.tt-quote b {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: right;
}

.tt-quote b small {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  margin-inline-start: 3px;
}

.tt-hero__aside {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.tt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--tt-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s ease, border-color 0.18s ease;
}

.tt-btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #8b5cf6, #6025bf);
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.tt-btn:active {
  transform: translateY(1px) scale(0.99);
}

.tt-btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.tt-seg {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--tt-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  gap: 2px;
}

[data-theme-mode="light"] .tt-seg {
  background: rgba(16, 24, 40, 0.035);
}

.tt-seg button {
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.tt-seg button.is-active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(183, 156, 255, 0.24);
}

[data-theme-mode="light"] .tt-seg button.is-active {
  box-shadow: inset 0 0 0 1px rgba(96, 37, 191, 0.22);
}

/* ── Stale / error banner ────────────────────────────────────────── */
.tt-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(251, 113, 133, 0.32);
  border-radius: var(--tt-radius-sm);
  background: rgba(251, 113, 133, 0.08);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.8;
}

.tt-banner::before {
  content: "!";
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(251, 113, 133, 0.18);
  color: var(--down);
  font-weight: 900;
  font-size: 12px;
}

/* ── Chart stage ─────────────────────────────────────────────────── */
.tt-stage {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--tt-line);
  border-radius: var(--tt-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tt-stage__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tt-line);
}

.tt-stage__tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tt-interval {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px dashed var(--tt-line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.tt-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 34px;
  padding: 8px 16px 0;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tt-legend__time {
  font-weight: 700;
  color: var(--text);
}

.tt-legend__item b {
  color: var(--text);
  font-weight: 700;
  direction: ltr;
  unicode-bidi: isolate;
}

.tt-legend__item.is-up b { color: var(--up); }
.tt-legend__item.is-down b { color: var(--down); }

.tt-chart-wrap {
  position: relative;
  height: var(--tt-chart-height);
  min-height: 260px;
  padding: 0 4px;
}

.tt-chart {
  width: 100%;
  height: 100%;
}

.tt-chart-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}

.tt-chart-msg strong {
  display: block;
  color: var(--text);
  font-size: 14.5px;
}

.tt-skeleton {
  position: absolute;
  inset: 16px;
  display: none;
  grid-template-rows: 3fr 1fr;
  gap: 12px;
  pointer-events: none;
}

.tt-skeleton.is-on {
  display: grid;
}

.tt-skeleton span {
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(183, 156, 255, 0.05), rgba(183, 156, 255, 0.14), rgba(183, 156, 255, 0.05));
  background-size: 220% 100%;
  animation: tt-shimmer 1.6s linear infinite;
}

.tt-skeleton__price {
  height: 100%;
}

.tt-stage__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--tt-line);
  color: var(--muted);
  font-size: 11px;
}

.tt-attr {
  letter-spacing: 0.01em;
}

/* ── Lower panels ────────────────────────────────────────────────── */
.tt-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: var(--tt-gap);
  align-items: start;
}

.tt-panel {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--tt-line);
  border-radius: var(--tt-radius);
  background: var(--surface);
}

.tt-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--tt-line);
}

.tt-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.tt-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--tt-line);
}

.tt-stat {
  display: grid;
  gap: 2px;
  padding: 13px 15px;
  background: var(--surface);
}

.tt-stat span {
  font-size: 11px;
  color: var(--muted);
}

.tt-stat b {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: right;
}

.tt-stat b small {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-inline-start: 3px;
}

.tt-stat.is-up b { color: var(--up); }
.tt-stat.is-down b { color: var(--down); }

/* ── Converter ───────────────────────────────────────────────────── */
.tt-conv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  padding: 16px;
}

.tt-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tt-field span {
  font-size: 11.5px;
  color: var(--muted);
}

.tt-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--tt-line);
  border-radius: var(--tt-radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.18s ease, background 0.18s ease;
}

[data-theme-mode="light"] .tt-field input {
  background: rgba(16, 24, 40, 0.025);
}

.tt-field input:focus {
  outline: none;
  border-color: rgba(183, 156, 255, 0.5);
  background: rgba(183, 156, 255, 0.06);
}

[data-theme-mode="light"] .tt-field input:focus {
  border-color: rgba(96, 37, 191, 0.45);
  background: rgba(96, 37, 191, 0.04);
}

.tt-swap {
  display: grid;
  place-items: center;
  width: 34px;
  height: 46px;
  color: var(--muted);
  font-size: 15px;
  user-select: none;
}

.tt-hint {
  padding: 0 16px 16px;
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--muted);
}

/* ── Footnote ────────────────────────────────────────────────────── */
.tt-note {
  display: grid;
  gap: 4px;
  padding: 2px 4px;
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--muted);
}

.tt-note b {
  color: var(--text);
  font-weight: 700;
}

/* ── Motion ──────────────────────────────────────────────────────── */
@keyframes tt-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@keyframes tt-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tt-flash {
  0% { background: rgba(183, 156, 255, 0.16); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: no-preference) {
  .tt-hero,
  .tt-stage,
  .tt-lower > .tt-panel {
    animation: tt-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .tt-stage { animation-delay: 0.05s; }
  .tt-lower > .tt-panel:nth-child(2) { animation-delay: 0.1s; }
  .tt-live i { animation: tt-pulse 2.6s ease-in-out infinite; }
  .tt-chart-wrap.is-updated { animation: tt-flash 0.9s ease-out; }
}

@keyframes tt-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12); }
  50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.05); }
}

@media (prefers-reduced-motion: reduce) {
  .tt-skeleton span { animation: none; }
  .tt-btn,
  .tt-seg button,
  .tt-field input { transition: none; }
}

@media (hover: hover) {
  .tt-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-strong);
  }
  .tt-btn--primary:hover {
    background: linear-gradient(135deg, #9a6bff, #6d2fd6);
    border-color: transparent;
  }
  .tt-seg button:hover:not(.is-active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
  }
  [data-theme-mode="light"] .tt-seg button:hover:not(.is-active) {
    background: rgba(16, 24, 40, 0.05);
  }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tt-hero {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 16px;
    padding: 18px;
  }
  .tt-hero__aside {
    justify-content: flex-start;
    width: 100%;
  }
  .tt-lower {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .tether-shell {
    --tt-chart-height: clamp(280px, 40vh, 360px);
  }
  .tt-meta {
    gap: 6px 10px;
  }
  .tt-meta__sep {
    display: none;
  }
  .tt-hero {
    padding: 16px;
    gap: 12px;
  }
  .tt-chip {
    min-height: 26px;
    padding: 3px 9px;
    font-size: 11px;
  }
  .tt-stage__head {
    padding: 10px 12px;
    gap: 8px;
  }
  .tt-range {
    width: 100%;
    justify-content: space-between;
  }
  .tt-range button {
    flex: 1;
    padding: 0 8px;
    font-size: 12px;
  }
  .tt-hero__aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
  }
  #ttRefresh {
    width: 100%;
  }
  .tt-legend {
    gap: 10px;
    padding: 8px 12px 0;
  }
  .tt-chart-wrap {
    padding: 0;
  }
  .tt-quotes {
    gap: 8px 14px;
  }
  .tt-quote {
    min-width: 72px;
  }
  .tt-conv {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .tt-swap {
    width: 100%;
    height: 22px;
    transform: rotate(90deg);
  }
  .tt-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
