:root {
  color-scheme: dark;
  --page: #000;
  --panel: #101012;
  --panel-raised: #151518;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f7f7fa;
  --muted: #a7a7b0;
  --accent-start: #754cff;
  --accent-end: #e467bd;
  --accent: #704cf4;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.calculator-app {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 26px 18px 52px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 10px 24px;
}

.app-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2.35rem, 8vw, 3.25rem);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 1;
}

.info-button {
  display: grid;
  width: 37px;
  height: 37px;
  padding: 0;
  place-items: center;
  border: 2px solid #babaca;
  border-radius: 50%;
  background: transparent;
  color: #d7d7e2;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 1.55rem;
  line-height: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, #141416 0%, #0f0f11 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 12px 32px rgba(0, 0, 0, 0.13);
}

.rate-panel {
  padding: 23px 24px 26px;
}

.rate-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.rate-panel-top h2 {
  white-space: nowrap;
}

h2 {
  margin: 0;
  color: #f3f3f7;
  font-size: clamp(1.08rem, 4.2vw, 1.43rem);
  font-weight: 650;
  letter-spacing: -0.025em;
}

.rate-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 224px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #151518;
}

.rate-mode-button,
.choice-button {
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: #c7c7d0;
  cursor: pointer;
  font-weight: 540;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.rate-mode-button.is-active,
.choice-button.is-active {
  border-color: rgba(160, 130, 255, 0.62);
  background: linear-gradient(112deg, var(--accent-start), #6947eb 56%, #774aed 100%);
  box-shadow: 0 4px 18px rgba(104, 71, 235, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: #fff;
}

.rate-mode-button:active,
.choice-button:active,
.refresh-button:active {
  transform: scale(0.98);
}

.rate-display {
  display: grid;
  min-height: 202px;
  margin-top: 28px;
  padding: 27px 18px 25px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.027), transparent 52%), #141416;
  text-align: center;
}

.rate-display p {
  margin: 0;
}

#rate-caption,
#rate-direction {
  color: var(--muted);
  font-size: clamp(1rem, 3.9vw, 1.3rem);
  letter-spacing: -0.025em;
}

#active-rate,
.custom-rate-input {
  width: min(100%, 340px);
  margin: 8px 0 2px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: clamp(3.35rem, 12vw, 4.85rem);
  font-weight: 690;
  letter-spacing: -0.065em;
  line-height: 1;
  text-align: center;
}

.custom-rate-input {
  padding: 0 6px 8px;
  border-bottom: 2px solid #8a67ff;
  outline: none;
}

.rate-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 28px;
}

.refresh-button {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #956cff;
  cursor: pointer;
  font-size: clamp(1.3rem, 4.94vw, 1.625rem);
  font-weight: 560;
}

.refresh-button svg {
  width: 38px;
  height: 38px;
  stroke-width: 1.7;
}

.refresh-button.is-loading svg {
  animation: rotate 900ms linear infinite;
}

.rate-updated-at {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 2.5vw, 0.96rem);
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.price-panel,
.choices-panel {
  margin-top: 20px;
  padding: 23px 24px 26px;
}

.amount-control {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 151px;
  margin-top: 20px;
  padding: 20px 27px;
  border: 2px solid #875cff;
  border-radius: 22px;
  background: #101012;
  box-shadow: 0 0 0 1px rgba(128, 87, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.024);
}

#amount {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: clamp(3.65rem, 14vw, 5.7rem);
  font-weight: 650;
  letter-spacing: -0.075em;
  line-height: 1;
}

#currency {
  width: 156px;
  height: 82px;
  padding: 0 50px 0 25px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: 0;
  background-color: #151518;
  background-image: linear-gradient(45deg, transparent 50%, #b5b5c0 50%), linear-gradient(135deg, #b5b5c0 50%, transparent 50%);
  background-position: calc(100% - 29px) 34px, calc(100% - 21px) 34px;
  background-repeat: no-repeat;
  background-size: 9px 9px, 9px 9px;
  color: #fff;
  font-size: clamp(1.2rem, 4.5vw, 1.5rem);
  font-weight: 560;
}

.choice-grid {
  display: grid;
  gap: 18px;
  margin-top: 19px;
}

.commission-options {
  grid-template-columns: repeat(3, 1fr);
}

.delivery-options {
  grid-template-columns: repeat(4, 1fr);
}

.custom-delivery-button,
.custom-delivery-input {
  grid-column: span 2;
  width: min(100%, 250px);
}

.custom-delivery-input {
  padding: 0 18px;
  border: 1px solid #875cff;
  border-radius: 13px;
  outline: 0;
  appearance: none;
  background: #171719;
  color: #fff;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(128, 87, 255, 0.1);
}

.custom-delivery-input:focus,
.custom-delivery-input:focus-visible {
  border-color: #875cff;
  outline: 0;
  box-shadow: 0 0 0 1px rgba(160, 130, 255, 0.48), 0 4px 18px rgba(104, 71, 235, 0.18);
}

.custom-delivery-input::placeholder {
  color: #85858f;
}

.choice-button {
  min-width: 0;
  border-color: var(--line);
  background: #171719;
  color: #f1f1f5;
  font-size: clamp(1rem, 3.9vw, 1.28rem);
}

.total-panel {
  display: grid;
  min-height: 248px;
  margin-top: 20px;
  padding: 33px 20px 27px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.total-panel p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  letter-spacing: -0.03em;
}

#total-cost {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  background: linear-gradient(100deg, #6849ff 3%, #ad59ff 48%, #fb86b7 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-size: clamp(3.5rem, 14.6vw, 6.45rem);
  font-weight: 720;
  letter-spacing: -0.078em;
  line-height: 0.94;
}

.calculation-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 30px;
  color: #92929c;
  font-size: clamp(0.95rem, 3.6vw, 1.17rem);
}

.calculation-note svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(158, 119, 255, 0.72);
  outline-offset: 3px;
}

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

@media (max-width: 530px) {
  .calculator-app {
    padding: 22px 15px 44px;
  }

  .app-header {
    margin: 0 8px 22px;
  }

  .rate-panel,
  .price-panel,
  .choices-panel {
    padding: 20px 18px 21px;
  }

  .rate-panel-top {
    gap: 12px;
  }

  .rate-mode {
    min-width: 0;
    width: 224px;
  }

  .rate-panel-top h2 {
    font-size: 1rem;
  }

  .rate-actions {
    flex-direction: column;
    gap: 9px;
  }

  .amount-control {
    min-height: 128px;
    padding: 17px 18px;
  }

  #currency {
    width: 118px;
    height: 66px;
    padding-left: 17px;
    background-position: calc(100% - 25px) 27px, calc(100% - 17px) 27px;
  }

  .choice-grid {
    gap: 10px;
  }

  .delivery-options {
    grid-template-columns: repeat(4, 1fr);
  }

  .total-panel {
    min-height: 224px;
  }
}

@media (max-width: 380px) {
  .rate-panel-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .rate-mode {
    width: 100%;
  }

  .choice-button {
    font-size: 0.88rem;
  }
}
