*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

body,
.site-header,
.karat-card,
.panel,
.control,
.spot,
.modal__panel,
.live-dot {
  transition:
    background-color var(--speed) var(--ease),
    color var(--speed) var(--ease),
    border-color var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

@property --ring {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

.topbar {
  min-height: var(--header);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand tools";
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding-block: 0.55rem;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  justify-self: start;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.mark {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--gold) 22%, transparent);
}

.brand__name {
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The ring beside "Updated" fills until the next price arrives. */
.asof__ring {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
}

.asof__arc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(from -90deg, var(--gold) var(--ring), var(--line-strong) 0);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  transition: --ring 1s linear;
}

.asof__arc.is-reset {
  transition: none;
}

.ticker.is-down .asof__arc {
  background: conic-gradient(from -90deg, var(--down) var(--ring), var(--line-strong) 0);
}

.ticker.is-closed .asof__arc {
  background: var(--line-strong);
}

.asof__count {
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

.asof__count:empty {
  display: none;
}

.asof__count::before {
  content: "·";
  margin-inline-end: 0.45rem;
  color: var(--faint);
  font-weight: 400;
}

.live-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--faint);
}

.ticker.is-live .live-dot {
  background: var(--up);
  animation: pulse 1.8s var(--ease) infinite;
}

.ticker.is-down .live-dot {
  background: var(--down);
}

.header-tools {
  grid-area: tools;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
}

.header-switch {
  position: relative;
  min-width: 5.4rem;
  max-width: 13rem;
  flex: 1 1 auto;
}

.header-switch:has(.header-select--lang) {
  min-width: max-content;
  max-width: 8.5rem;
  flex: 0 0 auto;
}

.header-select,
.picker__button {
  appearance: none;
  width: 100%;
  max-width: 100%;
  min-height: 2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236b6458' d='M1 1.2 6 6.2 11 1.2'/%3E%3C/svg%3E") no-repeat right 0.65rem center / 0.65rem;
  color: var(--ink);
  padding: 0.35rem 1.7rem 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.2;
  text-align: start;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.header-select--lang {
  width: auto;
  max-width: 8.5rem;
}

html[dir="rtl"] .header-select,
html[dir="rtl"] .picker__button {
  background-position: left 0.65rem center;
  padding: 0.35rem 0.8rem 0.35rem 1.7rem;
}

.picker {
  overflow: visible;
}

.picker.is-open {
  z-index: 30;
}

.picker__panel {
  position: absolute;
  z-index: 32;
  top: calc(100% + 0.45rem);
  inset-inline-end: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(16.5rem, calc(100vw - 1rem));
  max-width: calc(100vw - 1rem);
  max-height: min(22rem, 70vh);
  padding: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.picker__panel.is-anchored {
  position: fixed;
  inset: auto;
  max-height: min(22rem, calc(100vh - var(--picker-top, 4rem) - 0.75rem));
}

.picker__panel--wide {
  width: min(20rem, calc(100vw - 1.5rem));
}

.picker__panel[hidden] {
  display: none;
}

.picker__search {
  appearance: none;
  width: 100%;
  margin-bottom: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--bg);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 1rem;
}

.picker__search:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.picker__list {
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.picker__option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.65rem;
  cursor: pointer;
}

.picker__option:hover,
.picker__option.is-active {
  background: var(--gold-soft);
}

.picker__option[aria-selected="true"] {
  background: color-mix(in srgb, var(--gold) 18%, var(--surface));
}

.picker__code {
  flex: none;
  font-weight: 600;
}

.picker__name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: end;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker__empty {
  padding: 0.7rem 0.65rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.theme-toggle {
  flex: none;
  align-self: center;
  box-sizing: border-box;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  line-height: 0;
}

.theme-toggle svg {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
}

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* ---------- Metal tabs ---------- */

.metalbar {
  display: flex;
  justify-content: center;
  padding: 0.85rem 1rem 0;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  width: fit-content;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.tab {
  min-height: 2.1rem;
  min-width: 4.75rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- Buttons ---------- */

.share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex: none;
  min-height: 2.1rem;
  padding-block: 0;
  padding-inline: 0.7rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1;
}

.share svg {
  width: 1rem;
  height: 1rem;
}

.share:hover {
  border-color: var(--gold);
}

.share:disabled {
  opacity: 0.55;
  cursor: progress;
}

.tab:focus-visible,
.share:focus-visible,
.theme-toggle:focus-visible,
.karat-card:focus-visible,
.control:focus-visible,
.unit-toggle__item:focus-within,
.seg__item:focus-visible,
.modal__close:focus-visible,
.picker__button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Page + hero ---------- */

.page {
  display: grid;
  gap: 1.75rem;
  padding-block: 1.5rem 3rem;
}

.page > *,
.panel,
.table-scroll,
.hero,
.calc-layout {
  min-width: 0;
}

.hero {
  display: grid;
  gap: 0.7rem;
}

.hero__intro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 1rem;
}

.hero__title {
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.3;
}

.hero__asof {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--faint);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.spot {
  display: grid;
  gap: 0.3rem;
  min-height: 21rem;
  padding: 1.15rem 1.15rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--gold) 6%, var(--surface)) 0%, var(--surface) 58%),
    var(--surface);
  box-shadow: var(--shadow);
}

