:root {
  --bg: #0f1420;
  --card-bg: #171e2e;
  --card-border: #262f45;
  --text: #e7ebf5;
  --text-dim: #8b93a7;
  --accent: #5b8cff;
  --accent-2: #34d399;
  --danger: #f87171;
  --input-bg: #0f1420;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 12px 48px;
}

.app__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.app__header h1 {
  font-size: 22px;
  margin: 0;
}

.status {
  font-size: 13px;
  color: var(--text-dim);
}

.status.error {
  color: var(--danger);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.card h2 {
  margin-top: 0;
  font-size: 16px;
}

.hint {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin-top: -4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.field label {
  font-size: 12px;
  color: var(--text-dim);
}

input,
select {
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 8px;
  font-size: 14px;
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.converter__row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.swap-btn {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

.swap-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.converter__result {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.result-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--accent-2);
}

.rate-edit {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.rate-edit label {
  font-size: 11px;
  color: var(--text-dim);
}

.rate-edit input {
  width: 140px;
  text-align: right;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-align: right;
}

.link-btn:hover {
  text-decoration: underline;
}

.chains {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0;
}

.chain-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: 0;
  padding: 12px 26px 10px 10px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.015);
  overflow-x: auto;
}

.chain-row__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: 1px solid var(--card-border);
  color: var(--danger);
  cursor: pointer;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 12px;
  line-height: 1;
}

.chain-row__remove:hover {
  border-color: var(--danger);
}

.chain-block {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  flex-shrink: 0;
  width: 84px;
}

.chain-block__rate {
  min-height: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.chain-block__rate-label {
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
  line-height: 1.2;
}

.chain-block__rate input {
  width: 100%;
  min-width: 0;
  text-align: center;
  padding: 4px 2px;
  font-size: 12px;
}

.chain-block__currency {
  appearance: none;
  -webkit-appearance: none;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-align-last: center;
  padding: 7px 4px;
  cursor: pointer;
}

.chain-block__currency:hover,
.chain-block__currency:focus {
  border-color: var(--accent);
  outline: none;
}

.chain-block__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--danger);
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.chain-block:hover .chain-block__remove {
  opacity: 1;
}

.chain-connector {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 30px;
  margin-bottom: 17px;
  flex-shrink: 0;
}

.chain-connector__arrow {
  color: var(--text-dim);
  font-size: 14px;
}

.chain-connector__plus {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chain-connector:hover .chain-connector__plus {
  opacity: 1;
  transform: scale(1);
}

.chain-connector:hover .chain-connector__arrow {
  opacity: 0;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn--secondary {
  background: transparent;
  border: 1px dashed var(--card-border);
  color: var(--text-dim);
}

.btn--secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  filter: none;
}

.compare {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
}

.compare-row.best {
  border-color: var(--accent-2);
  background: rgba(52, 211, 153, 0.08);
}

.compare-row__label {
  font-size: 13px;
  color: var(--text-dim);
}

.compare-row__value {
  font-size: 16px;
  font-weight: 600;
}

.compare-row.best .compare-row__value {
  color: var(--accent-2);
}

.compare-diff {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.app__footer {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  margin-top: 30px;
}

.app__footer a {
  color: var(--accent);
}

@media (min-width: 600px) {
  .chain-block {
    width: 104px;
  }

  .chain-block__currency {
    font-size: 15px;
    padding: 9px 6px;
  }

  .chain-block__rate input {
    font-size: 13px;
    padding: 5px 4px;
  }

  .chain-block__rate-label {
    font-size: 10px;
  }

  .chain-connector {
    width: 34px;
  }
}

@media (max-width: 480px) {
  .converter__row {
    flex-direction: column;
    align-items: stretch;
  }

  .swap-btn {
    align-self: center;
    transform: rotate(90deg);
  }

  .converter__result {
    flex-direction: column;
    align-items: stretch;
  }

  .rate-edit {
    align-items: stretch;
  }

  .rate-edit input {
    width: 100%;
  }
}
