:root {
  --bg: #0b1120;
  --bg-raised: #111a2e;
  --card: #131d33;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --gold: #f0b429;
  --gold-soft: rgba(240, 180, 41, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(240, 180, 41, 0.08), transparent);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  vertical-align: -0.2em;
}

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

.site-header {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color 0.25s;
}

.brand:hover {
  color: #ffd35c;
}

.brand-mark {
  width: 1.8rem;
  height: 1.8rem;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.brand:hover .brand-mark {
  transform: rotate(-12deg) scale(1.08);
  filter: drop-shadow(0 0 8px rgba(240, 180, 41, 0.55));
}

/* ---------- Hero ---------- */

.hero {
  padding: 3rem 0 2.5rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero .accent {
  color: var(--gold);
}

.hero-sub {
  margin: 1.25rem auto 0;
  max-width: 34rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 300;
}

.hero-lead {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
}

/* ---------- Price bar ---------- */

.price-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  margin-bottom: 1rem;
}

.price-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.price-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.price-note {
  text-transform: none;
  letter-spacing: 0;
}

.price-value {
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.price-meta {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.price-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

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

.refresh-btn.spinning .icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- API error ---------- */

.api-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #fca5a5;
}

.manual-price {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--text);
  font-size: 0.85rem;
}

.manual-price input {
  max-width: 12rem;
}

/* ---------- Wizard ---------- */

.wizard-dots {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-bottom: 1.5rem;
}

.dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  border: none;
  background: var(--border-strong);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s;
}

.dot-active {
  background: var(--gold);
}

.wizard-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.wizard-overline {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 50%;
}

.wizard-title {
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}

.wizard-nav {
  display: flex;
  align-items: center;
  margin: 0 -1.75rem;
  padding: 1rem 1.75rem 0;
  border-top: 1px solid var(--border);
}

.wizard-nav-right {
  justify-content: flex-end;
}

.wizard-nav-split {
  justify-content: space-between;
}

.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  background: var(--gold);
  color: #0b1120;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-next:hover {
  background: #ffd35c;
  transform: translateX(2px);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-back:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-reset {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-reset:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.field {
  margin-bottom: 1.5rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.field-hint {
  display: block;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.field-row {
  display: flex;
  gap: 0.75rem;
}

.field-row .input-wrap {
  flex: 1;
}

.field-row .select-wrap {
  flex: 0 0 11rem;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.input-prefix,
.input-suffix {
  padding: 0 0.9rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  user-select: none;
}

.input-prefix { padding-right: 0; }
.input-suffix { padding-left: 0; }

input[type="number"],
select {
  width: 100%;
  padding: 0.8rem 0.9rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.4rem;
  font-size: 0.92rem;
}

select option {
  background: var(--card);
  color: var(--text);
}

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

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

input::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

.gold-row {
  align-items: center;
  margin-bottom: 0.6rem;
}

.row-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.row-remove:hover {
  color: var(--red);
  border-color: var(--red);
}

.add-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
  padding: 0.35rem 0.2rem;
  border: none;
  background: transparent;
  color: var(--gold);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.add-row:hover {
  opacity: 0.75;
}

.field-value {
  margin-top: 0.45rem;
  font-size: 0.85rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.tag-minus {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
}

/* ---------- Optional section ---------- */

.optional-section {
  border-top: 1px solid var(--border);
  margin: 0 -1.75rem 0;
  padding: 0 1.75rem;
}

.optional-section summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 0;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  color: var(--text);
  transition: color 0.2s;
}

.optional-section summary:hover {
  color: var(--gold);
}

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

.chevron {
  transition: transform 0.2s;
  color: var(--text-muted);
}

.optional-section[open] .chevron {
  transform: rotate(90deg);
}

.optional-fields {
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

/* ---------- Result ---------- */

.result {
  border: 1px solid var(--border);
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: rgba(11, 17, 32, 0.5);
  border-radius: var(--radius-sm);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.result-row-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.nisab-select {
  width: auto;
  display: inline-block;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 1.9rem 0.15rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.4rem;
  background-position: right 0.55rem center;
  background-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
}

.nisab-select:hover {
  border-color: var(--gold);
  color: var(--text);
}

.result-main {
  margin-top: 1.25rem;
  text-align: center;
}

.result-status {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.result-status.below-nisab {
  color: var(--green);
  background: var(--green-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.result-amount {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-amount-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.result-amount-value {
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(240, 180, 41, 0.25);
  letter-spacing: -0.01em;
}

/* ---------- Info ---------- */

.info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 3rem 0;
}

.info-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
}

.info-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.info-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.info-quote {
  margin-top: 0.75rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--gold);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text);
  opacity: 0.9;
}

.info-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.info-sources a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gold);
  text-decoration: none;
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  transition: background 0.2s;
}

.info-sources a:hover {
  background: rgba(240, 180, 41, 0.28);
}

.info-sources a::after {
  content: "";
  width: 0.7em;
  height: 0.7em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f0b429' stroke-width='2.4'%3E%3Cpath d='M7 17L17 7M9 7h8v8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.site-footer p + p {
  margin-top: 0.75rem;
}

.footer-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--green);
}

.footer-copy {
  opacity: 0.7;
}

/* ---------- Focus & motion ---------- */

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

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

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

  .hero {
    padding: 2rem 0 1.75rem;
  }

  .card {
    padding: 1.25rem;
  }

  .optional-section {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .field-row {
    flex-direction: column;
  }

  .field-row .select-wrap {
    flex: 1;
  }

  .gold-row {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .gold-row .input-wrap:first-child {
    flex: 1 1 4.5rem;
  }

  .gold-row .select-wrap {
    flex: 1 1 8rem;
  }

  .gold-row select {
    font-size: 0.85rem;
    padding-left: 0.6rem;
    padding-right: 1.9rem;
    background-position: right 0.5rem center;
  }

  .price-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .price-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .price-meta {
    margin-left: 0;
    justify-content: space-between;
  }
}