.spot__label {
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spot__price {
  margin-top: 0.1rem;
  color: var(--ink);
  font-size: clamp(2.1rem, 8vw, 3rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.spot__price.is-flash-up {
  animation: price-blink 0.45s var(--ease), text-up 1.6s var(--ease);
}

.spot__price.is-flash-down {
  animation: price-blink 0.45s var(--ease), text-down 1.6s var(--ease);
}

.spot__price.is-flash-same {
  animation: price-blink 0.7s var(--ease);
}

.spot__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin-top: 0.2rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chip.is-up {
  background: var(--up-soft);
  color: var(--up);
}

.chip.is-down {
  background: var(--down-soft);
  color: var(--down);
}

.spot__delta,
.spot__rangename,
.spot__unit {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.spot__delta:empty {
  display: none;
}

.spot__unit {
  color: var(--faint);
}

.spot-chart {
  display: block;
  width: 100%;
  height: 8.5rem;
  margin-top: 0.5rem;
  overflow: visible;
}

.spot-chart.is-empty {
  opacity: 0;
}

.spot-chart {
  --tone: var(--gold);
}

.spot-chart.is-up {
  --tone: var(--up);
}

.spot-chart.is-down {
  --tone: var(--down);
}

.spot-chart__stop--top {
  stop-color: var(--tone);
  stop-opacity: 0.32;
}

.spot-chart__stop--bottom {
  stop-color: var(--tone);
  stop-opacity: 0;
}

.spot-chart__line {
  fill: none;
  stroke: var(--tone);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spot-chart__halo {
  fill: var(--tone);
  opacity: 0.18;
  transform-box: fill-box;
  transform-origin: center;
  animation: halo 2.2s ease-out infinite;
}

@keyframes halo {
  0% {
    opacity: 0.35;
    transform: scale(0.55);
  }
  100% {
    opacity: 0;
    transform: scale(1.7);
  }
}

.spot-chart__dot {
  fill: var(--tone);
  stroke: var(--surface);
  stroke-width: 2;
}

.spot__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.4rem;
}

.spot__hint {
  color: var(--faint);
  font-size: 0.78rem;
}

/* Segmented control (chart ranges) */

.seg {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.18rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}

.seg__item {
  min-height: 1.9rem;
  min-width: 2.8rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.seg__item[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* Ticker tape */

.tape {
  overflow: hidden;
  direction: ltr;
  unicode-bidi: isolate;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tape__viewport {
  overflow: hidden;
  direction: ltr;
  unicode-bidi: isolate;
  mask-image: linear-gradient(90deg, transparent, #000 1.1rem, #000 calc(100% - 1.1rem), transparent);
}

.tape__track {
  display: flex;
  width: max-content;
  direction: ltr;
  unicode-bidi: isolate;
  will-change: transform;
  animation: tape-scroll var(--tape-seconds, 36s) linear infinite;
}

.tape:hover .tape__track,
.tape:focus-within .tape__track {
  animation-play-state: paused;
}

.tape__group {
  display: flex;
  flex: none;
  align-items: center;
  gap: 1.15rem;
  padding: 0.62rem 1.15rem;
}

.tape__item {
  display: flex;
  align-items: baseline;
  gap: 0.42rem;
  white-space: nowrap;
}

.tape__label {
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tape__value {
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.tape__sep {
  flex: none;
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: var(--line-strong);
}

@keyframes tape-scroll {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(calc(-1 * var(--tape-shift, 50%)), 0, 0); }
}

/* ---------- Sections ---------- */

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.section-head h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.note {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.note--section {
  margin-top: -0.35rem;
  margin-bottom: 0.85rem;
}

/* Karat rows */

.karat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 0.65rem;
  min-height: 12rem;
}

.karat-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 4.6rem;
  padding: 0.7rem 1rem;
  overflow: hidden;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.karat-card:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
}

.karat-card__id {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.karat-card__mark {
  display: flex;
  align-items: flex-start;
  color: var(--gold);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.karat-card__mark span {
  margin-top: 0.15rem;
  margin-inline-start: 0.1rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.karat-card__prefix {
  margin-top: 0.3rem !important;
  margin-inline-end: 0.25rem;
  margin-inline-start: 0 !important;
  letter-spacing: 0 !important;
}

.karat-card__fine {
  color: var(--faint);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.karat-card__figures {
  display: grid;
  gap: 0.1rem;
  margin-inline-start: auto;
  text-align: end;
}

.karat-card__price {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.karat-card__unit {
  color: var(--faint);
  font-size: 0.75rem;
}

.karat-card__go {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  color: var(--faint);
}

.karat-card__go::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-top: 2px solid currentColor;
  border-inline-end: 2px solid currentColor;
  transform: rotate(45deg);
}

html[dir="rtl"] .karat-card__go::before {
  transform: rotate(-45deg);
}

html[data-metal="silver"] {
  --gold: #5e6a74;
}

html[data-theme="dark"][data-metal="silver"] {
  --gold: #c5ced6;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 0.25rem);
  box-shadow: var(--shadow);
  padding: 1rem;
}

/* Bars table */

.table-scroll {
  overflow-x: auto;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
}

.price-table th {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: start;
  padding: 0.35rem 0.75rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.price-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.price-table tr:last-child td {
  border-bottom: 0;
}

.price-table tbody tr:hover td {
  background: var(--bg-elev);
}

.num {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.price-table th.num {
  text-align: end;
}

.weight-name {
  display: block;
  font-weight: 500;
  white-space: nowrap;
}

.price-table td.num {
  white-space: nowrap;
}

.weight-grams {
  display: block;
  color: var(--faint);
  font-size: 0.75rem;
}

/* ---------- Calculator ---------- */

.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 1.5rem;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
  align-content: start;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field > span,
.field > label {
  color: var(--muted);
  font-size: 0.8125rem;
}

.control {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: 0.8rem;
  padding: 0.7rem 0.85rem;
}

.control::placeholder {
  color: var(--faint);
  opacity: 0.75;
}

.control--select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) 55%, calc(100% - 0.75rem) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 2rem;
}

html[dir="rtl"] .control--select {
  background-position: 1.1rem 55%, 0.75rem 55%;
}

input[type="number"] {
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.unit-field {
  display: flex;
  align-items: stretch;
  min-width: 0;
  min-height: 2.6rem;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: 0.8rem;
}

.unit-field:focus-within {
  border-color: var(--gold);
}

.unit-field .control {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
}

.unit-field .control:focus-visible {
  outline: none;
}

.unit-toggle {
  display: flex;
  flex: none;
  align-items: stretch;
  align-self: stretch;
  gap: 0.12rem;
  margin: 0.22rem;
  margin-inline-start: 0;
  padding: 0.12rem;
  border-radius: 0.6rem;
  background: color-mix(in srgb, var(--ink) 6%, var(--bg));
}

.unit-toggle__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.48rem;
  padding: 0 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
}

.unit-toggle__item input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.unit-toggle__item:has(input:checked) {
  background: var(--ink);
  color: var(--bg);
}

.result {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  margin: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.result div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.result dt {
  color: var(--muted);
}

.result dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.result__total {
  flex-direction: column;
  gap: 0.15rem !important;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.result__total dt {
  font-size: 0.8125rem;
}

.result__total dd {
  color: var(--gold);
  font-size: clamp(1.6rem, 6vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.result.is-empty dd {
  color: var(--faint);
}

/* ---------- Multi-item calculator ---------- */

.calc-main {
  display: grid;
  gap: 0.9rem;
  align-content: start;
  min-width: 0;
}

.calc-rows {
  display: grid;
  gap: 0.8rem;
}

.calc-item {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 0.2rem);
  background: var(--bg-elev);
}

.calc-item__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.calc-item__title {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.calc-item__sum {
  margin-inline-start: auto;
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.calc-item__remove {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.calc-item__remove svg {
  width: 0.9rem;
  height: 0.9rem;
}

.calc-item__remove:hover {
  border-color: var(--down);
  color: var(--down);
}

.calc-rows[data-single="true"] .calc-item__remove {
  display: none;
}

.calc-item__grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 0.7fr;
  gap: 0.75rem;
}

.calc-item__grid .field--wide {
  grid-column: 1 / -1;
}

.calc-bar,
.calc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.calc-side {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.calc-bar .share:disabled,
.calc-actions .share:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.calc-photo {
  position: relative;
  display: inline-flex;
  width: 2.5rem;
  height: 2.5rem;
}

.calc-photo[hidden] {
  display: none;
}

.calc-photo img {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0.65rem;
  object-fit: cover;
}

.calc-photo__remove {
  position: absolute;
  top: -0.4rem;
  inset-inline-end: -0.4rem;
  display: grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}

.calc-photo__remove svg {
  width: 0.7rem;
  height: 0.7rem;
}

.calc-history {
  margin-top: 1rem;
}

.calc-history[hidden] {
  display: none;
}

.calc-history__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.calc-history__head h3 {
  margin: 0;
  font-size: 1rem;
}

.calc-history__list {
  display: grid;
  gap: 0.6rem;
  margin: 0.85rem 0 0.5rem;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 0.2rem);
  background: var(--bg-elev);
}

.history-item__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-item__total {
  color: var(--gold);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.history-item__when {
  color: var(--faint);
  font-size: 0.8rem;
}

.history-item__items {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.history-item__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

@media (max-width: 480px) {
  .calc-item__grid {
    grid-template-columns: 1fr 1fr;
  }

  .calc-item__grid .field:nth-child(3) {
    grid-column: 1 / -1;
  }
}

/* ---------- SEO content ---------- */

.seo-block,
.faq,
.seo-snapshot,
.guide {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  max-width: 46rem;
}

.seo-block h2,
.faq h2,
.seo-snapshot h2,
.guide h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--ink);
}

.seo-block p,
.seo-snapshot p,
.faq__item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.guide .table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.guide .price-table td,
.guide .price-table th {
  padding-inline: 0.9rem;
}

.guide .price-table td:first-child {
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

.guide .price-table td {
  color: var(--muted);
  font-size: 0.9rem;
}

.guide .price-table td:nth-child(2) {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.faq {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.faq__item {
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0 0.75rem;
}

.faq__item summary {
  cursor: pointer;
  font-weight: 550;
  font-size: 0.9375rem;
  color: var(--ink);
  list-style: none;
  padding-block: 0.3rem;
}

.faq__item summary::-webkit-details-marker {
  display: none;
}

.faq__item summary::before {
  content: '+';
  display: inline-block;
  width: 1.1em;
  color: var(--gold);
  font-weight: 600;
}

.faq__item[open] summary::before {
  content: '−';
}

.faq__item p {
  margin-top: 0.5rem;
  padding-inline-start: 1.1em;
}

.seo-snapshot ul {
  margin: 0.75rem 0 0;
  padding-inline-start: 1.2rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.disclaimer {
  max-width: 46rem;
  margin-top: 1.5rem;
  color: var(--faint);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.site-footer {
  color: var(--faint);
  font-size: 0.8125rem;
  padding-bottom: 0.5rem;
  margin-top: 0.5rem;
}

/* ---------- Price flashes ---------- */

.karat-card.is-flash-up .karat-card__price {
  animation: price-blink 0.45s var(--ease), text-up 1.6s var(--ease);
}

.karat-card.is-flash-down .karat-card__price {
  animation: price-blink 0.45s var(--ease), text-down 1.6s var(--ease);
}

.karat-card.is-flash-up {
  animation: card-up 1.6s var(--ease);
}

.karat-card.is-flash-down {
  animation: card-down 1.6s var(--ease);
}

.karat-card.is-flash-same .karat-card__price {
  animation: price-blink 0.7s var(--ease);
}

@keyframes price-blink {
  0%, 100% { opacity: 1; }
  40% { opacity: 0.2; }
}

@keyframes text-up {
  0% { color: var(--up); }
  100% { color: var(--ink); }
}

@keyframes text-down {
  0% { color: var(--down); }
  100% { color: var(--ink); }
}

@keyframes card-up {
  0% { background-color: var(--up-soft); border-color: var(--up); }
  100% { background-color: var(--surface); border-color: var(--line); }
}

@keyframes card-down {
  0% { background-color: var(--down-soft); border-color: var(--down); }
  100% { background-color: var(--surface); border-color: var(--line); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 45%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
}

/* ---------- Modal (dialog on desktop, bottom sheet on phones) ---------- */

html.is-modal-open,
html.is-modal-open body {
  overflow: hidden;
}

html.is-modal-open body {
  position: fixed;
  inset-inline: 0;
  width: 100%;
}

.modal {
  width: min(58rem, calc(100vw - 1.5rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
}

.modal[open] {
  animation: modal-in 0.28s var(--ease);
}

.modal::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(3px);
}

.modal__panel {
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 0.35rem);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem 1.35rem;
}

.modal__grip {
  display: none;
  height: 1.6rem;
  margin: -0.5rem 0 0.1rem;
  touch-action: none;
  cursor: grab;
}

.modal__grip::before {
  content: "";
  display: block;
  width: 2.6rem;
  height: 0.3rem;
  margin: 0.65rem auto 0;
  border-radius: 999px;
  background: var(--line-strong);
}

.modal__head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.modal__id {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.modal__mark {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 3.2rem;
  height: 3.2rem;
  padding: 0 0.6rem;
  border-radius: 1rem;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal__titles {
  min-width: 0;
}

.modal__titles h2 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.modal__sub {
  color: var(--faint);
  font-size: 0.8rem;
}

.modal__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-inline-start: auto;
}

.modal__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
}

.modal__close svg {
  width: 1rem;
  height: 1rem;
}

.modal__price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.7rem;
  margin-top: 1.1rem;
}

.modal__price {
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.modal__unit,
.modal__note {
  color: var(--faint);
  font-size: 0.85rem;
}

.modal__price-row .chip {
  align-self: center;
}

.modal__ranges {
  margin-top: 0.9rem;
}

.modal__body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(16rem, 0.8fr);
  gap: 1.25rem;
  align-items: start;
  margin-top: 0.9rem;
}

.modal-calc {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.modal-calc__title {
  font-weight: 600;
}

.modal-calc__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.modal-calc__fields .field--wide {
  grid-column: 1 / -1;
}

.modal-calc .result {
  background: var(--surface);
}

.chart-focus {
  min-height: 1.3rem;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.chart {
  width: 100%;
  height: 15rem;
  display: block;
  touch-action: pan-y;
  overflow: visible;
}

.chart__area {
  fill: url(#chart-fill);
}

.chart__stop--top {
  stop-color: var(--gold);
  stop-opacity: 0.32;
}

.chart__stop--bottom {
  stop-color: var(--gold);
  stop-opacity: 0;
}

.chart__line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart.is-up {
  --gold: var(--up);
}

.chart.is-down {
  --gold: var(--down);
}

.chart__dot {
  fill: var(--surface);
  stroke: var(--gold);
  stroke-width: 2.5;
}

.chart__hit {
  pointer-events: all;
}

.chart__grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart__label,
.chart__tag-text {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.chart__label {
  fill: var(--faint);
  font-size: 11px;
}

.chart__guide {
  stroke: var(--gold);
  stroke-opacity: 0.45;
  stroke-dasharray: 3 4;
}

.chart__tag-bg {
  fill: var(--surface);
  stroke: var(--gold);
  stroke-width: 1.25;
}

.chart__tag-text {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
  color: var(--faint);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.chart-meta > span {
  white-space: nowrap;
}

@media (max-width: 640px) {
  .chart-meta {
    flex-wrap: wrap;
  }
  .chart-meta #chart-span {
    order: 3;
    flex: 0 0 100%;
    text-align: center;
    white-space: normal;
  }
}

.chart-empty {
  display: none;
  margin-top: 1.5rem;
  color: var(--muted);
  text-align: center;
}

.modal.is-empty .chart,
.modal.is-empty .chart-meta,
.modal.is-empty .chart-focus {
  display: none;
}

.modal.is-empty .chart-empty {
  display: block;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* ---------- Responsive ---------- */

@media (min-width: 900px) {
  .spot {
    min-height: 23rem;
  }

  .spot-chart {
    height: 11rem;
  }
}

@media (max-width: 900px) {
  .modal__body {
    grid-template-columns: 1fr;
  }

  .calc-layout,
  .fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 0;
    gap: 0.35rem;
    padding-block: 0.4rem;
  }

  .brand {
    gap: 0.4rem;
  }

  .mark {
    width: 0.5rem;
    height: 0.5rem;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent);
  }

  .brand__name {
    font-size: 0.95rem;
  }

  .metalbar {
    padding-top: 0.7rem;
  }

  .header-switch,
  .header-switch:has(.header-select--lang) {
    flex: none;
    min-width: 0;
    max-width: none;
  }

  .header-select,
  .header-select--lang,
  .picker__button {
    width: auto;
    max-width: 4.6rem;
    min-height: 1.85rem;
    padding: 0.22rem 1.05rem 0.22rem 0.5rem;
    font-size: 0.72rem;
    background-position: right 0.35rem center;
  }

  html[dir="rtl"] .header-select,
  html[dir="rtl"] .header-select--lang,
  html[dir="rtl"] .picker__button {
    padding: 0.22rem 0.5rem 0.22rem 1.05rem;
    background-position: left 0.35rem center;
  }

  .picker__panel,
  .picker__panel--wide {
    width: min(18.5rem, calc(100vw - 1rem));
  }

  .theme-toggle {
    width: 1.85rem;
    height: 1.85rem;
  }

  .price-table th,
  .price-table td {
    padding-inline: 0.5rem;
  }

  .col-spread {
    display: none;
  }
}

@media (max-width: 640px) {
  .spot {
    padding-inline: 1rem;
  }

  .spot-chart {
    height: 7.5rem;
  }

  .spot__foot {
    justify-content: center;
  }

  .spot__hint {
    width: 100%;
    text-align: center;
  }

  .modal {
    width: 100%;
    max-height: 94dvh;
    margin: auto 0 0;
  }

  .modal[open] {
    animation: none;
  }

  .modal[open] .modal__panel {
    animation: sheet-in 0.34s var(--ease);
  }

  .modal__panel {
    max-height: 94dvh;
    padding: 0.9rem 1rem max(1.35rem, env(safe-area-inset-bottom));
    border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    border-bottom: 0;
  }

  .modal__grip {
    display: block;
  }

  .modal__ranges .seg {
    display: flex;
  }

  .modal__ranges .seg__item {
    flex: 1;
  }

  .chart {
    height: 13rem;
  }

  .modal-calc__fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .karat-card:hover {
    transform: none;
  }

  .tape__viewport {
    overflow-x: auto;
    mask-image: none;
  }

  .tape__track {
    width: max-content;
  }

  .tape__group + .tape__group {
    display: none;
  }
}
