:root {
  color-scheme: dark;
  --bg: #0d0f10;
  --panel: #171a1d;
  --panel-soft: #1d2226;
  --line: #2b3136;
  --text: #f1f0ea;
  --muted: #9aa3a9;
  --dim: #687178;
  --gold: #d7b15a;
  --silver: #c5ced4;
  --copper: #c7764c;
  --green: #75b88a;
  --danger: #d96b6b;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Futura, "Futura PT", "Trebuchet MS", Arial, sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at top left, rgba(215, 177, 90, 0.13), transparent 30rem),
    linear-gradient(135deg, #0d0f10 0%, #111619 48%, #101112 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.topbar {
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo,
.brand-fallback {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  object-fit: contain;
  background: #101315;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-logo.is-hidden,
.brand.has-logo .brand-fallback {
  display: none;
}

.brand-fallback {
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 700;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.9;
  text-transform: uppercase;
}

h2 {
  font-size: 1.25rem;
  text-transform: uppercase;
}

.brand p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 26, 29, 0.94);
  box-shadow: var(--shadow);
}

.calculator-panel,
.results-panel,
.metal-panel {
  padding: 20px;
}

.metal-panel {
  margin-top: 18px;
}

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

.eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(215, 177, 90, 0.55);
  border-radius: 8px;
  color: var(--gold);
  background: #111416;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
  background: #181c1f;
}

.icon-button span {
  line-height: 1;
  font-size: 1.4rem;
}

.icon-button.subtle {
  color: var(--silver);
  border-color: var(--line);
}

.weight-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.weight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

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

.field span,
.switch-row {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.field small {
  color: var(--dim);
  font-size: 0.72rem;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0f1214;
  outline: none;
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 177, 90, 0.14);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 12px) 20px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.unit {
  min-height: 46px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.money-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1214;
}

.money-input:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 177, 90, 0.14);
}

.money-input span {
  padding-left: 12px;
  color: var(--gold);
}

.money-input input {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding-left: 6px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111416;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #080a0b;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 150ms ease, background 150ms ease;
}

.switch-row input:checked + .switch {
  border-color: rgba(117, 184, 138, 0.65);
  background: rgba(117, 184, 138, 0.16);
}

.switch-row input:checked + .switch::after {
  transform: translateX(20px);
  background: var(--green);
}

.result-stack {
  display: grid;
  gap: 12px;
}

.result-card {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.result-card.primary {
  display: grid;
  gap: 8px;
  background: linear-gradient(135deg, rgba(215, 177, 90, 0.2), rgba(29, 34, 38, 0.95));
  border-color: rgba(215, 177, 90, 0.45);
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

dd {
  color: var(--text);
  font-size: 1.2rem;
}

.result-card.primary dd {
  color: var(--gold);
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 1;
}

.result-card.inline dd {
  font-size: 1rem;
}

.pricing-group {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pricing-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.kitco-link {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(215, 177, 90, 0.55);
  border-radius: 8px;
  color: var(--gold);
  background: #111416;
  font-size: 0.78rem;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.kitco-link:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
  background: #181c1f;
}

.pricing-switch {
  margin-top: 0;
}

.pricing-results {
  display: grid;
  gap: 12px;
  margin: 0;
}

.metal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metal-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111416;
}

.metal-card.is-active {
  border-color: rgba(215, 177, 90, 0.8);
  background: rgba(215, 177, 90, 0.12);
}

.metal-card img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.metal-card.has-custom-icon .metal-icon {
  display: none;
}

.metal-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--metal-color);
}

.metal-name {
  color: var(--text);
  font-size: 0.95rem;
  text-transform: uppercase;
}

.metal-data {
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 840px) {
  .workspace,
  .controls-grid,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-logo,
  .brand-fallback {
    width: 54px;
    height: 54px;
  }

  .calculator-panel,
  .results-panel,
  .metal-panel {
    padding: 14px;
  }

  .metal-grid {
    grid-template-columns: 1fr;
  }
}
